|
|
@ -16,6 +16,7 @@ import {CdkVirtualScrollViewport} from "@angular/cdk/scrolling";
|
|
|
|
import {TagService} from "../../../../services/tag/tag.service";
|
|
|
|
import {TagService} from "../../../../services/tag/tag.service";
|
|
|
|
import {LoggingService} from "../../../../services/logging/logging.service";
|
|
|
|
import {LoggingService} from "../../../../services/logging/logging.service";
|
|
|
|
import {BusyIndicatorComponent} from "../../app-common/busy-indicator/busy-indicator.component";
|
|
|
|
import {BusyIndicatorComponent} from "../../app-common/busy-indicator/busy-indicator.component";
|
|
|
|
|
|
|
|
import {Observable} from "rxjs";
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: "app-tag-edit",
|
|
|
|
selector: "app-tag-edit",
|
|
|
@ -32,7 +33,7 @@ export class TagEditComponent implements AfterViewInit, OnChanges {
|
|
|
|
@ViewChild(BusyIndicatorComponent) busyIndicator!: BusyIndicatorComponent;
|
|
|
|
@ViewChild(BusyIndicatorComponent) busyIndicator!: BusyIndicatorComponent;
|
|
|
|
|
|
|
|
|
|
|
|
public tags: Tag[] = [];
|
|
|
|
public tags: Tag[] = [];
|
|
|
|
public allTags: Tag[] = [];
|
|
|
|
public allTags: Observable<Tag[]>;
|
|
|
|
public editMode: string = "Toggle";
|
|
|
|
public editMode: string = "Toggle";
|
|
|
|
private fileTags: { [key: number]: Tag[] } = {};
|
|
|
|
private fileTags: { [key: number]: Tag[] } = {};
|
|
|
|
|
|
|
|
|
|
|
@ -41,10 +42,10 @@ export class TagEditComponent implements AfterViewInit, OnChanges {
|
|
|
|
private logger: LoggingService,
|
|
|
|
private logger: LoggingService,
|
|
|
|
private tagService: TagService,
|
|
|
|
private tagService: TagService,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
this.allTags = tagService.tags.asObservable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async ngAfterViewInit() {
|
|
|
|
async ngAfterViewInit() {
|
|
|
|
this.tagService.tags.subscribe(tags => this.allTags = tags);
|
|
|
|
|
|
|
|
await this.tagService.loadTags();
|
|
|
|
await this.tagService.loadTags();
|
|
|
|
await this.tagService.loadNamespaces();
|
|
|
|
await this.tagService.loadNamespaces();
|
|
|
|
await this.loadFileTags();
|
|
|
|
await this.loadFileTags();
|
|
|
@ -58,12 +59,12 @@ export class TagEditComponent implements AfterViewInit, OnChanges {
|
|
|
|
|
|
|
|
|
|
|
|
public async editTag(tag: string): Promise<void> {
|
|
|
|
public async editTag(tag: string): Promise<void> {
|
|
|
|
if (tag.length > 0) {
|
|
|
|
if (tag.length > 0) {
|
|
|
|
let tagInstance = this.allTags.find(
|
|
|
|
let tagInstance = this.tagService.tags.value.find(
|
|
|
|
t => t.getNormalizedOutput() === tag);
|
|
|
|
t => t.getNormalizedOutput() === tag);
|
|
|
|
|
|
|
|
|
|
|
|
if (!tagInstance) {
|
|
|
|
if (!tagInstance) {
|
|
|
|
tagInstance = (await this.tagService.createTags([tag]))[0];
|
|
|
|
tagInstance = (await this.tagService.createTags([tag]))[0];
|
|
|
|
this.allTags.push(tagInstance);
|
|
|
|
this.tagService.tags.next([...this.tagService.tags.value, tagInstance]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
this.changeDetector.markForCheck();
|
|
|
|
switch (this.editMode) {
|
|
|
|
switch (this.editMode) {
|
|
|
@ -95,11 +96,13 @@ export class TagEditComponent implements AfterViewInit, OnChanges {
|
|
|
|
file.id,
|
|
|
|
file.id,
|
|
|
|
addedTags, removedTags
|
|
|
|
addedTags, removedTags
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (addedTags.length > 0) {
|
|
|
|
if (addedTags.length > 0) {
|
|
|
|
await this.tagService.loadTags();
|
|
|
|
await this.tagService.loadTags();
|
|
|
|
await this.tagService.loadNamespaces();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.tagService.loadTags();
|
|
|
|
|
|
|
|
await this.tagService.loadNamespaces();
|
|
|
|
this.mapFileTagsToTagList();
|
|
|
|
this.mapFileTagsToTagList();
|
|
|
|
const index = this.tags.indexOf(tag);
|
|
|
|
const index = this.tags.indexOf(tag);
|
|
|
|
if (index >= 0) {
|
|
|
|
if (index >= 0) {
|
|
|
@ -142,6 +145,8 @@ export class TagEditComponent implements AfterViewInit, OnChanges {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.tagService.loadTags();
|
|
|
|
|
|
|
|
await this.tagService.loadNamespaces();
|
|
|
|
this.mapFileTagsToTagList();
|
|
|
|
this.mapFileTagsToTagList();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.tagEditEvent.emit(this);
|
|
|
|
this.tagEditEvent.emit(this);
|
|
|
|