Add file metadata sidebar entry

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 7501e65d5c
commit e233c1e59c

@ -1474,7 +1474,7 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]]
name = "mediarepo-api"
version = "0.12.0"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=16b892eab0b3446198601a8f5829d0bd54d2efdf#16b892eab0b3446198601a8f5829d0bd54d2efdf"
source = "git+https://github.com/Trivernis/mediarepo-api.git?rev=914292532e562eed389a1a49e0bb802a9f9327e1#914292532e562eed389a1a49e0bb802a9f9327e1"
dependencies = [
"async-trait",
"chrono",

@ -25,7 +25,7 @@ typemap_rev = "0.1.5"
[dependencies.mediarepo-api]
git = "https://github.com/Trivernis/mediarepo-api.git"
rev = "16b892eab0b3446198601a8f5829d0bd54d2efdf"
rev = "914292532e562eed389a1a49e0bb802a9f9327e1"
features = [ "tauri-plugin" ]
[features]

@ -0,0 +1,13 @@
<div class="metadata-inner">
<app-metadata-entry *ngIf="mode === 'read'" [value]="value" [attributeName]="attributeName"></app-metadata-entry>
<mat-form-field *ngIf="mode === 'write'">
<mat-label>{{attributeName}}</mat-label>
<input [formControl]="formControl" type="text" matInput [value]="value">
</mat-form-field>
<button *ngIf="mode === 'write'" mat-button (click)="this.onSave()">
<ng-icon name="mat-save"></ng-icon>
</button>
<button *ngIf="mode === 'read'" mat-button (click)="mode = 'write'">
<ng-icon name="mat-edit"></ng-icon>
</button>
</div>

@ -0,0 +1,17 @@
.metadata-inner {
display: flex;
flex-direction: row;
}
button {
float: right;
}
app-metadata-entry {
width: calc(100% - 4em);
display: block;
}
mat-form-field {
width: calc(100% - 4em);
}

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { EditableMetadataEntryComponent } from './editable-metadata-entry.component';
describe('EditableMetadataEntryComponent', () => {
let component: EditableMetadataEntryComponent;
let fixture: ComponentFixture<EditableMetadataEntryComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ EditableMetadataEntryComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(EditableMetadataEntryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,36 @@
import {
Component,
EventEmitter,
Input,
OnChanges,
OnInit,
Output
} from "@angular/core";
import {FormControl} from "@angular/forms";
@Component({
selector: "app-editable-metadata-entry",
templateUrl: "./editable-metadata-entry.component.html",
styleUrls: ["./editable-metadata-entry.component.scss"]
})
export class EditableMetadataEntryComponent implements OnInit{
@Input() attributeName!: string;
@Input() value!: string;
@Input() mode: "read" | "write" = "read";
@Output() valueChangeEvent = new EventEmitter<string>();
public formControl = new FormControl();
constructor() {
}
public ngOnInit(): void {
this.formControl.setValue(this.value);
}
public onSave(): void {
this.valueChangeEvent.emit(this.formControl.value);
this.mode = "read";
}
}

@ -6,13 +6,12 @@
<div class="file-metadata-entries-scroll-container">
<div class="file-metadata-entries">
<app-metadata-entry attributeName="Name" [value]="file.name ?? ''"></app-metadata-entry>
<app-editable-metadata-entry attributeName="Name" [value]="file.name ?? ''" (valueChangeEvent)="this.saveFileName($event)"></app-editable-metadata-entry>
<app-metadata-entry attributeName="Hash" [value]="file.hash"></app-metadata-entry>
<app-metadata-entry attributeName="Mime Type" [value]="file.mime_type ?? 'unknown'"></app-metadata-entry>
<app-metadata-entry attributeName="Imported at" [value]="file.import_time.toLocaleString()"></app-metadata-entry>
<app-metadata-entry attributeName="Created at" [value]="file.creation_time.toLocaleString()"></app-metadata-entry>
<app-metadata-entry attributeName="Changed at" [value]="file.change_time.toLocaleString()"></app-metadata-entry>
<app-metadata-entry attributeName="Comment" [value]="file.comment ?? ''"></app-metadata-entry>
</div>
</div>

@ -15,7 +15,7 @@
user-select: none;
height: auto;
app-metadata-entry {
app-metadata-entry, app-editable-metadata-entry {
margin: 0.5em 0;
width: 100%;
display: block;

@ -6,30 +6,22 @@ import {
SimpleChanges
} from "@angular/core";
import {File} from "../../../../models/File";
import {FileService} from "../../../../services/file/file.service";
@Component({
selector: "app-file-metadata",
templateUrl: "./file-metadata.component.html",
styleUrls: ["./file-metadata.component.scss"]
})
export class FileMetadataComponent implements OnInit, OnChanges {
export class FileMetadataComponent {
@Input() file!: File;
constructor() {
constructor(private fileService: FileService) {
}
public async ngOnInit(): Promise<void> {
await this.loadFileInformation();
}
public async ngOnChanges(changes: SimpleChanges): Promise<void> {
if (changes["file"]) {
await this.loadFileInformation();
}
}
private async loadFileInformation() {
public async saveFileName(name: string) {
const newFile = await this.fileService.updateFileName(this.file, name);
this.file.name = newFile.name;
}
}

@ -3,7 +3,7 @@ import {CommonModule} from "@angular/common";
import {TagEditComponent} from "./tag-edit/tag-edit.component";
import {FileSearchComponent} from "./file-search/file-search.component";
import {NgIconsModule} from "@ng-icons/core";
import {MatRemove, MatChangeCircle, MatAddCircle, MatRemoveCircle, MatDeleteSweep, MatFilterAlt} from "@ng-icons/material-icons";
import {MatRemove, MatChangeCircle, MatAddCircle, MatRemoveCircle, MatDeleteSweep, MatFilterAlt, MatSave, MatEdit} from "@ng-icons/material-icons";
import {MatRippleModule} from "@angular/material/core";
import {MatButtonModule} from "@angular/material/button";
import {InputModule} from "../input/input.module";
@ -27,7 +27,9 @@ import {MatCheckboxModule} from "@angular/material/checkbox";
import {MatProgressBarModule} from "@angular/material/progress-bar";
import {MatMenuModule} from "@angular/material/menu";
import { FileMetadataComponent } from "./file-metadata/file-metadata.component";
import { MetadataEntryComponent } from './file-metadata/metadata-entry/metadata-entry.component';
import { MetadataEntryComponent } from "./file-metadata/metadata-entry/metadata-entry.component";
import { EditableMetadataEntryComponent } from "./file-metadata/editable-metadata-entry/editable-metadata-entry.component";
import {ReactiveFormsModule} from "@angular/forms";
@NgModule({
@ -41,6 +43,7 @@ import { MetadataEntryComponent } from './file-metadata/metadata-entry/metadata-
FilesystemImportComponent,
FileMetadataComponent,
MetadataEntryComponent,
EditableMetadataEntryComponent,
],
exports: [
TagEditComponent,
@ -75,6 +78,7 @@ import { MetadataEntryComponent } from './file-metadata/metadata-entry/metadata-
MatCheckboxModule,
MatProgressBarModule,
MatMenuModule,
ReactiveFormsModule,
]
})
export class SidebarModule {

Loading…
Cancel
Save