diff --git a/src/app/components/logs-viewer/logs-viewer.component.ts b/src/app/components/logs-viewer/logs-viewer.component.ts index fbeeb46..5a218cc 100644 --- a/src/app/components/logs-viewer/logs-viewer.component.ts +++ b/src/app/components/logs-viewer/logs-viewer.component.ts @@ -61,7 +61,8 @@ export class LogsViewerComponent implements OnInit { data: { dialogTitle: 'Clear logs', dialogText: 'Would you like to clear your logs? This will delete all your current logs, permanently.', - submitText: 'Clear' + submitText: 'Clear', + warnSubmitColor: true } }); dialogRef.afterClosed().subscribe(confirmed => { diff --git a/src/app/dialogs/confirm-dialog/confirm-dialog.component.html b/src/app/dialogs/confirm-dialog/confirm-dialog.component.html index 5c6ef6b..ddfde17 100644 --- a/src/app/dialogs/confirm-dialog/confirm-dialog.component.html +++ b/src/app/dialogs/confirm-dialog/confirm-dialog.component.html @@ -6,7 +6,7 @@ - +
diff --git a/src/app/dialogs/confirm-dialog/confirm-dialog.component.ts b/src/app/dialogs/confirm-dialog/confirm-dialog.component.ts index 36892b8..31ec18a 100644 --- a/src/app/dialogs/confirm-dialog/confirm-dialog.component.ts +++ b/src/app/dialogs/confirm-dialog/confirm-dialog.component.ts @@ -15,12 +15,14 @@ export class ConfirmDialogComponent implements OnInit { doneEmitter: EventEmitter = null; onlyEmitOnDone = false; - + + warnSubmitColor = false; constructor(@Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef) { if (this.data.dialogTitle) { this.dialogTitle = this.data.dialogTitle }; if (this.data.dialogText) { this.dialogText = this.data.dialogText }; if (this.data.submitText) { this.submitText = this.data.submitText }; + if (this.data.warnSubmitColor) { this.warnSubmitColor = this.data.warnSubmitColor }; // checks if emitter exists, if so don't autoclose as it should be handled by caller if (this.data.doneEmitter) { diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html index 8e6fc0d..1342457 100644 --- a/src/app/settings/settings.component.html +++ b/src/app/settings/settings.component.html @@ -135,7 +135,7 @@ {{category['name']}} - + diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts index ec0c6d4..26c6eaa 100644 --- a/src/app/settings/settings.component.ts +++ b/src/app/settings/settings.component.ts @@ -82,7 +82,11 @@ export class SettingsComponent implements OnInit { dropCategory(event: CdkDragDrop) { moveItemInArray(this.postsService.categories, event.previousIndex, event.currentIndex); - this.postsService.updateCategories(this.postsService.categories); + this.postsService.updateCategories(this.postsService.categories).subscribe(res => { + + }, err => { + this.postsService.openSnackBar('Failed to update categories!'); + }); } openAddCategoryDialog() { @@ -113,6 +117,29 @@ export class SettingsComponent implements OnInit { }); } + deleteCategory(category) { + const dialogRef = this.dialog.open(ConfirmDialogComponent, { + data: { + dialogTitle: 'Delete category', + dialogText: `Would you like to delete ${category['name']}?`, + submitText: 'Delete', + warnSubmitColor: true + } + }); + dialogRef.afterClosed().subscribe(confirmed => { + if (confirmed) { + this.postsService.deleteCategory(category['uid']).subscribe(res => { + if (res['success']) { + this.postsService.openSnackBar(`Successfully deleted ${category['name']}!`); + this.postsService.reloadCategories(); + } + }, err => { + this.postsService.openSnackBar(`Failed to delete ${category['name']}!`); + }); + } + }); + } + openEditCategoryDialog(category) { this.dialog.open(EditCategoryDialogComponent, { data: { @@ -206,7 +233,8 @@ export class SettingsComponent implements OnInit { dialogTitle: 'Kill downloads', dialogText: 'Are you sure you want to kill all downloads? Any subscription and non-subscription downloads will end immediately, though this operation may take a minute or so to complete.', submitText: 'Kill all downloads', - doneEmitter: done + doneEmitter: done, + warnSubmitColor: true } }); done.subscribe(confirmed => {