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 { apiReq } from "./api-utils";
const prefix = baseURL + "/recipes/categories";
const prefix = baseURL + "categories";
const categoryURLs = {
get_all: `${prefix}/all`,
get_all: `${prefix}`,
get_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 { store } from "../store/store";
const migrationBase = baseURL + "migrations/";
const migrationBase = baseURL + "migrations";
const migrationURLs = {
// New
all: migrationBase,
delete: (folder, file) => `${migrationBase}/${folder}/${file}/delete/`,
import: (folder, file) => `${migrationBase}/${folder}/${file}/import/`,
delete: (folder, file) => `${migrationBase}/${folder}/${file}/delete`,
import: (folder, file) => `${migrationBase}/${folder}/${file}/import`,
};
export default {

View file

@ -1,12 +1,12 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
const settingsBase = baseURL + "site-settings/";
const settingsBase = baseURL + "site-settings";
const settingsURLs = {
siteSettings: `${settingsBase}`,
updateSiteSettings: `${settingsBase}`,
testWebhooks: `${settingsBase}webhooks/test`,
testWebhooks: `${settingsBase}/webhooks/test`,
};
export default {

View file

@ -37,7 +37,7 @@
class="my-3"
:label="$t('recipe.recipe-name')"
v-model="value.name"
:rules="[rules.required, rules.whiteSpace]"
:rules="[rules.required]"
>
</v-text-field>
<v-textarea
@ -91,7 +91,7 @@
dense
>
<v-icon
class="mr-n1"
class="mr-n1"
slot="prepend"
color="error"
@click="removeIngredient(index)"

View file

@ -65,7 +65,7 @@
<v-divider></v-divider>
<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") }}
</v-btn>
<v-spacer></v-spacer>

View file

@ -17,7 +17,7 @@
<v-row dense>
<v-col
:sm="6"
:sm="12"
:md="6"
:lg="4"
:xl="3"
@ -78,7 +78,7 @@ export default {
},
async getAvailableMigrations() {
let response = await api.migrations.getMigrations();
response.forEach(element => {
response.forEach((element) => {
if (element.type === "nextcloud") {
this.migrations.nextcloud.availableImports = element.files;
} else if (element.type === "chowdown") {

View file

@ -70,7 +70,7 @@
"title": "Title",
"total-time": "Total Time",
"prep-time": "Prep Time",
"perform-time": "Cook Time / Perform Time",
"perform-time": "Cook Time",
"api-extras": "API Extras",
"object-key": "Object Key",
"object-value": "Object Value",
@ -155,4 +155,4 @@
"description": "Migrate data from Chowdown"
}
}
}
}

View file

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

View file

@ -143,19 +143,30 @@ export default {
deleteRecipe() {
api.recipes.delete(this.recipeDetails.slug);
},
validateRecipe() {
if (this.jsonEditor) {
return true;
} else {
return this.$refs.recipeEditor.validateRecipe();
}
},
async saveRecipe() {
if (this.$refs.recipeEditor.validateRecipe()) {
console.log("Thank you");
}
let slug = await api.recipes.update(this.recipeDetails);
if (this.validateRecipe()) {
let slug = await api.recipes.update(this.recipeDetails);
if (this.fileObject) {
await api.recipes.updateImage(this.recipeDetails.slug, this.fileObject);
}
if (this.fileObject) {
await api.recipes.updateImage(
this.recipeDetails.slug,
this.fileObject
);
}
this.form = false;
this.imageKey += 1;
this.$router.push(`/recipe/${slug}`);
this.form = false;
this.imageKey += 1;
if (slug != this.recipeDetails.slug) {
this.$router.push(`/recipe/${slug}`);
}
}
},
showForm() {
this.form = true;

View file

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

View file

@ -43,7 +43,7 @@ const monthsShort = [
export default {
getImageURL(image) {
return `/api/recipe/image/${image}/`;
return `/api/recipes/${image}/image`;
},
generateUniqueKey(item, index) {
const uniqueKey = `${item}-${index}`;