From 8e4b951ecce4ea9049a975300475d73ae98fa12b Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Thu, 22 Apr 2021 22:13:55 -0800 Subject: [PATCH] Get Recipes Route Rewrite (#339) * deprecate old route * auto-gen * recipe card infinite scroll * fix datatable * set hard-limit option * add loader * set scroll on navigation * add auto-import * fix slow initial load * remove console.logs Co-authored-by: hay-kot --- docs/docs/overrides/api.html | 2 +- frontend/src/api/recipe.js | 19 ++-------- .../components/ImportSummaryDialog/index.vue | 2 +- .../src/components/MealPlan/MealPlanNew.vue | 14 +++---- .../src/components/Recipe/EditorButtonRow.vue | 2 +- .../src/components/Recipe/RecipeTimeCard.vue | 5 --- frontend/src/components/UI/CardSection.vue | 38 +++++++++++++++++-- .../src/components/UI/Search/SearchBar.vue | 6 ++- .../src/pages/Admin/MealPlanner/index.vue | 1 - .../pages/Admin/Migration/MigrationDialog.vue | 2 +- .../pages/Admin/Settings/HomePageSettings.vue | 3 +- frontend/src/pages/HomePage.vue | 4 +- frontend/src/pages/Recipes/AllRecipes.vue | 4 +- frontend/src/pages/SearchPage/index.vue | 11 +++++- frontend/src/routes/index.js | 3 ++ frontend/src/store/index.js | 22 +++++------ mealie/db/db_base.py | 6 ++- mealie/routes/recipe/all_recipe_routes.py | 22 ++++++++--- template.env | 35 ++++++++++++++--- 19 files changed, 128 insertions(+), 73 deletions(-) diff --git a/docs/docs/overrides/api.html b/docs/docs/overrides/api.html index 8d1f2e77add8..62decc3f868f 100644 --- a/docs/docs/overrides/api.html +++ b/docs/docs/overrides/api.html @@ -14,7 +14,7 @@
diff --git a/frontend/src/api/recipe.js b/frontend/src/api/recipe.js index 42d5c47eb889..c86e5b4cf42c 100644 --- a/frontend/src/api/recipe.js +++ b/frontend/src/api/recipe.js @@ -2,7 +2,6 @@ import { baseURL } from "./api-utils"; import { apiReq } from "./api-utils"; import { store } from "../store"; import { router } from "../main"; -import qs from "qs"; const prefix = baseURL + "recipes/"; @@ -78,22 +77,10 @@ export const recipeAPI = { router.push(`/`); }, - async allByKeys(recipeKeys, num = 9999) { - const response = await apiReq.get(recipeURLs.allRecipes, { - params: { - keys: recipeKeys, - num: num, - }, - paramsSerializer: params => { - return qs.stringify(params, { arrayFormat: "repeat" }); - }, + async allSummary(start = 0, limit = 9999) { + const response = await apiReq.get(recipeURLs.summary, { + params: { start: start, limit: limit }, }); - - return response.data; - }, - - async allSummary() { - const response = await apiReq.get(recipeURLs.summary); return response.data; }, diff --git a/frontend/src/components/ImportSummaryDialog/index.vue b/frontend/src/components/ImportSummaryDialog/index.vue index c41aa912e4d9..5088e1491950 100644 --- a/frontend/src/components/ImportSummaryDialog/index.vue +++ b/frontend/src/components/ImportSummaryDialog/index.vue @@ -45,7 +45,7 @@ diff --git a/frontend/src/components/UI/Search/SearchBar.vue b/frontend/src/components/UI/Search/SearchBar.vue index a2e055d2a386..776a913bd743 100644 --- a/frontend/src/components/UI/Search/SearchBar.vue +++ b/frontend/src/components/UI/Search/SearchBar.vue @@ -89,7 +89,6 @@ export default { searchSlug: "", search: "", menuModel: false, - data: [], result: [], fuseResults: [], isDark: false, @@ -107,9 +106,12 @@ export default { }, mounted() { this.isDark = this.$store.getters.getIsDark; - this.data = this.$store.getters.getRecentRecipes; + this.$store.dispatch("requestAllRecipes"); }, computed: { + data() { + return this.$store.getters.getRecentRecipes; + }, autoResults() { return this.fuseResults.length > 1 ? this.fuseResults : this.results; }, diff --git a/frontend/src/pages/Admin/MealPlanner/index.vue b/frontend/src/pages/Admin/MealPlanner/index.vue index 2f13cfb7d791..3e03abdffd15 100644 --- a/frontend/src/pages/Admin/MealPlanner/index.vue +++ b/frontend/src/pages/Admin/MealPlanner/index.vue @@ -135,7 +135,6 @@ export default { this.groupSettings.webhookUrls.splice(index, 1); }, async saveGroupSettings() { - console.log(this.groupSettings); await api.groups.update(this.groupSettings); await this.$store.dispatch("requestCurrentGroup"); this.getSiteSettings(); diff --git a/frontend/src/pages/Admin/Migration/MigrationDialog.vue b/frontend/src/pages/Admin/Migration/MigrationDialog.vue index 485f2baf746e..478a92ac99c1 100644 --- a/frontend/src/pages/Admin/Migration/MigrationDialog.vue +++ b/frontend/src/pages/Admin/Migration/MigrationDialog.vue @@ -42,7 +42,7 @@