|
|
@ -1,5 +1,5 @@
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
Component, ElementRef,
|
|
|
|
Input,
|
|
|
|
Input,
|
|
|
|
OnChanges,
|
|
|
|
OnChanges,
|
|
|
|
OnInit,
|
|
|
|
OnInit,
|
|
|
@ -14,6 +14,7 @@ import {MatAutocompleteSelectedEvent} from "@angular/material/autocomplete";
|
|
|
|
import {Observable} from "rxjs";
|
|
|
|
import {Observable} from "rxjs";
|
|
|
|
import {map, startWith} from "rxjs/operators";
|
|
|
|
import {map, startWith} from "rxjs/operators";
|
|
|
|
import {TagService} from "../../services/tag/tag.service";
|
|
|
|
import {TagService} from "../../services/tag/tag.service";
|
|
|
|
|
|
|
|
import {FileService} from "../../services/file/file.service";
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'app-file-edit',
|
|
|
|
selector: 'app-file-edit',
|
|
|
@ -33,9 +34,11 @@ export class FileEditComponent implements OnInit, OnChanges {
|
|
|
|
public editMode: string = "Toggle";
|
|
|
|
public editMode: string = "Toggle";
|
|
|
|
|
|
|
|
|
|
|
|
@ViewChild("tagScroll") tagScroll!: CdkVirtualScrollViewport;
|
|
|
|
@ViewChild("tagScroll") tagScroll!: CdkVirtualScrollViewport;
|
|
|
|
|
|
|
|
@ViewChild("fileNameInput") fileNameInput!: ElementRef<HTMLInputElement>;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
private tagService: TagService,
|
|
|
|
private tagService: TagService,
|
|
|
|
|
|
|
|
private fileService: FileService,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
this.suggestionTags = this.tagInputForm.valueChanges.pipe(startWith(null),
|
|
|
|
this.suggestionTags = this.tagInputForm.valueChanges.pipe(startWith(null),
|
|
|
|
map(
|
|
|
|
map(
|
|
|
@ -47,11 +50,26 @@ export class FileEditComponent implements OnInit, OnChanges {
|
|
|
|
this.tagService.tags.subscribe(tags => this.allTags = tags);
|
|
|
|
this.tagService.tags.subscribe(tags => this.allTags = tags);
|
|
|
|
await this.tagService.loadTags();
|
|
|
|
await this.tagService.loadTags();
|
|
|
|
await this.loadFileTags();
|
|
|
|
await this.loadFileTags();
|
|
|
|
|
|
|
|
this.resetFileNameInput();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async ngOnChanges(changes: SimpleChanges) {
|
|
|
|
async ngOnChanges(changes: SimpleChanges) {
|
|
|
|
if (changes["files"]) {
|
|
|
|
if (changes["files"]) {
|
|
|
|
await this.loadFileTags()
|
|
|
|
await this.loadFileTags()
|
|
|
|
|
|
|
|
this.resetFileNameInput();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async changeFileName(value: string) {
|
|
|
|
|
|
|
|
const name = value.trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (name.length > 0) {
|
|
|
|
|
|
|
|
const file = this.files[0];
|
|
|
|
|
|
|
|
console.log("Updating name to", name);
|
|
|
|
|
|
|
|
const responseFile = await this.fileService.updateFileName(file, name);
|
|
|
|
|
|
|
|
console.log("Updated name");
|
|
|
|
|
|
|
|
file.name = responseFile.name;
|
|
|
|
|
|
|
|
this.resetFileNameInput();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -145,6 +163,12 @@ export class FileEditComponent implements OnInit, OnChanges {
|
|
|
|
this.mapFileTagsToTagList();
|
|
|
|
this.mapFileTagsToTagList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private resetFileNameInput() {
|
|
|
|
|
|
|
|
if (this.files.length === 1) {
|
|
|
|
|
|
|
|
this.fileNameInput.nativeElement.value = this.files[0].name ?? "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private mapFileTagsToTagList() {
|
|
|
|
private mapFileTagsToTagList() {
|
|
|
|
let tags: Tag[] = [];
|
|
|
|
let tags: Tag[] = [];
|
|
|
|
for (const file of this.files) {
|
|
|
|
for (const file of this.files) {
|
|
|
|