2018-11-05 02:28:32 +08:00
|
|
|
import {PhotoDTO} from '../../../common/entities/PhotoDTO';
|
|
|
|
import {Utils} from '../../../common/Utils';
|
|
|
|
import {Config} from '../../../common/config/public/Config';
|
|
|
|
import {MediaDTO} from '../../../common/entities/MediaDTO';
|
|
|
|
|
|
|
|
export class MediaIcon {
|
|
|
|
|
|
|
|
|
|
|
|
protected replacementSizeCache: number | boolean = false;
|
|
|
|
|
|
|
|
constructor(public media: MediaDTO) {
|
|
|
|
|
|
|
|
}
|
2018-11-25 22:22:07 +08:00
|
|
|
|
|
|
|
getExtension(): string {
|
|
|
|
return this.media.name.substr(this.media.name.lastIndexOf('.') + 1);
|
|
|
|
}
|
2018-11-05 02:28:32 +08:00
|
|
|
|
|
|
|
iconLoaded() {
|
|
|
|
this.media.readyIcon = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
isIconAvailable() {
|
|
|
|
return this.media.readyIcon;
|
|
|
|
}
|
|
|
|
|
2018-12-05 04:43:07 +08:00
|
|
|
getRelativePath(): string {
|
|
|
|
return Utils.concatUrls(this.media.directory.path, this.media.directory.name, this.media.name);
|
|
|
|
}
|
|
|
|
|
2018-11-05 02:28:32 +08:00
|
|
|
getIconPath() {
|
|
|
|
return Utils.concatUrls(Config.Client.urlBase,
|
|
|
|
'/api/gallery/content/',
|
|
|
|
this.media.directory.path, this.media.directory.name, this.media.name, 'icon');
|
|
|
|
}
|
|
|
|
|
|
|
|
getPhotoPath() {
|
|
|
|
return Utils.concatUrls(Config.Client.urlBase,
|
|
|
|
'/api/gallery/content/',
|
|
|
|
this.media.directory.path, this.media.directory.name, this.media.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-05 04:43:07 +08:00
|
|
|
equals(other: MediaDTO | MediaIcon): boolean {
|
2018-11-05 02:28:32 +08:00
|
|
|
// is gridphoto
|
|
|
|
if (other instanceof MediaIcon) {
|
|
|
|
return this.media.directory.path === other.media.directory.path &&
|
|
|
|
this.media.directory.name === other.media.directory.name && this.media.name === other.media.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// is media
|
|
|
|
if (other.directory) {
|
|
|
|
return this.media.directory.path === other.directory.path &&
|
|
|
|
this.media.directory.name === other.directory.name && this.media.name === other.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|