Add context menu action to regenerate a thumbnail

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 6510e6392a
commit 09f3225aa3

@ -1473,8 +1473,8 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.11.0" version = "0.11.1"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=8f19fe419203842e3e7bff130d52be90de733504#8f19fe419203842e3e7bff130d52be90de733504" source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=d56e2c7406e9b8b15b22bc2714eebff00f63d778#d56e2c7406e9b8b15b22bc2714eebff00f63d778"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"chrono", "chrono",

@ -30,7 +30,7 @@ features = ["env-filter"]
[dependencies.mediarepo-api] [dependencies.mediarepo-api]
git = "https://github.com/Trivernis/mediarepo-api.git" git = "https://github.com/Trivernis/mediarepo-api.git"
rev = "8f19fe419203842e3e7bff130d52be90de733504" rev = "d56e2c7406e9b8b15b22bc2714eebff00f63d778"
features = ["tauri-plugin"] features = ["tauri-plugin"]
[features] [features]

@ -1,5 +1,4 @@
<div class="menu-anchor" [matMenuTriggerFor]="contextMenu" [style.left]="x" [style.top]="y"></div> <div class="menu-anchor" [matMenuTriggerFor]="contextMenu" [style.left]="x" [style.top]="y"></div>
<mat-menu #contextMenu="matMenu"> <mat-menu #contextMenu="matMenu">
<ng-content select="mat-menu-item"></ng-content>
<ng-content></ng-content> <ng-content></ng-content>
</mat-menu> </mat-menu>

@ -1,5 +1,5 @@
<app-context-menu #contextMenu> <app-context-menu #contextMenu>
<button mat-menu-item (click)="this.copyFileHash()">Copy Hash</button> <button mat-menu-item (click)="this.copyFileHash()">Copy Hash</button>
<button mat-menu-item (click)="this.exportFile()">Save As...</button> <button mat-menu-item (click)="this.exportFile()">Save As...</button>
<ng-content select="mat-menu-item"></ng-content> <ng-content></ng-content>
</app-context-menu> </app-context-menu>

@ -13,4 +13,6 @@
</cdk-virtual-scroll-viewport> </cdk-virtual-scroll-viewport>
</div> </div>
<app-file-context-menu #fileContextMenu></app-file-context-menu> <app-file-context-menu #fileContextMenu>
<button mat-menu-item (click)="this.regenerateThumbnail(fileContextMenu.file)">Regenerate thumbnail</button>
</app-file-context-menu>

@ -15,6 +15,7 @@ import {FileGridEntryComponent} from "./file-grid-entry/file-grid-entry.componen
import {GridEntry} from "./file-grid-entry/GridEntry"; import {GridEntry} from "./file-grid-entry/GridEntry";
import {CdkVirtualScrollViewport} from "@angular/cdk/scrolling"; import {CdkVirtualScrollViewport} from "@angular/cdk/scrolling";
import {TabService} from "../../services/tab/tab.service"; import {TabService} from "../../services/tab/tab.service";
import {FileService} from "../../services/file/file.service";
@Component({ @Component({
selector: 'app-file-grid', selector: 'app-file-grid',
@ -39,7 +40,10 @@ export class FileGridComponent implements OnChanges, OnInit {
private ctrlClicked = false; private ctrlClicked = false;
private gridEntries: GridEntry[] = [] private gridEntries: GridEntry[] = []
constructor(private tabService: TabService) { constructor(
private tabService: TabService,
private fileService: FileService,
) {
tabService.selectedTab.subscribe(() => this.adjustElementSizes()); tabService.selectedTab.subscribe(() => this.adjustElementSizes());
} }
@ -189,4 +193,8 @@ export class FileGridComponent implements OnChanges, OnInit {
this.virtualScroll.checkViewportSize(); this.virtualScroll.checkViewportSize();
} }
} }
public async regenerateThumbnail(file: File) {
await this.fileService.deleteThumbnails(file);
}
} }

@ -61,7 +61,22 @@ export class FileService {
return this.sanitizer.bypassSecurityTrustResourceUrl(`content://${file.hash}`) return this.sanitizer.bypassSecurityTrustResourceUrl(`content://${file.hash}`)
} }
/**
* Saves a file locally
* @param {File} file
* @param {string} targetPath
* @returns {Promise<void>}
*/
public async saveFile(file: File, targetPath: string) { public async saveFile(file: File, targetPath: string) {
await invoke("plugin:mediarepo|save_file_locally", {id: file.id, path: targetPath}) await invoke("plugin:mediarepo|save_file_locally", {id: file.id, path: targetPath})
} }
/**
* Deletes all thumbnails of a file
* @param {File} file
* @returns {Promise<void>}
*/
public async deleteThumbnails(file: File) {
await invoke("plugin:mediarepo|delete_thumbnails", {id: file.id});
}
} }

Loading…
Cancel
Save