Fix issue with unselecting files

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 2f4d7ff73d
commit 16de88cf38

@ -10,6 +10,18 @@
background-color: darken(mat.get-color-from-palette($primary-palette, 'darker'), 35); background-color: darken(mat.get-color-from-palette($primary-palette, 'darker'), 35);
color: white color: white
} }
::ng-deep ::-webkit-scrollbar {
width: 10px;
}
::ng-deep ::-webkit-scrollbar-thumb {
background: mat.get-color-from-palette($primary-palette, 'darker');
border-radius: 1px;
}
::ng-deep ::-webkit-scrollbar-thumb:hover {
background: mat.get-color-from-palette($primary-palette);
}
.warn { .warn {
background-color: mat.get-color-from-palette($warn-palette); background-color: mat.get-color-from-palette($warn-palette);

@ -27,6 +27,7 @@ export class FileGridEntryComponent implements OnInit, OnDestroy {
selectedThumbnail: Thumbnail | undefined; selectedThumbnail: Thumbnail | undefined;
contentUrl: SafeResourceUrl | undefined; contentUrl: SafeResourceUrl | undefined;
constructor(private fileService: FileService, private errorBroker: ErrorBrokerService) { } constructor(private fileService: FileService, private errorBroker: ErrorBrokerService) { }
async ngOnInit() { async ngOnInit() {
@ -37,21 +38,20 @@ export class FileGridEntryComponent implements OnInit, OnDestroy {
if (this.contentUrl) { if (this.contentUrl) {
const url = this.contentUrl; const url = this.contentUrl;
this.contentUrl = undefined; this.contentUrl = undefined;
URL?.revokeObjectURL(url as string);
} }
} }
async loadImage() { async loadImage() {
try { try {
const thumbnails = await this.fileService.getThumbnails(this.gridEntry.file.hash); const thumbnails = await this.fileService.getThumbnails(this.gridEntry.file.hash);
let thumbnail = thumbnails.find(t => (t.height > 250 || t.width > 250) && (t.height < 500 && t.width < 500)); let thumbnail = thumbnails.find(t => (t.height > 250 || t.width > 250) && (t.height < 500 && t.width < 500));
this.selectedThumbnail = thumbnail; this.selectedThumbnail = thumbnail;
if (!thumbnail) { if (!thumbnail) {
console.log("Thumbnail is empty?!", thumbnails); console.log("Thumbnail is empty?!", thumbnails);
} else { } else {
this.contentUrl = await this.fileService.readThumbnail(thumbnail!!); this.contentUrl = await this.fileService.readThumbnail(thumbnail!!);
} }
} catch (err) { } catch (err) {
this.errorBroker.showError(err); this.errorBroker.showError(err);
} }

@ -62,7 +62,14 @@ export class FileGridComponent implements OnChanges {
this.handleShiftSelect(clickedEntry); this.handleShiftSelect(clickedEntry);
} else { } else {
clickedEntry.selected = !clickedEntry.selected; clickedEntry.selected = !clickedEntry.selected;
this.selectedEntries.push(clickedEntry); if (!clickedEntry.selected) {
const index = this.selectedEntries.indexOf(clickedEntry);
if (index > -1) {
this.selectedEntries.splice(index, 1);
}
} else {
this.selectedEntries.push(clickedEntry);
}
} }
if (this.selectedEntries.length == 1) { if (this.selectedEntries.length == 1) {
this.fileSelectEvent.emit(this.selectedEntries.map(entry => entry.file)[0]); this.fileSelectEvent.emit(this.selectedEntries.map(entry => entry.file)[0]);

@ -4,6 +4,7 @@
</mat-toolbar> </mat-toolbar>
<mat-drawer-container> <mat-drawer-container>
<mat-drawer mode="side" opened> <mat-drawer mode="side" opened>
<div class="drawer-sidebar-inner">
<mat-form-field id="tag-search" appearance="fill"> <mat-form-field id="tag-search" appearance="fill">
<mat-chip-list #chipList> <mat-chip-list #chipList>
<mat-chip *ngFor="let tag of searchTags" (removed)="removeSearchTag(tag)" [removable]="true"> <mat-chip *ngFor="let tag of searchTags" (removed)="removeSearchTag(tag)" [removable]="true">
@ -20,15 +21,20 @@
(matChipInputTokenEnd)="addSearchTag($event)"/> (matChipInputTokenEnd)="addSearchTag($event)"/>
</mat-form-field> </mat-form-field>
<h1>Tags</h1> <div id="file-tag-list">
<mat-selection-list [multiple]="false"> <h1>Selection Tags</h1>
<mat-list-option <mat-selection-list [multiple]="false" *ngIf="tags.length > 0">
*ngFor="let tag of tags">{{tag.namespace ? tag.namespace + ':' + tag.name : tag.name}}</mat-list-option> <mat-list-option
</mat-selection-list> *ngFor="let tag of tags">{{tag.namespace ? tag.namespace + ':' + tag.name : tag.name}}</mat-list-option>
</mat-selection-list>
</div>
</div>
</mat-drawer> </mat-drawer>
<mat-drawer-content> <mat-drawer-content>
<app-file-grid (fileDblClickEvent)="openFile($event)" [files]="files" <app-file-grid (fileDblClickEvent)="openFile($event)" [files]="files"
(fileSelectEvent)="onFileSelect($event)"></app-file-grid> (fileSelectEvent)="onFileSelect($event)"
(fileMultiselectEvent)="onFileMultiSelect($event)"
></app-file-grid>
</mat-drawer-content> </mat-drawer-content>
</mat-drawer-container> </mat-drawer-container>

@ -12,9 +12,21 @@
width: 100%; width: 100%;
} }
#file-tag-list {
height: calc(100% - 8em);
overflow: auto;
}
.drawer-sidebar-inner {
height: 100%;
width: 100%;
display: block;
}
mat-drawer { mat-drawer {
height: 100%; height: 100%;
width: 25%; width: 25%;
overflow: hidden;
} }
mat-drawer-content { mat-drawer-content {

@ -35,6 +35,12 @@ export class HomeComponent implements OnInit {
await this.fileService.getFiles(); await this.fileService.getFiles();
} }
async onFileMultiSelect(files: File[]) {
if (files.length === 0) {
this.clearFileDetails();
}
}
async onFileSelect(file: File | undefined) { async onFileSelect(file: File | undefined) {
if (file) { if (file) {
await this.showFileDetails(file); await this.showFileDetails(file);

Loading…
Cancel
Save