mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-11-26 21:54:24 -05:00
nuxt init
This commit is contained in:
80
frontend.old/src/api/about.js
Normal file
80
frontend.old/src/api/about.js
Normal file
@@ -0,0 +1,80 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from "@/i18n.js";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
export const aboutAPI = {
|
||||
async getEvents() {
|
||||
const resposne = await apiReq.get(API_ROUTES.aboutEvents);
|
||||
return resposne.data;
|
||||
},
|
||||
async deleteEvent(id) {
|
||||
const resposne = await apiReq.delete(API_ROUTES.aboutEventsId(id));
|
||||
return resposne.data;
|
||||
},
|
||||
async deleteAllEvents() {
|
||||
const resposne = await apiReq.delete(API_ROUTES.aboutEvents);
|
||||
return resposne.data;
|
||||
},
|
||||
|
||||
async allEventNotifications() {
|
||||
const response = await apiReq.get(API_ROUTES.aboutEventsNotifications);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async createNotification(data) {
|
||||
const response = await apiReq.post(API_ROUTES.aboutEventsNotifications, data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async deleteNotification(id) {
|
||||
const response = await apiReq.delete(API_ROUTES.aboutEventsNotificationsId(id));
|
||||
return response.data;
|
||||
},
|
||||
async testNotificationByID(id) {
|
||||
const response = await apiReq.post(
|
||||
API_ROUTES.aboutEventsNotificationsTest,
|
||||
{ id: id },
|
||||
() => i18n.t("events.something-went-wrong"),
|
||||
() => i18n.t("events.test-message-sent")
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
async testNotificationByURL(url) {
|
||||
const response = await apiReq.post(
|
||||
API_ROUTES.aboutEventsNotificationsTest,
|
||||
{ test_url: url },
|
||||
() => i18n.t("events.something-went-wrong"),
|
||||
() => i18n.t("events.test-message-sent")
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
// async getAppInfo() {
|
||||
// const response = await apiReq.get(aboutURLs.version);
|
||||
// return response.data;
|
||||
// },
|
||||
|
||||
// async getDebugInfo() {
|
||||
// const response = await apiReq.get(aboutURLs.debug);
|
||||
// return response.data;
|
||||
// },
|
||||
|
||||
// async getLogText(num) {
|
||||
// const response = await apiReq.get(aboutURLs.log(num));
|
||||
// return response.data;
|
||||
// },
|
||||
|
||||
// async getLastJson() {
|
||||
// const response = await apiReq.get(aboutURLs.lastRecipe);
|
||||
// return response.data;
|
||||
// },
|
||||
|
||||
// async getIsDemo() {
|
||||
// const response = await apiReq.get(aboutURLs.demo);
|
||||
// return response.data;
|
||||
// },
|
||||
|
||||
// async getStatistics() {
|
||||
// const response = await apiReq.get(aboutURLs.statistics);
|
||||
// return response.data;
|
||||
// },
|
||||
};
|
||||
121
frontend.old/src/api/api-utils.js
Normal file
121
frontend.old/src/api/api-utils.js
Normal file
@@ -0,0 +1,121 @@
|
||||
import { prefix } from "./apiRoutes";
|
||||
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) {
|
||||
if (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 requests = {
|
||||
/**
|
||||
*
|
||||
* @param {*} funcCall Callable Axios Function
|
||||
* @param {*} url Destination url
|
||||
* @param {*} data Request Data
|
||||
* @param {*} getErrorText Error Text Function
|
||||
* @param {*} getSuccessText Success Text Function
|
||||
* @returns Object response
|
||||
*/
|
||||
unsafe: async function(funcCall, url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
const response = await funcCall(url, data).catch(function(error) {
|
||||
handleError(error, getErrorText);
|
||||
});
|
||||
return handleResponse(response, getSuccessText);
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {*} funcCall Callable Axios Function
|
||||
* @param {*} url Destination url
|
||||
* @param {*} data Request Data
|
||||
* @param {*} getErrorText Error Text Function
|
||||
* @param {*} getSuccessText Success Text Function
|
||||
* @returns Array [response, error]
|
||||
*/
|
||||
safe: async function(funcCall, url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
const response = await funcCall(url, data).catch(function(error) {
|
||||
handleError(error, getErrorText);
|
||||
return [null, error];
|
||||
});
|
||||
return [handleResponse(response, getSuccessText), null];
|
||||
},
|
||||
};
|
||||
|
||||
const apiReq = {
|
||||
get: async function(url, getErrorText = defaultErrorText) {
|
||||
return axios.get(url).catch(function(error) {
|
||||
handleError(error, getErrorText);
|
||||
});
|
||||
},
|
||||
|
||||
getSafe: async function(url) {
|
||||
let error = null;
|
||||
const response = await axios.get(url).catch(e => {
|
||||
error = e;
|
||||
});
|
||||
return [response, error];
|
||||
},
|
||||
|
||||
post: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
return await requests.unsafe(axios.post, url, data, getErrorText, getSuccessText);
|
||||
},
|
||||
|
||||
postSafe: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
return await requests.safe(axios.post, url, data, getErrorText, getSuccessText);
|
||||
},
|
||||
|
||||
put: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
return await requests.unsafe(axios.put, url, data, getErrorText, getSuccessText);
|
||||
},
|
||||
|
||||
putSafe: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
return await requests.safe(axios.put, url, data, getErrorText, getSuccessText);
|
||||
},
|
||||
|
||||
patch: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
return await requests.unsafe(axios.patch, url, data, getErrorText, getSuccessText);
|
||||
},
|
||||
|
||||
patchSafe: async function(url, data, getErrorText = defaultErrorText, getSuccessText) {
|
||||
return await requests.safe(axios.patch, url, data, getErrorText, getSuccessText);
|
||||
},
|
||||
|
||||
delete: async function(url, data, getErrorText = defaultErrorText, getSuccessText = defaultSuccessText) {
|
||||
return await requests.unsafe(axios.delete, url, data, getErrorText, getSuccessText);
|
||||
},
|
||||
|
||||
deleteSafe: async function(url, data, getErrorText = defaultErrorText, getSuccessText = defaultSuccessText) {
|
||||
return await requests.unsafe(axios.delete, url, data, getErrorText, getSuccessText);
|
||||
},
|
||||
|
||||
download: async function(url) {
|
||||
const response = await this.get(url);
|
||||
const token = response.data.fileToken;
|
||||
|
||||
const tokenURL = prefix + "/utils/download?token=" + token;
|
||||
window.open(tokenURL, "_blank");
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
export { apiReq };
|
||||
90
frontend.old/src/api/apiRoutes.js
Normal file
90
frontend.old/src/api/apiRoutes.js
Normal file
@@ -0,0 +1,90 @@
|
||||
// This Content is Auto Generated
|
||||
export const prefix = "/api";
|
||||
export const API_ROUTES = {
|
||||
aboutEvents: `${prefix}/about/events`,
|
||||
aboutEventsNotifications: `${prefix}/about/events/notifications`,
|
||||
aboutEventsNotificationsTest: `${prefix}/about/events/notifications/test`,
|
||||
aboutRecipesDefaults: `${prefix}/about/recipes/defaults`,
|
||||
authRefresh: `${prefix}/auth/refresh`,
|
||||
authToken: `${prefix}/auth/token`,
|
||||
authTokenLong: `${prefix}/auth/token/long`,
|
||||
backupsAvailable: `${prefix}/backups/available`,
|
||||
backupsExportDatabase: `${prefix}/backups/export/database`,
|
||||
backupsUpload: `${prefix}/backups/upload`,
|
||||
categories: `${prefix}/categories`,
|
||||
categoriesEmpty: `${prefix}/categories/empty`,
|
||||
debug: `${prefix}/debug`,
|
||||
debugLastRecipeJson: `${prefix}/debug/last-recipe-json`,
|
||||
debugLog: `${prefix}/debug/log`,
|
||||
debugStatistics: `${prefix}/debug/statistics`,
|
||||
debugVersion: `${prefix}/debug/version`,
|
||||
groups: `${prefix}/groups`,
|
||||
groupsSelf: `${prefix}/groups/self`,
|
||||
mealPlansAll: `${prefix}/meal-plans/all`,
|
||||
mealPlansCreate: `${prefix}/meal-plans/create`,
|
||||
mealPlansThisWeek: `${prefix}/meal-plans/this-week`,
|
||||
mealPlansToday: `${prefix}/meal-plans/today`,
|
||||
mealPlansTodayImage: `${prefix}/meal-plans/today/image`,
|
||||
migrations: `${prefix}/migrations`,
|
||||
recipesCategory: `${prefix}/recipes/category`,
|
||||
recipesCreate: `${prefix}/recipes/create`,
|
||||
recipesCreateFromZip: `${prefix}/recipes/create-from-zip`,
|
||||
recipesCreateUrl: `${prefix}/recipes/create-url`,
|
||||
recipesSummary: `${prefix}/recipes/summary`,
|
||||
recipesSummaryUncategorized: `${prefix}/recipes/summary/uncategorized`,
|
||||
recipesSummaryUntagged: `${prefix}/recipes/summary/untagged`,
|
||||
recipesTag: `${prefix}/recipes/tag`,
|
||||
recipesTestScrapeUrl: `${prefix}/recipes/test-scrape-url`,
|
||||
shoppingLists: `${prefix}/shopping-lists`,
|
||||
siteSettings: `${prefix}/site-settings`,
|
||||
siteSettingsCustomPages: `${prefix}/site-settings/custom-pages`,
|
||||
siteSettingsWebhooksTest: `${prefix}/site-settings/webhooks/test`,
|
||||
tags: `${prefix}/tags`,
|
||||
tagsEmpty: `${prefix}/tags/empty`,
|
||||
themes: `${prefix}/themes`,
|
||||
themesCreate: `${prefix}/themes/create`,
|
||||
users: `${prefix}/users`,
|
||||
usersApiTokens: `${prefix}/users/api-tokens`,
|
||||
usersSelf: `${prefix}/users/self`,
|
||||
usersSignUps: `${prefix}/users/sign-ups`,
|
||||
utilsDownload: `${prefix}/utils/download`,
|
||||
|
||||
aboutEventsId: id => `${prefix}/about/events/${id}`,
|
||||
aboutEventsNotificationsId: id => `${prefix}/about/events/notifications/${id}`,
|
||||
backupsFileNameDelete: file_name => `${prefix}/backups/${file_name}/delete`,
|
||||
backupsFileNameDownload: file_name => `${prefix}/backups/${file_name}/download`,
|
||||
backupsFileNameImport: file_name => `${prefix}/backups/${file_name}/import`,
|
||||
categoriesCategory: category => `${prefix}/categories/${category}`,
|
||||
debugLogNum: num => `${prefix}/debug/log/${num}`,
|
||||
groupsId: id => `${prefix}/groups/${id}`,
|
||||
mealPlansId: id => `${prefix}/meal-plans/${id}`,
|
||||
mealPlansIdShoppingList: id => `${prefix}/meal-plans/${id}/shopping-list`,
|
||||
mealPlansPlanId: plan_id => `${prefix}/meal-plans/${plan_id}`,
|
||||
mediaRecipesRecipeSlugAssetsFileName: (recipe_slug, file_name) =>
|
||||
`${prefix}/media/recipes/${recipe_slug}/assets/${file_name}`,
|
||||
mediaRecipesRecipeSlugImagesFileName: (recipe_slug, file_name) =>
|
||||
`${prefix}/media/recipes/${recipe_slug}/images/${file_name}`,
|
||||
migrationsImportTypeFileNameDelete: (import_type, file_name) =>
|
||||
`${prefix}/migrations/${import_type}/${file_name}/delete`,
|
||||
migrationsImportTypeFileNameImport: (import_type, file_name) =>
|
||||
`${prefix}/migrations/${import_type}/${file_name}/import`,
|
||||
migrationsImportTypeUpload: import_type => `${prefix}/migrations/${import_type}/upload`,
|
||||
recipesRecipeSlug: recipe_slug => `${prefix}/recipes/${recipe_slug}`,
|
||||
recipesRecipeSlugAssets: recipe_slug => `${prefix}/recipes/${recipe_slug}/assets`,
|
||||
recipesRecipeSlugImage: recipe_slug => `${prefix}/recipes/${recipe_slug}/image`,
|
||||
recipesRecipeSlugZip: recipe_slug => `${prefix}/recipes/${recipe_slug}/zip`,
|
||||
recipesSlugComments: slug => `${prefix}/recipes/${slug}/comments`,
|
||||
recipesSlugCommentsId: (slug, id) => `${prefix}/recipes/${slug}/comments/${id}`,
|
||||
shoppingListsId: id => `${prefix}/shopping-lists/${id}`,
|
||||
siteSettingsCustomPagesId: id => `${prefix}/site-settings/custom-pages/${id}`,
|
||||
tagsTag: tag => `${prefix}/tags/${tag}`,
|
||||
themesId: id => `${prefix}/themes/${id}`,
|
||||
usersApiTokensTokenId: token_id => `${prefix}/users/api-tokens/${token_id}`,
|
||||
usersId: id => `${prefix}/users/${id}`,
|
||||
usersIdFavorites: id => `${prefix}/users/${id}/favorites`,
|
||||
usersIdFavoritesSlug: (id, slug) => `${prefix}/users/${id}/favorites/${slug}`,
|
||||
usersIdImage: id => `${prefix}/users/${id}/image`,
|
||||
usersIdPassword: id => `${prefix}/users/${id}/password`,
|
||||
usersIdResetPassword: id => `${prefix}/users/${id}/reset-password`,
|
||||
usersSignUpsToken: token => `${prefix}/users/sign-ups/${token}`,
|
||||
};
|
||||
62
frontend.old/src/api/backup.js
Normal file
62
frontend.old/src/api/backup.js
Normal file
@@ -0,0 +1,62 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "@/store";
|
||||
import i18n from "@/i18n.js";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
export const backupAPI = {
|
||||
/**
|
||||
* Request all backups available on the server
|
||||
* @returns {Array} List of Available Backups
|
||||
*/
|
||||
async requestAvailable() {
|
||||
let response = await apiReq.get(API_ROUTES.backupsAvailable);
|
||||
return response.data;
|
||||
},
|
||||
/**
|
||||
* Calls for importing a file on the server
|
||||
* @param {string} fileName
|
||||
* @param {object} data
|
||||
* @returns A report containing status of imported items
|
||||
*/
|
||||
async import(fileName, data) {
|
||||
let response = await apiReq.post(API_ROUTES.backupsFileNameImport(fileName), data);
|
||||
store.dispatch("requestRecentRecipes");
|
||||
return response;
|
||||
},
|
||||
/**
|
||||
* Removes a file from the server
|
||||
* @param {string} fileName
|
||||
*/
|
||||
async delete(fileName) {
|
||||
return apiReq.delete(
|
||||
API_ROUTES.backupsFileNameDelete(fileName),
|
||||
null,
|
||||
() => i18n.t("settings.backup.unable-to-delete-backup"),
|
||||
() => i18n.t("settings.backup.backup-deleted")
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Creates a backup on the serve given a set of options
|
||||
* @param {object} data
|
||||
* @returns
|
||||
*/
|
||||
async create(options) {
|
||||
return apiReq.post(
|
||||
API_ROUTES.backupsExportDatabase,
|
||||
options,
|
||||
() => i18n.t("settings.backup.error-creating-backup-see-log-file"),
|
||||
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?
|
||||
* @param {string} fileName
|
||||
* @returns Download URL
|
||||
*/
|
||||
async download(fileName) {
|
||||
const url = API_ROUTES.backupsFileNameDownload(fileName);
|
||||
apiReq.download(url);
|
||||
},
|
||||
};
|
||||
111
frontend.old/src/api/category.js
Normal file
111
frontend.old/src/api/category.js
Normal file
@@ -0,0 +1,111 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "@/store";
|
||||
import i18n from "@/i18n.js";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
export const categoryAPI = {
|
||||
async getAll() {
|
||||
let response = await apiReq.get(API_ROUTES.categories);
|
||||
return response.data;
|
||||
},
|
||||
async getEmpty() {
|
||||
let response = await apiReq.get(API_ROUTES.categoriesEmpty);
|
||||
return response.data;
|
||||
},
|
||||
async create(name) {
|
||||
const response = await apiReq.post(
|
||||
API_ROUTES.categories,
|
||||
{ name: name },
|
||||
() => i18n.t("category.category-creation-failed"),
|
||||
() => i18n.t("category.category-created")
|
||||
);
|
||||
if (response) {
|
||||
store.dispatch("requestCategories");
|
||||
return response.data;
|
||||
}
|
||||
},
|
||||
async getRecipesInCategory(category) {
|
||||
let response = await apiReq.get(API_ROUTES.categoriesCategory(category));
|
||||
return response.data;
|
||||
},
|
||||
async update(name, newName, overrideRequest = false) {
|
||||
const response = await apiReq.put(
|
||||
API_ROUTES.categoriesCategory(name),
|
||||
{ name: newName },
|
||||
() => i18n.t("category.category-update-failed"),
|
||||
() => i18n.t("category.category-updated")
|
||||
);
|
||||
if (response && !overrideRequest) {
|
||||
store.dispatch("requestCategories");
|
||||
return response.data;
|
||||
}
|
||||
},
|
||||
async delete(category, overrideRequest = false) {
|
||||
const response = await apiReq.delete(
|
||||
API_ROUTES.categoriesCategory(category),
|
||||
null,
|
||||
() => i18n.t("category.category-deletion-failed"),
|
||||
() => i18n.t("category.category-deleted")
|
||||
);
|
||||
if (response && !overrideRequest) {
|
||||
store.dispatch("requestCategories");
|
||||
}
|
||||
return response;
|
||||
},
|
||||
};
|
||||
|
||||
export const tagAPI = {
|
||||
async getAll() {
|
||||
let response = await apiReq.get(API_ROUTES.tags);
|
||||
return response.data;
|
||||
},
|
||||
async getEmpty() {
|
||||
let response = await apiReq.get(API_ROUTES.tagsEmpty);
|
||||
return response.data;
|
||||
},
|
||||
async create(name) {
|
||||
const response = await apiReq.post(
|
||||
API_ROUTES.tags,
|
||||
{ name: name },
|
||||
() => i18n.t("tag.tag-creation-failed"),
|
||||
() => i18n.t("tag.tag-created")
|
||||
);
|
||||
if (response) {
|
||||
store.dispatch("requestTags");
|
||||
return response.data;
|
||||
}
|
||||
},
|
||||
async getRecipesInTag(tag) {
|
||||
let response = await apiReq.get(API_ROUTES.tagsTag(tag));
|
||||
return response.data;
|
||||
},
|
||||
async update(name, newName, overrideRequest = false) {
|
||||
const response = await apiReq.put(
|
||||
API_ROUTES.tagsTag(name),
|
||||
{ name: newName },
|
||||
() => i18n.t("tag.tag-update-failed"),
|
||||
() => i18n.t("tag.tag-updated")
|
||||
);
|
||||
|
||||
if (response) {
|
||||
if (!overrideRequest) {
|
||||
store.dispatch("requestTags");
|
||||
}
|
||||
return response.data;
|
||||
}
|
||||
},
|
||||
async delete(tag, overrideRequest = false) {
|
||||
const response = await apiReq.delete(
|
||||
API_ROUTES.tagsTag(tag),
|
||||
null,
|
||||
() => i18n.t("tag.tag-deletion-failed"),
|
||||
() => i18n.t("tag.tag-deleted")
|
||||
);
|
||||
if (response) {
|
||||
if (!overrideRequest) {
|
||||
store.dispatch("requestTags");
|
||||
}
|
||||
return response.data;
|
||||
}
|
||||
},
|
||||
};
|
||||
53
frontend.old/src/api/groups.js
Normal file
53
frontend.old/src/api/groups.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from "@/i18n.js";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
function deleteErrorText(response) {
|
||||
switch (response.data.detail) {
|
||||
case "GROUP_WITH_USERS":
|
||||
return i18n.t("group.cannot-delete-group-with-users");
|
||||
|
||||
case "GROUP_NOT_FOUND":
|
||||
return i18n.t("group.group-not-found");
|
||||
|
||||
case "DEFAULT_GROUP":
|
||||
return i18n.t("group.cannot-delete-default-group");
|
||||
|
||||
default:
|
||||
return i18n.t("group.group-deletion-failed");
|
||||
}
|
||||
}
|
||||
|
||||
export const groupAPI = {
|
||||
async allGroups() {
|
||||
let response = await apiReq.get(API_ROUTES.groups);
|
||||
return response.data;
|
||||
},
|
||||
create(name) {
|
||||
return apiReq.post(
|
||||
API_ROUTES.groups,
|
||||
{ name: name },
|
||||
() => i18n.t("group.user-group-creation-failed"),
|
||||
() => i18n.t("group.user-group-created")
|
||||
);
|
||||
},
|
||||
delete(id) {
|
||||
return apiReq.delete(API_ROUTES.groupsId(id), null, deleteErrorText, function() {
|
||||
return i18n.t("group.group-deleted");
|
||||
});
|
||||
},
|
||||
async current() {
|
||||
const response = await apiReq.get(API_ROUTES.groupsSelf, null, null);
|
||||
if (response) {
|
||||
return response.data;
|
||||
}
|
||||
},
|
||||
update(data) {
|
||||
return apiReq.put(
|
||||
API_ROUTES.groupsId(data.id),
|
||||
data,
|
||||
() => i18n.t("group.error-updating-group"),
|
||||
() => i18n.t("settings.group-settings-updated")
|
||||
);
|
||||
},
|
||||
};
|
||||
37
frontend.old/src/api/index.js
Normal file
37
frontend.old/src/api/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { backupAPI } from "./backup";
|
||||
import { recipeAPI } from "./recipe";
|
||||
import { mealplanAPI } from "./mealplan";
|
||||
import { settingsAPI } from "./settings";
|
||||
import { themeAPI } from "./themes";
|
||||
import { migrationAPI } from "./migration";
|
||||
import { utilsAPI } from "./upload";
|
||||
import { categoryAPI, tagAPI } from "./category";
|
||||
import { metaAPI } from "./meta";
|
||||
import { userAPI } from "./users";
|
||||
import { signupAPI } from "./signUps";
|
||||
import { groupAPI } from "./groups";
|
||||
import { siteSettingsAPI } from "./siteSettings";
|
||||
import { aboutAPI } from "./about";
|
||||
import { shoppingListsAPI } from "./shoppingLists";
|
||||
|
||||
/**
|
||||
* The main object namespace for interacting with the backend database
|
||||
*/
|
||||
export const api = {
|
||||
recipes: recipeAPI,
|
||||
siteSettings: siteSettingsAPI,
|
||||
backups: backupAPI,
|
||||
mealPlans: mealplanAPI,
|
||||
settings: settingsAPI,
|
||||
themes: themeAPI,
|
||||
migrations: migrationAPI,
|
||||
utils: utilsAPI,
|
||||
categories: categoryAPI,
|
||||
tags: tagAPI,
|
||||
meta: metaAPI,
|
||||
users: userAPI,
|
||||
signUps: signupAPI,
|
||||
groups: groupAPI,
|
||||
about: aboutAPI,
|
||||
shoppingLists: shoppingListsAPI,
|
||||
};
|
||||
57
frontend.old/src/api/mealplan.js
Normal file
57
frontend.old/src/api/mealplan.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from "@/i18n.js";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
export const mealplanAPI = {
|
||||
create(postBody) {
|
||||
return apiReq.post(
|
||||
API_ROUTES.mealPlansCreate,
|
||||
postBody,
|
||||
() => i18n.t("meal-plan.mealplan-creation-failed"),
|
||||
() => i18n.t("meal-plan.mealplan-created")
|
||||
);
|
||||
},
|
||||
|
||||
async all() {
|
||||
let response = await apiReq.get(API_ROUTES.mealPlansAll);
|
||||
return response;
|
||||
},
|
||||
|
||||
async thisWeek() {
|
||||
let response = await apiReq.get(API_ROUTES.mealPlansThisWeek);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async today() {
|
||||
let response = await apiReq.get(API_ROUTES.mealPlansToday);
|
||||
return response;
|
||||
},
|
||||
|
||||
async getById(id) {
|
||||
let response = await apiReq.get(API_ROUTES.mealPlansId(id));
|
||||
return response.data;
|
||||
},
|
||||
|
||||
delete(id) {
|
||||
return apiReq.delete(
|
||||
API_ROUTES.mealPlansId(id),
|
||||
null,
|
||||
() => i18n.t("meal-plan.mealplan-deletion-failed"),
|
||||
() => i18n.t("meal-plan.mealplan-deleted")
|
||||
);
|
||||
},
|
||||
|
||||
update(id, body) {
|
||||
return apiReq.put(
|
||||
API_ROUTES.mealPlansId(id),
|
||||
body,
|
||||
() => i18n.t("meal-plan.mealplan-update-failed"),
|
||||
() => i18n.t("meal-plan.mealplan-updated")
|
||||
);
|
||||
},
|
||||
|
||||
async shoppingList(id) {
|
||||
let response = await apiReq.get(API_ROUTES.mealPlansIdShoppingList(id));
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
29
frontend.old/src/api/meta.js
Normal file
29
frontend.old/src/api/meta.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
export const metaAPI = {
|
||||
async getAppInfo() {
|
||||
const response = await apiReq.get(API_ROUTES.debugVersion);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async getDebugInfo() {
|
||||
const response = await apiReq.get(API_ROUTES.debug);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async getLogText(num) {
|
||||
const response = await apiReq.get(API_ROUTES.debugLogNum(num));
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async getLastJson() {
|
||||
const response = await apiReq.get(API_ROUTES.debugLastRecipeJson);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async getStatistics() {
|
||||
const response = await apiReq.get(API_ROUTES.debugStatistics);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
25
frontend.old/src/api/migration.js
Normal file
25
frontend.old/src/api/migration.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "../store";
|
||||
import i18n from "@/i18n.js";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
export const migrationAPI = {
|
||||
async getMigrations() {
|
||||
let response = await apiReq.get(API_ROUTES.migrations);
|
||||
return response.data;
|
||||
},
|
||||
async delete(folder, file) {
|
||||
const response = await apiReq.delete(
|
||||
API_ROUTES.migrationsImportTypeFileNameDelete(folder, file),
|
||||
null,
|
||||
() => i18n.t("general.file-folder-not-found"),
|
||||
() => i18n.t("migration.migration-data-removed")
|
||||
);
|
||||
return response;
|
||||
},
|
||||
async import(folder, file) {
|
||||
let response = await apiReq.post(API_ROUTES.migrationsImportTypeFileNameImport(folder, file));
|
||||
store.dispatch("requestRecentRecipes");
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
181
frontend.old/src/api/recipe.js
Normal file
181
frontend.old/src/api/recipe.js
Normal file
@@ -0,0 +1,181 @@
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "../store";
|
||||
import i18n from "@/i18n.js";
|
||||
|
||||
export const recipeAPI = {
|
||||
/**
|
||||
* Returns the Default Recipe Settings for the Site
|
||||
* @returns {AxoisResponse} Axois Response Object
|
||||
*/
|
||||
async getDefaultSettings() {
|
||||
const response = await apiReq.get(API_ROUTES.aboutRecipesDefaults);
|
||||
return response;
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a Recipe by URL
|
||||
* @param {string} recipeURL
|
||||
* @returns {string} Recipe Slug
|
||||
*/
|
||||
async createByURL(recipeURL) {
|
||||
const response = await apiReq.post(API_ROUTES.recipesCreateUrl, { url: recipeURL }, false, () =>
|
||||
i18n.t("recipe.recipe-created")
|
||||
);
|
||||
|
||||
store.dispatch("requestRecentRecipes");
|
||||
return response;
|
||||
},
|
||||
|
||||
async getAllByCategory(categories) {
|
||||
let response = await apiReq.post(API_ROUTES.recipesCategory, categories);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async create(recipeData) {
|
||||
const response = await apiReq.post(
|
||||
API_ROUTES.recipesCreate,
|
||||
recipeData,
|
||||
() => i18n.t("recipe.recipe-creation-failed"),
|
||||
() => i18n.t("recipe.recipe-created")
|
||||
);
|
||||
store.dispatch("requestRecentRecipes");
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async requestDetails(recipeSlug) {
|
||||
const response = await apiReq.getSafe(API_ROUTES.recipesRecipeSlug(recipeSlug));
|
||||
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(
|
||||
API_ROUTES.recipesRecipeSlugImage(recipeSlug),
|
||||
formData,
|
||||
() => i18n.t("general.image-upload-failed"),
|
||||
successMessage
|
||||
);
|
||||
},
|
||||
|
||||
async createAsset(recipeSlug, fileObject, name, icon) {
|
||||
const fd = new FormData();
|
||||
fd.append("file", fileObject);
|
||||
fd.append("extension", fileObject.name.split(".").pop());
|
||||
fd.append("name", name);
|
||||
fd.append("icon", icon);
|
||||
const response = apiReq.post(API_ROUTES.recipesRecipeSlugAssets(recipeSlug), fd);
|
||||
return response;
|
||||
},
|
||||
|
||||
updateImagebyURL(slug, url) {
|
||||
return apiReq.post(
|
||||
API_ROUTES.recipesRecipeSlugImage(slug),
|
||||
{ url: url },
|
||||
() => i18n.t("general.image-upload-failed"),
|
||||
() => i18n.t("recipe.recipe-image-updated")
|
||||
);
|
||||
},
|
||||
|
||||
async update(data) {
|
||||
let response = await apiReq.put(
|
||||
API_ROUTES.recipesRecipeSlug(data.slug),
|
||||
data,
|
||||
() => i18n.t("recipe.recipe-update-failed"),
|
||||
() => i18n.t("recipe.recipe-updated")
|
||||
);
|
||||
if (response) {
|
||||
store.dispatch("patchRecipe", response.data);
|
||||
return response.data.slug; // ! Temporary until I rewrite to refresh page without additional request
|
||||
}
|
||||
},
|
||||
|
||||
async patch(data) {
|
||||
let response = await apiReq.patch(API_ROUTES.recipesRecipeSlug(data.slug), data);
|
||||
store.dispatch("patchRecipe", response.data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async delete(recipeSlug) {
|
||||
const response = await apiReq.delete(
|
||||
API_ROUTES.recipesRecipeSlug(recipeSlug),
|
||||
null,
|
||||
() => i18n.t("recipe.unable-to-delete-recipe"),
|
||||
() => i18n.t("recipe.recipe-deleted")
|
||||
);
|
||||
store.dispatch("dropRecipe", response.data);
|
||||
return response;
|
||||
},
|
||||
|
||||
async allSummary(start = 0, limit = 9999) {
|
||||
const response = await apiReq.get(API_ROUTES.recipesSummary, {
|
||||
params: { start: start, limit: limit },
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async allUntagged() {
|
||||
const response = await apiReq.get(API_ROUTES.recipesSummaryUntagged);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async allUnategorized() {
|
||||
const response = await apiReq.get(API_ROUTES.recipesSummaryUncategorized);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
recipeImage(recipeSlug, version = null, key = null) {
|
||||
return `/api/media/recipes/${recipeSlug}/images/original.webp?&rnd=${key}&version=${version}`;
|
||||
},
|
||||
|
||||
recipeSmallImage(recipeSlug, version = null, key = null) {
|
||||
return `/api/media/recipes/${recipeSlug}/images/min-original.webp?&rnd=${key}&version=${version}`;
|
||||
},
|
||||
|
||||
recipeTinyImage(recipeSlug, version = null, key = null) {
|
||||
return `/api/media/recipes/${recipeSlug}/images/tiny-original.webp?&rnd=${key}&version=${version}`;
|
||||
},
|
||||
|
||||
recipeAssetPath(recipeSlug, assetName) {
|
||||
return `/api/media/recipes/${recipeSlug}/assets/${assetName}`;
|
||||
},
|
||||
|
||||
/** Create comment in the Database
|
||||
* @param slug
|
||||
*/
|
||||
async createComment(slug, data) {
|
||||
const response = await apiReq.post(API_ROUTES.recipesSlugComments(slug), data);
|
||||
return response.data;
|
||||
},
|
||||
/** Update comment in the Database
|
||||
* @param slug
|
||||
* @param id
|
||||
*/
|
||||
async updateComment(slug, id, data) {
|
||||
const response = await apiReq.put(API_ROUTES.recipesSlugCommentsId(slug, id), data);
|
||||
return response.data;
|
||||
},
|
||||
/** Delete comment from the Database
|
||||
* @param slug
|
||||
* @param id
|
||||
*/
|
||||
async deleteComment(slug, id) {
|
||||
const response = await apiReq.delete(API_ROUTES.recipesSlugCommentsId(slug, id));
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async testScrapeURL(url) {
|
||||
const response = await apiReq.post(API_ROUTES.recipesTestScrapeUrl, { url: url });
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
19
frontend.old/src/api/settings.js
Normal file
19
frontend.old/src/api/settings.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
export const settingsAPI = {
|
||||
async requestAll() {
|
||||
let response = await apiReq.get(API_ROUTES.siteSettings);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async testWebhooks() {
|
||||
let response = await apiReq.post(API_ROUTES.siteSettingsWebhooksTest);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async update(body) {
|
||||
let response = await apiReq.put(API_ROUTES.siteSettings, body);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
33
frontend.old/src/api/shoppingLists.js
Normal file
33
frontend.old/src/api/shoppingLists.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// This Content is Auto Generated
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
import { apiReq } from "./api-utils";
|
||||
|
||||
export const shoppingListsAPI = {
|
||||
/** Create Shopping List in the Database
|
||||
*/
|
||||
async createShoppingList(data) {
|
||||
const response = await apiReq.post(API_ROUTES.shoppingLists, data);
|
||||
return response.data;
|
||||
},
|
||||
/** Get Shopping List from the Database
|
||||
* @param id
|
||||
*/
|
||||
async getShoppingList(id) {
|
||||
const response = await apiReq.get(API_ROUTES.shoppingListsId(id));
|
||||
return response.data;
|
||||
},
|
||||
/** Update Shopping List in the Database
|
||||
* @param id
|
||||
*/
|
||||
async updateShoppingList(id, data) {
|
||||
const response = await apiReq.put(API_ROUTES.shoppingListsId(id), data);
|
||||
return response.data;
|
||||
},
|
||||
/** Delete Shopping List from the Database
|
||||
* @param id
|
||||
*/
|
||||
async deleteShoppingList(id) {
|
||||
const response = await apiReq.delete(API_ROUTES.shoppingListsId(id));
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
35
frontend.old/src/api/signUps.js
Normal file
35
frontend.old/src/api/signUps.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from "@/i18n.js";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
export const signupAPI = {
|
||||
async getAll() {
|
||||
let response = await apiReq.get(API_ROUTES.usersSignUps);
|
||||
return response.data;
|
||||
},
|
||||
async createToken(data) {
|
||||
let response = await apiReq.post(
|
||||
API_ROUTES.usersSignUps,
|
||||
data,
|
||||
() => i18n.t("signup.sign-up-link-creation-failed"),
|
||||
() => i18n.t("signup.sign-up-link-created")
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
async deleteToken(token) {
|
||||
return await apiReq.delete(
|
||||
API_ROUTES.usersSignUpsToken(token),
|
||||
null,
|
||||
() => i18n.t("signup.sign-up-token-deletion-failed"),
|
||||
() => i18n.t("signup.sign-up-token-deleted")
|
||||
);
|
||||
},
|
||||
async createUser(token, data) {
|
||||
return apiReq.post(
|
||||
API_ROUTES.usersSignUpsToken(token),
|
||||
data,
|
||||
() => i18n.t("user.you-are-not-allowed-to-create-a-user"),
|
||||
() => i18n.t("user.user-created")
|
||||
);
|
||||
},
|
||||
};
|
||||
71
frontend.old/src/api/siteSettings.js
Normal file
71
frontend.old/src/api/siteSettings.js
Normal file
@@ -0,0 +1,71 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import { store } from "@/store";
|
||||
import i18n from "@/i18n.js";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
export const siteSettingsAPI = {
|
||||
async get() {
|
||||
let response = await apiReq.get(API_ROUTES.siteSettings);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async update(body) {
|
||||
const response = await apiReq.put(
|
||||
API_ROUTES.siteSettings,
|
||||
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(API_ROUTES.siteSettingsCustomPages);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async getPage(id) {
|
||||
let response = await apiReq.get(API_ROUTES.siteSettingsCustomPagesId(id));
|
||||
return response.data;
|
||||
},
|
||||
|
||||
createPage(body) {
|
||||
return apiReq.post(
|
||||
API_ROUTES.siteSettingsCustomPages,
|
||||
body,
|
||||
() => i18n.t("page.page-creation-failed"),
|
||||
() => i18n.t("page.new-page-created")
|
||||
);
|
||||
},
|
||||
|
||||
async deletePage(id) {
|
||||
return await apiReq.delete(
|
||||
API_ROUTES.siteSettingsCustomPagesId(id),
|
||||
null,
|
||||
() => i18n.t("page.page-deletion-failed"),
|
||||
() => i18n.t("page.page-deleted")
|
||||
);
|
||||
},
|
||||
|
||||
updatePage(body) {
|
||||
return apiReq.put(
|
||||
API_ROUTES.siteSettingsCustomPagesId(body.id),
|
||||
body,
|
||||
() => i18n.t("page.page-update-failed"),
|
||||
() => i18n.t("page.page-updated")
|
||||
);
|
||||
},
|
||||
|
||||
async updateAllPages(allPages) {
|
||||
let response = await apiReq.put(
|
||||
API_ROUTES.siteSettingsCustomPages,
|
||||
allPages,
|
||||
() => i18n.t("page.pages-update-failed"),
|
||||
() => i18n.t("page.pages-updated")
|
||||
);
|
||||
return response;
|
||||
},
|
||||
};
|
||||
42
frontend.old/src/api/themes.js
Normal file
42
frontend.old/src/api/themes.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from "@/i18n.js";
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
|
||||
export const themeAPI = {
|
||||
async requestAll() {
|
||||
let response = await apiReq.get(API_ROUTES.themes);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async requestByName(name) {
|
||||
let response = await apiReq.get(API_ROUTES.themesId(name));
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async create(postBody) {
|
||||
return await apiReq.post(
|
||||
API_ROUTES.themesCreate,
|
||||
postBody,
|
||||
() => i18n.t("settings.theme.error-creating-theme-see-log-file"),
|
||||
() => i18n.t("settings.theme.theme-saved")
|
||||
);
|
||||
},
|
||||
|
||||
update(data) {
|
||||
return apiReq.put(
|
||||
API_ROUTES.themesId(data.id),
|
||||
data,
|
||||
() => i18n.t("settings.theme.error-updating-theme"),
|
||||
() => i18n.t("settings.theme.theme-updated")
|
||||
);
|
||||
},
|
||||
|
||||
delete(id) {
|
||||
return apiReq.delete(
|
||||
API_ROUTES.themesId(id),
|
||||
null,
|
||||
() => i18n.t("settings.theme.error-deleting-theme"),
|
||||
() => i18n.t("settings.theme.theme-deleted")
|
||||
);
|
||||
},
|
||||
};
|
||||
14
frontend.old/src/api/upload.js
Normal file
14
frontend.old/src/api/upload.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from "@/i18n.js";
|
||||
|
||||
export const utilsAPI = {
|
||||
// import { api } from "@/api";
|
||||
uploadFile(url, fileObject) {
|
||||
return apiReq.post(
|
||||
url,
|
||||
fileObject,
|
||||
() => i18n.t("general.failure-uploading-file"),
|
||||
() => i18n.t("general.file-uploaded")
|
||||
);
|
||||
},
|
||||
};
|
||||
107
frontend.old/src/api/users.js
Normal file
107
frontend.old/src/api/users.js
Normal file
@@ -0,0 +1,107 @@
|
||||
import { API_ROUTES } from "./apiRoutes";
|
||||
import { apiReq } from "./api-utils";
|
||||
import i18n from "@/i18n.js";
|
||||
|
||||
export const userAPI = {
|
||||
async login(formData) {
|
||||
let response = await apiReq.post(API_ROUTES.authToken, formData, null, () => {
|
||||
return i18n.t("user.user-successfully-logged-in");
|
||||
});
|
||||
return response;
|
||||
},
|
||||
async refresh() {
|
||||
return apiReq.getSafe(API_ROUTES.authRefresh);
|
||||
},
|
||||
async allUsers() {
|
||||
let response = await apiReq.get(API_ROUTES.users);
|
||||
return response.data;
|
||||
},
|
||||
create(user) {
|
||||
return apiReq.post(
|
||||
API_ROUTES.users,
|
||||
user,
|
||||
() => i18n.t("user.user-creation-failed"),
|
||||
() => i18n.t("user.user-created")
|
||||
);
|
||||
},
|
||||
async self() {
|
||||
return apiReq.getSafe(API_ROUTES.usersSelf);
|
||||
},
|
||||
async byID(id) {
|
||||
let response = await apiReq.get(API_ROUTES.usersId(id));
|
||||
return response.data;
|
||||
},
|
||||
update(user) {
|
||||
return apiReq.put(
|
||||
API_ROUTES.usersId(user.id),
|
||||
user,
|
||||
() => i18n.t("user.user-update-failed"),
|
||||
() => i18n.t("user.user-updated")
|
||||
);
|
||||
},
|
||||
changePassword(id, password) {
|
||||
return apiReq.put(
|
||||
API_ROUTES.usersIdPassword(id),
|
||||
password,
|
||||
() => i18n.t("user.existing-password-does-not-match"),
|
||||
() => i18n.t("user.password-updated")
|
||||
);
|
||||
},
|
||||
|
||||
delete(id) {
|
||||
return apiReq.delete(API_ROUTES.usersId(id), null, deleteErrorText, () => {
|
||||
return i18n.t("user.user-deleted");
|
||||
});
|
||||
},
|
||||
resetPassword(id) {
|
||||
return apiReq.put(
|
||||
API_ROUTES.usersIdResetPassword(id),
|
||||
null,
|
||||
() => i18n.t("user.password-reset-failed"),
|
||||
() => i18n.t("user.password-has-been-reset-to-the-default-password")
|
||||
);
|
||||
},
|
||||
async createAPIToken(name) {
|
||||
const response = await apiReq.post(API_ROUTES.usersApiTokens, { name });
|
||||
return response.data;
|
||||
},
|
||||
async deleteAPIToken(id) {
|
||||
const response = await apiReq.delete(API_ROUTES.usersApiTokensTokenId(id));
|
||||
return response.data;
|
||||
},
|
||||
/** Adds a Recipe to the users favorites
|
||||
* @param id
|
||||
*/
|
||||
async getFavorites(id) {
|
||||
const response = await apiReq.get(API_ROUTES.usersIdFavorites(id));
|
||||
return response.data;
|
||||
},
|
||||
/** Adds a Recipe to the users favorites
|
||||
* @param id
|
||||
*/
|
||||
async addFavorite(id, slug) {
|
||||
const response = await apiReq.post(API_ROUTES.usersIdFavoritesSlug(id, slug));
|
||||
return response.data;
|
||||
},
|
||||
/** Adds a Recipe to the users favorites
|
||||
* @param id
|
||||
*/
|
||||
async removeFavorite(id, slug) {
|
||||
const response = await apiReq.delete(API_ROUTES.usersIdFavoritesSlug(id, slug));
|
||||
return response.data;
|
||||
},
|
||||
|
||||
userProfileImage(id) {
|
||||
if (!id || id === undefined) return;
|
||||
return `/api/users/${id}/image`;
|
||||
},
|
||||
};
|
||||
|
||||
const deleteErrorText = response => {
|
||||
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");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user