2018-08-07 18:17:14 +00:00
|
|
|
import Abstract from 'model/abstract';
|
2018-10-31 02:33:18 +00:00
|
|
|
import Api from 'common/api';
|
2018-08-07 18:17:14 +00:00
|
|
|
|
|
|
|
class Photo extends Abstract {
|
|
|
|
getEntityName() {
|
2018-09-12 14:37:30 +00:00
|
|
|
return this.PhotoTitle;
|
2018-08-07 18:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getId() {
|
|
|
|
return this.ID;
|
|
|
|
}
|
|
|
|
|
2018-08-09 21:10:05 +00:00
|
|
|
getGoogleMapsLink() {
|
2018-09-12 14:37:30 +00:00
|
|
|
return 'https://www.google.com/maps/place/' + this.PhotoLat + ',' + this.PhotoLong;
|
2018-08-09 21:10:05 +00:00
|
|
|
}
|
|
|
|
|
2018-09-24 09:27:46 +00:00
|
|
|
getThumbnailUrl(type, size) {
|
|
|
|
return '/api/v1/thumbnails/' + type + '/' + size + '/' + this.FileHash;
|
|
|
|
}
|
|
|
|
|
2018-09-24 17:07:43 +00:00
|
|
|
getThumbnailSrcset() {
|
|
|
|
const result = [];
|
|
|
|
|
|
|
|
result.push(this.getThumbnailUrl('fit', 320) + ' 320w');
|
|
|
|
result.push(this.getThumbnailUrl('fit', 500) + ' 500w');
|
|
|
|
result.push(this.getThumbnailUrl('fit', 720) + ' 720w');
|
|
|
|
result.push(this.getThumbnailUrl('fit', 1280) + ' 1280w');
|
|
|
|
result.push(this.getThumbnailUrl('fit', 1920) + ' 1920w');
|
|
|
|
result.push(this.getThumbnailUrl('fit', 2560) + ' 2560w');
|
|
|
|
result.push(this.getThumbnailUrl('fit', 3840) + ' 3840w');
|
|
|
|
|
|
|
|
return result.join(', ');
|
|
|
|
}
|
|
|
|
|
2019-02-11 21:55:29 +00:00
|
|
|
calculateWidth(height) {
|
|
|
|
return height * this.FileAspectRatio;
|
|
|
|
}
|
|
|
|
|
2018-09-24 17:07:43 +00:00
|
|
|
getThumbnailSizes() {
|
|
|
|
const result = [];
|
|
|
|
|
2018-09-25 09:00:09 +00:00
|
|
|
result.push('(min-width: 2560px) 3840px');
|
|
|
|
result.push('(min-width: 1920px) 2560px');
|
|
|
|
result.push('(min-width: 1280px) 1920px');
|
|
|
|
result.push('(min-width: 720px) 1280px');
|
|
|
|
result.push('(min-width: 500px) 720px');
|
|
|
|
result.push('(min-width: 320px) 500px');
|
|
|
|
result.push('320px');
|
2018-09-24 17:07:43 +00:00
|
|
|
|
|
|
|
return result.join(', ');
|
|
|
|
}
|
|
|
|
|
|
|
|
getLocation() {
|
|
|
|
const location = [];
|
|
|
|
|
|
|
|
if (this.LocationID) {
|
|
|
|
if (this.LocName && !this.LocCity && !this.LocCounty) {
|
|
|
|
location.push(this.LocName)
|
|
|
|
} else if (this.LocCity) {
|
|
|
|
location.push(this.LocCity)
|
|
|
|
} else if (this.LocCounty) {
|
|
|
|
location.push(this.LocCounty)
|
|
|
|
}
|
|
|
|
|
2018-09-24 17:26:25 +00:00
|
|
|
if (this.LocState && this.LocState !== this.LocCity) {
|
2018-09-24 17:07:43 +00:00
|
|
|
location.push(this.LocState)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.LocCountry) {
|
|
|
|
location.push(this.LocCountry)
|
|
|
|
}
|
|
|
|
} else if (this.CountryName) {
|
|
|
|
location.push(this.CountryName)
|
|
|
|
} else {
|
|
|
|
location.push('Unknown')
|
|
|
|
}
|
|
|
|
|
|
|
|
return location.join(', ');
|
|
|
|
}
|
|
|
|
|
|
|
|
getFullLocation() {
|
|
|
|
const location = [];
|
|
|
|
|
|
|
|
if (this.LocationID) {
|
|
|
|
if (this.LocName) {
|
|
|
|
location.push(this.LocName)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.LocCity) {
|
|
|
|
location.push(this.LocCity)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.LocPostcode) {
|
|
|
|
location.push(this.LocPostcode)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.LocCounty) {
|
|
|
|
location.push(this.LocCounty)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.LocState) {
|
|
|
|
location.push(this.LocState)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.LocCountry) {
|
|
|
|
location.push(this.LocCountry)
|
|
|
|
}
|
|
|
|
} else if (this.CountryName) {
|
|
|
|
location.push(this.CountryName)
|
|
|
|
} else {
|
|
|
|
location.push('Unknown')
|
|
|
|
}
|
|
|
|
|
|
|
|
return location.join(', ');
|
|
|
|
}
|
|
|
|
|
|
|
|
getCamera() {
|
|
|
|
if (this.CameraModel) {
|
|
|
|
return this.CameraModel
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'Unknown'
|
|
|
|
}
|
|
|
|
|
2018-10-31 02:33:18 +00:00
|
|
|
like(liked) {
|
|
|
|
if (liked === true) {
|
|
|
|
return Api.post(this.getEntityResource() + "/like");
|
|
|
|
} else {
|
|
|
|
return Api.delete(this.getEntityResource() + "/like");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-07 18:17:14 +00:00
|
|
|
static getCollectionResource() {
|
|
|
|
return 'photos';
|
|
|
|
}
|
|
|
|
|
|
|
|
static getModelName() {
|
|
|
|
return 'Photo';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Photo;
|