You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
3 years ago
|
import {Component, ViewChild} from "@angular/core";
|
||
3 years ago
|
import {File} from "../../../../models/File";
|
||
3 years ago
|
import {ContextMenuComponent} from "../../app-common/context-menu/context-menu.component";
|
||
3 years ago
|
import {clipboard} from "@tauri-apps/api";
|
||
3 years ago
|
import {FileService} from "../../../../services/file/file.service";
|
||
|
import {ErrorBrokerService} from "../../../../services/error-broker/error-broker.service";
|
||
|
import {FileHelper} from "../../../../services/file/file.helper";
|
||
3 years ago
|
|
||
|
@Component({
|
||
3 years ago
|
selector: "app-file-context-menu",
|
||
|
templateUrl: "./file-context-menu.component.html",
|
||
|
styleUrls: ["./file-context-menu.component.scss"]
|
||
3 years ago
|
})
|
||
|
export class FileContextMenuComponent {
|
||
|
|
||
3 years ago
|
public file!: File;
|
||
3 years ago
|
|
||
3 years ago
|
@ViewChild("contextMenu") contextMenu!: ContextMenuComponent;
|
||
3 years ago
|
|
||
3 years ago
|
constructor(private fileService: FileService, private errorBroker: ErrorBrokerService) {
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
public onContextMenu(event: MouseEvent, file: File) {
|
||
|
this.file = file;
|
||
|
this.contextMenu.onContextMenu(event);
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
public async copyFileHash(): Promise<void> {
|
||
|
await clipboard.writeText(this.file.hash);
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
public async exportFile(): Promise<void> {
|
||
|
const path = await FileHelper.getFileDownloadLocation(this.file)
|
||
3 years ago
|
|
||
3 years ago
|
if (path) {
|
||
|
try {
|
||
|
await this.fileService.saveFile(this.file, path);
|
||
|
} catch (err) {
|
||
|
this.errorBroker.showError(err);
|
||
|
}
|
||
|
}
|
||
3 years ago
|
}
|
||
|
}
|