mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
api refactoring + random cleanup
This commit is contained in:
parent
c44edf97ae
commit
38e4afcc3c
11 changed files with 38 additions and 27 deletions
|
@ -1,10 +1,10 @@
|
||||||
import { baseURL } from "./api-utils";
|
import { baseURL } from "./api-utils";
|
||||||
import { apiReq } from "./api-utils";
|
import { apiReq } from "./api-utils";
|
||||||
|
|
||||||
const prefix = baseURL + "/recipes/categories";
|
const prefix = baseURL + "categories";
|
||||||
|
|
||||||
const categoryURLs = {
|
const categoryURLs = {
|
||||||
get_all: `${prefix}/all`,
|
get_all: `${prefix}`,
|
||||||
get_category: (category) => `${prefix}/${category}`,
|
get_category: (category) => `${prefix}/${category}`,
|
||||||
delete_category: (category) => `${prefix}/${category}`,
|
delete_category: (category) => `${prefix}/${category}`,
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,13 +2,13 @@ import { baseURL } from "./api-utils";
|
||||||
import { apiReq } from "./api-utils";
|
import { apiReq } from "./api-utils";
|
||||||
import { store } from "../store/store";
|
import { store } from "../store/store";
|
||||||
|
|
||||||
const migrationBase = baseURL + "migrations/";
|
const migrationBase = baseURL + "migrations";
|
||||||
|
|
||||||
const migrationURLs = {
|
const migrationURLs = {
|
||||||
// New
|
// New
|
||||||
all: migrationBase,
|
all: migrationBase,
|
||||||
delete: (folder, file) => `${migrationBase}/${folder}/${file}/delete/`,
|
delete: (folder, file) => `${migrationBase}/${folder}/${file}/delete`,
|
||||||
import: (folder, file) => `${migrationBase}/${folder}/${file}/import/`,
|
import: (folder, file) => `${migrationBase}/${folder}/${file}/import`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { baseURL } from "./api-utils";
|
import { baseURL } from "./api-utils";
|
||||||
import { apiReq } from "./api-utils";
|
import { apiReq } from "./api-utils";
|
||||||
|
|
||||||
const settingsBase = baseURL + "site-settings/";
|
const settingsBase = baseURL + "site-settings";
|
||||||
|
|
||||||
const settingsURLs = {
|
const settingsURLs = {
|
||||||
siteSettings: `${settingsBase}`,
|
siteSettings: `${settingsBase}`,
|
||||||
updateSiteSettings: `${settingsBase}`,
|
updateSiteSettings: `${settingsBase}`,
|
||||||
testWebhooks: `${settingsBase}webhooks/test`,
|
testWebhooks: `${settingsBase}/webhooks/test`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
class="my-3"
|
class="my-3"
|
||||||
:label="$t('recipe.recipe-name')"
|
:label="$t('recipe.recipe-name')"
|
||||||
v-model="value.name"
|
v-model="value.name"
|
||||||
:rules="[rules.required, rules.whiteSpace]"
|
:rules="[rules.required]"
|
||||||
>
|
>
|
||||||
</v-text-field>
|
</v-text-field>
|
||||||
<v-textarea
|
<v-textarea
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
dense
|
dense
|
||||||
>
|
>
|
||||||
<v-icon
|
<v-icon
|
||||||
class="mr-n1"
|
class="mr-n1"
|
||||||
slot="prepend"
|
slot="prepend"
|
||||||
color="error"
|
color="error"
|
||||||
@click="removeIngredient(index)"
|
@click="removeIngredient(index)"
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
|
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-btn color="accent" text :href="`/api/backups/${name}/download/`">
|
<v-btn color="accent" text :href="`/api/backups/${name}/download`">
|
||||||
{{ $t("general.download") }}
|
{{ $t("general.download") }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
<v-row dense>
|
<v-row dense>
|
||||||
<v-col
|
<v-col
|
||||||
:sm="6"
|
:sm="12"
|
||||||
:md="6"
|
:md="6"
|
||||||
:lg="4"
|
:lg="4"
|
||||||
:xl="3"
|
:xl="3"
|
||||||
|
@ -78,7 +78,7 @@ export default {
|
||||||
},
|
},
|
||||||
async getAvailableMigrations() {
|
async getAvailableMigrations() {
|
||||||
let response = await api.migrations.getMigrations();
|
let response = await api.migrations.getMigrations();
|
||||||
response.forEach(element => {
|
response.forEach((element) => {
|
||||||
if (element.type === "nextcloud") {
|
if (element.type === "nextcloud") {
|
||||||
this.migrations.nextcloud.availableImports = element.files;
|
this.migrations.nextcloud.availableImports = element.files;
|
||||||
} else if (element.type === "chowdown") {
|
} else if (element.type === "chowdown") {
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"total-time": "Total Time",
|
"total-time": "Total Time",
|
||||||
"prep-time": "Prep Time",
|
"prep-time": "Prep Time",
|
||||||
"perform-time": "Cook Time / Perform Time",
|
"perform-time": "Cook Time",
|
||||||
"api-extras": "API Extras",
|
"api-extras": "API Extras",
|
||||||
"object-key": "Object Key",
|
"object-key": "Object Key",
|
||||||
"object-value": "Object Value",
|
"object-value": "Object Value",
|
||||||
|
|
|
@ -23,7 +23,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
title: null,
|
title: "",
|
||||||
recipes: [],
|
recipes: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -143,19 +143,30 @@ export default {
|
||||||
deleteRecipe() {
|
deleteRecipe() {
|
||||||
api.recipes.delete(this.recipeDetails.slug);
|
api.recipes.delete(this.recipeDetails.slug);
|
||||||
},
|
},
|
||||||
|
validateRecipe() {
|
||||||
|
if (this.jsonEditor) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return this.$refs.recipeEditor.validateRecipe();
|
||||||
|
}
|
||||||
|
},
|
||||||
async saveRecipe() {
|
async saveRecipe() {
|
||||||
if (this.$refs.recipeEditor.validateRecipe()) {
|
if (this.validateRecipe()) {
|
||||||
console.log("Thank you");
|
let slug = await api.recipes.update(this.recipeDetails);
|
||||||
}
|
|
||||||
let slug = await api.recipes.update(this.recipeDetails);
|
|
||||||
|
|
||||||
if (this.fileObject) {
|
if (this.fileObject) {
|
||||||
await api.recipes.updateImage(this.recipeDetails.slug, this.fileObject);
|
await api.recipes.updateImage(
|
||||||
}
|
this.recipeDetails.slug,
|
||||||
|
this.fileObject
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
this.form = false;
|
this.form = false;
|
||||||
this.imageKey += 1;
|
this.imageKey += 1;
|
||||||
this.$router.push(`/recipe/${slug}`);
|
if (slug != this.recipeDetails.slug) {
|
||||||
|
this.$router.push(`/recipe/${slug}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
showForm() {
|
showForm() {
|
||||||
this.form = true;
|
this.form = true;
|
||||||
|
|
|
@ -43,7 +43,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
searchResults: null,
|
searchResults: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -43,7 +43,7 @@ const monthsShort = [
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getImageURL(image) {
|
getImageURL(image) {
|
||||||
return `/api/recipe/image/${image}/`;
|
return `/api/recipes/${image}/image`;
|
||||||
},
|
},
|
||||||
generateUniqueKey(item, index) {
|
generateUniqueKey(item, index) {
|
||||||
const uniqueKey = `${item}-${index}`;
|
const uniqueKey = `${item}-${index}`;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue