From 2a158ab290c99f3737044918c13f90bb926cb32b Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 10 Apr 2021 21:42:04 -0800 Subject: [PATCH] feature/debug-info (#286) * rename 'ENV' to 'PRODUCTION' and default to true * set env PRODUCTION * refactor file download process * add last_recipe.json and log downloads * changelog + version bump * set env on workflows * bump version Co-authored-by: hay-kot --- .github/workflows/pytest.yml | 2 + Dockerfile | 3 +- Dockerfile.dev | 2 + docs/docs/changelog/v0.4.2.md | 23 +++++++++ docs/docs/overrides/api.html | 2 +- docs/mkdocs.yml | 1 + frontend/src/api/api-utils.js | 11 +++- frontend/src/api/backup.js | 14 ++--- .../components/Admin/Backup/ImportDialog.vue | 36 ++++--------- frontend/src/components/UI/TheDownloadBtn.vue | 51 +++++++++++++++++++ frontend/src/pages/Admin/About/index.vue | 13 +++++ mealie/app.py | 4 +- mealie/core/config.py | 9 ++-- mealie/core/security.py | 8 ++- mealie/routes/backup_routes.py | 11 ++-- mealie/routes/debug_routes.py | 13 +++-- mealie/routes/deps.py | 21 ++++++++ mealie/routes/utility_routes.py | 20 ++++++++ 18 files changed, 191 insertions(+), 53 deletions(-) create mode 100644 docs/docs/changelog/v0.4.2.md create mode 100644 frontend/src/components/UI/TheDownloadBtn.vue create mode 100644 mealie/routes/utility_routes.py diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 5df2230caf53..dc6f341fc6d9 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -11,6 +11,8 @@ on: jobs: tests: + env: + PRODUCTION: false runs-on: ubuntu-latest steps: #---------------------------------------------- diff --git a/Dockerfile b/Dockerfile index 53025eccd0de..e1321727d013 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,7 @@ RUN apk add --no-cache libxml2-dev \ zlib-dev -ENV ENV True +ENV PRODUCTION true EXPOSE 80 WORKDIR /app/ @@ -48,6 +48,7 @@ COPY ./dev/data/templates /app/data/templates COPY --from=build-stage /app/dist /app/dist VOLUME [ "/app/data/" ] + RUN chmod +x /app/mealie/run.sh CMD /app/mealie/run.sh diff --git a/Dockerfile.dev b/Dockerfile.dev index bce6c5ea0cfc..2c5519117dae 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -2,6 +2,8 @@ FROM python:3 WORKDIR /app/ +ENV PRODUCTION false + RUN apt-get update -y && \ apt-get install -y python-pip python-dev diff --git a/docs/docs/changelog/v0.4.2.md b/docs/docs/changelog/v0.4.2.md new file mode 100644 index 000000000000..fc7a61ad9d52 --- /dev/null +++ b/docs/docs/changelog/v0.4.2.md @@ -0,0 +1,23 @@ +# v0.4.2 + +**App Version: v0.4.2** + +**Database Version: v0.4.0** + +!!! error "Breaking Changes" + 1. With a recent refactor some users been experiencing issues with an environmental variable not being set correct. If you are experiencing issues, please provide your comments [Here](https://github.com/hay-kot/mealie/issues/281). + + 2. If you are a developer, you may experience issues with development as a new environmental variable has been introduced. Setting `PRODUCTION=false` will allow you to develop as normal. + +- Improved Nextcloud Migration. Mealie will now walk the directories in a zip file looking for directories that match the pattern of a Nextcloud Recipe. Closes #254 + - Rewrite Keywords to Tag Fields + - Rewrite url to orgURL +- Improved Chowdown Migration +- Migration report is now similar to the Backup report +- Tags/Categories are now title cased on import "dinner" -> "Dinner" +- Fixed Initialization script (v0.4.1a Hot Fix) Closes #274 +- Depreciate `ENV` variable to `PRODUCTION` +- Set `PRODUCTION` env variable to default to true +- Unify Logger across the backend +- mealie.log and last_recipe.json are now downloadable from the frontend from the /admin/about +- New download schema where you request a token and then use that token to hit a single endpoint to download a file. This is a notable change if you are using the API to download backups. \ No newline at end of file diff --git a/docs/docs/overrides/api.html b/docs/docs/overrides/api.html index 3d542032d4e5..b3dc7a1e3618 100644 --- a/docs/docs/overrides/api.html +++ b/docs/docs/overrides/api.html @@ -14,7 +14,7 @@
diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index ab46a17c748e..2b1560f6cb47 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -77,6 +77,7 @@ nav: - Guidelines: "contributors/developers-guide/general-guidelines.md" - Development Road Map: "roadmap.md" - Change Log: + - v0.4.2 Backend/Migrations: "changelog/v0.4.2.md" - v0.4.1 Frontend/UI: "changelog/v0.4.1.md" - v0.4.0 Authentication: "changelog/v0.4.0.md" - v0.3.0 Improvements: "changelog/v0.3.0.md" diff --git a/frontend/src/api/api-utils.js b/frontend/src/api/api-utils.js index 8c4b0e71d132..853d5ac9fa72 100644 --- a/frontend/src/api/api-utils.js +++ b/frontend/src/api/api-utils.js @@ -61,9 +61,16 @@ const apiReq = { processResponse(response); return response; }, + + async download(url) { + const response = await this.get(url); + const token = response.data.fileToken; + + const tokenURL = baseURL + "utils/download?token=" + token; + window.open(tokenURL, "_blank"); + return response.data; + }, }; - - export { apiReq }; export { baseURL }; diff --git a/frontend/src/api/backup.js b/frontend/src/api/backup.js index 3ec9a1285e53..b6afd6e98bb2 100644 --- a/frontend/src/api/backup.js +++ b/frontend/src/api/backup.js @@ -4,7 +4,7 @@ import { store } from "@/store"; const backupBase = baseURL + "backups/"; -const backupURLs = { +export const backupURLs = { // Backup available: `${backupBase}available`, createBackup: `${backupBase}export/database`, @@ -13,6 +13,8 @@ const backupURLs = { downloadBackup: fileName => `${backupBase}${fileName}/download`, }; + + export const backupAPI = { /** * Request all backups available on the server @@ -43,19 +45,19 @@ export const backupAPI = { /** * Creates a backup on the serve given a set of options * @param {object} data - * @returns + * @returns */ async create(options) { let response = apiReq.post(backupURLs.createBackup, options); return response; }, /** - * Downloads a file from the server. I don't actually think this is used? - * @param {string} fileName + * Downloads a file from the server. I don't actually think this is used? + * @param {string} fileName * @returns Download URL */ async download(fileName) { - let response = await apiReq.get(backupURLs.downloadBackup(fileName)); - return response.data; + const url = backupURLs.downloadBackup(fileName); + apiReq.download(url); }, }; diff --git a/frontend/src/components/Admin/Backup/ImportDialog.vue b/frontend/src/components/Admin/Backup/ImportDialog.vue index 0d54aeaa5b6e..b379dd9827ce 100644 --- a/frontend/src/components/Admin/Backup/ImportDialog.vue +++ b/frontend/src/components/Admin/Backup/ImportDialog.vue @@ -37,14 +37,7 @@ - - {{ $t("general.download") }} - + {{ $t("general.delete") }} @@ -66,9 +59,10 @@ diff --git a/frontend/src/components/UI/TheDownloadBtn.vue b/frontend/src/components/UI/TheDownloadBtn.vue new file mode 100644 index 000000000000..bc13898d6d18 --- /dev/null +++ b/frontend/src/components/UI/TheDownloadBtn.vue @@ -0,0 +1,51 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/pages/Admin/About/index.vue b/frontend/src/pages/Admin/About/index.vue index 453520b1a866..a8abc0a1e23f 100644 --- a/frontend/src/pages/Admin/About/index.vue +++ b/frontend/src/pages/Admin/About/index.vue @@ -20,6 +20,17 @@ + + + + + @@ -27,7 +38,9 @@