2018-03-31 03:30:30 +08:00
|
|
|
import {Component, ElementRef, EventEmitter, Input, Output} from '@angular/core';
|
2018-11-05 02:28:32 +08:00
|
|
|
import {CameraMetadata, PhotoDTO} from '../../../../../common/entities/PhotoDTO';
|
2018-03-31 03:30:30 +08:00
|
|
|
import {Config} from '../../../../../common/config/public/Config';
|
2018-11-05 02:28:32 +08:00
|
|
|
import {MediaDTO} from '../../../../../common/entities/MediaDTO';
|
2017-07-10 04:00:42 +08:00
|
|
|
|
|
|
|
@Component({
|
2018-05-04 07:17:08 +08:00
|
|
|
selector: 'app-info-panel',
|
2017-07-10 04:00:42 +08:00
|
|
|
styleUrls: ['./info-panel.lightbox.gallery.component.css'],
|
|
|
|
templateUrl: './info-panel.lightbox.gallery.component.html',
|
|
|
|
})
|
|
|
|
export class InfoPanelLightboxComponent {
|
2018-11-05 02:28:32 +08:00
|
|
|
@Input() media: MediaDTO;
|
2017-07-18 00:30:16 +08:00
|
|
|
@Output('onClose') onClose = new EventEmitter();
|
2017-07-14 05:39:09 +08:00
|
|
|
public mapEnabled = true;
|
2017-07-10 04:00:42 +08:00
|
|
|
|
2017-07-11 04:00:22 +08:00
|
|
|
constructor(public elementRef: ElementRef) {
|
2017-07-14 05:39:09 +08:00
|
|
|
this.mapEnabled = Config.Client.Map.enabled;
|
2017-07-10 04:00:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
calcMpx() {
|
2018-11-05 02:28:32 +08:00
|
|
|
return (this.media.metadata.size.width * this.media.metadata.size.height / 1000000).toFixed(2);
|
2017-07-10 04:00:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
calcFileSize() {
|
2018-05-04 07:17:08 +08:00
|
|
|
const postFixes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
2017-07-10 04:00:42 +08:00
|
|
|
let index = 0;
|
2018-11-05 02:28:32 +08:00
|
|
|
let size = this.media.metadata.fileSize;
|
2017-07-10 04:00:42 +08:00
|
|
|
while (size > 1000 && index < postFixes.length - 1) {
|
|
|
|
size /= 1000;
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
return size.toFixed(2) + postFixes[index];
|
|
|
|
}
|
|
|
|
|
2018-05-29 00:03:52 +08:00
|
|
|
isThisYear() {
|
|
|
|
return (new Date()).getFullYear() ===
|
2018-11-05 02:28:32 +08:00
|
|
|
(new Date(this.media.metadata.creationDate)).getFullYear();
|
2017-07-10 04:00:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getTime() {
|
2018-11-05 02:28:32 +08:00
|
|
|
const date = new Date(this.media.metadata.creationDate);
|
2017-07-22 01:33:24 +08:00
|
|
|
return date.toTimeString().split(' ')[0];
|
2017-07-10 04:00:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
toFraction(f) {
|
|
|
|
if (f > 1) {
|
|
|
|
return f;
|
|
|
|
}
|
2018-03-31 03:30:30 +08:00
|
|
|
return '1/' + (1 / f);
|
2017-07-10 04:00:42 +08:00
|
|
|
}
|
|
|
|
|
2018-05-14 04:59:57 +08:00
|
|
|
hasPositionData(): boolean {
|
2018-11-05 02:28:32 +08:00
|
|
|
return MediaDTO.hasPositionData(this.media);
|
2018-05-14 04:59:57 +08:00
|
|
|
}
|
|
|
|
|
2017-07-10 04:00:42 +08:00
|
|
|
hasGPS() {
|
2018-11-05 02:28:32 +08:00
|
|
|
return this.media.metadata.positionData && this.media.metadata.positionData.GPSData &&
|
|
|
|
this.media.metadata.positionData.GPSData.latitude && this.media.metadata.positionData.GPSData.longitude;
|
2017-07-10 04:00:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
getPositionText(): string {
|
2018-11-05 02:28:32 +08:00
|
|
|
if (!this.media.metadata.positionData) {
|
2018-03-31 03:30:30 +08:00
|
|
|
return '';
|
2017-07-10 04:00:42 +08:00
|
|
|
}
|
2018-11-05 02:28:32 +08:00
|
|
|
let str = this.media.metadata.positionData.city ||
|
|
|
|
this.media.metadata.positionData.state || '';
|
2017-07-10 04:00:42 +08:00
|
|
|
|
2018-05-04 07:17:08 +08:00
|
|
|
if (str.length !== 0) {
|
2018-03-31 03:30:30 +08:00
|
|
|
str += ', ';
|
2017-07-10 04:00:42 +08:00
|
|
|
}
|
2018-11-05 02:28:32 +08:00
|
|
|
str += this.media.metadata.positionData.country || '';
|
2017-07-10 04:00:42 +08:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
2017-07-18 00:30:16 +08:00
|
|
|
|
2018-11-05 02:28:32 +08:00
|
|
|
get CameraData(): CameraMetadata {
|
|
|
|
return (<PhotoDTO>this.media).metadata.cameraData;
|
|
|
|
}
|
|
|
|
|
2017-07-18 00:30:16 +08:00
|
|
|
close() {
|
|
|
|
this.onClose.emit();
|
|
|
|
}
|
2017-07-10 04:00:42 +08:00
|
|
|
}
|
|
|
|
|