api refactoring + random cleanup

This commit is contained in:
hayden 2021-02-03 19:07:19 -09:00
commit 38e4afcc3c
11 changed files with 38 additions and 27 deletions

View file

@ -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}`,
}; };

View file

@ -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 {

View file

@ -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 {

View file

@ -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

View file

@ -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>

View file

@ -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") {

View file

@ -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",

View file

@ -23,7 +23,7 @@ export default {
}, },
data() { data() {
return { return {
title: null, title: "",
recipes: [], recipes: [],
}; };
}, },

View file

@ -143,19 +143,30 @@ export default {
deleteRecipe() { deleteRecipe() {
api.recipes.delete(this.recipeDetails.slug); api.recipes.delete(this.recipeDetails.slug);
}, },
async saveRecipe() { validateRecipe() {
if (this.$refs.recipeEditor.validateRecipe()) { if (this.jsonEditor) {
console.log("Thank you"); return true;
} else {
return this.$refs.recipeEditor.validateRecipe();
} }
},
async saveRecipe() {
if (this.validateRecipe()) {
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;
if (slug != this.recipeDetails.slug) {
this.$router.push(`/recipe/${slug}`); this.$router.push(`/recipe/${slug}`);
}
}
}, },
showForm() { showForm() {
this.form = true; this.form = true;

View file

@ -43,7 +43,7 @@ export default {
}, },
data() { data() {
return { return {
searchResults: null, searchResults: [],
}; };
}, },
methods: { methods: {

View file

@ -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}`;