Implemented ability to delete a library and ensure that after adding or deleting, the manage library page refreshes.
This commit is contained in:
parent
1816b6c68d
commit
c8bbbceecd
3 changed files with 21 additions and 13 deletions
|
|
@ -41,4 +41,8 @@ export class LibraryService {
|
|||
return this.httpClient.post(this.baseUrl + 'library/create', model);
|
||||
}
|
||||
|
||||
delete(libraryId: number) {
|
||||
return this.httpClient.delete(this.baseUrl + 'library/delete?libraryId=' + libraryId, {});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<h4>
|
||||
{{library.name | titlecase}}
|
||||
<div class="pull-right">
|
||||
<button class="btn btn-danger mr-2 btn-sm"><i class="fa fa-trash" title="Delete {{library.name | titlecase}}"></i></button>
|
||||
<button class="btn btn-danger mr-2 btn-sm" (click)="deleteLibrary(library)"><i class="fa fa-trash" title="Delete {{library.name | titlecase}}"></i></button>
|
||||
<button class="btn btn-primary btn-sm" ><i class="fa fa-pencil" title="Edit {{library.name | titlecase}}"></i></button>
|
||||
</div>
|
||||
</h4>
|
||||
|
|
@ -23,6 +23,4 @@
|
|||
<ng-template #createLibrary>
|
||||
<app-library-editor-modal></app-library-editor-modal>
|
||||
</ng-template>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary" (click)="addFolder('')">Add Folder</button>
|
||||
</div>
|
||||
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue