2018-03-31 03:30:30 +08:00
|
|
|
import {PhotoDTO} from '../../../common/entities/PhotoDTO';
|
|
|
|
import {Utils} from '../../../common/Utils';
|
2018-05-13 00:19:51 +08:00
|
|
|
import {Config} from '../../../common/config/public/Config';
|
2018-03-31 03:30:30 +08:00
|
|
|
|
2017-03-21 04:37:23 +08:00
|
|
|
export class IconPhoto {
|
|
|
|
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
protected replacementSizeCache: number | boolean = false;
|
2017-03-21 04:37:23 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
constructor(public photo: PhotoDTO) {
|
2017-03-21 04:37:23 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2017-03-21 04:37:23 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
iconLoaded() {
|
|
|
|
this.photo.readyIcon = true;
|
|
|
|
}
|
2017-03-21 04:37:23 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
isIconAvailable() {
|
|
|
|
return this.photo.readyIcon;
|
|
|
|
}
|
2017-03-21 04:37:23 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
getIconPath() {
|
2018-05-13 00:19:51 +08:00
|
|
|
return Utils.concatUrls(Config.Client.urlBase,
|
|
|
|
'/api/gallery/content/',
|
|
|
|
this.photo.directory.path, this.photo.directory.name, this.photo.name, 'icon');
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2017-03-21 04:37:23 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
getPhotoPath() {
|
2018-05-13 00:19:51 +08:00
|
|
|
return Utils.concatUrls(Config.Client.urlBase,
|
|
|
|
'/api/gallery/content/',
|
|
|
|
this.photo.directory.path, this.photo.directory.name, this.photo.name);
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2017-03-21 04:37:23 +08:00
|
|
|
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
equals(other: PhotoDTO | IconPhoto): boolean {
|
2018-05-13 00:19:51 +08:00
|
|
|
// is gridphoto
|
2017-06-11 04:32:56 +08:00
|
|
|
if (other instanceof IconPhoto) {
|
2018-05-13 00:19:51 +08:00
|
|
|
return this.photo.directory.path === other.photo.directory.path &&
|
|
|
|
this.photo.directory.name === other.photo.directory.name && this.photo.name === other.photo.name;
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2017-03-21 04:37:23 +08:00
|
|
|
|
2018-05-13 00:19:51 +08:00
|
|
|
// is photo
|
2017-06-11 04:32:56 +08:00
|
|
|
if (other.directory) {
|
2018-05-13 00:19:51 +08:00
|
|
|
return this.photo.directory.path === other.directory.path &&
|
|
|
|
this.photo.directory.name === other.directory.name && this.photo.name === other.name;
|
2017-03-21 04:37:23 +08:00
|
|
|
}
|
2017-06-11 04:32:56 +08:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|