Warn on Refresh Metadata (#610)

* Warn the user about the dangers of refresh metadata and promote them to use a scan instead.

* Removed presence hub and moved it over to message hub.

When a library scan is in progress, now a spinner will show on manage libraries page.

* Code cleanup
This commit is contained in:
Joseph Milazzo 2021-09-30 17:36:58 -07:00 committed by GitHub
parent 9b536ce700
commit 0ac54e682f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 101 additions and 77 deletions

View file

@ -7,7 +7,10 @@
<li *ngFor="let library of libraries; let idx = index;" class="list-group-item">
<div>
<h4>
<span id="library-name--{{idx}}">{{library.name | titlecase}}</span>
<span id="library-name--{{idx}}">{{library.name | titlecase}}</span>&nbsp;
<div class="spinner-border text-primary" style="width: 1.5rem; height: 1.5rem;" role="status" *ngIf="scanInProgress.hasOwnProperty(library.id) && scanInProgress[library.id]" title="Scan in progress">
<span class="sr-only">Scan for {{library.name}} in progress</span>
</div>
<div class="float-right">
<button class="btn btn-secondary mr-2 btn-sm" (click)="scanLibrary(library)" placement="top" ngbTooltip="Scan Library" attr.aria-label="Scan Library"><i class="fa fa-sync-alt" title="Scan"></i></button>
<button class="btn btn-danger mr-2 btn-sm" [disabled]="deletionInProgress" (click)="deleteLibrary(library)"><i class="fa fa-trash" placement="top" ngbTooltip="Delete Library" attr.aria-label="Delete {{library.name | titlecase}}"></i></button>

View file

@ -4,8 +4,10 @@ import { ToastrService } from 'ngx-toastr';
import { Subject } from 'rxjs';
import { take, takeUntil } from 'rxjs/operators';
import { ConfirmService } from 'src/app/shared/confirm.service';
import { ScanLibraryProgressEvent } from 'src/app/_models/events/scan-library-progress-event';
import { Library, LibraryType } from 'src/app/_models/library';
import { LibraryService } from 'src/app/_services/library.service';
import { MessageHubService } from 'src/app/_services/message-hub.service';
import { LibraryEditorModalComponent } from '../_modals/library-editor-modal/library-editor-modal.component';
@Component({
@ -22,13 +24,21 @@ export class ManageLibraryComponent implements OnInit, OnDestroy {
* If a deletion is in progress for a library
*/
deletionInProgress: boolean = false;
scanInProgress: {[key: number]: boolean} = {};
private readonly onDestroy = new Subject<void>();
constructor(private modalService: NgbModal, private libraryService: LibraryService, private toastr: ToastrService, private confirmService: ConfirmService) { }
constructor(private modalService: NgbModal, private libraryService: LibraryService,
private toastr: ToastrService, private confirmService: ConfirmService,
private hubService: MessageHubService) { }
ngOnInit(): void {
this.getLibraries();
this.hubService.scanLibrary.subscribe((event: ScanLibraryProgressEvent) => {
this.scanInProgress[event.libraryId] = event.progress !== 100;
});
}
ngOnDestroy() {

View file

@ -9,7 +9,7 @@
<li *ngFor="let member of members; let idx = index;" class="list-group-item">
<div>
<h4>
<i class="presence fa fa-circle" title="Active" aria-hidden="true" *ngIf="false && (presence.onlineUsers$ | async)?.includes(member.username)"></i><span id="member-name--{{idx}}">{{member.username | titlecase}} </span><span *ngIf="member.username === loggedInUsername">(You)</span>
<i class="presence fa fa-circle" title="Active" aria-hidden="true" *ngIf="false && (messageHub.onlineUsers$ | async)?.includes(member.username)"></i><span id="member-name--{{idx}}">{{member.username | titlecase}} </span><span *ngIf="member.username === loggedInUsername">(You)</span>
<div class="float-right" *ngIf="canEditMember(member)">
<button class="btn btn-danger mr-2" (click)="deleteUser(member)" placement="top" ngbTooltip="Delete User" attr.aria-label="Delete User {{member.username | titlecase}}"><i class="fa fa-trash" aria-hidden="true"></i></button>
<button class="btn btn-secondary mr-2" (click)="updatePassword(member)" placement="top" ngbTooltip="Change Password" attr.aria-label="Change Password for {{member.username | titlecase}}"><i class="fa fa-key" aria-hidden="true"></i></button>

View file

@ -1,6 +1,6 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { take, takeUntil } from 'rxjs/operators';
import { take } from 'rxjs/operators';
import { MemberService } from 'src/app/_services/member.service';
import { Member } from 'src/app/_models/member';
import { User } from 'src/app/_models/user';
@ -10,8 +10,8 @@ import { ToastrService } from 'ngx-toastr';
import { ResetPasswordModalComponent } from '../_modals/reset-password-modal/reset-password-modal.component';
import { ConfirmService } from 'src/app/shared/confirm.service';
import { EditRbsModalComponent } from '../_modals/edit-rbs-modal/edit-rbs-modal.component';
import { PresenceHubService } from 'src/app/_services/presence-hub.service';
import { Subject } from 'rxjs';
import { MessageHubService } from 'src/app/_services/message-hub.service';
@Component({
selector: 'app-manage-users',
@ -34,7 +34,7 @@ export class ManageUsersComponent implements OnInit, OnDestroy {
private modalService: NgbModal,
private toastr: ToastrService,
private confirmService: ConfirmService,
public presence: PresenceHubService) {
public messageHub: MessageHubService) {
this.accountService.currentUser$.pipe(take(1)).subscribe((user: User) => {
this.loggedInUsername = user.username;
});