mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-03-10 12:05:49 -04:00
* automated docs update * recipe rating component * recipe partial updates - closes #25 * use Vue.delete to update store * format * arrow functions * fix tests * format * initial context menu * localize * add confirmation dialog * context menu * fix bare exception * update line length * format all file with prettier * update changelog * download as json * update python dependencies * update javascript dependencies Co-authored-by: hay-kot <hay-kot@pm.me>
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
import { baseURL } from "./api-utils";
|
|
import { apiReq } from "./api-utils";
|
|
import i18n from "@/i18n.js";
|
|
|
|
const prefix = baseURL + "themes";
|
|
|
|
const settingsURLs = {
|
|
allThemes: `${baseURL}themes`,
|
|
specificTheme: themeName => `${prefix}/${themeName}`,
|
|
createTheme: `${prefix}/create`,
|
|
updateTheme: themeName => `${prefix}/${themeName}`,
|
|
deleteTheme: themeName => `${prefix}/${themeName}`,
|
|
};
|
|
|
|
export const themeAPI = {
|
|
async requestAll() {
|
|
let response = await apiReq.get(settingsURLs.allThemes);
|
|
return response.data;
|
|
},
|
|
|
|
async requestByName(name) {
|
|
let response = await apiReq.get(settingsURLs.specificTheme(name));
|
|
return response.data;
|
|
},
|
|
|
|
async create(postBody) {
|
|
return await apiReq.post(
|
|
settingsURLs.createTheme,
|
|
postBody,
|
|
() => i18n.t("settings.theme.error-creating-theme-see-log-file"),
|
|
() => i18n.t("settings.theme.theme-saved")
|
|
);
|
|
},
|
|
|
|
update(themeName, colors) {
|
|
const body = {
|
|
name: themeName,
|
|
colors: colors,
|
|
};
|
|
return apiReq.put(
|
|
settingsURLs.updateTheme(themeName),
|
|
body,
|
|
() => i18n.t("settings.theme.error-updating-theme"),
|
|
() => i18n.t("settings.theme.theme-updated")
|
|
);
|
|
},
|
|
|
|
delete(themeName) {
|
|
return apiReq.delete(
|
|
settingsURLs.deleteTheme(themeName),
|
|
null,
|
|
() => i18n.t("settings.theme.error-deleting-theme"),
|
|
() => i18n.t("settings.theme.theme-deleted")
|
|
);
|
|
},
|
|
};
|