From d7bd68198e3b31d7507372c6b965065a0499ce9b Mon Sep 17 00:00:00 2001 From: Hayden Date: Sat, 9 Jan 2021 13:29:48 -0900 Subject: [PATCH 1/5] final changelog --- docs/docs/changelog.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/docs/changelog.md b/docs/docs/changelog.md index 61e4afb60c4d..267eae44a3bf 100644 --- a/docs/docs/changelog.md +++ b/docs/docs/changelog.md @@ -6,8 +6,8 @@ A quality update with major props to [zackbcom](https://github.com/zackbcom) for - Fixed empty backup failure without markdown template - Fixed opacity issues with marked steps - [mtoohey31](https://github.com/mtoohey31) - Fixed hot-reloading development environment - [grssmnn](https://github.com/grssmnn) - - Fixed recipe not saving without image - - Fixed parsing error on image property null + - Fixed recipe not saving without image - Issue #7 + Issue #54 + - Fixed parsing error on image property null - Issue #43 ### General Improvements - Added Confirmation component to deleting recipes - [zackbcom](https://github.com/zackbcom) @@ -20,7 +20,7 @@ A quality update with major props to [zackbcom](https://github.com/zackbcom) for - Users can now add custom json key/value pairs to all recipes via the editor for access in 3rd part applications. For example users can add a "message" field in the extras that can be accessed on API calls to play a message over google home. - Improved image rendering (nearly x2 speed) - Improved documentation + API Documentation - - Improved recipe parsing + - Improved recipe parsing - Issue #51 - User feedback on backup importing ## v0.0.1 - Pre-release Patch From cdad8b054ef815c51b346641a20c12439184293f Mon Sep 17 00:00:00 2001 From: Hayden Date: Sat, 9 Jan 2021 13:34:20 -0900 Subject: [PATCH 2/5] gif path --- docs/docs/api/api-usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/api/api-usage.md b/docs/docs/api/api-usage.md index 911e11347462..95f288f97bac 100644 --- a/docs/docs/api/api-usage.md +++ b/docs/docs/api/api-usage.md @@ -6,7 +6,7 @@ Recipes extras are a key feature of the Mealie API. They allow you to create cus For example you could add `{"message": "Remember to thaw the chicken"}` to a recipe and use the webhooks built into mealie to send that message payload to a destination to be processed. -![api-extras-gif](/gifs/api-extras.gif) +![api-extras-gif](../gifs/api-extras.gif) ## Examples From af87045037938f78f51d018f51f16adfbd9877a1 Mon Sep 17 00:00:00 2001 From: Hayden Date: Sat, 9 Jan 2021 18:04:53 -0900 Subject: [PATCH 3/5] nextcloud migration --- .gitignore | 2 + .vscode/settings.json | 1 + dev/non-working-links.txt | 1 + frontend/src/api/migration.js | 13 + .../Settings/Migration/ChowdownCard.vue | 73 +++++ .../Settings/Migration/NextcloudCard.vue | 69 +++++ .../components/Settings/Migration/index.vue | 66 ++--- mealie/app.py | 1 - mealie/data/debug/last_recipe.json | 127 +++++---- mealie/data/migration/.gitkeep | 0 mealie/routes/migration_routes.py | 25 +- mealie/scratch.py | 0 mealie/services/migrations/chowdown.py | 2 +- mealie/services/migrations/nextcloud.py | 89 ++++++ mealie/services/scrape_services.py | 43 ++- mealie/settings.py | 11 + .../Air Fryer Shrimp/recipe.json | 63 +++++ .../Air Fryer Shrimp/thumb.jpg | Bin 0 -> 5858 bytes .../Chicken Parmigiana/recipe.json | 259 ++++++++++++++++++ .../Chicken Parmigiana/thumb.jpg | Bin 0 -> 10533 bytes .../Skillet Shepherd's Pie/recipe.json | 89 ++++++ .../test/data/nextcloud_recipes/nextcloud.zip | Bin 0 -> 182110 bytes mealie/test/test_nextcloud.py | 43 +++ 23 files changed, 851 insertions(+), 126 deletions(-) create mode 100644 dev/non-working-links.txt create mode 100644 frontend/src/components/Settings/Migration/ChowdownCard.vue create mode 100644 frontend/src/components/Settings/Migration/NextcloudCard.vue create mode 100644 mealie/data/migration/.gitkeep create mode 100644 mealie/scratch.py create mode 100644 mealie/services/migrations/nextcloud.py create mode 100644 mealie/test/data/nextcloud_recipes/Air Fryer Shrimp/recipe.json create mode 100644 mealie/test/data/nextcloud_recipes/Air Fryer Shrimp/thumb.jpg create mode 100644 mealie/test/data/nextcloud_recipes/Chicken Parmigiana/recipe.json create mode 100644 mealie/test/data/nextcloud_recipes/Chicken Parmigiana/thumb.jpg create mode 100644 mealie/test/data/nextcloud_recipes/Skillet Shepherd's Pie/recipe.json create mode 100644 mealie/test/data/nextcloud_recipes/nextcloud.zip create mode 100644 mealie/test/test_nextcloud.py diff --git a/.gitignore b/.gitignore index 7230489b4556..4ec39805fc83 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ mealie/temp/api.html mealie/data/backups/* mealie/data/debug/* mealie/data/img/* +mealie/data/migration/* !mealie/dist/* #Exception to keep folders @@ -19,6 +20,7 @@ mealie/data/img/* !mealie/data/backups/.gitkeep !mealie/data/backups/dev_sample_data* !mealie/data/debug/.gitkeep +!mealie/data/migration/.gitkeep !mealie/data/img/.gitkeep .DS_Store diff --git a/.vscode/settings.json b/.vscode/settings.json index 9c2025d7034e..0445b096ab37 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,6 +11,7 @@ "python.discoverTest": true, "python.testing.pytestEnabled": true, "cSpell.enableFiletypes": [ + "!javascript", "!python" ], "python.testing.pytestArgs": [ diff --git a/dev/non-working-links.txt b/dev/non-working-links.txt new file mode 100644 index 000000000000..7de14cfcb732 --- /dev/null +++ b/dev/non-working-links.txt @@ -0,0 +1 @@ +http://www.cookingforkeeps.com/2013/02/05/blue-cheese-stuffed-turkey-meatballs-with-raspberry-balsamic-glaze-2/ \ No newline at end of file diff --git a/frontend/src/api/migration.js b/frontend/src/api/migration.js index 7b8ba1610803..ae2132f57a9f 100644 --- a/frontend/src/api/migration.js +++ b/frontend/src/api/migration.js @@ -6,6 +6,11 @@ const migrationBase = baseURL + "migration/"; const migrationURLs = { chowdownURL: migrationBase + "chowdown/repo/", + nextcloudAvaiable: migrationBase + "nextcloud/available/", + nextcloudImport: (selection) => + `${migrationBase}nextcloud/${selection}/import/`, + nextcloudDelete: (selection) => + `${migrationBase}nextcloud/${selection}/delete/`, }; export default { @@ -15,4 +20,12 @@ export default { store.dispatch("requestRecentRecipes"); return response.data; }, + async getNextcloudImports() { + let response = await apiReq.get(migrationURLs.nextcloudAvaiable); + return response.data; + }, + async importNextcloud(selected) { + let response = await apiReq.post(migrationURLs.nextcloudImport(selected)); + return response.data; + }, }; diff --git a/frontend/src/components/Settings/Migration/ChowdownCard.vue b/frontend/src/components/Settings/Migration/ChowdownCard.vue new file mode 100644 index 000000000000..716b398d06ae --- /dev/null +++ b/frontend/src/components/Settings/Migration/ChowdownCard.vue @@ -0,0 +1,73 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/Settings/Migration/NextcloudCard.vue b/frontend/src/components/Settings/Migration/NextcloudCard.vue new file mode 100644 index 000000000000..0e5980be7f74 --- /dev/null +++ b/frontend/src/components/Settings/Migration/NextcloudCard.vue @@ -0,0 +1,69 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/Settings/Migration/index.vue b/frontend/src/components/Settings/Migration/index.vue index 19fa41653614..1100bd4cfdae 100644 --- a/frontend/src/components/Settings/Migration/index.vue +++ b/frontend/src/components/Settings/Migration/index.vue @@ -2,64 +2,42 @@ Recipe Migration - -

- Currently Chowdown via public Repo URL is the only supported type of - migration -

- - - - - - - - Migrate - - - - -

Failed Recipes

- - - {{ fail }} - - -
- -

Failed Images

- - - {{ fail }} - - -
-
+ + + Chowdown + Nextcloud Recipes + + + + + + + +
+ diff --git a/frontend/src/components/Settings/Migration/UploadMigrationButton.vue b/frontend/src/components/Settings/Migration/UploadMigrationButton.vue new file mode 100644 index 000000000000..c9072cc2f57d --- /dev/null +++ b/frontend/src/components/Settings/Migration/UploadMigrationButton.vue @@ -0,0 +1,42 @@ + + + + + \ No newline at end of file diff --git a/mealie/routes/migration_routes.py b/mealie/routes/migration_routes.py index 350030d0e8c1..8a7430c6a2a6 100644 --- a/mealie/routes/migration_routes.py +++ b/mealie/routes/migration_routes.py @@ -1,4 +1,6 @@ -from fastapi import APIRouter, HTTPException +import shutil + +from fastapi import APIRouter, File, HTTPException, UploadFile from models.migration_models import ChowdownURL from services.migrations.chowdown import chowdown_migrate as chowdow_migrate from services.migrations.nextcloud import migrate as nextcloud_migrate @@ -46,3 +48,33 @@ async def import_nextcloud_directory(selection: str): """ Imports all the recipes in a given directory """ return nextcloud_migrate(selection) + + +@router.delete("/api/migration/{file_folder_name}/delete/", tags=["Migration"]) +async def delete_migration_data(file_folder_name: str): + """ Removes migration data from the file system """ + + remove_path = MIGRATION_DIR.joinpath(file_folder_name) + + if remove_path.is_file(): + remove_path.unlink() + elif remove_path.is_dir(): + shutil.rmtree(remove_path) + else: + SnackResponse.error("File/Folder not found.") + + return SnackResponse.info(f"Migration Data Remove: {remove_path.absolute()}") + + +@router.post("/api/migration/upload/", tags=["Migration"]) +async def upload_nextcloud_zipfile(archive: UploadFile = File(...)): + """ Upload a .zip File to later be imported into Mealie """ + dest = MIGRATION_DIR.joinpath(archive.filename) + + with dest.open("wb") as buffer: + shutil.copyfileobj(archive.file, buffer) + + if dest.is_file: + return SnackResponse.success("Migration data uploaded") + else: + return SnackResponse.error("Failure uploading file") From 51f3d702a21a9cf96887cc730c9d4bd59702d37f Mon Sep 17 00:00:00 2001 From: Hayden Date: Sat, 9 Jan 2021 19:45:08 -0900 Subject: [PATCH 5/5] switch icon on import --- .../Settings/Migration/UploadMigrationButton.vue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/src/components/Settings/Migration/UploadMigrationButton.vue b/frontend/src/components/Settings/Migration/UploadMigrationButton.vue index c9072cc2f57d..5b8193a13ba4 100644 --- a/frontend/src/components/Settings/Migration/UploadMigrationButton.vue +++ b/frontend/src/components/Settings/Migration/UploadMigrationButton.vue @@ -6,6 +6,8 @@ v-model="file" accept=".zip" @change="upload" + :prepend-icon="icon" + class="file-icon" > @@ -18,6 +20,7 @@ export default { return { file: null, loading: false, + icon: "mdi-paperclip", }; }, methods: { @@ -32,6 +35,7 @@ export default { this.loading = false; this.$emit("uploaded"); this.file = null; + this.icon = "mdi-check"; } }, }, @@ -39,4 +43,7 @@ export default { \ No newline at end of file