Implemented ability to delete a library and ensure that after adding or deleting, the manage library page refreshes.

This commit is contained in:
Joseph Milazzo 2021-01-02 12:59:33 -06:00
parent 1816b6c68d
commit c8bbbceecd
3 changed files with 21 additions and 13 deletions

View file

@ -19,25 +19,31 @@ export class ManageLibraryComponent implements OnInit {
ngOnInit(): void {
this.getLibraries();
}
getLibraries() {
this.libraryService.getLibraries().subscribe(libraries => {
this.libraries = libraries;
});
}
addLibrary() {
const modalRef = this.modalService.open(LibraryEditorModalComponent);
}
addFolder(library: string) {
const modalRef = this.modalService.open(DirectoryPickerComponent);
modalRef.closed.subscribe((closeResult: DirectoryPickerResult) => {
console.log('Closed Result', closeResult);
if (closeResult.success) {
console.log('Add folder path to Library');
modalRef.closed.subscribe(refresh => {
if (refresh) {
this.getLibraries();
}
});
}
deleteLibrary(library: Library) {
if (confirm('Are you sure you want to delete this library? You cannot undo this action.')) {
this.libraryService.delete(library.id).subscribe(() => {
this.getLibraries();
});
}
}
}