1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

fixing infobar keyword error

This commit is contained in:
Braun Patrik 2017-07-16 17:15:42 +02:00
parent 49b749d90b
commit 029dd68e5c
3 changed files with 34 additions and 10 deletions

View File

@ -33,7 +33,7 @@ export class DiskMangerWorker {
return reject({file: fullPath, error: err}); return reject({file: fullPath, error: err});
} }
const metadata: PhotoMetadata = <PhotoMetadata>{ const metadata: PhotoMetadata = <PhotoMetadata>{
keywords: {}, keywords: [],
cameraData: {}, cameraData: {},
positionData: null, positionData: null,
size: {}, size: {},
@ -51,6 +51,7 @@ export class DiskMangerWorker {
try { try {
const exif = exif_parser.create(data).parse(); const exif = exif_parser.create(data).parse();
console.log(exif);
metadata.cameraData = <CameraMetadata> { metadata.cameraData = <CameraMetadata> {
ISO: exif.tags.ISO, ISO: exif.tags.ISO,
model: exif.tags.Model, model: exif.tags.Model,
@ -69,9 +70,20 @@ export class DiskMangerWorker {
}; };
} }
metadata.size = <ImageSize> {width: exif.imageSize.width, height: exif.imageSize.height}; if (exif.tags.CreateDate || exif.tags.DateTimeOriginal || exif.tags.ModifyDate) {
metadata.creationDate = exif.tags.CreateDate || exif.tags.DateTimeOriginal || exif.tags.ModifyDate;
}
if (exif.imageSize) {
metadata.size = <ImageSize> {width: exif.imageSize.width, height: exif.imageSize.height};
} else if (exif.tags.RelatedImageWidth && exif.tags.RelatedImageHeight) {
metadata.size = <ImageSize> {width: exif.tags.RelatedImageWidth, height: exif.tags.RelatedImageHeight};
} else {
metadata.size = <ImageSize> {width: 1, height: 1};
}
} catch (err) { } catch (err) {
Logger.info(LOG_TAG, "Error parsing exif", fullPath); Logger.debug(LOG_TAG, "Error parsing exif", fullPath, err);
metadata.size = <ImageSize> {width: 1, height: 1}; metadata.size = <ImageSize> {width: 1, height: 1};
} }
@ -83,13 +95,15 @@ export class DiskMangerWorker {
metadata.positionData.state = iptcData.province_or_state; metadata.positionData.state = iptcData.province_or_state;
metadata.positionData.city = iptcData.city; metadata.positionData.city = iptcData.city;
} }
metadata.keywords = <string[]> (iptcData.keywords || []); metadata.keywords = <string[]> (iptcData.keywords || []);
metadata.creationDate = <number> (iptcData.date_time ? iptcData.date_time.getTime() : 0); metadata.creationDate = <number> (iptcData.date_time ? iptcData.date_time.getTime() : metadata.creationDate);
} catch (err) { } catch (err) {
Logger.info(LOG_TAG, "Error parsing iptc data", fullPath, err); Logger.debug(LOG_TAG, "Error parsing iptc data", fullPath, err);
} }
metadata.creationDate = metadata.creationDate || 0;
return resolve(metadata); return resolve(metadata);
} catch (err) { } catch (err) {
return reject({file: fullPath, error: err}); return reject({file: fullPath, error: err});

View File

@ -1,4 +1,4 @@
<div #photoContainer class="photo-container" (mouseover)="hover()" (mouseout)="mouseOut()"> <div #photoContainer class="photo-container" (mouseover)="mouseOver()" (mouseout)="mouseOut()">
<img #img [src]="thumbnail.Src" *ngIf="thumbnail.Available"> <img #img [src]="thumbnail.Src" *ngIf="thumbnail.Available">
<gallery-grid-photo-loading <gallery-grid-photo-loading
@ -24,7 +24,7 @@
</ng-template> </ng-template>
</div> </div>
<div class="photo-keywords"> <div class="photo-keywords" *ngIf="gridPhoto.photo.metadata.keywords && gridPhoto.photo.metadata.keywords.length">
<ng-template ngFor let-keyword [ngForOf]="gridPhoto.photo.metadata.keywords" let-last="last"> <ng-template ngFor let-keyword [ngForOf]="gridPhoto.photo.metadata.keywords" let-last="last">
<a *ngIf="searchEnabled" <a *ngIf="searchEnabled"
[routerLink]="['/search', keyword, {type: SearchTypes[SearchTypes.keyword]}]">#{{keyword}}</a> [routerLink]="['/search', keyword, {type: SearchTypes[SearchTypes.keyword]}]">#{{keyword}}</a>

View File

@ -86,14 +86,24 @@ export class GalleryPhotoComponent implements IRenderable, OnInit, OnDestroy {
} }
hover() { mouseOver() {
this.infoBar.visible = true; this.infoBar.visible = true;
if (this.animationTimer != null) { if (this.animationTimer != null) {
clearTimeout(this.animationTimer); clearTimeout(this.animationTimer);
} }
this.animationTimer = setTimeout(() => { this.animationTimer = setTimeout(() => {
this.infoBar.marginTop = -this.infoDiv.nativeElement.clientHeight;
this.infoBar.background = "rgba(0,0,0,0.8)"; this.infoBar.background = "rgba(0,0,0,0.8)";
if (!this.infoDiv) {
this.animationTimer = setTimeout(() => {
if (!this.infoDiv) {
this.infoBar.marginTop = -50;
return;
}
this.infoBar.marginTop = -this.infoDiv.nativeElement.clientHeight;
}, 10);
return;
}
}, 1); }, 1);
} }