mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-21 22:13:31 -07:00
Refactor API texts handling
This commit is contained in:
parent
d104b4e6d5
commit
f5f3b5d9b3
30 changed files with 366 additions and 290 deletions
|
@ -1,56 +1,55 @@
|
|||
const baseURL = "/api/";
|
||||
import axios from "axios";
|
||||
import { store } from "../store";
|
||||
import utils from "@/utils";
|
||||
|
||||
axios.defaults.headers.common[
|
||||
"Authorization"
|
||||
] = `Bearer ${store.getters.getToken}`;
|
||||
|
||||
function handleError(error, getText) {
|
||||
utils.notify.error(getText(error.response));
|
||||
return false;
|
||||
}
|
||||
function handleResponse(response, getText) {
|
||||
if(response && getText) {
|
||||
const successText = getText(response);
|
||||
utils.notify.success(successText);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
function defaultErrorText(response) {
|
||||
return response.statusText;
|
||||
}
|
||||
|
||||
function defaultSuccessText(response) {
|
||||
return response.statusText;
|
||||
}
|
||||
|
||||
const apiReq = {
|
||||
post: async function(url, data) {
|
||||
let response = await axios.post(url, data).catch(function(error) {
|
||||
if (error.response) {
|
||||
return error.response;
|
||||
}
|
||||
});
|
||||
return response;
|
||||
post: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
const response = await axios.post(url, data).catch(function(error) { handleError(error, getErrorText) });
|
||||
return handleResponse(response, getSuccessText);
|
||||
},
|
||||
|
||||
put: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
const response = await axios.put(url, data).catch(function(error) { handleError(error, getErrorText) });
|
||||
return handleResponse(response, getSuccessText);
|
||||
},
|
||||
|
||||
patch: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
const response = await axios.patch(url, data).catch(function(error) { handleError(error, getErrorText) });
|
||||
return handleResponse(response, getSuccessText);
|
||||
},
|
||||
|
||||
put: async function(url, data) {
|
||||
let response = await axios.put(url, data).catch(function(error) {
|
||||
if (error.response) {
|
||||
return error.response;
|
||||
} else return;
|
||||
});
|
||||
return response;
|
||||
},
|
||||
patch: async function(url, data) {
|
||||
let response = await axios.patch(url, data).catch(function(error) {
|
||||
if (error.response) {
|
||||
processResponse(error.response);
|
||||
return response;
|
||||
} else return;
|
||||
});
|
||||
processResponse(response);
|
||||
return response;
|
||||
get: function(url, data, getErrorText = defaultErrorText) {
|
||||
return axios.get(url, data).catch(function(error) { handleError(error, getErrorText) });
|
||||
},
|
||||
|
||||
get: async function(url, data) {
|
||||
let response = await axios.get(url, data).catch(function(error) {
|
||||
if (error.response) {
|
||||
return error.response;
|
||||
} else return;
|
||||
});
|
||||
return response;
|
||||
},
|
||||
|
||||
delete: async function(url, data) {
|
||||
let response = await axios.delete(url, data).catch(function(error) {
|
||||
if (error.response) {
|
||||
return error.response;
|
||||
}
|
||||
});
|
||||
return response;
|
||||
delete: async function(url, data, getErrorText = defaultErrorText, getSuccessText = defaultSuccessText ) {
|
||||
const response = await axios.delete(url, data).catch( function(error) { handleError(error, getErrorText) } );
|
||||
return handleResponse(response, getSuccessText);
|
||||
},
|
||||
|
||||
async download(url) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "@/store";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
const backupBase = baseURL + "backups/";
|
||||
|
||||
|
@ -40,7 +41,12 @@ export const backupAPI = {
|
|||
* @param {string} fileName
|
||||
*/
|
||||
async delete(fileName) {
|
||||
return await apiReq.delete(backupURLs.deleteBackup(fileName));
|
||||
return apiReq.delete(
|
||||
backupURLs.deleteBackup(fileName),
|
||||
null,
|
||||
function() { return i18n.t('settings.backup.unable-to-delete-backup'); },
|
||||
function() { return i18n.t('settings.backup.backup-deleted'); }
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Creates a backup on the serve given a set of options
|
||||
|
@ -48,8 +54,12 @@ export const backupAPI = {
|
|||
* @returns
|
||||
*/
|
||||
async create(options) {
|
||||
let response = apiReq.post(backupURLs.createBackup, options);
|
||||
return response;
|
||||
return apiReq.post(
|
||||
backupURLs.createBackup,
|
||||
options,
|
||||
function() { return i18n.t('settings.backup.error-creating-backup-see-log-file'); },
|
||||
function(response) { return i18n.t('settings.backup.backup-created-at-response-export_path', {path: response.data.export_path}); }
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Downloads a file from the server. I don't actually think this is used?
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "@/store";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
const prefix = baseURL + "categories";
|
||||
|
||||
|
@ -22,26 +23,41 @@ export const categoryAPI = {
|
|||
return response.data;
|
||||
},
|
||||
async create(name) {
|
||||
let response = await apiReq.post(categoryURLs.getAll, { name: name });
|
||||
store.dispatch("requestCategories");
|
||||
return response.data;
|
||||
const response = await apiReq.post(
|
||||
categoryURLs.getAll,
|
||||
{ name: name },
|
||||
function() { return i18n.t('settings.category-creation-failed'); },
|
||||
function() { return i18n.t('settings.category-created'); }
|
||||
);
|
||||
if(response) {
|
||||
store.dispatch("requestCategories");
|
||||
return response.data;
|
||||
}
|
||||
},
|
||||
async getRecipesInCategory(category) {
|
||||
let response = await apiReq.get(categoryURLs.getCategory(category));
|
||||
return response.data;
|
||||
},
|
||||
async update(name, newName, overrideRequest = false) {
|
||||
let response = await apiReq.put(categoryURLs.updateCategory(name), {
|
||||
name: newName,
|
||||
});
|
||||
if (!overrideRequest) {
|
||||
const response = await apiReq.put(
|
||||
categoryURLs.updateCategory(name),
|
||||
{ name: newName },
|
||||
function() { return i18n.t('settings.category-update-failed'); },
|
||||
function() { return i18n.t('settings.category-updated'); }
|
||||
);
|
||||
if (response && !overrideRequest) {
|
||||
store.dispatch("requestCategories");
|
||||
return response.data;
|
||||
}
|
||||
return response.data;
|
||||
},
|
||||
async delete(category, overrideRequest = false) {
|
||||
let response = await apiReq.delete(categoryURLs.deleteCategory(category));
|
||||
if (!overrideRequest) {
|
||||
const response = await apiReq.delete(
|
||||
categoryURLs.deleteCategory(category),
|
||||
null,
|
||||
function() { return i18n.t('settings.category-deletion-failed'); },
|
||||
function() { return i18n.t('settings.category-deleted'); }
|
||||
);
|
||||
if (response && !overrideRequest) {
|
||||
store.dispatch("requestCategories");
|
||||
}
|
||||
return response;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from '@/i18n.js';
|
||||
const groupPrefix = baseURL + "groups";
|
||||
|
||||
const groupsURLs = {
|
||||
|
@ -10,25 +11,54 @@ const groupsURLs = {
|
|||
update: id => `${groupPrefix}/${id}`,
|
||||
};
|
||||
|
||||
function deleteErrorText(response) {
|
||||
console.log(response.data);
|
||||
switch(response.data.detail) {
|
||||
case 'GROUP_WITH_USERS':
|
||||
return i18n.t('user.cannot-delete-group-with-users');
|
||||
|
||||
case 'GROUP_NOT_FOUND':
|
||||
return i18n.t('user.group-not-found');
|
||||
|
||||
case 'DEFAULT_GROUP':
|
||||
return i18n.t('user.cannot-delete-default-group');
|
||||
|
||||
default:
|
||||
return i18n.t('user.group-deletion-failed');
|
||||
}
|
||||
}
|
||||
|
||||
export const groupAPI = {
|
||||
async allGroups() {
|
||||
let response = await apiReq.get(groupsURLs.groups);
|
||||
return response.data;
|
||||
},
|
||||
async create(name) {
|
||||
let response = await apiReq.post(groupsURLs.create, { name: name });
|
||||
return response;
|
||||
create(name) {
|
||||
return apiReq.post(
|
||||
groupsURLs.create,
|
||||
{ name: name },
|
||||
function() { return i18n.t('user.user-group-creation-failed'); },
|
||||
function() { return i18n.t('user.user-group-created'); }
|
||||
);
|
||||
},
|
||||
async delete(id) {
|
||||
let response = await apiReq.delete(groupsURLs.delete(id));
|
||||
return response;
|
||||
delete(id) {
|
||||
return apiReq.delete(
|
||||
groupsURLs.delete(id),
|
||||
null,
|
||||
deleteErrorText,
|
||||
function() { return i18n.t('user.group-deleted'); }
|
||||
);
|
||||
},
|
||||
async current() {
|
||||
let response = await apiReq.get(groupsURLs.current);
|
||||
return response.data;
|
||||
},
|
||||
async update(data) {
|
||||
let response = await apiReq.put(groupsURLs.update(data.id), data);
|
||||
return response;
|
||||
update(data) {
|
||||
return apiReq.put(
|
||||
groupsURLs.update(data.id),
|
||||
data,
|
||||
function() { return i18n.t('user.error-updating-group'); },
|
||||
function() { return i18n.t('settings.group-settings-updated'); }
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
const prefix = baseURL + "meal-plans/";
|
||||
|
||||
|
@ -15,9 +16,13 @@ const mealPlanURLs = {
|
|||
};
|
||||
|
||||
export const mealplanAPI = {
|
||||
async create(postBody) {
|
||||
let response = await apiReq.post(mealPlanURLs.create, postBody);
|
||||
return response;
|
||||
create(postBody) {
|
||||
return apiReq.post(
|
||||
mealPlanURLs.create,
|
||||
postBody,
|
||||
function() { return i18n.t('meal-plan.mealplan-creation-failed')},
|
||||
function() { return i18n.t('meal-plan.mealplan-created'); }
|
||||
);
|
||||
},
|
||||
|
||||
async all() {
|
||||
|
@ -35,14 +40,21 @@ export const mealplanAPI = {
|
|||
return response;
|
||||
},
|
||||
|
||||
async delete(id) {
|
||||
let response = await apiReq.delete(mealPlanURLs.delete(id));
|
||||
return response;
|
||||
delete(id) {
|
||||
return apiReq.delete(mealPlanURLs.delete(id),
|
||||
null,
|
||||
function() { return i18n.t('meal-plan.mealplan-deletion-failed'); },
|
||||
function() { return i18n.t('meal-plan.mealplan-deleted'); }
|
||||
);
|
||||
},
|
||||
|
||||
async update(id, body) {
|
||||
let response = await apiReq.put(mealPlanURLs.update(id), body);
|
||||
return response;
|
||||
update(id, body) {
|
||||
return apiReq.put(
|
||||
mealPlanURLs.update(id),
|
||||
body,
|
||||
function() { return i18n.t('meal-plan.mealplan-update-failed'); },
|
||||
function() { return i18n.t('meal-plan.mealplan-updated'); }
|
||||
);
|
||||
},
|
||||
|
||||
async shoppingList(id) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "../store";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
const migrationBase = baseURL + "migrations";
|
||||
|
||||
|
@ -17,7 +18,12 @@ export const migrationAPI = {
|
|||
return response.data;
|
||||
},
|
||||
async delete(folder, file) {
|
||||
let response = await apiReq.delete(migrationURLs.delete(folder, file));
|
||||
const response = await apiReq.delete(
|
||||
migrationURLs.delete(folder, file),
|
||||
null,
|
||||
function() { return i18n.t('general.file-folder-not-found'); },
|
||||
function() { return i18n.t('migration.migration-data-removed'); }
|
||||
);
|
||||
return response;
|
||||
},
|
||||
async import(folder, file) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "../store";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
const prefix = baseURL + "recipes/";
|
||||
|
||||
|
@ -24,9 +25,12 @@ export const recipeAPI = {
|
|||
* @returns {string} Recipe Slug
|
||||
*/
|
||||
async createByURL(recipeURL) {
|
||||
let response = await apiReq.post(recipeURLs.createByURL, {
|
||||
url: recipeURL,
|
||||
});
|
||||
const response = await apiReq.post(
|
||||
recipeURLs.createByURL,
|
||||
{ url: recipeURL },
|
||||
function() { return i18n.t('recipe.recipe-creation-failed'); },
|
||||
function() { return i18n.t('recipe.recipe-created'); }
|
||||
);
|
||||
|
||||
store.dispatch("requestRecentRecipes");
|
||||
return response;
|
||||
|
@ -41,7 +45,12 @@ export const recipeAPI = {
|
|||
},
|
||||
|
||||
async create(recipeData) {
|
||||
let response = await apiReq.post(recipeURLs.create, recipeData);
|
||||
const response = await apiReq.post(
|
||||
recipeURLs.create,
|
||||
recipeData,
|
||||
function() { return i18n.t('recipe.recipe-creation-failed'); },
|
||||
function() { return i18n.t('recipe.recipe-created'); }
|
||||
);
|
||||
store.dispatch("requestRecentRecipes");
|
||||
return response.data;
|
||||
},
|
||||
|
@ -51,17 +60,31 @@ export const recipeAPI = {
|
|||
return response.data;
|
||||
},
|
||||
|
||||
async updateImage(recipeSlug, fileObject) {
|
||||
const fd = new FormData();
|
||||
fd.append("image", fileObject);
|
||||
fd.append("extension", fileObject.name.split(".").pop());
|
||||
let response = apiReq.put(recipeURLs.updateImage(recipeSlug), fd);
|
||||
return response;
|
||||
updateImage(recipeSlug, fileObject, overrideSuccessMsg = false) {
|
||||
const formData = new FormData();
|
||||
formData.append("image", fileObject);
|
||||
formData.append("extension", fileObject.name.split(".").pop());
|
||||
|
||||
let successMessage = null;
|
||||
if(!overrideSuccessMsg) {
|
||||
successMessage = function() { return overrideSuccessMsg ? null : i18n.t('recipe.recipe-image-updated'); };
|
||||
}
|
||||
|
||||
return apiReq.put(
|
||||
recipeURLs.updateImage(recipeSlug),
|
||||
formData,
|
||||
function() { return i18n.t('general.image-upload-failed'); },
|
||||
successMessage
|
||||
);
|
||||
},
|
||||
|
||||
async updateImagebyURL(slug, url) {
|
||||
const response = apiReq.post(recipeURLs.updateImage(slug), { url: url });
|
||||
return response;
|
||||
updateImagebyURL(slug, url) {
|
||||
return apiReq.post(
|
||||
recipeURLs.updateImage(slug),
|
||||
{ url: url },
|
||||
function() { return i18n.t('general.image-upload-failed'); },
|
||||
function() { return i18n.t('recipe.recipe-image-updated'); }
|
||||
);
|
||||
},
|
||||
|
||||
async update(data) {
|
||||
|
@ -76,8 +99,13 @@ export const recipeAPI = {
|
|||
return response.data;
|
||||
},
|
||||
|
||||
async delete(recipeSlug) {
|
||||
return await apiReq.delete(recipeURLs.delete(recipeSlug));
|
||||
delete(recipeSlug) {
|
||||
return apiReq.delete(
|
||||
recipeURLs.delete(recipeSlug),
|
||||
null,
|
||||
function() { return i18n.t('recipe.unable-to-delete-recipe'); },
|
||||
function() { return i18n.t('recipe.recipe-deleted'); }
|
||||
);
|
||||
},
|
||||
|
||||
async allSummary(start = 0, limit = 9999) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
const signUpPrefix = baseURL + "users/sign-ups";
|
||||
|
||||
|
@ -20,9 +21,16 @@ export const signupAPI = {
|
|||
return response.data;
|
||||
},
|
||||
async deleteToken(token) {
|
||||
return await apiReq.delete(signUpURLs.deleteToken(token));
|
||||
return await apiReq.delete(signUpURLs.deleteToken(token),
|
||||
null,
|
||||
null,
|
||||
function() { return i18n.t('user.sign-up-token-deleted'); }
|
||||
);
|
||||
},
|
||||
async createUser(token, data) {
|
||||
return apiReq.post(signUpURLs.createUser(token), data);
|
||||
return apiReq.post(signUpURLs.createUser(token), data,
|
||||
function() { return i18n.t('user.you-are-not-allowed-to-create-a-user'); },
|
||||
function() { return i18n.t('user.user-created'); }
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "@/store";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
const settingsBase = baseURL + "site-settings";
|
||||
|
||||
|
@ -19,8 +20,15 @@ export const siteSettingsAPI = {
|
|||
},
|
||||
|
||||
async update(body) {
|
||||
let response = await apiReq.put(settingsURLs.updateSiteSettings, body);
|
||||
store.dispatch("requestSiteSettings");
|
||||
const response = await apiReq.put(
|
||||
settingsURLs.updateSiteSettings,
|
||||
body,
|
||||
function() { return i18n.t('settings.settings-update-failed'); },
|
||||
function() { return i18n.t('settings.settings-updated'); }
|
||||
);
|
||||
if(response) {
|
||||
store.dispatch("requestSiteSettings");
|
||||
}
|
||||
return response;
|
||||
},
|
||||
|
||||
|
@ -34,20 +42,39 @@ export const siteSettingsAPI = {
|
|||
return response.data;
|
||||
},
|
||||
|
||||
async createPage(body) {
|
||||
return await apiReq.post(settingsURLs.customPages, body);
|
||||
createPage(body) {
|
||||
return apiReq.post(
|
||||
settingsURLs.customPages,
|
||||
body,
|
||||
function() { return i18n.t('page.page-creation-failed'); },
|
||||
function() { return i18n.t('page.new-page-created'); }
|
||||
);
|
||||
},
|
||||
|
||||
async deletePage(id) {
|
||||
return await apiReq.delete(settingsURLs.customPage(id));
|
||||
return await apiReq.delete(
|
||||
settingsURLs.customPage(id),
|
||||
null,
|
||||
function() { return i18n.t('page.page-deletion-failed'); },
|
||||
function() { return i18n.t('page.page-deleted'); });
|
||||
},
|
||||
|
||||
async updatePage(body) {
|
||||
return await apiReq.put(settingsURLs.customPage(body.id), body);
|
||||
updatePage(body) {
|
||||
return apiReq.put(
|
||||
settingsURLs.customPage(body.id),
|
||||
body,
|
||||
function() { return i18n.t('page.page-update-failed'); },
|
||||
function() { return i18n.t('page.page-updated'); }
|
||||
);
|
||||
},
|
||||
|
||||
async updateAllPages(allPages) {
|
||||
let response = await apiReq.put(settingsURLs.customPages, allPages);
|
||||
let response = await apiReq.put(
|
||||
settingsURLs.customPages,
|
||||
allPages,
|
||||
function() { return i18n.t('page.pages-update-failed'); },
|
||||
function() { return i18n.t('page.pages-updated'); }
|
||||
);
|
||||
return response;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
const prefix = baseURL + "themes";
|
||||
|
||||
|
@ -23,18 +24,31 @@ export const themeAPI = {
|
|||
},
|
||||
|
||||
async create(postBody) {
|
||||
return await apiReq.post(settingsURLs.createTheme, postBody);
|
||||
return await apiReq.post(
|
||||
settingsURLs.createTheme,
|
||||
postBody,
|
||||
function() { return i18n.t('settings.theme.error-creating-theme-see-log-file'); },
|
||||
function() { return i18n.t('settings.theme.theme-saved'); });
|
||||
},
|
||||
|
||||
async update(themeName, colors) {
|
||||
update(themeName, colors) {
|
||||
const body = {
|
||||
name: themeName,
|
||||
colors: colors,
|
||||
};
|
||||
return await apiReq.put(settingsURLs.updateTheme(themeName), body);
|
||||
return apiReq.put(
|
||||
settingsURLs.updateTheme(themeName),
|
||||
body,
|
||||
function() { return i18n.t('settings.theme.error-updating-theme'); },
|
||||
function() { return i18n.t('settings.theme.theme-updated'); });
|
||||
},
|
||||
|
||||
async delete(themeName) {
|
||||
return await apiReq.delete(settingsURLs.deleteTheme(themeName));
|
||||
delete(themeName) {
|
||||
return apiReq.delete(
|
||||
settingsURLs.deleteTheme(themeName),
|
||||
null,
|
||||
function() { return i18n.t('settings.theme.error-deleting-theme'); },
|
||||
function() { return i18n.t('settings.theme.theme-deleted'); }
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import { apiReq } from "./api-utils";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
export const utilsAPI = {
|
||||
// import { api } from "@/api";
|
||||
async uploadFile(url, fileObject) {
|
||||
uploadFile(url, fileObject) {
|
||||
console.log("API Called");
|
||||
|
||||
let response = await apiReq.post(url, fileObject, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
});
|
||||
return response;
|
||||
return apiReq.post(
|
||||
url,
|
||||
fileObject,
|
||||
function() { return i18n.t('general.failure-uploading-file'); },
|
||||
function() { return i18n.t('general.file-uploaded'); }
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { baseURL } from "./api-utils";
|
||||
import { apiReq } from "./api-utils";
|
||||
import axios from "axios";
|
||||
import i18n from '@/i18n.js';
|
||||
const authPrefix = baseURL + "auth";
|
||||
const userPrefix = baseURL + "users";
|
||||
|
||||
|
@ -17,6 +18,16 @@ const usersURLs = {
|
|||
resetPassword: id => `${userPrefix}/${id}/reset-password`,
|
||||
};
|
||||
|
||||
function deleteErrorText(response) {
|
||||
console.log(response.data);
|
||||
switch(response.data.detail) {
|
||||
case 'SUPER_USER':
|
||||
return i18n.t('user.error-cannot-delete-super-user');
|
||||
|
||||
default:
|
||||
return i18n.t('user.you-are-not-allowed-to-delete-this-user');
|
||||
}
|
||||
}
|
||||
export const userAPI = {
|
||||
async login(formData) {
|
||||
let response = await apiReq.post(authURLs.token, formData, {
|
||||
|
@ -36,8 +47,13 @@ export const userAPI = {
|
|||
let response = await apiReq.get(usersURLs.users);
|
||||
return response.data;
|
||||
},
|
||||
async create(user) {
|
||||
return await apiReq.post(usersURLs.users, user);
|
||||
create(user) {
|
||||
return apiReq.post(
|
||||
usersURLs.users,
|
||||
user,
|
||||
function() { return i18n.t('user.user-creation-failed'); },
|
||||
function() { return i18n.t('user.user-created'); }
|
||||
);
|
||||
},
|
||||
async self() {
|
||||
let response = await apiReq.get(usersURLs.self);
|
||||
|
@ -47,17 +63,37 @@ export const userAPI = {
|
|||
let response = await apiReq.get(usersURLs.userID(id));
|
||||
return response.data;
|
||||
},
|
||||
async update(user) {
|
||||
return await apiReq.put(usersURLs.userID(user.id), user);
|
||||
update(user) {
|
||||
return apiReq.put(
|
||||
usersURLs.userID(user.id),
|
||||
user,
|
||||
function() { return i18n.t('user.user-update-failed'); },
|
||||
function() { return i18n.t('user.user-updated'); }
|
||||
);
|
||||
},
|
||||
async changePassword(id, password) {
|
||||
let response = await apiReq.put(usersURLs.password(id), password);
|
||||
return response.data;
|
||||
changePassword(id, password) {
|
||||
return apiReq.put(
|
||||
usersURLs.password(id),
|
||||
password,
|
||||
function() { return i18n.t('user.existing-password-does-not-match'); },
|
||||
function() { return i18n.t('user.password-updated'); }
|
||||
);
|
||||
},
|
||||
async delete(id) {
|
||||
return await apiReq.delete(usersURLs.userID(id));
|
||||
|
||||
delete(id) {
|
||||
return apiReq.delete(
|
||||
usersURLs.userID(id),
|
||||
null,
|
||||
deleteErrorText,
|
||||
function() { return i18n.t('user.user-deleted'); }
|
||||
);
|
||||
},
|
||||
async resetPassword(id) {
|
||||
return await apiReq.put(usersURLs.resetPassword(id));
|
||||
resetPassword(id) {
|
||||
return apiReq.put(
|
||||
usersURLs.resetPassword(id),
|
||||
null,
|
||||
function() { return i18n.t('user.password-reset-failed'); },
|
||||
function() { return i18n.t('user.password-has-been-reset-to-the-default-password'); }
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -85,7 +85,6 @@
|
|||
<script>
|
||||
import { api } from "@/api";
|
||||
import { validators } from "@/mixins/validators";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
mixins: [validators],
|
||||
data() {
|
||||
|
@ -134,11 +133,7 @@ export default {
|
|||
};
|
||||
|
||||
if (this.$refs.signUpForm.validate()) {
|
||||
let response = await api.signUps.createUser(this.token, userData);
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(this.$t('user.you-are-not-allowed-to-create-a-user'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('user.user-created'));
|
||||
if (await api.signUps.createUser(this.token, userData)) {
|
||||
this.$emit("user-created");
|
||||
this.$router.push("/");
|
||||
}
|
||||
|
|
|
@ -36,11 +36,7 @@ export default {
|
|||
return utils.getDateAsPythonDate(dateObject);
|
||||
},
|
||||
async update() {
|
||||
const response = await api.mealPlans.update(this.mealPlan.uid, this.mealPlan);
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(this.$t('meal-plan.mealplan-update-failed'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('meal-plan.mealplan-updated'));
|
||||
if (await api.mealPlans.update(this.mealPlan.uid, this.mealPlan)) {
|
||||
this.$emit("updated");
|
||||
}
|
||||
},
|
||||
|
|
|
@ -197,16 +197,12 @@ export default {
|
|||
endDate: this.endDate,
|
||||
meals: this.meals,
|
||||
};
|
||||
const response = await api.mealPlans.create(mealBody);
|
||||
if (response.status != 201) {
|
||||
utils.notify.error(this.$t('meal-plan.mealplan-creation-failed'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('meal-plan.mealplan-created'));
|
||||
if (await api.mealPlans.create(mealBody)) {
|
||||
this.$emit(CREATE_EVENT);
|
||||
this.meals = [];
|
||||
this.startDate = null;
|
||||
this.endDate = null;
|
||||
}
|
||||
this.$emit(CREATE_EVENT);
|
||||
this.meals = [];
|
||||
this.startDate = null;
|
||||
this.endDate = null;
|
||||
},
|
||||
|
||||
getImage(image) {
|
||||
|
|
|
@ -46,7 +46,6 @@ const REFRESH_EVENT = "refresh";
|
|||
const UPLOAD_EVENT = "upload";
|
||||
import TheUploadBtn from "@/components/UI/Buttons/TheUploadBtn";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
components: {
|
||||
TheUploadBtn,
|
||||
|
@ -64,13 +63,9 @@ export default {
|
|||
},
|
||||
async getImageFromURL() {
|
||||
this.loading = true;
|
||||
const response = await api.recipes.updateImagebyURL(this.slug, this.url);
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(this.$t('general.image-upload-failed'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('general.image-updated'));
|
||||
if (await api.recipes.updateImagebyURL(this.slug, this.url)) {
|
||||
this.$emit(REFRESH_EVENT);
|
||||
}
|
||||
if (response) this.$emit(REFRESH_EVENT);
|
||||
this.loading = false;
|
||||
},
|
||||
},
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
<script>
|
||||
const UPLOAD_EVENT = "uploaded";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
props: {
|
||||
post: {
|
||||
|
@ -56,15 +55,10 @@ export default {
|
|||
let formData = new FormData();
|
||||
formData.append(this.fileName, this.file);
|
||||
|
||||
const response = await api.utils.uploadFile(this.url, formData);
|
||||
if(response.status != 200) {
|
||||
utils.notify.error(this.$t('general.failure-uploading-file'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('general.file-uploaded'));
|
||||
|
||||
if(await api.utils.uploadFile(this.url, formData)) {
|
||||
this.$emit(UPLOAD_EVENT);
|
||||
}
|
||||
this.isSelecting = false;
|
||||
this.$emit(UPLOAD_EVENT);
|
||||
}
|
||||
},
|
||||
onButtonClick() {
|
||||
|
|
|
@ -105,17 +105,15 @@ export default {
|
|||
async createRecipe() {
|
||||
if (this.$refs.urlForm.validate()) {
|
||||
this.processing = true;
|
||||
let response = await api.recipes.createByURL(this.recipeURL);
|
||||
if (response.status !== 201) {
|
||||
this.error = true;
|
||||
this.processing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this.addRecipe = false;
|
||||
const response = await api.recipes.createByURL(this.recipeURL);
|
||||
this.processing = false;
|
||||
this.recipeURL = "";
|
||||
this.$router.push(`/recipe/${response.data}`);
|
||||
if (response) {
|
||||
this.addRecipe = false;
|
||||
this.recipeURL = "";
|
||||
this.$router.push(`/recipe/${response.data}`);
|
||||
} else {
|
||||
this.error = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -130,7 +130,9 @@
|
|||
"page-updated": "Page updated",
|
||||
"pages-update-failed": "Pages update failed",
|
||||
"pages-updated": "Pages updated",
|
||||
"recent": "Recent"
|
||||
"recent": "Recent",
|
||||
"page-deletion-failed": "Page deletion failed",
|
||||
"page-deleted": "Page deleted"
|
||||
},
|
||||
"recipe": {
|
||||
"add-key": "Add Key",
|
||||
|
@ -172,7 +174,9 @@
|
|||
"title": "Title",
|
||||
"total-time": "Total Time",
|
||||
"unable-to-delete-recipe": "Unable to Delete Recipe",
|
||||
"view-recipe": "View Recipe"
|
||||
"view-recipe": "View Recipe",
|
||||
"recipe-creation-failed": "Recipe creation failed",
|
||||
"recipe-created": "Recipe created"
|
||||
},
|
||||
"search": {
|
||||
"category-filter": "Category Filter",
|
||||
|
@ -199,11 +203,12 @@
|
|||
"full-backup": "Full Backup",
|
||||
"import-summary": "Import Summary",
|
||||
"partial-backup": "Partial Backup",
|
||||
"unable-to-delete-backup-see-log-file": "Unable to Delete Backup. See Log File"
|
||||
"unable-to-delete-backup": "Unable to Delete Backup."
|
||||
},
|
||||
"backup-and-exports": "Backups",
|
||||
"backup-info": "Backups are exported in standard JSON format along with all the images stored on the file system. In your backup folder you'll find a .zip file that contains all of the recipe JSON and images from the database. Additionally, if you selected a markdown file, those will also be stored in the .zip file. To import a backup, it must be located in your backups folder. Automated backups are done each day at 3:00 AM.",
|
||||
"category-deleted": "Category Deleted",
|
||||
"category-creation-failed": "Category creation failed",
|
||||
"category-deletion-failed": "Category deletion failed",
|
||||
"change-password": "Change Password",
|
||||
"current": "Version:",
|
||||
|
@ -275,7 +280,10 @@
|
|||
"remove-unused": "Remove Unused",
|
||||
"assign-all": "Assign All",
|
||||
"bulk-assign": "Bulk Assign"
|
||||
}
|
||||
},
|
||||
"category-created": "Category created",
|
||||
"category-update-failed": "Category update failed",
|
||||
"category-updated": "Category updated"
|
||||
},
|
||||
"this": {},
|
||||
"user": {
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
<script>
|
||||
import ImportDialog from "./ImportDialog";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
props: {
|
||||
backups: Array,
|
||||
|
@ -63,22 +62,21 @@ export default {
|
|||
},
|
||||
async importBackup(data) {
|
||||
this.$emit("loading");
|
||||
let response = await api.backups.import(data.name, data);
|
||||
const response = await api.backups.import(data.name, data);
|
||||
if(response) {
|
||||
let importData = response.data;
|
||||
this.$emit("finished", importData);
|
||||
} else {
|
||||
this.$emit("finished");
|
||||
}
|
||||
|
||||
let importData = response.data;
|
||||
|
||||
this.$emit("finished", importData);
|
||||
},
|
||||
async deleteBackup(data) {
|
||||
this.$emit("loading");
|
||||
|
||||
const response = await api.backups.delete(data.name);
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(this.$t('settings.backup.unable-to-delete-backup-see-log-file'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('settings.backup.backup-deleted'));
|
||||
if (await api.backups.delete(data.name)) {
|
||||
this.selectedBackup = null;
|
||||
}
|
||||
this.selectedBackup = null;
|
||||
this.backupLoading = false;
|
||||
|
||||
this.$emit("finished");
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
<script>
|
||||
import ImportOptions from "./ImportOptions";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
components: { ImportOptions },
|
||||
data() {
|
||||
|
@ -98,14 +97,10 @@ export default {
|
|||
templates: this.selectedTemplates,
|
||||
};
|
||||
|
||||
const response = await api.backups.create(data);
|
||||
this.loading = false;
|
||||
if (response.status != 201) {
|
||||
utils.notify.error(this.$t('settings.backup.error-creating-backup-see-log-file'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('settings.backup.backup-created-at-response-export_path', {path: response.data.export_path}));
|
||||
if (await api.backups.create(data)) {
|
||||
this.$emit("created");
|
||||
}
|
||||
this.loading = false;
|
||||
|
||||
},
|
||||
appendTemplate(templateName) {
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
const RENDER_EVENT = "update";
|
||||
import ConfirmationDialog from "@/components/UI/Dialogs/ConfirmationDialog";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
components: { ConfirmationDialog },
|
||||
props: {
|
||||
|
@ -92,26 +91,7 @@ export default {
|
|||
this.$refs.deleteGroupConfirm.open();
|
||||
},
|
||||
async deleteGroup() {
|
||||
const response = await api.groups.delete(this.group.id);
|
||||
if (response.status != 200) {
|
||||
switch(response.data.detail) {
|
||||
case 'GROUP_WITH_USERS':
|
||||
utils.notify.error(this.$t('user.cannot-delete-group-with-users'));
|
||||
break;
|
||||
|
||||
case 'GROUP_NOT_FOUND':
|
||||
utils.notify.error(this.$t('user.group-not-found'));
|
||||
break;
|
||||
|
||||
case 'DEFAULT_GROUP':
|
||||
utils.notify.error(this.$t('user.cannot-delete-default-group'));
|
||||
break;
|
||||
|
||||
default:
|
||||
utils.notify.error(this.$t('user.group-deletion-failed'));
|
||||
}
|
||||
} else {
|
||||
utils.notify.success(this.$t('user.group-deleted'));
|
||||
if (await api.groups.delete(this.group.id)) {
|
||||
this.$emit(RENDER_EVENT);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -86,7 +86,6 @@
|
|||
import { validators } from "@/mixins/validators";
|
||||
import { api } from "@/api";
|
||||
import GroupCard from "./GroupCard";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
components: { GroupCard },
|
||||
mixins: [validators],
|
||||
|
@ -105,15 +104,11 @@ export default {
|
|||
methods: {
|
||||
async createGroup() {
|
||||
this.groupLoading = true;
|
||||
const response = await api.groups.create(this.newGroupName);
|
||||
if (response.status != 201) {
|
||||
utils.notify.error(this.$t('user.user-group-creation-failed'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('user.user-group-created'));
|
||||
this.groupLoading = false;
|
||||
if (await api.groups.create(this.newGroupName)) {
|
||||
this.groupDialog = false;
|
||||
this.$store.dispatch("requestAllGroups");
|
||||
}
|
||||
this.groupLoading = false;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -109,7 +109,6 @@
|
|||
<script>
|
||||
import ConfirmationDialog from "@/components/UI/Dialogs/ConfirmationDialog";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
import { validators } from "@/mixins/validators";
|
||||
export default {
|
||||
components: { ConfirmationDialog },
|
||||
|
@ -183,13 +182,9 @@ export default {
|
|||
},
|
||||
|
||||
async deleteToken() {
|
||||
const response = await api.signUps.deleteToken(this.activeId);
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(this.$t('general.not-authorized'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('user.sign-up-token-deleted'));
|
||||
if (await api.signUps.deleteToken(this.activeId)) {
|
||||
this.initialize();
|
||||
}
|
||||
this.initialize();
|
||||
},
|
||||
|
||||
editItem(item) {
|
||||
|
|
|
@ -146,7 +146,6 @@
|
|||
<script>
|
||||
import ConfirmationDialog from "@/components/UI/Dialogs/ConfirmationDialog";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
import { validators } from "@/mixins/validators";
|
||||
export default {
|
||||
components: { ConfirmationDialog },
|
||||
|
@ -224,18 +223,7 @@ export default {
|
|||
},
|
||||
|
||||
async deleteUser() {
|
||||
const response = await api.users.delete(this.activeId);
|
||||
if (response.status != 200) {
|
||||
switch(response.data.detail) {
|
||||
case 'SUPER_USER':
|
||||
utils.notify.error(this.$t('user.error-cannot-delete-super-user'));
|
||||
break;
|
||||
|
||||
default:
|
||||
utils.notify.error(this.$t('user.you-are-not-allowed-to-delete-this-user'));
|
||||
}
|
||||
} else {
|
||||
utils.notify.success(this.$t('user.user-deleted'));
|
||||
if (await api.users.delete(this.activeId)) {
|
||||
this.initialize();
|
||||
}
|
||||
},
|
||||
|
@ -283,31 +271,18 @@ export default {
|
|||
}
|
||||
await this.initialize();
|
||||
},
|
||||
async resetPassword() {
|
||||
const response = await api.users.resetPassword(this.editedItem.id);
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(this.$t('user.password-reset-failed'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('user.password-has-been-reset-to-the-default-password'));
|
||||
}
|
||||
resetPassword() {
|
||||
api.users.resetPassword(this.editedItem.id);
|
||||
},
|
||||
|
||||
async createUser() {
|
||||
const response = await api.users.create(this.editedItem);
|
||||
if(response.status!=201) {
|
||||
utils.notify.error(this.$t('user.user-creation-failed'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('user.user-created'));
|
||||
if(await api.users.create(this.editedItem)) {
|
||||
this.close();
|
||||
}
|
||||
},
|
||||
|
||||
async updateUser() {
|
||||
const response = await api.users.update(this.editedItem);
|
||||
if(response.status!=200) {
|
||||
utils.notify.error(this.$t('user.user-update-failed'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('user.user-updated'));
|
||||
if(await api.users.update(this.editedItem)) {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,6 @@
|
|||
import { api } from "@/api";
|
||||
import TimePickerDialog from "@/components/FormHelpers/TimePickerDialog";
|
||||
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
components: {
|
||||
TimePickerDialog,
|
||||
|
@ -136,11 +135,7 @@ export default {
|
|||
this.groupSettings.webhookUrls.splice(index, 1);
|
||||
},
|
||||
async saveGroupSettings() {
|
||||
const response = await api.groups.update(this.groupSettings);
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(this.$t('user.error-updating-group'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('settings.group-settings-updated'));
|
||||
if (await api.groups.update(this.groupSettings)) {
|
||||
await this.$store.dispatch("requestCurrentGroup");
|
||||
this.getSiteSettings();
|
||||
}
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
import TheUploadBtn from "@/components/UI/Buttons/TheUploadBtn";
|
||||
import { api } from "@/api";
|
||||
import MigrationDialog from "./MigrationDialog";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
props: {
|
||||
folder: String,
|
||||
|
@ -88,11 +87,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
async deleteMigration(file_name) {
|
||||
const response = await api.migrations.delete(this.folder, file_name);
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(this.$t('general.file-folder-not-found'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('migration.migration-data-removed'));
|
||||
if (await api.migrations.delete(this.folder, file_name)) {
|
||||
this.$emit("refresh");
|
||||
}
|
||||
},
|
||||
|
|
|
@ -147,7 +147,6 @@
|
|||
// import AvatarPicker from '@/components/AvatarPicker'
|
||||
import TheUploadBtn from "@/components/UI/Buttons/TheUploadBtn";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
import { validators } from "@/mixins/validators";
|
||||
import { initials } from "@/mixins/initials";
|
||||
export default {
|
||||
|
@ -203,10 +202,7 @@ export default {
|
|||
async updateUser() {
|
||||
this.loading = true;
|
||||
const response = await api.users.update(this.user);
|
||||
if(response.status != 200) {
|
||||
utils.notify.error(this.$t('user.user-update-failed'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('user.user-updated'));
|
||||
if(response) {
|
||||
this.$store.commit("setToken", response.data.access_token);
|
||||
this.refreshProfile();
|
||||
this.loading = false;
|
||||
|
@ -221,11 +217,7 @@ export default {
|
|||
};
|
||||
|
||||
if (this.$refs.passChange.validate()) {
|
||||
const response = await api.users.changePassword(this.user.id, data);
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(this.$t('user.existing-password-does-not-match'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('user.password-updated'));
|
||||
if (await api.users.changePassword(this.user.id, data)) {
|
||||
this.$emit("refresh");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
<script>
|
||||
const NEW_PAGE_EVENT = "refresh-page";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
||||
export default {
|
||||
components: {
|
||||
|
@ -83,21 +82,14 @@ export default {
|
|||
this.$refs.categoryFormSelector.setInit(this.page.categories);
|
||||
},
|
||||
async submitForm() {
|
||||
let response, sucessMessage, errorMessage;
|
||||
let response;
|
||||
if (this.create) {
|
||||
response = await api.siteSettings.createPage(this.page);
|
||||
sucessMessage = this.$t('page.new-page-created');
|
||||
errorMessage = this.$t('page.page-creation-failed');
|
||||
} else {
|
||||
response = await api.siteSettings.updatePage(this.page);
|
||||
sucessMessage = this.$t('page.page-updated');
|
||||
errorMessage = this.$t('page.page-update-failed');
|
||||
}
|
||||
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(errorMessage);
|
||||
} else {
|
||||
utils.notify.success(sucessMessage);
|
||||
if (response) {
|
||||
this.pageDialog = false;
|
||||
this.page.categories = [];
|
||||
this.$emit(NEW_PAGE_EVENT);
|
||||
|
|
|
@ -65,7 +65,6 @@
|
|||
import draggable from "vuedraggable";
|
||||
import CreatePageDialog from "./CreatePageDialog";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
components: {
|
||||
draggable,
|
||||
|
@ -110,11 +109,7 @@ export default {
|
|||
element.position = index;
|
||||
});
|
||||
|
||||
const response = await api.siteSettings.updateAllPages(this.customPages);
|
||||
if (response.status != 200) {
|
||||
utils.notify.error(this.$t('page.pages-update-failed'));
|
||||
} else {
|
||||
utils.notify.success(this.$t('page.pages-updated'));
|
||||
if (await api.siteSettings.updateAllPages(this.customPages)) {
|
||||
this.getPages();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue