2020-04-14 11:13:45 +00:00
|
|
|
import RestModel from "model/rest";
|
2019-06-17 19:45:06 +00:00
|
|
|
import Api from "common/api";
|
2020-04-20 09:51:42 +00:00
|
|
|
import {DateTime} from "luxon";
|
2019-06-17 19:45:06 +00:00
|
|
|
|
2020-04-14 11:13:45 +00:00
|
|
|
class Album extends RestModel {
|
2020-01-23 23:45:59 +00:00
|
|
|
getDefaults() {
|
|
|
|
return {
|
|
|
|
ID: 0,
|
|
|
|
CoverUUID: "",
|
|
|
|
AlbumUUID: "",
|
|
|
|
AlbumSlug: "",
|
|
|
|
AlbumName: "",
|
|
|
|
AlbumDescription: "",
|
|
|
|
AlbumNotes: "",
|
|
|
|
AlbumOrder: "",
|
|
|
|
AlbumTemplate: "",
|
2020-04-20 09:51:42 +00:00
|
|
|
AlbumFavorite: true,
|
2020-04-08 11:24:06 +00:00
|
|
|
Links: [],
|
2020-01-23 23:45:59 +00:00
|
|
|
CreatedAt: "",
|
|
|
|
UpdatedAt: "",
|
2020-01-31 14:29:06 +00:00
|
|
|
};
|
2020-01-23 23:45:59 +00:00
|
|
|
}
|
|
|
|
|
2019-06-17 19:45:06 +00:00
|
|
|
getEntityName() {
|
|
|
|
return this.AlbumSlug;
|
|
|
|
}
|
|
|
|
|
|
|
|
getId() {
|
|
|
|
return this.AlbumUUID;
|
|
|
|
}
|
|
|
|
|
|
|
|
getTitle() {
|
|
|
|
return this.AlbumName;
|
|
|
|
}
|
|
|
|
|
2020-05-21 11:26:28 +00:00
|
|
|
thumbnailUrl(type) {
|
2019-06-17 19:45:06 +00:00
|
|
|
return "/api/v1/albums/" + this.getId() + "/thumbnail/" + type;
|
|
|
|
}
|
|
|
|
|
2020-05-21 11:26:28 +00:00
|
|
|
thumbnailSrcset() {
|
2019-06-17 19:45:06 +00:00
|
|
|
const result = [];
|
|
|
|
|
2020-05-21 11:26:28 +00:00
|
|
|
result.push(this.thumbnailUrl("fit_720") + " 720w");
|
|
|
|
result.push(this.thumbnailUrl("fit_1280") + " 1280w");
|
|
|
|
result.push(this.thumbnailUrl("fit_1920") + " 1920w");
|
|
|
|
result.push(this.thumbnailUrl("fit_2560") + " 2560w");
|
|
|
|
result.push(this.thumbnailUrl("fit_3840") + " 3840w");
|
2019-06-17 19:45:06 +00:00
|
|
|
|
|
|
|
return result.join(", ");
|
|
|
|
}
|
|
|
|
|
2020-05-21 11:26:28 +00:00
|
|
|
thumbnailSizes() {
|
2019-06-17 19:45:06 +00:00
|
|
|
const result = [];
|
|
|
|
|
|
|
|
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("720px");
|
|
|
|
|
|
|
|
return result.join(", ");
|
|
|
|
}
|
|
|
|
|
|
|
|
getDateString() {
|
2019-09-19 21:23:39 +00:00
|
|
|
return DateTime.fromISO(this.CreatedAt).toLocaleString(DateTime.DATETIME_MED);
|
2019-06-17 19:45:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
toggleLike() {
|
|
|
|
this.AlbumFavorite = !this.AlbumFavorite;
|
|
|
|
|
2020-04-20 09:51:42 +00:00
|
|
|
if (this.AlbumFavorite) {
|
2019-06-17 19:45:06 +00:00
|
|
|
return Api.post(this.getEntityResource() + "/like");
|
|
|
|
} else {
|
|
|
|
return Api.delete(this.getEntityResource() + "/like");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
like() {
|
|
|
|
this.AlbumFavorite = true;
|
|
|
|
return Api.post(this.getEntityResource() + "/like");
|
|
|
|
}
|
|
|
|
|
|
|
|
unlike() {
|
|
|
|
this.AlbumFavorite = false;
|
|
|
|
return Api.delete(this.getEntityResource() + "/like");
|
|
|
|
}
|
|
|
|
|
|
|
|
static getCollectionResource() {
|
|
|
|
return "albums";
|
|
|
|
}
|
|
|
|
|
|
|
|
static getModelName() {
|
|
|
|
return "Album";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Album;
|