Files
mealie/frontend/src/api/siteSettings.js
Hayden be378cb20c feature/recipe-patch-improvements (#382)
* 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>
2021-05-01 20:46:02 -08:00

82 lines
1.9 KiB
JavaScript

import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import { store } from "@/store";
import i18n from "@/i18n.js";
const settingsBase = baseURL + "site-settings";
const settingsURLs = {
siteSettings: `${settingsBase}`,
updateSiteSettings: `${settingsBase}`,
testWebhooks: `${settingsBase}/webhooks/test`,
customPages: `${settingsBase}/custom-pages`,
customPage: id => `${settingsBase}/custom-pages/${id}`,
};
export const siteSettingsAPI = {
async get() {
let response = await apiReq.get(settingsURLs.siteSettings);
return response.data;
},
async update(body) {
const response = await apiReq.put(
settingsURLs.updateSiteSettings,
body,
() => i18n.t("settings.settings-update-failed"),
() => i18n.t("settings.settings-updated")
);
if (response) {
store.dispatch("requestSiteSettings");
}
return response;
},
async getPages() {
let response = await apiReq.get(settingsURLs.customPages);
return response.data;
},
async getPage(id) {
let response = await apiReq.get(settingsURLs.customPage(id));
return response.data;
},
createPage(body) {
return apiReq.post(
settingsURLs.customPages,
body,
() => i18n.t("page.page-creation-failed"),
() => i18n.t("page.new-page-created")
);
},
async deletePage(id) {
return await apiReq.delete(
settingsURLs.customPage(id),
null,
() => i18n.t("page.page-deletion-failed"),
() => i18n.t("page.page-deleted")
);
},
updatePage(body) {
return apiReq.put(
settingsURLs.customPage(body.id),
body,
() => i18n.t("page.page-update-failed"),
() => i18n.t("page.page-updated")
);
},
async updateAllPages(allPages) {
let response = await apiReq.put(
settingsURLs.customPages,
allPages,
() => i18n.t("page.pages-update-failed"),
() => i18n.t("page.pages-updated")
);
return response;
},
};