display meta data per image;

style improvements;
This commit is contained in:
Marco Zeisler 2021-01-16 00:40:38 +01:00
parent 24ee19660b
commit 5012c8943f
7 changed files with 73 additions and 31 deletions

View File

@ -24,6 +24,7 @@ import {AgmCoreModule} from '@agm/core';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'; import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import { FileUploaderComponent } from './component/file-uploader/file-uploader.component'; import { FileUploaderComponent } from './component/file-uploader/file-uploader.component';
import {MatSnackBarModule} from '@angular/material/snack-bar'; import {MatSnackBarModule} from '@angular/material/snack-bar';
import {MatGridListModule} from '@angular/material/grid-list';
@NgModule({ @NgModule({
declarations: [LandingComponent, ImagesComponent, MapComponent, FileUploaderComponent], declarations: [LandingComponent, ImagesComponent, MapComponent, FileUploaderComponent],
@ -54,6 +55,7 @@ import {MatSnackBarModule} from '@angular/material/snack-bar';
*/ */
}), }),
MatProgressSpinnerModule, MatProgressSpinnerModule,
MatGridListModule,
], ],
// enables injecting // enables injecting
providers: [ providers: [

View File

@ -10,6 +10,13 @@
type="file" type="file"
> >
<mat-form-field class="margin-right">
<mat-label>* Name</mat-label>
<input matInput
placeholder="Name"
[(ngModel)]="meta ? meta.name : name">
</mat-form-field>
<mat-form-field class="margin-right"> <mat-form-field class="margin-right">
<mat-label>Tag</mat-label> <mat-label>Tag</mat-label>
<input matInput <input matInput
@ -17,17 +24,10 @@
[(ngModel)]="meta ? meta.tag : tag"> [(ngModel)]="meta ? meta.tag : tag">
</mat-form-field> </mat-form-field>
<mat-form-field class="margin-right">
<mat-label>Name</mat-label>
<input matInput
placeholder="Name"
[(ngModel)]="meta ? meta.name : name">
</mat-form-field>
<mat-form-field *ngIf="mode==='post'" <mat-form-field *ngIf="mode==='post'"
class="margin-right" class="margin-right"
> >
<mat-label>Longitude</mat-label> <mat-label>* Longitude</mat-label>
<input matInput <input matInput
placeholder="Add longitude" placeholder="Add longitude"
[(ngModel)]="meta ? meta.longitude : longitude"> [(ngModel)]="meta ? meta.longitude : longitude">
@ -36,7 +36,7 @@
<mat-form-field *ngIf="mode==='post'" <mat-form-field *ngIf="mode==='post'"
class="margin-right" class="margin-right"
> >
<mat-label>Longitude</mat-label> <mat-label>* Latitude</mat-label>
<input matInput <input matInput
placeholder="Add latitude" placeholder="Add latitude"
[(ngModel)]="meta ? meta.latitude : latitude"> [(ngModel)]="meta ? meta.latitude : latitude">
@ -46,7 +46,7 @@
mat-raised-button mat-raised-button
class="margin-right" class="margin-right"
(click)="postFile()" (click)="postFile()"
[disabled]="!(file || mode !== 'post')" [disabled]="!file"
> >
<span *ngIf="mode==='post'; else updateImage">Upload Image</span> <span *ngIf="mode==='post'; else updateImage">Upload Image</span>
<ng-template #updateImage>Update Image</ng-template> <ng-template #updateImage>Update Image</ng-template>

View File

@ -50,7 +50,7 @@ export class FileUploaderComponent implements OnInit {
if (this.longitude && this.latitude) { if (this.longitude && this.latitude) {
metaDict['longitude'] = Number.parseFloat(this.longitude); metaDict['longitude'] = Number.parseFloat(this.longitude);
metaDict['latitude'] = Number.parseFloat(this.latitude); metaDict['latitude'] = Number.parseFloat(this.latitude);
} else if (this.meta.longitude && this.meta.latitude) { } else if (this.meta && this.meta.longitude && this.meta.latitude) {
metaDict['longitude'] = this.meta.longitude; metaDict['longitude'] = this.meta.longitude;
metaDict['latitude'] = this.meta.latitude; metaDict['latitude'] = this.meta.latitude;
} else { } else {
@ -60,7 +60,7 @@ export class FileUploaderComponent implements OnInit {
if (this.name) { if (this.name) {
metaDict['name'] = this.name; metaDict['name'] = this.name;
} else if (this.meta.name) { } else if (this.meta && this.meta.name) {
metaDict['name'] = this.meta.name; metaDict['name'] = this.meta.name;
} else { } else {
if (this.mode === 'post') { if (this.mode === 'post') {
@ -70,7 +70,7 @@ export class FileUploaderComponent implements OnInit {
if (this.tag) { if (this.tag) {
metaDict['tag'] = this.tag; metaDict['tag'] = this.tag;
} else if (this.meta.tag) { } else if (this.meta && this.meta.tag) {
metaDict['tag'] = this.meta.tag; metaDict['tag'] = this.meta.tag;
} }
@ -134,9 +134,19 @@ export class FileUploaderComponent implements OnInit {
this.snackBar.open('Upload successful', 'Dismiss'); this.snackBar.open('Upload successful', 'Dismiss');
this.reload.emit(this.currentFileName); this.reload.emit(this.currentFileName);
this.name = '';
this.tag = '';
this.longitude = '';
this.latitude = '';
} catch (err) { } catch (err) {
this.logger.error('error', err); this.logger.error('error', err);
this.snackBar.open(err.error.Error, 'Dismiss'); try {
this.snackBar.open(err.error.Error, 'Dismiss');
} catch {
this.snackBar.open(err.message, 'Dismiss');
}
} }
} }

View File

@ -11,13 +11,13 @@
(opened)="loadImage(i + paginationGetStart(), image.filename.split('.')[0])" (opened)="loadImage(i + paginationGetStart(), image.filename.split('.')[0])"
> >
<mat-expansion-panel-header (click)="$event.stopPropagation()"> <mat-expansion-panel-header (click)="$event.stopPropagation()">
<span style="width: 30em" <h4 style="width: 25em"
>{{image.name}}</span> >{{image.name}}</h4>
<span style="width: 30em" <h4 style="width: 25em"
>{{image.datetime}}</span> >{{image.datetime}}</h4>
<span style="width: 30em"> <h4 style="width: 25em; color: red">
✓ | X (TO BE DONE) ✓ | X (TO BE DONE)
</span> </h4>
<span style="float: right; margin-left: auto; margin-right: 1em;"> <span style="float: right; margin-left: auto; margin-right: 1em;">
<button mat-raised-button color="warn" <button mat-raised-button color="warn"
(click)="deleteImage(image); $event.stopPropagation()"> (click)="deleteImage(image); $event.stopPropagation()">
@ -26,22 +26,46 @@
</span> </span>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<ng-template matExpansionPanelContent> <mat-divider style="
<div style="width: 20em; height: 20em; border: solid; margin-bottom: 1em; display: flex"> margin-top: 1em;
<img *ngIf="image.image_b64, let b64; else loadingImage" margin-bottom: 1em;
[src]="b64" opacity: 20%;"></mat-divider>
style="width: 100%; margin: auto" [alt]="image.filename"/>
<ng-template #loadingImage>
<mat-spinner style="margin: auto;"></mat-spinner>
</ng-template>
</div> <ng-template matExpansionPanelContent>
<mat-grid-list cols="4" rowHeight="22em" style="width: 100%; margin: auto">
<mat-grid-tile style="justify-content: left!important;" colspan="1">
<div style="width: 20em; height: 20em; border: solid; margin-bottom: 1em; display: flex">
<img *ngIf="image.image_b64, let b64; else loadingImage"
[src]="b64"
style="width: 100%; margin: auto" [alt]="image.filename"/>
<ng-template #loadingImage>
<mat-spinner style="margin: auto;"></mat-spinner>
</ng-template>
</div>
</mat-grid-tile>
<mat-grid-tile colspan="3">
<div style="display: block; width: 100%">
<h3>Metadata:</h3>
<p *ngIf="image.filename">filename: {{image.filename}}</p>
<p *ngIf="image.tag">tag: {{image.tag}}</p>
<p *ngIf="image.latitude">latitude: {{image.latitude}}</p>
<p *ngIf="image.longitude">longitude: {{image.longitude}}</p>
<p *ngIf="image.version">version: {{image.version}}</p>
</div>
</mat-grid-tile>
</mat-grid-list>
<app-file-uploader [mode]="'put'" <app-file-uploader [mode]="'put'"
[filename]="image.filename.split('.')[0]" [filename]="image.filename.split('.')[0]"
[meta]=image [meta]=image
(reload)="loadImage(i + paginationGetStart(), $event.split('.')[0])" (reload)="this.reload.emit()"
></app-file-uploader> ></app-file-uploader>
<!-- (reload)="loadImage(i + paginationGetStart(), $event.split('.')[0])"-->
</ng-template> </ng-template>
</mat-expansion-panel> </mat-expansion-panel>

View File

@ -20,6 +20,7 @@ export interface ImageMetadata {
selected?: boolean; selected?: boolean;
image_b64?: string; image_b64?: string;
tag?: string; tag?: string;
version?: string;
} }
export interface GetImageResponse { export interface GetImageResponse {

View File

@ -21,3 +21,9 @@ h2 {
padding-left: 0 !important; padding-left: 0 !important;
margin-bottom: 1em; margin-bottom: 1em;
} }
.mat-figure {
justify-content: left !important;
display: grid !important;
align-items: baseline !important;
}