mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-04-02 11:51:28 +03:00
Added basic categorization functionality in the server & UI
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
import { Component, OnInit, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { PostsService } from 'app/posts.services';
|
||||
|
||||
@Component({
|
||||
selector: 'app-edit-category-dialog',
|
||||
templateUrl: './edit-category-dialog.component.html',
|
||||
styleUrls: ['./edit-category-dialog.component.scss']
|
||||
})
|
||||
export class EditCategoryDialogComponent implements OnInit {
|
||||
|
||||
updating = false;
|
||||
original_category = null;
|
||||
category = null;
|
||||
|
||||
propertyOptions = [
|
||||
{
|
||||
value: 'fulltitle',
|
||||
label: 'Title'
|
||||
},
|
||||
{
|
||||
value: 'id',
|
||||
label: 'ID'
|
||||
},
|
||||
{
|
||||
value: 'webpage_url',
|
||||
label: 'URL'
|
||||
},
|
||||
{
|
||||
value: 'view_count',
|
||||
label: 'Views'
|
||||
},
|
||||
{
|
||||
value: 'uploader',
|
||||
label: 'Uploader'
|
||||
},
|
||||
{
|
||||
value: '_filename',
|
||||
label: 'File Name'
|
||||
},
|
||||
{
|
||||
value: 'tags',
|
||||
label: 'Tags'
|
||||
}
|
||||
];
|
||||
|
||||
comparatorOptions = [
|
||||
{
|
||||
value: 'includes',
|
||||
label: 'includes'
|
||||
},
|
||||
{
|
||||
value: 'not_includes',
|
||||
label: 'not includes'
|
||||
},
|
||||
{
|
||||
value: 'equals',
|
||||
label: 'equals'
|
||||
},
|
||||
{
|
||||
value: 'not_equals',
|
||||
label: 'not equals'
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
constructor(@Inject(MAT_DIALOG_DATA) public data: any, private postsService: PostsService) {
|
||||
if (this.data) {
|
||||
this.original_category = this.data.category;
|
||||
this.category = JSON.parse(JSON.stringify(this.original_category));
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
addNewRule() {
|
||||
this.category['rules'].push({
|
||||
preceding_operator: 'or',
|
||||
property: 'fulltitle',
|
||||
comparator: 'includes',
|
||||
value: ''
|
||||
});
|
||||
}
|
||||
|
||||
saveClicked() {
|
||||
this.updating = true;
|
||||
this.postsService.updateCategory(this.category).subscribe(res => {
|
||||
this.updating = false;
|
||||
this.original_category = JSON.parse(JSON.stringify(this.category));
|
||||
}, err => {
|
||||
this.updating = false;
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
categoryChanged() {
|
||||
return JSON.stringify(this.category) === JSON.stringify(this.original_category);
|
||||
}
|
||||
|
||||
swapRules(original_index, new_index) {
|
||||
[this.category.rules[original_index], this.category.rules[new_index]] = [this.category.rules[new_index],
|
||||
this.category.rules[original_index]];
|
||||
}
|
||||
|
||||
removeRule(index) {
|
||||
this.category['rules'].splice(index, 1);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user