mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-27 07:00:55 +03:00
Added basic categorization functionality in the server & UI
This commit is contained in:
@@ -9,6 +9,9 @@ import { CURRENT_VERSION } from 'app/consts';
|
||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||
import { CookiesUploaderDialogComponent } from 'app/dialogs/cookies-uploader-dialog/cookies-uploader-dialog.component';
|
||||
import { ConfirmDialogComponent } from 'app/dialogs/confirm-dialog/confirm-dialog.component';
|
||||
import { moveItemInArray, CdkDragDrop } from '@angular/cdk/drag-drop';
|
||||
import { InputDialogComponent } from 'app/input-dialog/input-dialog.component';
|
||||
import { EditCategoryDialogComponent } from 'app/dialogs/edit-category-dialog/edit-category-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
@@ -77,6 +80,47 @@ export class SettingsComponent implements OnInit {
|
||||
})
|
||||
}
|
||||
|
||||
dropCategory(event: CdkDragDrop<string[]>) {
|
||||
moveItemInArray(this.postsService.categories, event.previousIndex, event.currentIndex);
|
||||
this.postsService.updateCategories(this.postsService.categories);
|
||||
}
|
||||
|
||||
openAddCategoryDialog() {
|
||||
const done = new EventEmitter<any>();
|
||||
const dialogRef = this.dialog.open(InputDialogComponent, {
|
||||
width: '300px',
|
||||
data: {
|
||||
inputTitle: 'Name the category',
|
||||
inputPlaceholder: 'Name',
|
||||
submitText: 'Add',
|
||||
doneEmitter: done
|
||||
}
|
||||
});
|
||||
|
||||
done.subscribe(name => {
|
||||
|
||||
// Eventually do additional checks on name
|
||||
if (name) {
|
||||
this.postsService.createCategory(name).subscribe(res => {
|
||||
if (res['success']) {
|
||||
this.postsService.reloadCategories();
|
||||
dialogRef.close();
|
||||
const new_category = res['new_category'];
|
||||
this.openEditCategoryDialog(new_category);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openEditCategoryDialog(category) {
|
||||
this.dialog.open(EditCategoryDialogComponent, {
|
||||
data: {
|
||||
category: category
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
generateAPIKey() {
|
||||
this.postsService.generateNewAPIKey().subscribe(res => {
|
||||
if (res['new_api_key']) {
|
||||
|
||||
Reference in New Issue
Block a user