2020-04-14 11:13:45 +00:00
|
|
|
|
import RestModel from "model/rest";
|
2019-05-09 04:48:10 +00:00
|
|
|
|
import Api from "common/api";
|
2020-01-23 23:45:59 +00:00
|
|
|
|
import {DateTime} from "luxon";
|
2020-05-14 09:57:26 +00:00
|
|
|
|
import Util from "common/util";
|
2018-08-07 18:17:14 +00:00
|
|
|
|
|
2020-04-18 23:28:35 +00:00
|
|
|
|
const SrcManual = "manual";
|
2020-05-15 07:39:32 +00:00
|
|
|
|
const CodecAvc1 = "avc1";
|
|
|
|
|
const TypeMP4 = "mp4";
|
|
|
|
|
const TypeJpeg = "jpg";
|
2020-04-18 21:20:54 +00:00
|
|
|
|
|
2020-04-14 11:13:45 +00:00
|
|
|
|
class Photo extends RestModel {
|
2020-01-23 23:45:59 +00:00
|
|
|
|
getDefaults() {
|
|
|
|
|
return {
|
|
|
|
|
ID: 0,
|
|
|
|
|
TakenAt: "",
|
2020-04-18 21:20:54 +00:00
|
|
|
|
TakenAtLocal: "",
|
|
|
|
|
TakenSrc: "",
|
|
|
|
|
TimeZone: "",
|
2020-01-23 23:45:59 +00:00
|
|
|
|
PhotoUUID: "",
|
|
|
|
|
PhotoPath: "",
|
|
|
|
|
PhotoName: "",
|
|
|
|
|
PhotoTitle: "",
|
2020-04-18 21:20:54 +00:00
|
|
|
|
TitleSrc: "",
|
2020-01-23 23:45:59 +00:00
|
|
|
|
PhotoFavorite: false,
|
|
|
|
|
PhotoPrivate: false,
|
2020-05-13 13:36:42 +00:00
|
|
|
|
PhotoVideo: false,
|
2020-04-24 11:21:18 +00:00
|
|
|
|
PhotoResolution: 0,
|
|
|
|
|
PhotoQuality: 0,
|
2020-01-23 23:45:59 +00:00
|
|
|
|
PhotoLat: 0.0,
|
|
|
|
|
PhotoLng: 0.0,
|
|
|
|
|
PhotoAltitude: 0,
|
|
|
|
|
PhotoIso: 0,
|
2020-04-18 21:20:54 +00:00
|
|
|
|
PhotoFocalLength: 0,
|
2020-01-24 09:25:08 +00:00
|
|
|
|
PhotoFNumber: 0.0,
|
2020-01-23 23:45:59 +00:00
|
|
|
|
PhotoExposure: "",
|
|
|
|
|
PhotoViews: 0,
|
|
|
|
|
Camera: {},
|
|
|
|
|
CameraID: 0,
|
2020-04-18 21:20:54 +00:00
|
|
|
|
CameraSrc: "",
|
2020-01-23 23:45:59 +00:00
|
|
|
|
Lens: {},
|
|
|
|
|
LensID: 0,
|
|
|
|
|
Location: null,
|
|
|
|
|
LocationID: "",
|
2020-04-18 21:20:54 +00:00
|
|
|
|
LocationSrc: "",
|
2020-01-23 23:45:59 +00:00
|
|
|
|
Place: null,
|
|
|
|
|
PlaceID: "",
|
|
|
|
|
PhotoCountry: "",
|
|
|
|
|
PhotoYear: 0,
|
|
|
|
|
PhotoMonth: 0,
|
2020-03-26 08:41:33 +00:00
|
|
|
|
Description: {
|
|
|
|
|
PhotoDescription: "",
|
|
|
|
|
PhotoKeywords: "",
|
|
|
|
|
PhotoNotes: "",
|
|
|
|
|
PhotoSubject: "",
|
|
|
|
|
PhotoArtist: "",
|
|
|
|
|
PhotoCopyright: "",
|
|
|
|
|
PhotoLicense: "",
|
|
|
|
|
},
|
2020-04-18 21:20:54 +00:00
|
|
|
|
DescriptionSrc: "",
|
2020-01-23 23:45:59 +00:00
|
|
|
|
Files: [],
|
|
|
|
|
Labels: [],
|
|
|
|
|
Keywords: [],
|
|
|
|
|
Albums: [],
|
2020-04-08 11:24:06 +00:00
|
|
|
|
Links: [],
|
2020-01-23 23:45:59 +00:00
|
|
|
|
CreatedAt: "",
|
|
|
|
|
UpdatedAt: "",
|
|
|
|
|
DeletedAt: null,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-07 18:17:14 +00:00
|
|
|
|
getEntityName() {
|
2018-09-12 14:37:30 +00:00
|
|
|
|
return this.PhotoTitle;
|
2018-08-07 18:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getId() {
|
2019-12-04 14:14:04 +00:00
|
|
|
|
return this.PhotoUUID;
|
2018-08-07 18:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 02:37:45 +00:00
|
|
|
|
getTitle() {
|
|
|
|
|
return this.PhotoTitle;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-26 00:22:53 +00:00
|
|
|
|
getColor() {
|
|
|
|
|
switch (this.PhotoColor) {
|
2020-04-25 12:55:26 +00:00
|
|
|
|
case "brown":
|
|
|
|
|
case "black":
|
|
|
|
|
case "white":
|
|
|
|
|
case "grey":
|
|
|
|
|
return "grey lighten-2";
|
|
|
|
|
default:
|
|
|
|
|
return this.PhotoColor + " lighten-4";
|
2019-04-26 00:22:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-18 15:27:08 +00:00
|
|
|
|
|
2018-08-09 21:10:05 +00:00
|
|
|
|
getGoogleMapsLink() {
|
2019-12-20 19:23:16 +00:00
|
|
|
|
return "https://www.google.com/maps/place/" + this.PhotoLat + "," + this.PhotoLng;
|
2018-08-09 21:10:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-24 00:33:04 +00:00
|
|
|
|
refreshFileAttr() {
|
2020-04-23 09:00:29 +00:00
|
|
|
|
const file = this.mainFile();
|
|
|
|
|
|
2020-04-29 08:22:33 +00:00
|
|
|
|
if (!file || !file.FileHash) {
|
2020-01-31 14:29:06 +00:00
|
|
|
|
return;
|
2020-01-24 00:33:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-23 09:00:29 +00:00
|
|
|
|
this.FileHash = file.FileHash;
|
|
|
|
|
this.FileWidth = file.FileWidth;
|
|
|
|
|
this.FileHeight = file.FileHeight;
|
|
|
|
|
}
|
2020-01-24 00:33:04 +00:00
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
isPlayable() {
|
2020-05-14 17:03:12 +00:00
|
|
|
|
if (!this.Files) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
return this.Files.findIndex(f => f.FileCodec === CodecAvc1) !== -1 || this.Files.findIndex(f => f.FileType === TypeMP4) !== -1;
|
2020-05-14 17:03:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-13 13:36:42 +00:00
|
|
|
|
videoFile() {
|
|
|
|
|
if (!this.Files) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
let file = this.Files.find(f => f.FileCodec === CodecAvc1);
|
|
|
|
|
|
|
|
|
|
if (!file) {
|
|
|
|
|
file = this.Files.find(f => f.FileType === TypeMP4);
|
|
|
|
|
}
|
2020-05-13 13:36:42 +00:00
|
|
|
|
|
|
|
|
|
if (!file) {
|
|
|
|
|
file = this.Files.find(f => !!f.FileVideo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return file;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
videoUri() {
|
2020-05-14 10:11:04 +00:00
|
|
|
|
const file = this.videoFile();
|
2020-05-13 13:36:42 +00:00
|
|
|
|
|
|
|
|
|
if (!file) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
return "/api/v1/videos/" + file.FileHash + "/" + TypeMP4;
|
2020-05-13 13:36:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-23 09:00:29 +00:00
|
|
|
|
mainFile() {
|
|
|
|
|
if (!this.Files) {
|
|
|
|
|
return false;
|
2020-01-24 00:33:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-23 09:00:29 +00:00
|
|
|
|
let file = this.Files.find(f => !!f.FilePrimary);
|
|
|
|
|
|
|
|
|
|
if (!file) {
|
2020-05-15 07:39:32 +00:00
|
|
|
|
file = this.Files.find(f => f.FileType === TypeJpeg);
|
2020-04-23 09:00:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return file;
|
2018-09-24 09:27:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-23 09:00:29 +00:00
|
|
|
|
mainFileHash() {
|
2020-04-21 14:34:43 +00:00
|
|
|
|
if (this.Files) {
|
2020-04-23 09:00:29 +00:00
|
|
|
|
let file = this.mainFile();
|
2020-04-21 14:34:43 +00:00
|
|
|
|
|
2020-04-23 09:00:29 +00:00
|
|
|
|
if (file && file.FileHash) {
|
|
|
|
|
return file.FileHash;
|
2020-04-21 14:34:43 +00:00
|
|
|
|
}
|
2020-04-21 08:23:27 +00:00
|
|
|
|
} else if (this.FileHash) {
|
2020-04-21 14:34:43 +00:00
|
|
|
|
return this.FileHash;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-23 12:30:28 +00:00
|
|
|
|
return "";
|
2020-04-21 14:34:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getThumbnailUrl(type) {
|
2020-04-23 09:00:29 +00:00
|
|
|
|
let hash = this.mainFileHash();
|
2020-04-21 14:34:43 +00:00
|
|
|
|
|
|
|
|
|
if (!hash) {
|
|
|
|
|
return "/api/v1/svg/photo";
|
2020-01-23 23:45:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 14:34:43 +00:00
|
|
|
|
return "/api/v1/thumbnails/" + hash + "/" + type;
|
2020-01-23 23:45:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-14 16:16:35 +00:00
|
|
|
|
getDownloadUrl() {
|
2020-04-23 09:00:29 +00:00
|
|
|
|
return "/api/v1/download/" + this.mainFileHash();
|
2019-05-14 16:16:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-24 17:07:43 +00:00
|
|
|
|
getThumbnailSrcset() {
|
|
|
|
|
const result = [];
|
|
|
|
|
|
2020-01-23 23:45:59 +00:00
|
|
|
|
result.push(this.getThumbnailUrl("fit_720") + " 720w");
|
2019-05-13 16:01:50 +00:00
|
|
|
|
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");
|
2018-09-24 17:07:43 +00:00
|
|
|
|
|
2019-05-09 04:48:10 +00:00
|
|
|
|
return result.join(", ");
|
2018-09-24 17:07:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-14 14:04:17 +00:00
|
|
|
|
calculateSize(width, height) {
|
2020-01-23 23:45:59 +00:00
|
|
|
|
if (width >= this.FileWidth && height >= this.FileHeight) { // Smaller
|
2019-05-14 14:04:17 +00:00
|
|
|
|
return {width: this.FileWidth, height: this.FileHeight};
|
2019-05-13 16:01:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-14 14:04:17 +00:00
|
|
|
|
const srcAspectRatio = this.FileWidth / this.FileHeight;
|
|
|
|
|
const maxAspectRatio = width / height;
|
|
|
|
|
|
|
|
|
|
let newW, newH;
|
|
|
|
|
|
|
|
|
|
if (srcAspectRatio > maxAspectRatio) {
|
|
|
|
|
newW = width;
|
|
|
|
|
newH = Math.round(newW / srcAspectRatio);
|
|
|
|
|
|
2019-05-13 16:01:50 +00:00
|
|
|
|
} else {
|
2019-05-14 14:04:17 +00:00
|
|
|
|
newH = height;
|
|
|
|
|
newW = Math.round(newH * srcAspectRatio);
|
2019-05-13 16:01:50 +00:00
|
|
|
|
}
|
2019-05-14 14:04:17 +00:00
|
|
|
|
|
|
|
|
|
return {width: newW, height: newH};
|
2019-02-11 21:55:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-24 17:07:43 +00:00
|
|
|
|
getThumbnailSizes() {
|
|
|
|
|
const result = [];
|
|
|
|
|
|
2019-05-09 04:48:10 +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");
|
2019-05-13 16:01:50 +00:00
|
|
|
|
result.push("720px");
|
2018-09-24 17:07:43 +00:00
|
|
|
|
|
2019-05-09 04:48:10 +00:00
|
|
|
|
return result.join(", ");
|
2018-09-24 17:07:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-06 22:04:34 +00:00
|
|
|
|
getDateString() {
|
2020-01-23 23:45:59 +00:00
|
|
|
|
if (this.TimeZone) {
|
2019-09-19 21:23:39 +00:00
|
|
|
|
return DateTime.fromISO(this.TakenAt).setZone(this.TimeZone).toLocaleString(DateTime.DATETIME_FULL);
|
2020-01-23 23:45:59 +00:00
|
|
|
|
} else if (this.TakenAt) {
|
2020-05-07 09:07:08 +00:00
|
|
|
|
return DateTime.fromISO(this.TakenAt).setZone("UTC").toLocaleString(DateTime.DATE_HUGE);
|
2019-09-19 21:23:39 +00:00
|
|
|
|
} else {
|
|
|
|
|
return "Unknown";
|
|
|
|
|
}
|
2019-06-06 22:04:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 02:37:45 +00:00
|
|
|
|
hasLocation() {
|
2019-12-20 19:23:16 +00:00
|
|
|
|
return this.PhotoLat !== 0 || this.PhotoLng !== 0;
|
2019-05-08 02:37:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-24 17:07:43 +00:00
|
|
|
|
getLocation() {
|
2019-12-28 19:24:20 +00:00
|
|
|
|
if (this.LocLabel) {
|
|
|
|
|
return this.LocLabel;
|
2018-09-24 17:07:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-21 16:24:29 +00:00
|
|
|
|
return "Unknown";
|
2018-09-24 17:07:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-14 09:57:26 +00:00
|
|
|
|
getVideoInfo() {
|
|
|
|
|
let result = [];
|
|
|
|
|
let file = this.videoFile();
|
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
if (!file) {
|
2020-05-14 09:57:26 +00:00
|
|
|
|
file = this.mainFile();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
if (!file) {
|
2020-05-14 09:57:26 +00:00
|
|
|
|
return "Video";
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
if (file.FileDuration > 0) {
|
|
|
|
|
result.push(Util.duration(file.FileDuration));
|
2020-05-14 09:57:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file.FileWidth && file.FileHeight) {
|
|
|
|
|
result.push(file.FileWidth + " × " + file.FileHeight);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
if (file.FileSize) {
|
2020-05-14 09:57:26 +00:00
|
|
|
|
const size = Number.parseFloat(file.FileSize) / 1048576;
|
|
|
|
|
|
|
|
|
|
result.push(size.toFixed(1) + " MB");
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
if (!result) {
|
2020-05-14 10:11:04 +00:00
|
|
|
|
return "Video";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result.join(", ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getPhotoInfo() {
|
|
|
|
|
let result = [];
|
|
|
|
|
let file = this.mainFile();
|
|
|
|
|
|
|
|
|
|
if (this.Camera) {
|
|
|
|
|
result.push(this.Camera.CameraMake + " " + this.Camera.CameraModel);
|
|
|
|
|
} else if (this.CameraModel && this.CameraMake) {
|
|
|
|
|
result.push(this.CameraMake + " " + this.CameraModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file && file.FileWidth && file.FileHeight) {
|
|
|
|
|
result.push(file.FileWidth + " × " + file.FileHeight);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
if (file && file.FileSize) {
|
2020-05-14 10:11:04 +00:00
|
|
|
|
const size = Number.parseFloat(file.FileSize) / 1048576;
|
|
|
|
|
|
|
|
|
|
result.push(size.toFixed(1) + " MB");
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-15 07:39:32 +00:00
|
|
|
|
if (!result) {
|
2020-05-14 10:11:04 +00:00
|
|
|
|
return "Unknown";
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-14 09:57:26 +00:00
|
|
|
|
return result.join(", ");
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-24 17:07:43 +00:00
|
|
|
|
getCamera() {
|
2020-04-18 23:13:55 +00:00
|
|
|
|
if (this.Camera) {
|
2020-01-30 05:17:02 +00:00
|
|
|
|
return this.Camera.CameraMake + " " + this.Camera.CameraModel;
|
|
|
|
|
} else if (this.CameraModel) {
|
2019-05-16 10:24:13 +00:00
|
|
|
|
return this.CameraMake + " " + this.CameraModel;
|
2018-09-24 17:07:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-09 04:48:10 +00:00
|
|
|
|
return "Unknown";
|
2018-09-24 17:07:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-21 15:59:12 +00:00
|
|
|
|
toggleLike() {
|
|
|
|
|
this.PhotoFavorite = !this.PhotoFavorite;
|
|
|
|
|
|
2020-01-23 23:45:59 +00:00
|
|
|
|
if (this.PhotoFavorite) {
|
2019-05-09 04:48:10 +00:00
|
|
|
|
return Api.post(this.getEntityResource() + "/like");
|
2018-10-31 02:33:18 +00:00
|
|
|
|
} else {
|
2019-05-09 04:48:10 +00:00
|
|
|
|
return Api.delete(this.getEntityResource() + "/like");
|
2018-10-31 02:33:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-24 16:19:18 +00:00
|
|
|
|
togglePrivate() {
|
|
|
|
|
this.PhotoPrivate = !this.PhotoPrivate;
|
|
|
|
|
|
|
|
|
|
return Api.put(this.getEntityResource(), {PhotoPrivate: this.PhotoPrivate});
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 08:23:27 +00:00
|
|
|
|
setPrimary(fileUUID) {
|
|
|
|
|
return Api.post(this.getEntityResource() + "/primary/" + fileUUID).then((r) => Promise.resolve(this.setValues(r.data)));
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-21 15:59:12 +00:00
|
|
|
|
like() {
|
|
|
|
|
this.PhotoFavorite = true;
|
|
|
|
|
return Api.post(this.getEntityResource() + "/like");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unlike() {
|
|
|
|
|
this.PhotoFavorite = false;
|
|
|
|
|
return Api.delete(this.getEntityResource() + "/like");
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 14:28:20 +00:00
|
|
|
|
addLabel(name) {
|
2020-04-16 18:57:00 +00:00
|
|
|
|
return Api.post(this.getEntityResource() + "/label", {LabelName: name, LabelPriority: 10})
|
2020-04-21 08:23:27 +00:00
|
|
|
|
.then((r) => Promise.resolve(this.setValues(r.data)));
|
2020-01-29 14:28:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-17 19:20:38 +00:00
|
|
|
|
activateLabel(id) {
|
2020-04-18 23:27:07 +00:00
|
|
|
|
return Api.put(this.getEntityResource() + "/label/" + id, {Uncertainty: 0})
|
2020-04-21 08:23:27 +00:00
|
|
|
|
.then((r) => Promise.resolve(this.setValues(r.data)));
|
2020-04-17 19:20:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renameLabel(id, name) {
|
|
|
|
|
return Api.put(this.getEntityResource() + "/label/" + id, {Label: {LabelName: name}})
|
2020-04-21 08:23:27 +00:00
|
|
|
|
.then((r) => Promise.resolve(this.setValues(r.data)));
|
2020-04-17 19:20:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-29 14:28:20 +00:00
|
|
|
|
removeLabel(id) {
|
|
|
|
|
return Api.delete(this.getEntityResource() + "/label/" + id)
|
2020-04-21 08:23:27 +00:00
|
|
|
|
.then((r) => Promise.resolve(this.setValues(r.data)));
|
2020-01-29 14:28:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-07 16:24:24 +00:00
|
|
|
|
update() {
|
|
|
|
|
const values = this.getValues(true);
|
|
|
|
|
|
2020-04-18 23:13:55 +00:00
|
|
|
|
if (values.PhotoTitle) {
|
2020-04-18 21:20:54 +00:00
|
|
|
|
values.TitleSrc = SrcManual;
|
2020-02-07 16:24:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 23:13:55 +00:00
|
|
|
|
if (values.Description) {
|
2020-04-18 21:20:54 +00:00
|
|
|
|
values.DescriptionSrc = SrcManual;
|
2020-03-25 13:14:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 23:13:55 +00:00
|
|
|
|
if (values.PhotoLat || values.PhotoLng) {
|
2020-04-18 21:20:54 +00:00
|
|
|
|
values.LocationSrc = SrcManual;
|
2020-02-07 16:24:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 23:13:55 +00:00
|
|
|
|
if (values.TakenAt || values.TimeZone) {
|
2020-04-18 21:20:54 +00:00
|
|
|
|
values.TakenSrc = SrcManual;
|
2020-02-07 16:24:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 23:13:55 +00:00
|
|
|
|
if (values.CameraID || values.LensID || values.PhotoFocalLength || values.PhotoFNumber || values.PhotoIso || values.PhotoExposure) {
|
2020-04-18 21:20:54 +00:00
|
|
|
|
values.CameraSrc = SrcManual;
|
2020-02-07 16:24:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Api.put(this.getEntityResource(), values).then((response) => Promise.resolve(this.setValues(response.data)));
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-07 18:17:14 +00:00
|
|
|
|
static getCollectionResource() {
|
2019-05-09 04:48:10 +00:00
|
|
|
|
return "photos";
|
2018-08-07 18:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getModelName() {
|
2019-05-09 04:48:10 +00:00
|
|
|
|
return "Photo";
|
2018-08-07 18:17:14 +00:00
|
|
|
|
}
|
2020-04-23 09:00:29 +00:00
|
|
|
|
|
|
|
|
|
static mergeResponse(results, response) {
|
|
|
|
|
if (response.offset === 0 || results.length === 0) {
|
|
|
|
|
return response.models;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (response.models.length > 0) {
|
|
|
|
|
let i = results.length - 1;
|
|
|
|
|
|
|
|
|
|
if (results[i].PhotoUUID === response.models[0].PhotoUUID) {
|
|
|
|
|
const first = response.models.shift();
|
2020-04-23 12:30:28 +00:00
|
|
|
|
results[i].Files = results[i].Files.concat(first.Files);
|
2020-04-23 09:00:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return results.concat(response.models);
|
|
|
|
|
}
|
2018-08-07 18:17:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Photo;
|