2018-12-07 22:06:13 +01:00
|
|
|
import {Component, EventEmitter, Input, Output} from '@angular/core';
|
2019-03-03 10:30:12 +01:00
|
|
|
import {CameraMetadata, PhotoDTO, PositionMetaData} from '../../../../../../common/entities/PhotoDTO';
|
|
|
|
import {Config} from '../../../../../../common/config/public/Config';
|
|
|
|
import {MediaDTO} from '../../../../../../common/entities/MediaDTO';
|
|
|
|
import {VideoDTO, VideoMetadata} from '../../../../../../common/entities/VideoDTO';
|
|
|
|
import {Utils} from '../../../../../../common/Utils';
|
|
|
|
import {QueryService} from '../../../../model/query.service';
|
2018-12-07 22:06:13 +01:00
|
|
|
import {MapService} from '../../map/map.service';
|
2017-07-09 22:00:42 +02:00
|
|
|
|
|
|
|
@Component({
|
2018-05-03 19:17:08 -04:00
|
|
|
selector: 'app-info-panel',
|
2017-07-09 22:00:42 +02:00
|
|
|
styleUrls: ['./info-panel.lightbox.gallery.component.css'],
|
|
|
|
templateUrl: './info-panel.lightbox.gallery.component.html',
|
|
|
|
})
|
|
|
|
export class InfoPanelLightboxComponent {
|
2018-11-04 19:28:32 +01:00
|
|
|
@Input() media: MediaDTO;
|
2018-11-17 19:32:31 +01:00
|
|
|
@Output() closed = new EventEmitter();
|
|
|
|
|
2017-07-13 23:39:09 +02:00
|
|
|
public mapEnabled = true;
|
2017-07-09 22:00:42 +02:00
|
|
|
|
2018-12-07 22:06:13 +01:00
|
|
|
constructor(public queryService: QueryService,
|
|
|
|
public mapService: MapService) {
|
2017-07-13 23:39:09 +02:00
|
|
|
this.mapEnabled = Config.Client.Map.enabled;
|
2017-07-09 22:00:42 +02:00
|
|
|
}
|
|
|
|
|
2018-11-17 20:15:48 +01:00
|
|
|
isPhoto() {
|
|
|
|
return this.media && MediaDTO.isPhoto(this.media);
|
|
|
|
}
|
|
|
|
|
2017-07-09 22:00:42 +02:00
|
|
|
calcMpx() {
|
2018-11-04 19:28:32 +01:00
|
|
|
return (this.media.metadata.size.width * this.media.metadata.size.height / 1000000).toFixed(2);
|
2017-07-09 22:00:42 +02:00
|
|
|
}
|
|
|
|
|
2018-12-02 20:57:16 +01:00
|
|
|
get FullPath(): string {
|
|
|
|
return Utils.concatUrls(this.media.directory.path, this.media.directory.name, this.media.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
get DirectoryPath() {
|
|
|
|
return Utils.concatUrls(this.media.directory.path, this.media.directory.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-09 23:25:39 +01:00
|
|
|
|
2017-07-09 22:00:42 +02:00
|
|
|
|
2018-05-28 12:03:52 -04:00
|
|
|
isThisYear() {
|
|
|
|
return (new Date()).getFullYear() ===
|
2018-11-04 19:28:32 +01:00
|
|
|
(new Date(this.media.metadata.creationDate)).getFullYear();
|
2017-07-09 22:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getTime() {
|
2018-11-04 19:28:32 +01:00
|
|
|
const date = new Date(this.media.metadata.creationDate);
|
2017-07-21 19:33:24 +02:00
|
|
|
return date.toTimeString().split(' ')[0];
|
2017-07-09 22:00:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-28 23:49:33 +01:00
|
|
|
toFraction(f: number) {
|
2017-07-09 22:00:42 +02:00
|
|
|
if (f > 1) {
|
|
|
|
return f;
|
|
|
|
}
|
2018-03-30 15:30:30 -04:00
|
|
|
return '1/' + (1 / f);
|
2017-07-09 22:00:42 +02:00
|
|
|
}
|
|
|
|
|
2018-11-17 20:15:48 +01:00
|
|
|
get VideoData(): VideoMetadata {
|
|
|
|
if (typeof (<VideoDTO>this.media).metadata.bitRate === 'undefined') {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return (<VideoDTO>this.media).metadata;
|
|
|
|
}
|
|
|
|
|
2018-05-13 16:59:57 -04:00
|
|
|
hasPositionData(): boolean {
|
2018-11-17 20:15:48 +01:00
|
|
|
return !!(<PhotoDTO>this.media).metadata.positionData &&
|
|
|
|
!!((<PhotoDTO>this.media).metadata.positionData.city ||
|
|
|
|
(<PhotoDTO>this.media).metadata.positionData.state ||
|
|
|
|
(<PhotoDTO>this.media).metadata.positionData.country);
|
2018-05-13 16:59:57 -04:00
|
|
|
}
|
|
|
|
|
2017-07-09 22:00:42 +02:00
|
|
|
hasGPS() {
|
2018-11-17 19:32:31 +01:00
|
|
|
return (<PhotoDTO>this.media).metadata.positionData && (<PhotoDTO>this.media).metadata.positionData.GPSData &&
|
|
|
|
(<PhotoDTO>this.media).metadata.positionData.GPSData.latitude && (<PhotoDTO>this.media).metadata.positionData.GPSData.longitude;
|
2017-07-09 22:00:42 +02:00
|
|
|
}
|
|
|
|
|
2018-11-17 20:15:48 +01:00
|
|
|
get PositionData(): PositionMetaData {
|
|
|
|
return (<PhotoDTO>this.media).metadata.positionData;
|
|
|
|
}
|
|
|
|
|
2017-07-09 22:00:42 +02:00
|
|
|
getPositionText(): string {
|
2018-11-17 19:32:31 +01:00
|
|
|
if (!(<PhotoDTO>this.media).metadata.positionData) {
|
2018-03-30 15:30:30 -04:00
|
|
|
return '';
|
2017-07-09 22:00:42 +02:00
|
|
|
}
|
2018-11-17 19:32:31 +01:00
|
|
|
let str = (<PhotoDTO>this.media).metadata.positionData.city ||
|
|
|
|
(<PhotoDTO>this.media).metadata.positionData.state || '';
|
2017-07-09 22:00:42 +02:00
|
|
|
|
2018-05-03 19:17:08 -04:00
|
|
|
if (str.length !== 0) {
|
2018-03-30 15:30:30 -04:00
|
|
|
str += ', ';
|
2017-07-09 22:00:42 +02:00
|
|
|
}
|
2018-11-17 19:32:31 +01:00
|
|
|
str += (<PhotoDTO>this.media).metadata.positionData.country || '';
|
2017-07-09 22:00:42 +02:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
2017-07-17 18:30:16 +02:00
|
|
|
|
2018-11-04 19:28:32 +01:00
|
|
|
get CameraData(): CameraMetadata {
|
|
|
|
return (<PhotoDTO>this.media).metadata.cameraData;
|
|
|
|
}
|
|
|
|
|
2017-07-17 18:30:16 +02:00
|
|
|
close() {
|
2018-11-17 19:32:31 +01:00
|
|
|
this.closed.emit();
|
2017-07-17 18:30:16 +02:00
|
|
|
}
|
2017-07-09 22:00:42 +02:00
|
|
|
}
|
|
|
|
|