From c32d7d7486b68684434c1f58151ab380bf330ae9 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 4 Dec 2021 14:18:46 -0900 Subject: [PATCH] =?UTF-8?q?=20feat:=20=E2=9C=A8=20add=20user=20recipe=20ex?= =?UTF-8?q?port=20functionality=20(#845)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(frontend): :sparkles: add user recipe export functionality * remove depreciated folders * change/remove depreciated folders * add testing variable in config * add GUID support for group_id * improve testing feedback on 422 errors * remove/cleanup files/folders * initial user export support * delete unused css * update backup page UI * remove depreciated settings * feat: :sparkles: export download links * fix #813 * remove top level statements * show footer * add export purger to scheduler * update purge glob * fix meal-planner lockout * feat: :sparkles: add bulk delete/purge exports * style(frontend): :lipstick: update UI for site settings * feat: :sparkles: add version checker * update documentation Co-authored-by: hay-kot --- .gitignore | 1 + dev/data/debug/.gitkeep | 0 dev/data/migration/.gitkeep | 0 .../installation/installation-checklist.md | 40 +- docs/docs/overrides/api.html | 2 +- frontend/api/admin/admin-about.ts | 2 + .../class-interfaces/recipe-bulk-actions.ts | 19 + .../Domain/Admin/AdminBackupImportOptions.vue | 24 +- .../Domain/Group/GroupExportData.vue | 60 +++ .../Domain/Recipe/RecipeDataTable.vue | 14 + .../global/BaseCardSectionTitle.vue | 15 +- frontend/pages/admin/backups.vue | 132 +++--- frontend/pages/admin/site-settings.vue | 142 ++++--- frontend/pages/meal-plan/planner.vue | 4 - frontend/pages/user/group/data/recipes.vue | 392 ++++++++++++++++++ .../pages/user/group/recipe-data/index.vue | 274 ------------ frontend/pages/user/profile/index.vue | 2 +- frontend/utils/icons/icons.ts | 2 + mealie/app.py | 1 + mealie/core/release_checker.py | 41 ++ mealie/core/settings/directories.py | 37 +- mealie/core/settings/settings.py | 5 + .../data_access_layer/access_model_factory.py | 9 +- .../db/data_access_layer/meal_access_model.py | 5 +- .../data_access_layer/recipe_access_model.py | 17 +- mealie/db/models/_model_utils/__init__.py | 1 + mealie/db/models/group/__init__.py | 1 + mealie/db/models/group/cookbook.py | 4 +- mealie/db/models/group/exports.py | 24 ++ mealie/db/models/group/group.py | 21 +- mealie/db/models/group/invite_tokens.py | 4 +- mealie/db/models/group/mealplan.py | 4 +- mealie/db/models/group/preferences.py | 4 +- mealie/db/models/group/report.py | 10 +- mealie/db/models/group/shopping_list.py | 3 +- mealie/db/models/group/webhooks.py | 7 +- mealie/db/models/recipe/category.py | 6 +- mealie/db/models/recipe/comment.py | 2 +- mealie/db/models/recipe/ingredient.py | 2 +- mealie/db/models/recipe/instruction.py | 4 +- mealie/db/models/recipe/recipe.py | 6 +- mealie/db/models/server/task.py | 5 +- mealie/db/models/users/users.py | 30 +- mealie/routes/admin/admin_about.py | 3 + mealie/routes/admin/admin_group.py | 70 ---- mealie/routes/handlers.py | 2 +- mealie/routes/recipe/__init__.py | 1 + mealie/routes/recipe/bulk_actions.py | 34 +- mealie/routes/recipe/recipe_crud_routes.py | 9 +- mealie/schema/admin/about.py | 1 + mealie/schema/cookbook/cookbook.py | 8 +- mealie/schema/group/group.py | 3 +- mealie/schema/group/group_exports.py | 17 + mealie/schema/group/group_preferences.py | 4 +- mealie/schema/group/invite_token.py | 6 +- mealie/schema/group/webhook.py | 4 +- mealie/schema/meal_plan/new_meal.py | 5 +- mealie/schema/recipe/recipe.py | 15 +- mealie/schema/reports/reports.py | 2 +- mealie/schema/server/tasks.py | 3 +- mealie/schema/user/user.py | 31 +- mealie/services/admin/admin_group_service.py | 15 +- mealie/services/exporter/__init__.py | 2 + mealie/services/exporter/_abc_exporter.py | 91 ++++ mealie/services/exporter/exporter.py | 51 +++ mealie/services/exporter/recipe_exporter.py | 41 ++ mealie/services/group_services/group_utils.py | 5 +- mealie/services/image/minify.py | 3 + mealie/services/migrations/_migration_base.py | 3 +- mealie/services/migrations/chowdown.py | 3 +- mealie/services/migrations/nextcloud.py | 3 +- mealie/services/recipe/recipe_bulk_service.py | 34 +- mealie/services/recipe/recipe_service.py | 10 +- .../services/scheduler/scheduler_service.py | 2 +- mealie/services/scheduler/tasks/__init__.py | 1 + .../scheduler/tasks/purge_group_exports.py | 46 ++ .../user_services/registration_service.py | 4 +- tests/fixtures/fixture_admin.py | 2 +- tests/fixtures/fixture_users.py | 4 +- .../admin_tests/test_group_admin_actions.py | 10 +- .../user_group_tests/test_group_cookbooks.py | 47 ++- .../user_recipe_tests/test_recipe_owner.py | 15 +- tests/pre_test.py | 1 + tests/utils/fixture_schemas.py | 7 +- 84 files changed, 1329 insertions(+), 667 deletions(-) delete mode 100644 dev/data/debug/.gitkeep delete mode 100644 dev/data/migration/.gitkeep create mode 100644 frontend/components/Domain/Group/GroupExportData.vue create mode 100644 frontend/pages/user/group/data/recipes.vue delete mode 100644 frontend/pages/user/group/recipe-data/index.vue create mode 100644 mealie/core/release_checker.py create mode 100644 mealie/db/models/group/exports.py delete mode 100644 mealie/routes/admin/admin_group.py create mode 100644 mealie/schema/group/group_exports.py create mode 100644 mealie/services/exporter/__init__.py create mode 100644 mealie/services/exporter/_abc_exporter.py create mode 100644 mealie/services/exporter/exporter.py create mode 100644 mealie/services/exporter/recipe_exporter.py create mode 100644 mealie/services/scheduler/tasks/purge_group_exports.py diff --git a/.gitignore b/.gitignore index 89c39468177a..d5cad462052e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ dev/data/debug/* dev/data/img/* dev/data/migration/* dev/data/users/* +dev/data/groups/* .DS_Store node_modules diff --git a/dev/data/debug/.gitkeep b/dev/data/debug/.gitkeep deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/dev/data/migration/.gitkeep b/dev/data/migration/.gitkeep deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/docs/docs/documentation/getting-started/installation/installation-checklist.md b/docs/docs/documentation/getting-started/installation/installation-checklist.md index cc1f5b0e8f12..7b56a8c94c76 100644 --- a/docs/docs/documentation/getting-started/installation/installation-checklist.md +++ b/docs/docs/documentation/getting-started/installation/installation-checklist.md @@ -2,35 +2,59 @@ To install Mealie on your server there are a few steps for proper configuration. Let's go through them. +!!! tip TLDR + Don't need step by step? Checkout the + + - [SQLite docker-compose](./sqlite.md) + - [Postgres docker-compose](./postgres.md) + ## Pre-work To deploy mealie on your local network it is highly recommended to use docker to deploy the image straight from dockerhub. Using the docker-compose templates provided, you should be able to get a stack up and running easily by changing a few default values and deploying. You can deploy with either SQLite (default) or Postgres. SQLite is sufficient for most use cases. Additionally, with Mealie's automated backup and restore functionality, you can easily move between SQLite and Postgres as you wish. [Get Docker](https://docs.docker.com/get-docker/) +[Get Docker Compose](https://docs.docker.com/compose/install/) + [Mealie on Dockerhub](https://hub.docker.com/r/hkotel/mealie) - linux/amd64 - linux/arm64 +!!! warning "32bit Support" + Due to a build dependency limitation, Mealie is not supported on 32bit ARM systems. If you're running into this limitation on a newer Raspberry Pi, please consider upgrading to a 64bit operating system on the Raspberry Pi. + + ## Step 1: Deciding on Deployment Type -SQLite is a popular, open source, self-contained, zero-configuration database that is the ideal choice for Mealie when you have 1-20 Users. If you need to support many concurrent users, you may want to consider a more robust database such as PostgreSQL. +SQLite is a popular, open source, self-contained, zero-configuration database that is the ideal choice for Mealie when you have 1-20 Users and your concurrent write operations will be some-what limited. If you need to support many concurrent users, you may want to consider a more robust database such as PostgreSQL. You can find the relevant ready to use docker-compose files for supported installations at the links below. -- [SQLite](/mealie/documentation/getting-started/installation/sqlite/) -- [PostgreSQL](/mealie/documentation/getting-started/installation/postgres/) +- [SQLite](./sqlite.md) +- [PostgreSQL](./postgres.md) + +## Step 2: Setting up your files. + +The following steps were tested on a Ubuntu 20.04 server, but should work for most other Linux distributions. These steps are not required, but is how I generally will setup services on my server. + + +1. SSH into your server and navigate to the home directory of the user you want to run Mealie as. If that is your current user, you can use `cd ~` to ensure you're in the right directory. +2. Create a directory called `docker` and navigate into it. `mkdir docker && cd docker` +3. Do the same for mealie `mkdir mealie && cd mealie` +4. Create a docker-compose.yaml file in the mealie directory. `touch docker-compose.yaml` +5. Use the text editor or your choice to edit the file and copy the contents of the docker-compose template for the deployment type you want to use. `nano docker-compose.yaml` or `vi docker-compose.yaml` + ## Step 2: Customizing The `docker-compose.yaml` files. -After you've decided on a database it's important to set a few ENV variables to ensure that you can use all the features of Mealie. I recommend that you verify and check that: +After you've decided setup the files it's important to set a few ENV variables to ensure that you can use all the features of Mealie. I recommend that you verify and check that: - [x] You've configured the relevant ENV variables for your database selection in the `docker-compose.yaml` files. -- [x] You've configured the [SMTP server settings](/mealie/documentation/getting-started/installation/backend-config/#email) (used for invitations, password resets, etc) +- [x] You've configured the [SMTP server settings](./backend-config.md#email) (used for invitations, password resets, etc) - [x] Verified the port mapped on the `mealie-frontend` container is an open port on your server (Default: 9925) -- [x] You've set the [`BASE_URL`](/mealie/documentation/getting-started/installation/backend-config/#general) variable. +- [x] You've set the [`BASE_URL`](./backend-config.md#general) variable. - [x] You've set the `DEFAULT_EMAIL` and `DEFAULT_GROUP` variable. -- [x] Make any theme changes on the frontend container. [See Frontend Config](/mealie/documentation/getting-started/installation/frontend-config/#themeing) +- [x] Make any theme changes on the frontend container. [See Frontend Config](./frontend-config.md#themeing) ## Step 3: Startup After you've configured your database, and updated the `docker-compose.yaml` files, you can start Mealie by running the following command in the directory where you've added your `docker-compose.yaml`. @@ -48,6 +72,6 @@ You should see the containers start up without error. You should now be able to **Password:** MyPassword ## Step 4: Backup -While v1.0.0 is a great step to data-stability and security, it's not a backup. As a core feature, Mealie will run a backup of the entire database every 24 hours. Optionally, you can also run backups whenever you'd like through the UI or the API. +While v1.0.0 is a great step to data-stability and security, it's not a backup. As a core feature, Mealie will run a backup every 24 hours. Optionally, you can also run backups whenever you'd like through the UI or the API. These backups are just plain .zip files that you can download from the UI or access via the mounted volume on your system. For complete data protection you MUST store these backups somewhere safe, and outside of the server where they are deployed. A favorite solution of mine is [autorestic](https://autorestic.vercel.app/) which can be configured via yaml to run an off-site backup on a regular basis. \ No newline at end of file diff --git a/docs/docs/overrides/api.html b/docs/docs/overrides/api.html index 95b6e816e7bc..7de978ea251a 100644 --- a/docs/docs/overrides/api.html +++ b/docs/docs/overrides/api.html @@ -14,7 +14,7 @@
diff --git a/frontend/api/admin/admin-about.ts b/frontend/api/admin/admin-about.ts index dac818f28c73..6f5933d9eed7 100644 --- a/frontend/api/admin/admin-about.ts +++ b/frontend/api/admin/admin-about.ts @@ -17,6 +17,7 @@ export interface AdminAboutInfo { dbType: string; dbUrl: string; defaultGroup: string; + versionLatest: string; } export interface AdminStatistics { @@ -31,6 +32,7 @@ export interface CheckAppConfig { emailReady: boolean; baseUrlSet: boolean; isSiteSecure: boolean; + isUpToDate: boolean; ldapReady: boolean; } diff --git a/frontend/api/class-interfaces/recipe-bulk-actions.ts b/frontend/api/class-interfaces/recipe-bulk-actions.ts index 1530642b400f..d8644d017fe6 100644 --- a/frontend/api/class-interfaces/recipe-bulk-actions.ts +++ b/frontend/api/class-interfaces/recipe-bulk-actions.ts @@ -31,10 +31,21 @@ interface BulkActionResponse { errors: BulkActionError[]; } +export interface GroupDataExport { + id: string; + groupId: string; + name: string; + filename: string; + path: string; + size: string; + expires: Date; +} + const prefix = "/api"; const routes = { bulkExport: prefix + "/recipes/bulk-actions/export", + purgeExports: prefix + "/recipes/bulk-actions/export/purge", bulkCategorize: prefix + "/recipes/bulk-actions/categorize", bulkTag: prefix + "/recipes/bulk-actions/tag", bulkDelete: prefix + "/recipes/bulk-actions/delete", @@ -56,4 +67,12 @@ export class BulkActionsAPI extends BaseAPI { async bulkDelete(payload: RecipeBulkDelete) { return await this.requests.post(routes.bulkDelete, payload); } + + async fetchExports() { + return await this.requests.get(routes.bulkExport); + } + + async purgeExports() { + return await this.requests.delete(routes.purgeExports); + } } diff --git a/frontend/components/Domain/Admin/AdminBackupImportOptions.vue b/frontend/components/Domain/Admin/AdminBackupImportOptions.vue index fe73d2a9b082..bf5e57d4b1c9 100644 --- a/frontend/components/Domain/Admin/AdminBackupImportOptions.vue +++ b/frontend/components/Domain/Admin/AdminBackupImportOptions.vue @@ -38,18 +38,6 @@ export default { value: true, text: this.$t("general.recipes"), }, - settings: { - value: true, - text: this.$t("general.settings"), - }, - pages: { - value: true, - text: this.$t("settings.pages"), - }, - themes: { - value: true, - text: this.$t("general.themes"), - }, users: { value: true, text: this.$t("user.users"), @@ -58,10 +46,6 @@ export default { value: true, text: this.$t("group.groups"), }, - notifications: { - value: true, - text: this.$t("events.notification"), - }, }, forceImport: false, }; @@ -73,12 +57,12 @@ export default { emitValue() { this.$emit(UPDATE_EVENT, { recipes: this.options.recipes.value, - settings: this.options.settings.value, - themes: this.options.themes.value, - pages: this.options.pages.value, + settings: false, + themes: false, + pages: false, users: this.options.users.value, groups: this.options.groups.value, - notifications: this.options.notifications.value, + notifications: false, forceImport: this.forceImport, }); }, diff --git a/frontend/components/Domain/Group/GroupExportData.vue b/frontend/components/Domain/Group/GroupExportData.vue new file mode 100644 index 000000000000..b1491882f7b6 --- /dev/null +++ b/frontend/components/Domain/Group/GroupExportData.vue @@ -0,0 +1,60 @@ + + + + diff --git a/frontend/components/Domain/Recipe/RecipeDataTable.vue b/frontend/components/Domain/Recipe/RecipeDataTable.vue index f7302b25f88c..0061c37f8bd1 100644 --- a/frontend/components/Domain/Recipe/RecipeDataTable.vue +++ b/frontend/components/Domain/Recipe/RecipeDataTable.vue @@ -7,6 +7,7 @@ :items="recipes" :items-per-page="15" class="elevation-0" + :loading="loading" @input="setValue(selected)" >