mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-06-01 04:36:12 -04:00
* fix settings * app info cleanup * bottom-bar experiment * remove dup key * type hints * add dependency * updated image with query parameters * read image options * add image minification * add image minification step * alt image routes * add image minification * set mobile bar to top Co-authored-by: hay-kot <hay-kot@pm.me>
107 lines
2.3 KiB
JavaScript
107 lines
2.3 KiB
JavaScript
import { vueApp } from "../main";
|
|
|
|
// TODO: Migrate to Mixins
|
|
const notifyHelpers = {
|
|
baseCSS: "notify-base",
|
|
error: "notify-error-color",
|
|
warning: "notify-warning-color",
|
|
success: "notify-success-color",
|
|
info: "notify-info-color",
|
|
};
|
|
|
|
const days = [
|
|
"Sunday",
|
|
"Monday",
|
|
"Tuesday",
|
|
"Wednesday",
|
|
"Thursday",
|
|
"Friday",
|
|
"Saturday",
|
|
];
|
|
const months = [
|
|
"January",
|
|
"February",
|
|
"March",
|
|
"April",
|
|
"May",
|
|
"June",
|
|
"July",
|
|
"August",
|
|
"September",
|
|
"October",
|
|
"November",
|
|
"December",
|
|
];
|
|
|
|
const monthsShort = [
|
|
"Jan",
|
|
"Feb",
|
|
"March",
|
|
"April",
|
|
"May",
|
|
"June",
|
|
"July",
|
|
"Aug",
|
|
"Sept",
|
|
"Oct",
|
|
"Nov",
|
|
"Dec",
|
|
];
|
|
|
|
export default {
|
|
getImageURL(image) {
|
|
return `/api/recipes/${image}/image?image_type=small`;
|
|
},
|
|
generateUniqueKey(item, index) {
|
|
const uniqueKey = `${item}-${index}`;
|
|
return uniqueKey;
|
|
},
|
|
getDateAsText(dateObject) {
|
|
const dow = days[dateObject.getUTCDay()];
|
|
const month = months[dateObject.getUTCMonth()];
|
|
const day = dateObject.getUTCDate();
|
|
// const year = dateObject.getFullYear();
|
|
|
|
return `${dow}, ${month} ${day}`;
|
|
},
|
|
getDateAsTextAlt(dateObject) {
|
|
const dow = days[dateObject.getUTCDay()];
|
|
const month = monthsShort[dateObject.getUTCMonth()];
|
|
const day = dateObject.getUTCDate();
|
|
// const year = dateObject.getFullYear();
|
|
|
|
return `${dow}, ${month} ${day}`;
|
|
},
|
|
getDateAsPythonDate(dateObject) {
|
|
const month = dateObject.getUTCMonth() + 1;
|
|
const day = dateObject.getUTCDate();
|
|
const year = dateObject.getFullYear();
|
|
|
|
return `${year}-${month}-${day}`;
|
|
},
|
|
notify: {
|
|
show: function(text, type = "info", title = null) {
|
|
vueApp.flashMessage.show({
|
|
status: type,
|
|
title: title,
|
|
message: text,
|
|
time: 3000,
|
|
blockClass: `${notifyHelpers.baseCSS} ${notifyHelpers[type]}`,
|
|
contentClass: `${notifyHelpers.baseCSS} ${notifyHelpers[type]}`,
|
|
});
|
|
},
|
|
info: function(text, title = null) {
|
|
this.show(text, "info", title);
|
|
},
|
|
success: function(text, title = null) {
|
|
this.show(text, "success", title);
|
|
},
|
|
error: function(text, title = null) {
|
|
this.show(text, "error", title);
|
|
},
|
|
warning: function(text, title = null) {
|
|
this.show(text, "warning", title);
|
|
},
|
|
},
|
|
};
|