mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-25 17:23:11 -05:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f5a564ff3 | ||
|
|
e11577f786 | ||
|
|
47e48e1350 | ||
|
|
9c379dfb83 | ||
|
|
b8cddfd6c5 | ||
|
|
114e878384 | ||
|
|
276e580ec4 |
5
.github/workflows/dockerbuild.prod.yml
vendored
5
.github/workflows/dockerbuild.prod.yml
vendored
@@ -1,9 +1,8 @@
|
||||
name: Docker Build Production
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
2
.github/workflows/pytest.yml
vendored
2
.github/workflows/pytest.yml
vendored
@@ -11,6 +11,8 @@ on:
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
env:
|
||||
PRODUCTION: false
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
#----------------------------------------------
|
||||
|
||||
9
.vscode/tasks.json
vendored
9
.vscode/tasks.json
vendored
@@ -52,6 +52,15 @@
|
||||
"group": "groupA"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Run python tests",
|
||||
"command": "make test",
|
||||
"type": "shell",
|
||||
"presentation": {
|
||||
"reveal": "always"
|
||||
},
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
20
Dockerfile
20
Dockerfile
@@ -7,14 +7,25 @@ RUN npm run build
|
||||
|
||||
FROM python:3.9-alpine
|
||||
|
||||
RUN apk add --no-cache libxml2-dev libxslt-dev libxml2 caddy libffi-dev
|
||||
ENV ENV prod
|
||||
|
||||
RUN apk add --no-cache libxml2-dev \
|
||||
libxslt-dev \
|
||||
libxml2 caddy \
|
||||
libffi-dev \
|
||||
python3 \
|
||||
python3-dev \
|
||||
jpeg-dev \
|
||||
lcms2-dev \
|
||||
openjpeg-dev \
|
||||
zlib-dev
|
||||
|
||||
|
||||
ENV PRODUCTION true
|
||||
EXPOSE 80
|
||||
WORKDIR /app/
|
||||
|
||||
COPY ./pyproject.toml /app/
|
||||
|
||||
|
||||
RUN apk add --update --no-cache --virtual .build-deps \
|
||||
curl \
|
||||
g++ \
|
||||
@@ -29,14 +40,15 @@ RUN apk add --update --no-cache --virtual .build-deps \
|
||||
cd /app/ && poetry install --no-root --no-dev && \
|
||||
apk --purge del .build-deps
|
||||
|
||||
|
||||
COPY ./mealie /app/mealie
|
||||
RUN poetry install --no-dev
|
||||
|
||||
COPY ./Caddyfile /app
|
||||
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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -12,10 +14,11 @@ RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-
|
||||
poetry config virtualenvs.create false
|
||||
|
||||
# Copy poetry.lock* in case it doesn't exist in the repo
|
||||
COPY ./pyproject.toml ./poetry.lock* /app/
|
||||
|
||||
RUN poetry install
|
||||
COPY ./pyproject.toml /app/
|
||||
|
||||
COPY ./mealie /app/mealie
|
||||
|
||||
CMD ["uvicorn", "mealie.app:app", "--host", "0.0.0.0", "--port", "9000", "--reload"]
|
||||
RUN poetry install
|
||||
|
||||
RUN chmod +x /app/mealie/run.sh
|
||||
CMD ["/app/mealie/run.sh", "reload"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||
# {{ recipe.name }}
|
||||
{{ recipe.description }}
|
||||
|
||||
@@ -29,8 +29,8 @@ services:
|
||||
db_type: sqlite
|
||||
TZ: America/Anchorage # Specify Correct Timezone for Date/Time to line up correctly.
|
||||
volumes:
|
||||
- ./app_data:/app_data
|
||||
- ./mealie:/app
|
||||
- ./dev/data:/app/dev/data
|
||||
- ./mealie:/app/mealie
|
||||
|
||||
# Mkdocs
|
||||
mealie-docs:
|
||||
|
||||
93
docs/docs/api-usage/bulk-url-import.md
Normal file
93
docs/docs/api-usage/bulk-url-import.md
Normal file
@@ -0,0 +1,93 @@
|
||||
!!! info
|
||||
This example was submitted by a user. Have an Example? Submit a PR!
|
||||
|
||||
|
||||
Recipes can be imported in bulk from a file containing a list of URLs. This can be done using the following bash or python scripts with the `list` file containing one URL per line.
|
||||
|
||||
#### Bash
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
function authentification () {
|
||||
auth=$(curl -X 'POST' \
|
||||
"$3/api/auth/token" \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
-d 'grant_type=&username='$1'&password='$2'&scope=&client_id=&client_secret=')
|
||||
|
||||
echo $auth | sed -e 's/.*token":"\(.*\)",.*/\1/'
|
||||
}
|
||||
|
||||
function import_from_file () {
|
||||
while IFS= read -r line
|
||||
do
|
||||
echo $line
|
||||
curl -X 'POST' \
|
||||
"$3/api/recipes/create-url" \
|
||||
-H "Authorization: Bearer $2" \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"url": "'$line'" }'
|
||||
echo
|
||||
done < "$1"
|
||||
}
|
||||
|
||||
input="list"
|
||||
mail="changeme@email.com"
|
||||
password="MyPassword"
|
||||
mealie_url=http://localhost:9000
|
||||
|
||||
|
||||
token=$(authentification $mail $password $mealie_url)
|
||||
import_from_file $input $token $mealie_url
|
||||
|
||||
```
|
||||
|
||||
#### Python
|
||||
```python
|
||||
import requests
|
||||
import re
|
||||
|
||||
def authentification(mail, password, mealie_url):
|
||||
headers = {
|
||||
'accept': 'application/json',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
data = {
|
||||
'grant_type': '',
|
||||
'username': mail,
|
||||
'password': password,
|
||||
'scope': '',
|
||||
'client_id': '',
|
||||
'client_secret': ''
|
||||
}
|
||||
auth = requests.post(mealie_url + "/api/auth/token", headers=headers, data=data)
|
||||
token = re.sub(r'.*token":"(.*)",.*', r'\1', auth.text)
|
||||
return token
|
||||
|
||||
def import_from_file(input_file, token, mealie_url):
|
||||
with open(input_file) as fp:
|
||||
for l in fp:
|
||||
line = re.sub(r'(.*)\n', r'\1', l)
|
||||
print(line)
|
||||
headers = {
|
||||
'Authorization': "Bearer " + token,
|
||||
'accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
data = {
|
||||
'url': line
|
||||
}
|
||||
response = requests.post(mealie_url + "/api/recipes/create-url", headers=headers, json=data)
|
||||
print(response.text)
|
||||
|
||||
input_file="list"
|
||||
mail="changeme@email.com"
|
||||
password="MyPassword"
|
||||
mealie_url="http://localhost:9000"
|
||||
|
||||
|
||||
token = authentification(mail, password, mealie_url)
|
||||
import_from_file(input_file, token, mealie_url)
|
||||
```
|
||||
|
||||
39
docs/docs/api-usage/getting-started.md
Normal file
39
docs/docs/api-usage/getting-started.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Usage
|
||||
|
||||
## Getting a Token
|
||||
|
||||
Currently Mealie doesn't support creating a long-live token. You can however get a token from the API. This example was pulled from the automatic API documentation provided by Mealie.
|
||||
|
||||
### Curl
|
||||
```bash
|
||||
curl -X 'POST' \
|
||||
'https://mealie-demo.hay-kot.dev/api/auth/token' \
|
||||
-H 'accept: application/json' \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
-d 'grant_type=&username=changeme%40email.com&password=demo&scope=&client_id=&client_secret='
|
||||
|
||||
```
|
||||
|
||||
#### Response
|
||||
```json
|
||||
{
|
||||
"snackbar": {
|
||||
"text": "User Successfully Logged In",
|
||||
"type": "success"
|
||||
},
|
||||
"access_token": "your-long-token-string",
|
||||
"token_type": "bearer"
|
||||
}
|
||||
```
|
||||
|
||||
## Key Components
|
||||
|
||||
### Exploring Your Local API
|
||||
On your local installation you can access interactive API documentation that provides `curl` examples and expected results. This allows you to easily test and interact with your API to identify places to include your own functionality. You can visit the documentation at `http://mealie.yourdomain.com/docs or see the example at the [Demo Site](https://mealie-demo.hay-kot.dev/docs)
|
||||
|
||||
### Recipe Extras
|
||||
Recipes extras are a key feature of the Mealie API. They allow you to create custom json key/value pairs within a recipe to reference from 3rd part applications. You can use these keys to contain information to trigger automation or custom messages to relay to your desired device.
|
||||
|
||||
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.
|
||||
|
||||

|
||||
30
docs/docs/api-usage/home-assistant.md
Normal file
30
docs/docs/api-usage/home-assistant.md
Normal file
@@ -0,0 +1,30 @@
|
||||
In a lot of ways, Home Assistant is why this project exists! Since it Mealie has a robust API it makes it a great fit for interacting with Home Assistant and pulling information into your dashboard.
|
||||
|
||||
### Get Todays Meal in Lovelace
|
||||
Starting in v0.4.1 you are now able to use the uri `/api/meal-plans/today/image?group_name=Home` to directly access the image to todays meal. This makes it incredible easy to include the image into your Home Assistant Dashboard using the picture entity.
|
||||
|
||||
Here's an example where `sensor.mealie_todays_meal` is pulling in the meal-plan name and I'm using the url to get the image.
|
||||
|
||||

|
||||
|
||||
```yaml
|
||||
type: picture-entity
|
||||
entity: sensor.mealie_todays_meal
|
||||
name: Dinner Tonight
|
||||
show_state: true
|
||||
show_name: true
|
||||
image: 'http://localhost:9000/api/meal-plans/today/image?group_name=Home'
|
||||
style:
|
||||
.: |
|
||||
ha-card {
|
||||
max-height: 300px !important;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
!!! tip
|
||||
Due to how Home Assistant works with images, I had to include the additional styling to get the images to not appear distorted. This includes and [additional installation](https://github.com/thomasloven/lovelace-card-mod) from HACS.
|
||||
BIN
docs/docs/assets/img/home-assistant-card.png
Normal file
BIN
docs/docs/assets/img/home-assistant-card.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 802 KiB |
@@ -1,14 +1,20 @@
|
||||
:root {
|
||||
[data-md-color-scheme="mealie"] {
|
||||
--md-primary-fg-color: #e58325;
|
||||
--md-primary-fg-color--light: #e58325;
|
||||
--md-primary-fg-color--dark: #e58325;
|
||||
--md-accent-fg-color: #e58325;
|
||||
--md-custom-h2-color: #333;
|
||||
--md-accent-fg-color--light: #e58325;
|
||||
--md-accent-fg-color--dark: #e58325;
|
||||
--md-default-accent-bg-color: #f7fafc;
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--md-primary-bg-color);
|
||||
[data-md-color-scheme="slate"] {
|
||||
--md-primary-fg-color: #e58325;
|
||||
--md-primary-fg-color--dark: #e58325;
|
||||
--md-accent-fg-color: #e58325;
|
||||
--md-accent-fg-color--dark: #e58325;
|
||||
--md-custom-h2-color: rgb(167, 167, 167);
|
||||
--md-default-bg-color: #1a1b1b;
|
||||
--md-default-accent-bg-color: #1f1e1e;
|
||||
}
|
||||
|
||||
/* frontpage elements */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
With the addition of group settings and a re-write of the database layer of the application backend, there is no migration path for your current site settings. Webhooks Settings, Meal Plan Categories are now managed by groups. Site settings, mainly homepage settings, are now site specific and managed by administrators. When upgrading be sure to uncheck the settings when importing your old data.
|
||||
|
||||
#### ENV Variables
|
||||
Names have been changed to be more consistent with industry standards. See the [Installation Page](/getting-started/install/) for new parameters.
|
||||
Names have been changed to be more consistent with industry standards. See the [Installation Page](/mealie/getting-started/install/) for new parameters.
|
||||
|
||||
## Bug Fixes
|
||||
- Fixed Search Results Limited to 100 - #198
|
||||
@@ -51,7 +51,7 @@
|
||||
- Create/Edit/Delete Restrictions
|
||||
|
||||
### Custom Pages
|
||||
- You can now create custom pages that are displayed on the homepage sidebar to organize categories of recipes into pages. For example, if you have several categories that encompass "Entrée" you can group all those categories together under the "Entrée" page. See [Building Pages](/site-administration/building-pages/) for more information.
|
||||
- You can now create custom pages that are displayed on the homepage sidebar to organize categories of recipes into pages. For example, if you have several categories that encompass "Entrée" you can group all those categories together under the "Entrée" page. See [Building Pages](/mealie/site-administration/building-pages/) for more information.
|
||||
!!! tip
|
||||
Note that this replaces the behavior of automatically adding categories to the sidebar.
|
||||
|
||||
|
||||
35
docs/docs/changelog/v0.4.1.md
Normal file
35
docs/docs/changelog/v0.4.1.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# v0.4.1
|
||||
|
||||
**App Version: v0.4.1**
|
||||
|
||||
**Database Version: v0.4.0**
|
||||
|
||||
!!! error "Breaking Changes"
|
||||
|
||||
#### Recipe Images
|
||||
While it *shouldn't* be a breaking change, I feel it is important to note that you may experience issues with the new image migration. Recipe images are now minified, this is done on start-up, import, migration, and when a new recipe is created. The initial boot or load may be a bit slow if you have lots of recipes but you likely won't notice. What you may notice is that if your recipe slug and the image name do not match, you will encounter issues with your images showing up. This can be resolved by finding the image directory and rename it to the appropriate slug. I did fix multiple edge cases, but it is likely more exists. As always make a backup before you update!
|
||||
|
||||
On the plus side, this comes with a huge performance increase! 🎉
|
||||
|
||||
- Add markdown support for ingredients - Resolves #32
|
||||
- Ingredients editor improvements
|
||||
- Fix Tags/Categories render problems on recipes
|
||||
- Tags redirect to new tag pages
|
||||
- Categories redirect to category pages
|
||||
- Fix Backup download blocked by authentication
|
||||
- Random meal-planner will no longer duplicate recipes unless no other options
|
||||
- New Quick Week button to generate next 5 day week of recipe slots.
|
||||
- Minor UI tweaks
|
||||
- Recipe Cards now display 2 recipe tags
|
||||
- Recipe images are now minified. This comes with a serious performance improvement. On initial startup you may experience some delays. Images are migrated to the new structure on startup, depending on the size of your database this can take some time.
|
||||
- Note that original images are still kept for large displays like on the individual recipe pages.
|
||||
- A smaller image is used for recipe cards
|
||||
- A 'tiny' image is used for search images.
|
||||
- Advanced Search Page. You can now use the search page to filter recipes to include/exclude tags and categories as well as select And/Or matching criteria.
|
||||
- Added link to advanced search on quick search
|
||||
- Better support for NextCloud imports
|
||||
- Translate keywords to tags
|
||||
- Fix rollback on failure
|
||||
- Recipe Tag/Category Input components have been unified and now share a single way to interact. To add a new category in the recipe editor you need to click to '+' icon next to the input and fill out the form. This is the same for adding a Tag.
|
||||
|
||||
|
||||
34
docs/docs/changelog/v0.4.2.md
Normal file
34
docs/docs/changelog/v0.4.2.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# 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.
|
||||
|
||||
## Bug Fixes
|
||||
- Fixed Initialization script (v0.4.1a Hot Fix) - Closes #274
|
||||
- Fixed nested list error on recipe scrape - Closes #306
|
||||
- Fixed ingredient checkboxes - Closes #304
|
||||
- Removed link on recent - Closes #297
|
||||
- Categories sidebar is auto generated if no pages are created - Closes #291
|
||||
- Fix tag issues on creating custom pages - Closes #290
|
||||
- Validate paths on export - Closes #275
|
||||
- Walk Nextcloud import directory - Closes #254
|
||||
|
||||
## General Improvements
|
||||
- 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"
|
||||
- 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.
|
||||
- Recipe images can now be added directly from a URL - [See #117 for details](https://github.com/hay-kot/mealie/issues/117)
|
||||
@@ -7,7 +7,7 @@ We love your input! We want to make contributing to this project as easy and tra
|
||||
- Submitting a fix
|
||||
- Proposing new features
|
||||
- Becoming a maintainer
|
||||
- [Help translate to a new language or improve current translations](../translating)
|
||||
- Help translate to a new language or improve current translations
|
||||
|
||||
[Remember to join the Discord and stay in touch with other developers working on the project](https://discord.gg/R6QDyJgbD2)!
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
# Usage
|
||||
|
||||
## Getting a Token
|
||||
Bla Bla
|
||||
|
||||
## Key Components
|
||||
### Recipe Extras
|
||||
Recipes extras are a key feature of the Mealie API. They allow you to create custom json key/value pairs within a recipe to reference from 3rd part applications. You can use these keys to contain information to trigger automation or custom messages to relay to your desired device.
|
||||
@@ -8,7 +11,4 @@ For example you could add `{"message": "Remember to thaw the chicken"}` to a rec
|
||||
|
||||

|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
Have Ideas? Submit a PR!
|
||||
Have Ideas? Submit a PR!
|
||||
|
||||
@@ -23,6 +23,11 @@ docker run \
|
||||
|
||||
```
|
||||
|
||||
!!! tip "Default Credentials"
|
||||
**Username:** changeme@email.com
|
||||
|
||||
**Password:** MyPassword
|
||||
|
||||
## Docker Compose with SQLite
|
||||
Deployment with docker-compose is the recommended method for deployment. The example below will create an instance of mealie available on port `9925` with the data volume mounted from the local directory. To use, create a docker-compose.yml file, paste the contents below and save. In the terminal run `docker-compose up -d` to start the container.
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
## Backing Up Your Data
|
||||
|
||||
[See Backups and Restore Section](/site-administration/backups-and-exports/) for details on backing up your data
|
||||
[See Backups and Restore Section](/mealie/site-administration/backups-and-exports/) for details on backing up your data
|
||||
|
||||
## Docker
|
||||
For all setups using Docker the updating process look something like this
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -16,7 +16,6 @@
|
||||
|
||||
.tx-container {
|
||||
padding-top: .0rem;
|
||||
background: var(--md-primary-bg-color)
|
||||
}
|
||||
|
||||
.tx-hero {
|
||||
@@ -27,7 +26,7 @@
|
||||
.tx-hero h1 {
|
||||
margin-bottom: 1rem;
|
||||
font-family: "Roboto";
|
||||
color: #30353a;
|
||||
color: var(--md-custom-h2-color);
|
||||
font-weight: 500
|
||||
}
|
||||
|
||||
@@ -68,7 +67,7 @@
|
||||
}
|
||||
|
||||
.feature-container {
|
||||
background-color: #F7FAFC;
|
||||
background-color: var(--md-default-accent-bg-color);
|
||||
}
|
||||
|
||||
.top-hr {
|
||||
@@ -85,7 +84,7 @@
|
||||
}
|
||||
|
||||
.feature-item h2 {
|
||||
color: #333;
|
||||
color: var(--md-custom-h2-color);
|
||||
font-weight: 300;
|
||||
font-size: 25px;
|
||||
white-space: nowrap;
|
||||
@@ -102,7 +101,7 @@
|
||||
line-height: 1.8em;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
color: #111;
|
||||
color: var(--webkit-print-color-adjust);
|
||||
margin: 0 0 10px;
|
||||
display: block;
|
||||
}
|
||||
@@ -162,11 +161,6 @@
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* .feature-item:hover {
|
||||
background-color: #fea55247;
|
||||
border-radius: 3px;
|
||||
} */
|
||||
}
|
||||
|
||||
.hr {
|
||||
|
||||
@@ -83,4 +83,4 @@ You can easily create and manage groups via the frontend in the admin panel unde
|
||||
User Groups can only be deleted if no users are apart of the group. If you want to delete a group, you must assign the users to another group before removing.
|
||||
|
||||
## Password Reset
|
||||
If a user forgets their password an administrator is able to reset their password through the user management page. In the user table, select edit. In the popup windows click the "Reset Password" to reset a users password to the default. This is either 'MyPassword' or set through an environment variable. See the [Installation Page](/getting-started/install/) for more details on environmental variables
|
||||
If a user forgets their password an administrator is able to reset their password through the user management page. In the user table, select edit. In the popup windows click the "Reset Password" to reset a users password to the default. This is either 'MyPassword' or set through an environment variable. See the [Installation Page](/mealie/getting-started/install/) for more details on environmental variables
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
site_name: Mealie
|
||||
demo_url: https://mealie-demo.hay-kot.dev/
|
||||
theme:
|
||||
palette:
|
||||
# Light mode
|
||||
- media: "(prefers-color-scheme: light)"
|
||||
scheme: mealie
|
||||
toggle:
|
||||
icon: material/weather-night
|
||||
name: Switch to dark mode
|
||||
# Dark mode
|
||||
- media: "(prefers-color-scheme: dark)"
|
||||
scheme: slate
|
||||
toggle:
|
||||
icon: material/weather-sunny
|
||||
name: Switch to light mode
|
||||
custom_dir: docs/overrides
|
||||
features:
|
||||
- navigation.top
|
||||
- navigation.instant
|
||||
- navigation.expand
|
||||
- navigation.sections
|
||||
@@ -42,7 +56,6 @@ nav:
|
||||
- Organizing Recipes: "getting-started/organizing-recipes.md"
|
||||
- Planning Meals: "getting-started/meal-planner.md"
|
||||
- iOS Shortcuts: "getting-started/ios.md"
|
||||
- API Usage: "getting-started/api-usage.md"
|
||||
- Site Administration:
|
||||
- User Settings: "site-administration/user-settings.md"
|
||||
- Site Settings: "site-administration/site-settings.md"
|
||||
@@ -50,6 +63,10 @@ nav:
|
||||
- User Management: "site-administration/user-management.md"
|
||||
- Backups and Restore: "site-administration/backups-and-exports.md"
|
||||
- Recipe Migration: "site-administration/migration-imports.md"
|
||||
- API Usage:
|
||||
- Getting Started: "api-usage/getting-started.md"
|
||||
- Home Assistant: "api-usage/home-assistant.md"
|
||||
- Bulk Url Import: "api-usage/bulk-url-import.md"
|
||||
- API Reference: "api/redoc.md"
|
||||
- Contributors Guide:
|
||||
- Non-Code: "contributors/non-coders.md"
|
||||
@@ -60,6 +77,8 @@ 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"
|
||||
- v0.2.0 Now With Tests!: "changelog/v0.2.0.md"
|
||||
|
||||
@@ -1,35 +1,6 @@
|
||||
<template>
|
||||
<v-app>
|
||||
<v-app-bar clipped-left dense app color="primary" dark class="d-print-none">
|
||||
<router-link v-if="!(isMobile && search)" to="/">
|
||||
<v-btn icon>
|
||||
<v-icon size="40"> mdi-silverware-variant </v-icon>
|
||||
</v-btn>
|
||||
</router-link>
|
||||
|
||||
<div v-if="!isMobile" btn class="pl-2">
|
||||
<v-toolbar-title style="cursor: pointer" @click="$router.push('/')"
|
||||
>Mealie
|
||||
</v-toolbar-title>
|
||||
</div>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
<v-expand-x-transition>
|
||||
<SearchBar
|
||||
ref="mainSearchBar"
|
||||
v-if="search"
|
||||
:show-results="true"
|
||||
@selected="navigateFromSearch"
|
||||
:max-width="isMobile ? '100%' : '450px'"
|
||||
/>
|
||||
</v-expand-x-transition>
|
||||
<v-btn icon @click="search = !search">
|
||||
<v-icon>mdi-magnify</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<SiteMenu />
|
||||
<LanguageMenu />
|
||||
</v-app-bar>
|
||||
<TheAppBar />
|
||||
<v-main>
|
||||
<v-banner v-if="demo" sticky
|
||||
><div class="text-center">
|
||||
@@ -47,34 +18,25 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SiteMenu from "@/components/UI/SiteMenu";
|
||||
import SearchBar from "@/components/UI/Search/SearchBar";
|
||||
import TheAppBar from "@/components/UI/TheAppBar";
|
||||
import AddRecipeFab from "@/components/UI/AddRecipeFab";
|
||||
import LanguageMenu from "@/components/UI/LanguageMenu";
|
||||
import Vuetify from "./plugins/vuetify";
|
||||
import { user } from "@/mixins/user";
|
||||
import { api } from "./api";
|
||||
|
||||
export default {
|
||||
name: "App",
|
||||
|
||||
components: {
|
||||
SiteMenu,
|
||||
TheAppBar,
|
||||
AddRecipeFab,
|
||||
SearchBar,
|
||||
LanguageMenu,
|
||||
},
|
||||
|
||||
mixins: [user],
|
||||
|
||||
watch: {
|
||||
$route() {
|
||||
this.search = false;
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return this.$vuetify.breakpoint.name === "xs";
|
||||
demo() {
|
||||
const appInfo = this.$store.getters.getAppInfo;
|
||||
return appInfo.demoStatus;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -96,15 +58,9 @@ export default {
|
||||
this.$store.dispatch("requestTags");
|
||||
this.darkModeSystemCheck();
|
||||
this.darkModeAddEventListener();
|
||||
|
||||
const api_status = await api.meta.getIsDemo();
|
||||
this.demo = api_status.demoStatus;
|
||||
this.$store.dispatch("requestAppInfo");
|
||||
},
|
||||
|
||||
data: () => ({
|
||||
search: false,
|
||||
demo: false,
|
||||
}),
|
||||
methods: {
|
||||
// For Later!
|
||||
|
||||
@@ -126,9 +82,6 @@ export default {
|
||||
this.darkModeSystemCheck();
|
||||
});
|
||||
},
|
||||
navigateFromSearch(slug) {
|
||||
this.$router.push(`/recipe/${slug}`);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -160,6 +113,7 @@ export default {
|
||||
|
||||
.notify-base {
|
||||
color: white !important;
|
||||
/* min-height: 50px; */
|
||||
margin-right: 60px;
|
||||
margin-bottom: -5px;
|
||||
opacity: 0.9 !important;
|
||||
@@ -176,11 +130,4 @@ export default {
|
||||
*::-webkit-scrollbar-thumb {
|
||||
background: grey;
|
||||
}
|
||||
|
||||
.notify-base {
|
||||
color: white !important;
|
||||
margin-right: 60px;
|
||||
margin-bottom: -5px;
|
||||
opacity: 0.9 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,27 +5,27 @@ import { store } from "@/store";
|
||||
const prefix = baseURL + "categories";
|
||||
|
||||
const categoryURLs = {
|
||||
get_all: `${prefix}`,
|
||||
get_category: category => `${prefix}/${category}`,
|
||||
delete_category: category => `${prefix}/${category}`,
|
||||
getAll: `${prefix}`,
|
||||
getCategory: category => `${prefix}/${category}`,
|
||||
deleteCategory: category => `${prefix}/${category}`,
|
||||
};
|
||||
|
||||
export const categoryAPI = {
|
||||
async getAll() {
|
||||
let response = await apiReq.get(categoryURLs.get_all);
|
||||
let response = await apiReq.get(categoryURLs.getAll);
|
||||
return response.data;
|
||||
},
|
||||
async create(name) {
|
||||
let response = await apiReq.post(categoryURLs.get_all, { name: name });
|
||||
let response = await apiReq.post(categoryURLs.getAll, { name: name });
|
||||
store.dispatch("requestCategories");
|
||||
return response.data;
|
||||
},
|
||||
async getRecipesInCategory(category) {
|
||||
let response = await apiReq.get(categoryURLs.get_category(category));
|
||||
let response = await apiReq.get(categoryURLs.getCategory(category));
|
||||
return response.data;
|
||||
},
|
||||
async delete(category) {
|
||||
let response = await apiReq.delete(categoryURLs.delete_category(category));
|
||||
let response = await apiReq.delete(categoryURLs.deleteCategory(category));
|
||||
store.dispatch("requestCategories");
|
||||
return response.data;
|
||||
},
|
||||
@@ -44,6 +44,11 @@ export const tagAPI = {
|
||||
let response = await apiReq.get(tagURLs.getAll);
|
||||
return response.data;
|
||||
},
|
||||
async create(name) {
|
||||
let response = await apiReq.post(tagURLs.getAll, { name: name });
|
||||
store.dispatch("requestTags");
|
||||
return response.data;
|
||||
},
|
||||
async getRecipesInTag(tag) {
|
||||
let response = await apiReq.get(tagURLs.getTag(tag));
|
||||
return response.data;
|
||||
|
||||
@@ -5,15 +5,22 @@ const prefix = baseURL + "debug";
|
||||
|
||||
const debugURLs = {
|
||||
version: `${prefix}/version`,
|
||||
debug: `${prefix}`,
|
||||
lastRecipe: `${prefix}/last-recipe-json`,
|
||||
demo: `${prefix}/is-demo`,
|
||||
};
|
||||
|
||||
export const metaAPI = {
|
||||
async get_version() {
|
||||
async getAppInfo() {
|
||||
let response = await apiReq.get(debugURLs.version);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async getDebugInfo() {
|
||||
const response = await apiReq.get(debugURLs.debug);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async getLastJson() {
|
||||
let response = await apiReq.get(debugURLs.lastRecipe);
|
||||
return response.data;
|
||||
@@ -21,7 +28,6 @@ export const metaAPI = {
|
||||
|
||||
async getIsDemo() {
|
||||
let response = await apiReq.get(debugURLs.demo);
|
||||
console.log(response);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ const prefix = baseURL + "recipes/";
|
||||
|
||||
const recipeURLs = {
|
||||
allRecipes: baseURL + "recipes",
|
||||
summary: baseURL + "recipes" + "/summary",
|
||||
allRecipesByCategory: prefix + "category",
|
||||
create: prefix + "create",
|
||||
createByURL: prefix + "create-url",
|
||||
@@ -56,9 +57,12 @@ export const recipeAPI = {
|
||||
const fd = new FormData();
|
||||
fd.append("image", fileObject);
|
||||
fd.append("extension", fileObject.name.split(".").pop());
|
||||
|
||||
let response = apiReq.put(recipeURLs.updateImage(recipeSlug), fd);
|
||||
return response;
|
||||
},
|
||||
|
||||
async updateImagebyURL(slug, url) {
|
||||
const response = apiReq.post(recipeURLs.updateImage(slug), { url: url });
|
||||
return response;
|
||||
},
|
||||
|
||||
@@ -87,4 +91,21 @@ export const recipeAPI = {
|
||||
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async allSummary() {
|
||||
const response = await apiReq.get(recipeURLs.summary);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
recipeImage(recipeSlug) {
|
||||
return `/api/recipes/${recipeSlug}/image?image_type=original`;
|
||||
},
|
||||
|
||||
recipeSmallImage(recipeSlug) {
|
||||
return `/api/recipes/${recipeSlug}/image?image_type=small`;
|
||||
},
|
||||
|
||||
recipeTinyImage(recipeSlug) {
|
||||
return `/api/recipes/${recipeSlug}/image?image_type=tiny`;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
</v-list>
|
||||
|
||||
<v-list nav dense class="fixedBottom">
|
||||
<v-list-item href="">
|
||||
<v-list-item to="/admin/about">
|
||||
<v-list-item-icon class="mr-3 pt-1">
|
||||
<v-icon :color="newVersionAvailable ? 'red--text' : ''">
|
||||
mdi-information
|
||||
@@ -83,10 +83,11 @@
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>
|
||||
{{ $t("settings.current") }}
|
||||
{{ version }}
|
||||
{{ appVersion }}
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle>
|
||||
<a
|
||||
@click.prevent
|
||||
href="https://github.com/hay-kot/mealie/releases/latest"
|
||||
target="_blank"
|
||||
:class="newVersionAvailable ? 'red--text' : 'green--text'"
|
||||
@@ -106,14 +107,12 @@
|
||||
import { validators } from "@/mixins/validators";
|
||||
import { initials } from "@/mixins/initials";
|
||||
import { user } from "@/mixins/user";
|
||||
import { api } from "@/api";
|
||||
import axios from "axios";
|
||||
export default {
|
||||
mixins: [validators, initials, user],
|
||||
data() {
|
||||
return {
|
||||
latestVersion: null,
|
||||
version: null,
|
||||
hideImage: false,
|
||||
showSidebar: false,
|
||||
mobile: false,
|
||||
@@ -163,8 +162,6 @@ export default {
|
||||
this.mobile = this.viewScale();
|
||||
this.showSidebar = !this.viewScale();
|
||||
this.getVersion();
|
||||
let versionData = await api.meta.get_version();
|
||||
this.version = versionData.version;
|
||||
},
|
||||
|
||||
computed: {
|
||||
@@ -172,7 +169,11 @@ export default {
|
||||
return `api/users/${this.user.id}/image`;
|
||||
},
|
||||
newVersionAvailable() {
|
||||
return this.latestVersion == this.version ? false : true;
|
||||
return this.latestVersion == this.appVersion ? false : true;
|
||||
},
|
||||
appVersion() {
|
||||
const appInfo = this.$store.getters.getAppInfo;
|
||||
return appInfo.version;
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -37,9 +37,7 @@
|
||||
<v-divider></v-divider>
|
||||
|
||||
<v-card-actions>
|
||||
<v-btn color="accent" text :href="`/api/backups/${name}/download`">
|
||||
{{ $t("general.download") }}
|
||||
</v-btn>
|
||||
<TheDownloadBtn :download-url="downloadUrl" />
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="error" text @click="raiseEvent('delete')">
|
||||
{{ $t("general.delete") }}
|
||||
@@ -61,8 +59,10 @@
|
||||
|
||||
<script>
|
||||
import ImportOptions from "@/components/Admin/Backup/ImportOptions";
|
||||
import TheDownloadBtn from "@/components/UI/TheDownloadBtn.vue";
|
||||
import { backupURLs } from "@/api/backup";
|
||||
export default {
|
||||
components: { ImportOptions },
|
||||
components: { ImportOptions, TheDownloadBtn },
|
||||
props: {
|
||||
name: {
|
||||
default: "Backup Name",
|
||||
@@ -83,8 +83,14 @@ export default {
|
||||
dialog: false,
|
||||
forceImport: false,
|
||||
rebaseImport: false,
|
||||
downloading: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
downloadUrl() {
|
||||
return backupURLs.downloadBackup(this.name);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
updateOptions(options) {
|
||||
this.options = options;
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DataTable from "./DataTable";
|
||||
import DataTable from "@/components/Admin/Backup/ImportSummaryDialog/DataTable";
|
||||
export default {
|
||||
components: {
|
||||
DataTable,
|
||||
@@ -145,4 +145,4 @@ export default {
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
<v-text-field
|
||||
autofocus
|
||||
v-model="page.name"
|
||||
label="Page Name"
|
||||
:label="$t('settings.page-name')"
|
||||
></v-text-field>
|
||||
<CategorySelector
|
||||
<CategoryTagSelector
|
||||
v-model="page.categories"
|
||||
ref="categoryFormSelector"
|
||||
@mounted="catMounted = true"
|
||||
:tag-selector="false"
|
||||
/>
|
||||
</v-card-text>
|
||||
|
||||
@@ -43,10 +44,10 @@
|
||||
<script>
|
||||
const NEW_PAGE_EVENT = "refresh-page";
|
||||
import { api } from "@/api";
|
||||
import CategorySelector from "@/components/FormHelpers/CategorySelector";
|
||||
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
||||
export default {
|
||||
components: {
|
||||
CategorySelector,
|
||||
CategoryTagSelector,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
<CreatePageDialog ref="createDialog" @refresh-page="getPages" />
|
||||
<v-card-text>
|
||||
<h2 class="mt-1 mb-1 ">
|
||||
Custom Pages
|
||||
{{$t('settings.custom-pages')}}
|
||||
<span>
|
||||
<v-btn color="success" @click="newPage" small class="ml-3">
|
||||
Create
|
||||
{{$t('general.create')}}
|
||||
</v-btn>
|
||||
</span>
|
||||
</h2>
|
||||
@@ -41,11 +41,11 @@
|
||||
|
||||
<v-card-actions>
|
||||
<v-btn text small color="error" @click="deletePage(item.id)">
|
||||
Delete
|
||||
{{$t('general.delete')}}
|
||||
</v-btn>
|
||||
<v-spacer> </v-spacer>
|
||||
<v-btn small text color="success" @click="editPage(index)">
|
||||
Edit
|
||||
{{$t('general.edit')}}
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
@@ -55,7 +55,7 @@
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="success" @click="savePages">
|
||||
Save
|
||||
{{$t('general.save')}}
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
@@ -76,8 +76,8 @@ export default {
|
||||
customPages: [],
|
||||
newPageData: {
|
||||
create: true,
|
||||
title: "New Page",
|
||||
buttonText: "Create",
|
||||
title: this.$t('settings.new-page'),
|
||||
buttonText: this.$t('general.create'),
|
||||
data: {
|
||||
name: "",
|
||||
categories: [],
|
||||
@@ -86,8 +86,8 @@ export default {
|
||||
},
|
||||
editPageData: {
|
||||
create: false,
|
||||
title: "Edit Page",
|
||||
buttonText: "Update",
|
||||
title: this.$t('settings.edit-page'),
|
||||
buttonText: this.$t('general.update'),
|
||||
data: {},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
</v-toolbar-title>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
<NewCategoryDialog />
|
||||
<NewCategoryTagDialog :tag-dialog="false" />
|
||||
</v-app-bar>
|
||||
<v-list height="300" dense style="overflow:auto">
|
||||
<v-list-item-group>
|
||||
@@ -133,13 +133,13 @@
|
||||
import { api } from "@/api";
|
||||
import LanguageMenu from "@/components/UI/LanguageMenu";
|
||||
import draggable from "vuedraggable";
|
||||
import NewCategoryDialog from "./NewCategoryDialog.vue";
|
||||
import NewCategoryTagDialog from "@/components/UI/Dialogs/NewCategoryTagDialog.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
draggable,
|
||||
LanguageMenu,
|
||||
NewCategoryDialog,
|
||||
NewCategoryTagDialog,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -273,7 +273,6 @@ export default {
|
||||
await this.initialize();
|
||||
},
|
||||
resetPassword() {
|
||||
console.log(this.activeId);
|
||||
api.users.resetPassword(this.editedItem.id);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -42,4 +42,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.v-text-field{
|
||||
max-width: 300px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<v-card outlined class="my-2" :loading="loading">
|
||||
<MigrationDialog ref="migrationDialog" />
|
||||
<v-card-title>
|
||||
{{ title }}
|
||||
<v-spacer></v-spacer>
|
||||
@@ -40,7 +41,13 @@
|
||||
<v-btn color="error" text @click="deleteMigration(migration.name)">
|
||||
{{ $t("general.delete") }}
|
||||
</v-btn>
|
||||
<v-btn color="accent" text @click="importMigration(migration.name)">
|
||||
<v-btn
|
||||
color="accent"
|
||||
text
|
||||
@click="importMigration(migration.name)"
|
||||
:loading="loading"
|
||||
:disabled="loading"
|
||||
>
|
||||
{{ $t("general.import") }}
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
@@ -61,6 +68,7 @@
|
||||
import UploadBtn from "../../UI/UploadBtn";
|
||||
import utils from "@/utils";
|
||||
import { api } from "@/api";
|
||||
import MigrationDialog from "@/components/Admin/Migration/MigrationDialog.vue";
|
||||
export default {
|
||||
props: {
|
||||
folder: String,
|
||||
@@ -70,6 +78,7 @@ export default {
|
||||
},
|
||||
components: {
|
||||
UploadBtn,
|
||||
MigrationDialog,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -82,10 +91,11 @@ export default {
|
||||
this.$emit("refresh");
|
||||
},
|
||||
async importMigration(file_name) {
|
||||
this.loading == true;
|
||||
this.loading = true;
|
||||
let response = await api.migrations.import(this.folder, file_name);
|
||||
this.$emit("imported", response.successful, response.failed);
|
||||
this.loading == false;
|
||||
this.$refs.migrationDialog.open(response);
|
||||
// this.$emit("imported", response.successful, response.failed);
|
||||
this.loading = false;
|
||||
},
|
||||
readableTime(timestamp) {
|
||||
let date = new Date(timestamp);
|
||||
|
||||
109
frontend/src/components/Admin/Migration/MigrationDialog.vue
Normal file
109
frontend/src/components/Admin/Migration/MigrationDialog.vue
Normal file
@@ -0,0 +1,109 @@
|
||||
|
||||
|
||||
<template>
|
||||
<div class="text-center">
|
||||
<v-dialog v-model="dialog" width="70%">
|
||||
<v-card>
|
||||
<v-app-bar dark color="primary mb-2">
|
||||
<v-icon large left>
|
||||
mdi-import
|
||||
</v-icon>
|
||||
<v-toolbar-title class="headline">
|
||||
Migration Summary
|
||||
</v-toolbar-title>
|
||||
<v-spacer></v-spacer>
|
||||
</v-app-bar>
|
||||
<v-card-text class="mb-n4">
|
||||
<v-row>
|
||||
<div v-for="values in allNumbers" :key="values.title">
|
||||
<v-card-text>
|
||||
<div>
|
||||
<h3>{{ values.title }}</h3>
|
||||
</div>
|
||||
<div class="success--text">Success: {{ values.success }}</div>
|
||||
<div class="error--text">Failed: {{ values.failure }}</div>
|
||||
</v-card-text>
|
||||
</div>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
<v-tabs v-model="tab">
|
||||
<v-tab>{{ $t("general.recipes") }}</v-tab>
|
||||
</v-tabs>
|
||||
<v-tabs-items v-model="tab">
|
||||
<v-tab-item v-for="(table, index) in allTables" :key="index">
|
||||
<v-card flat>
|
||||
<DataTable :data-headers="importHeaders" :data-set="table" />
|
||||
</v-card>
|
||||
</v-tab-item>
|
||||
</v-tabs-items>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DataTable from "@/components/Admin/Backup/ImportSummaryDialog/DataTable";
|
||||
export default {
|
||||
components: {
|
||||
DataTable,
|
||||
},
|
||||
data: () => ({
|
||||
tab: null,
|
||||
dialog: false,
|
||||
recipeData: [],
|
||||
themeData: [],
|
||||
settingsData: [],
|
||||
userData: [],
|
||||
groupData: [],
|
||||
pageData: [],
|
||||
importHeaders: [
|
||||
{
|
||||
text: "Status",
|
||||
value: "status",
|
||||
},
|
||||
{
|
||||
text: "Name",
|
||||
align: "start",
|
||||
sortable: true,
|
||||
value: "name",
|
||||
},
|
||||
|
||||
{ text: "Exception", value: "data-table-expand", align: "center" },
|
||||
],
|
||||
allDataTables: [],
|
||||
}),
|
||||
|
||||
computed: {
|
||||
recipeNumbers() {
|
||||
return this.calculateNumbers(this.$t("general.recipes"), this.recipeData);
|
||||
},
|
||||
allNumbers() {
|
||||
return [this.recipeNumbers];
|
||||
},
|
||||
allTables() {
|
||||
return [this.recipeData];
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
calculateNumbers(title, list_array) {
|
||||
if (!list_array) return;
|
||||
let numbers = { title: title, success: 0, failure: 0 };
|
||||
list_array.forEach(element => {
|
||||
if (element.status) {
|
||||
numbers.success++;
|
||||
} else numbers.failure++;
|
||||
});
|
||||
return numbers;
|
||||
},
|
||||
open(importData) {
|
||||
this.recipeData = importData;
|
||||
|
||||
this.dialog = true;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
@@ -1,50 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-select
|
||||
:items="allCategories"
|
||||
v-model="selected"
|
||||
label="Categories"
|
||||
chips
|
||||
deletable-chips
|
||||
dense
|
||||
item-text="name"
|
||||
multiple
|
||||
return-object
|
||||
@input="emitChange"
|
||||
></v-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const MOUNTED_EVENT = "mounted";
|
||||
export default {
|
||||
props: {
|
||||
value: Array,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selected: [],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$emit(MOUNTED_EVENT);
|
||||
},
|
||||
|
||||
computed: {
|
||||
allCategories() {
|
||||
return this.$store.getters.getAllCategories;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
emitChange() {
|
||||
this.$emit("input", this.selected);
|
||||
},
|
||||
setInit(val) {
|
||||
this.selected = val;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
129
frontend/src/components/FormHelpers/CategoryTagSelector.vue
Normal file
129
frontend/src/components/FormHelpers/CategoryTagSelector.vue
Normal file
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<v-autocomplete
|
||||
:items="activeItems"
|
||||
v-model="selected"
|
||||
:value="value"
|
||||
:label="inputLabel"
|
||||
chips
|
||||
deletable-chips
|
||||
:dense="dense"
|
||||
item-text="name"
|
||||
persistent-hint
|
||||
multiple
|
||||
:hint="hint"
|
||||
:solo="solo"
|
||||
:return-object="returnObject"
|
||||
:flat="flat"
|
||||
@input="emitChange"
|
||||
>
|
||||
<template v-slot:selection="data">
|
||||
<v-chip
|
||||
class="ma-1"
|
||||
:input-value="data.selected"
|
||||
close
|
||||
@click:close="removeByIndex(data.index)"
|
||||
label
|
||||
color="accent"
|
||||
dark
|
||||
:key="data.index"
|
||||
>
|
||||
{{ data.item.name || data.item }}
|
||||
</v-chip>
|
||||
</template>
|
||||
<template v-slot:append-outer="">
|
||||
<NewCategoryTagDialog
|
||||
v-if="showAdd"
|
||||
:tag-dialog="tagSelector"
|
||||
@created-item="pushToItem"
|
||||
/>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import NewCategoryTagDialog from "@/components/UI/Dialogs/NewCategoryTagDialog";
|
||||
const MOUNTED_EVENT = "mounted";
|
||||
export default {
|
||||
components: {
|
||||
NewCategoryTagDialog,
|
||||
},
|
||||
props: {
|
||||
value: Array,
|
||||
solo: {
|
||||
default: false,
|
||||
},
|
||||
dense: {
|
||||
default: true,
|
||||
},
|
||||
returnObject: {
|
||||
default: true,
|
||||
},
|
||||
tagSelector: {
|
||||
default: false,
|
||||
},
|
||||
hint: {
|
||||
default: null,
|
||||
},
|
||||
showAdd: {
|
||||
default: false,
|
||||
},
|
||||
showLabel: {
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selected: [],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.$emit(MOUNTED_EVENT);
|
||||
this.setInit(this.value);
|
||||
},
|
||||
|
||||
watch: {
|
||||
value(val) {
|
||||
this.selected = val;
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
inputLabel() {
|
||||
if (!this.showLabel) return null;
|
||||
return this.tagSelector ? this.$t('recipe.tags') : this.$t('recipe.categories');
|
||||
},
|
||||
activeItems() {
|
||||
let ItemObjects = [];
|
||||
if (this.tagSelector) ItemObjects = this.$store.getters.getAllTags;
|
||||
else {
|
||||
ItemObjects = this.$store.getters.getAllCategories;
|
||||
}
|
||||
if (this.returnObject) return ItemObjects;
|
||||
else {
|
||||
return ItemObjects.map(x => x.name);
|
||||
}
|
||||
},
|
||||
flat() {
|
||||
return this.selected.length > 0 && this.solo;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
emitChange() {
|
||||
this.$emit("input", this.selected);
|
||||
},
|
||||
setInit(val) {
|
||||
this.selected = val;
|
||||
},
|
||||
removeByIndex(index) {
|
||||
this.selected.splice(index, 1);
|
||||
},
|
||||
pushToItem(createdItem) {
|
||||
createdItem = this.returnObject ? createdItem : createdItem.name;
|
||||
this.selected.push(createdItem);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
@@ -22,13 +22,11 @@
|
||||
<v-text-field
|
||||
v-if="!options.isLoggingIn"
|
||||
v-model="user.name"
|
||||
light="light"
|
||||
prepend-icon="person"
|
||||
:label="$t('general.name')"
|
||||
></v-text-field>
|
||||
<v-text-field
|
||||
v-model="user.email"
|
||||
light="light"
|
||||
prepend-icon="mdi-email"
|
||||
validate-on-blur
|
||||
:label="$t('user.email')"
|
||||
@@ -36,7 +34,6 @@
|
||||
></v-text-field>
|
||||
<v-text-field
|
||||
v-model="user.password"
|
||||
light="light"
|
||||
class="mb-2s"
|
||||
prepend-icon="mdi-lock"
|
||||
:label="$t('user.password')"
|
||||
@@ -47,7 +44,6 @@
|
||||
<v-card-actions>
|
||||
<v-btn
|
||||
v-if="options.isLoggingIn"
|
||||
dark
|
||||
color="primary"
|
||||
block="block"
|
||||
type="submit"
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import utils from "@/utils";
|
||||
import SearchDialog from "../UI/Search/SearchDialog";
|
||||
import { api } from "@/api";
|
||||
export default {
|
||||
components: {
|
||||
SearchDialog,
|
||||
@@ -47,7 +47,7 @@ export default {
|
||||
methods: {
|
||||
getImage(slug) {
|
||||
if (slug) {
|
||||
return utils.getImageURL(slug);
|
||||
return api.recipes.recipeSmallImage(slug);
|
||||
}
|
||||
},
|
||||
setSlug(name, slug) {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-card-title class="headline">
|
||||
<v-card-title class=" headline">
|
||||
{{ $t("meal-plan.create-a-new-meal-plan") }}
|
||||
<v-btn color="info" class="ml-auto" @click="setQuickWeek()">
|
||||
<v-icon left>mdi-calendar-minus</v-icon> Quick Week
|
||||
</v-btn>
|
||||
</v-card-title>
|
||||
|
||||
<v-divider></v-divider>
|
||||
<v-card-text>
|
||||
<v-row dense>
|
||||
@@ -101,6 +105,7 @@ export default {
|
||||
endDate: null,
|
||||
menu1: false,
|
||||
menu2: false,
|
||||
usedRecipes: [1],
|
||||
};
|
||||
},
|
||||
|
||||
@@ -115,17 +120,14 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
groupSettings() {
|
||||
this.buildMealStore();
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
this.$store.dispatch("requestCurrentGroup");
|
||||
await this.$store.dispatch("requestCurrentGroup");
|
||||
await this.buildMealStore();
|
||||
},
|
||||
|
||||
computed: {
|
||||
groupSettings() {
|
||||
console.log(this.$store.getters.getCurrentGroup);
|
||||
return this.$store.getters.getCurrentGroup;
|
||||
},
|
||||
actualStartDate() {
|
||||
@@ -152,11 +154,15 @@ export default {
|
||||
endComputedDateFormatted() {
|
||||
return this.formatDate(this.endDate);
|
||||
},
|
||||
filteredRecipes() {
|
||||
const recipes = this.items.filter(x => !this.usedRecipes.includes(x));
|
||||
return recipes.length > 0 ? recipes : this.items;
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
async buildMealStore() {
|
||||
let categories = Array.from(this.groupSettings.categories, x => x.name);
|
||||
const categories = Array.from(this.groupSettings.categories, x => x.name);
|
||||
this.items = await api.recipes.getAllByCategory(categories);
|
||||
|
||||
if (this.items.length === 0) {
|
||||
@@ -171,15 +177,20 @@ export default {
|
||||
this.items = await api.recipes.allByKeys(keys);
|
||||
}
|
||||
},
|
||||
get_random(list) {
|
||||
const object = list[Math.floor(Math.random() * list.length)];
|
||||
return object;
|
||||
getRandom(list) {
|
||||
let recipe = 1;
|
||||
while (this.usedRecipes.includes(recipe)) {
|
||||
recipe = list[Math.floor(Math.random() * list.length)];
|
||||
}
|
||||
return recipe;
|
||||
},
|
||||
random() {
|
||||
this.usedRecipes = [1];
|
||||
this.meals.forEach((element, index) => {
|
||||
let recipe = this.get_random(this.items);
|
||||
let recipe = this.getRandom(this.filteredRecipes);
|
||||
this.meals[index]["slug"] = recipe.slug;
|
||||
this.meals[index]["name"] = recipe.name;
|
||||
this.usedRecipes.push(recipe);
|
||||
});
|
||||
},
|
||||
processTime(index) {
|
||||
@@ -212,7 +223,7 @@ export default {
|
||||
},
|
||||
|
||||
getImage(image) {
|
||||
return utils.getImageURL(image);
|
||||
return api.recipes.recipeSmallImage(image);
|
||||
},
|
||||
|
||||
formatDate(date) {
|
||||
@@ -227,6 +238,33 @@ export default {
|
||||
const [month, day, year] = date.split("/");
|
||||
return `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
||||
},
|
||||
getNextDayOfTheWeek(dayName, excludeToday = true, refDate = new Date()) {
|
||||
const dayOfWeek = [
|
||||
"sun",
|
||||
"mon",
|
||||
"tue",
|
||||
"wed",
|
||||
"thu",
|
||||
"fri",
|
||||
"sat",
|
||||
].indexOf(dayName.slice(0, 3).toLowerCase());
|
||||
if (dayOfWeek < 0) return;
|
||||
refDate.setHours(0, 0, 0, 0);
|
||||
refDate.setDate(
|
||||
refDate.getDate() +
|
||||
+!!excludeToday +
|
||||
((dayOfWeek + 7 - refDate.getDay() - +!!excludeToday) % 7)
|
||||
);
|
||||
return refDate;
|
||||
},
|
||||
setQuickWeek() {
|
||||
const nextMonday = this.getNextDayOfTheWeek("Monday", false);
|
||||
const nextEndDate = new Date(nextMonday);
|
||||
nextEndDate.setDate(nextEndDate.getDate() + 4);
|
||||
|
||||
this.startDate = nextMonday.toISOString().substr(0, 10);
|
||||
this.endDate = nextEndDate.toISOString().substr(0, 10);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
<template>
|
||||
<v-card hover :to="`/recipe/${slug}`" max-height="125">
|
||||
<v-card
|
||||
hover
|
||||
:to="`/recipe/${slug}`"
|
||||
max-height="125"
|
||||
@click="$emit('selected')"
|
||||
>
|
||||
<v-list-item>
|
||||
<v-list-item-avatar rounded size="125" class="mt-0 ml-n4">
|
||||
<v-img :src="getImage(image)"> </v-img>
|
||||
<v-img :src="getImage(slug)"> </v-img>
|
||||
</v-list-item-avatar>
|
||||
<v-list-item-content class="align-self-start">
|
||||
<v-list-item-title>
|
||||
@@ -20,7 +25,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import utils from "@/utils";
|
||||
import { api } from "@/api";
|
||||
export default {
|
||||
props: {
|
||||
name: String,
|
||||
@@ -35,7 +40,7 @@ export default {
|
||||
|
||||
methods: {
|
||||
getImage(image) {
|
||||
return utils.getImageURL(image);
|
||||
return api.recipes.recipeSmallImage(image);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
:elevation="hover ? 12 : 2"
|
||||
:to="route ? `/recipe/${slug}` : ''"
|
||||
@click="$emit('click')"
|
||||
min-height="275"
|
||||
>
|
||||
<v-img height="200" :src="getImage(image)">
|
||||
<v-img height="200" :src="getImage(slug)">
|
||||
<v-expand-transition v-if="description">
|
||||
<div
|
||||
v-if="hover"
|
||||
@@ -25,43 +26,53 @@
|
||||
</div>
|
||||
</v-card-title>
|
||||
|
||||
<v-card-actions class="">
|
||||
<v-row dense align="center">
|
||||
<v-col>
|
||||
<v-rating
|
||||
class="mr-2"
|
||||
color="secondary"
|
||||
background-color="secondary lighten-3"
|
||||
dense
|
||||
length="5"
|
||||
size="15"
|
||||
:value="rating"
|
||||
></v-rating>
|
||||
</v-col>
|
||||
<v-col></v-col>
|
||||
<v-col align="end"> </v-col>
|
||||
</v-row>
|
||||
<v-card-actions>
|
||||
<v-rating
|
||||
class="mr-2 my-auto"
|
||||
color="secondary"
|
||||
background-color="secondary lighten-3"
|
||||
dense
|
||||
length="5"
|
||||
size="15"
|
||||
:value="rating"
|
||||
></v-rating>
|
||||
<v-spacer></v-spacer>
|
||||
<RecipeChips
|
||||
:items="tags"
|
||||
:title="false"
|
||||
:limit="2"
|
||||
:small="true"
|
||||
:isCategory="false"
|
||||
/>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-hover>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import utils from "@/utils";
|
||||
import RecipeChips from "@/components/Recipe/RecipeViewer/RecipeChips";
|
||||
import { api } from "@/api";
|
||||
export default {
|
||||
components: {
|
||||
RecipeChips,
|
||||
},
|
||||
props: {
|
||||
name: String,
|
||||
slug: String,
|
||||
description: String,
|
||||
rating: Number,
|
||||
image: String,
|
||||
|
||||
route: {
|
||||
default: true,
|
||||
},
|
||||
tags: {
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getImage(image) {
|
||||
return utils.getImageURL(image);
|
||||
return api.recipes.recipeSmallImage(image);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div class="text-center">
|
||||
<v-menu offset-y top nudge-top="6" :close-on-content-click="false">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-btn color="accent" dark v-bind="attrs" v-on="on">
|
||||
Image
|
||||
</v-btn>
|
||||
</template>
|
||||
<v-card width="400">
|
||||
<v-card-title class="headline flex mb-0">
|
||||
<div>
|
||||
Recipe Image
|
||||
</div>
|
||||
<UploadBtn
|
||||
class="ml-auto"
|
||||
url="none"
|
||||
file-name="image"
|
||||
:text-btn="false"
|
||||
@uploaded="uploadImage"
|
||||
/>
|
||||
</v-card-title>
|
||||
<v-card-text class="mt-n5">
|
||||
<div>
|
||||
<v-text-field label="URL" class="pt-5" clearable v-model="url">
|
||||
<template v-slot:append-outer>
|
||||
<v-btn
|
||||
class="ml-2"
|
||||
color="primary"
|
||||
@click="getImageFromURL"
|
||||
:loading="loading"
|
||||
>
|
||||
Get
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-text-field>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-menu>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const REFRESH_EVENT = "refresh";
|
||||
const UPLOAD_EVENT = "upload";
|
||||
import UploadBtn from "@/components/UI/UploadBtn";
|
||||
import { api } from "@/api";
|
||||
// import axios from "axios";
|
||||
export default {
|
||||
components: {
|
||||
UploadBtn,
|
||||
},
|
||||
props: {
|
||||
slug: String,
|
||||
},
|
||||
data: () => ({
|
||||
items: [{ title: "Upload Image" }, { title: "From URL" }],
|
||||
url: "",
|
||||
loading: false,
|
||||
}),
|
||||
methods: {
|
||||
uploadImage(fileObject) {
|
||||
this.$emit(UPLOAD_EVENT, fileObject);
|
||||
},
|
||||
async getImageFromURL() {
|
||||
this.loading = true;
|
||||
const response = await api.recipes.updateImagebyURL(this.slug, this.url);
|
||||
if (response) this.$emit(REFRESH_EVENT);
|
||||
this.loading = false;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
@@ -0,0 +1,81 @@
|
||||
<template>
|
||||
<div v-if="valueNotNull || edit">
|
||||
<h2 class="my-4">Nutrition</h2>
|
||||
<div v-if="edit">
|
||||
<div v-for="(item, key, index) in value" :key="index">
|
||||
<v-text-field
|
||||
dense
|
||||
:value="value[key]"
|
||||
:label="labels[key].label"
|
||||
:suffix="labels[key].suffix"
|
||||
type="number"
|
||||
autocomplete="off"
|
||||
@input="updateValue(key, $event)"
|
||||
></v-text-field>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="showViewer">
|
||||
<v-list dense>
|
||||
<v-list-item-group color="primary">
|
||||
<v-list-item v-for="(item, key, index) in labels" :key="index">
|
||||
<v-list-item-content>
|
||||
<v-list-item-title class="pl-4 text-subtitle-1 flex row ">
|
||||
<div>{{ item.label }}</div>
|
||||
<div class="ml-auto mr-1">{{ value[key] }}</div>
|
||||
<div>{{ item.suffix }}</div>
|
||||
</v-list-item-title>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
</v-list-item-group>
|
||||
</v-list>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
value: {},
|
||||
edit: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
labels: {
|
||||
calories: {
|
||||
label: "Calories",
|
||||
suffix: "calories",
|
||||
},
|
||||
fatContent: { label: "Fat Content", suffix: "grams" },
|
||||
fiberContent: { label: "Fiber Content", suffix: "grams" },
|
||||
proteinContent: { label: "Protein Content", suffix: "grams" },
|
||||
sodiumContent: { label: "Sodium Content", suffix: "milligrams" },
|
||||
sugarContent: { label: "Sugar Content", suffix: "grams" },
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
showViewer() {
|
||||
return !this.edit && this.valueNotNull;
|
||||
},
|
||||
valueNotNull() {
|
||||
for (const property in this.value) {
|
||||
const valueProperty = this.value[property];
|
||||
if (valueProperty && valueProperty !== "") return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
updateValue(key, value) {
|
||||
this.$emit("input", { ...this.value, [key]: value });
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
@@ -2,16 +2,12 @@
|
||||
<v-form ref="form">
|
||||
<v-card-text>
|
||||
<v-row dense>
|
||||
<v-col cols="3"></v-col>
|
||||
<v-col>
|
||||
<v-file-input
|
||||
v-model="fileObject"
|
||||
:label="$t('general.image-file')"
|
||||
truncate-length="30"
|
||||
@change="uploadImage"
|
||||
></v-file-input>
|
||||
</v-col>
|
||||
<v-col cols="3"></v-col>
|
||||
<ImageUploadBtn
|
||||
class="mt-2"
|
||||
@upload="uploadImage"
|
||||
:slug="value.slug"
|
||||
@refresh="$emit('upload')"
|
||||
/>
|
||||
</v-row>
|
||||
<v-row dense>
|
||||
<v-col>
|
||||
@@ -83,14 +79,16 @@
|
||||
:key="generateKey('ingredient', index)"
|
||||
>
|
||||
<v-row align="center">
|
||||
<v-text-field
|
||||
<v-textarea
|
||||
class="mr-2"
|
||||
:label="$t('recipe.ingredient')"
|
||||
v-model="value.recipeIngredient[index]"
|
||||
append-outer-icon="mdi-menu"
|
||||
mdi-move-resize
|
||||
auto-grow
|
||||
solo
|
||||
dense
|
||||
rows="1"
|
||||
>
|
||||
<v-icon
|
||||
class="mr-n1"
|
||||
@@ -100,7 +98,7 @@
|
||||
>
|
||||
mdi-delete
|
||||
</v-icon>
|
||||
</v-text-field>
|
||||
</v-textarea>
|
||||
</v-row>
|
||||
</div>
|
||||
</transition-group>
|
||||
@@ -112,60 +110,21 @@
|
||||
<BulkAdd @bulk-data="appendIngredients" />
|
||||
|
||||
<h2 class="mt-6">{{ $t("recipe.categories") }}</h2>
|
||||
<v-combobox
|
||||
dense
|
||||
multiple
|
||||
chips
|
||||
item-color="secondary"
|
||||
deletable-chips
|
||||
<CategoryTagSelector
|
||||
:return-object="false"
|
||||
v-model="value.recipeCategory"
|
||||
hide-selected
|
||||
:items="allCategories"
|
||||
text="name"
|
||||
:search-input.sync="categoriesSearchInput"
|
||||
@change="categoriesSearchInput = ''"
|
||||
>
|
||||
<template v-slot:selection="data">
|
||||
<v-chip
|
||||
class="ma-1"
|
||||
:input-value="data.selected"
|
||||
close
|
||||
@click:close="removeCategory(data.index)"
|
||||
label
|
||||
color="accent"
|
||||
dark
|
||||
>
|
||||
{{ data.item }}
|
||||
</v-chip>
|
||||
</template>
|
||||
</v-combobox>
|
||||
:show-add="true"
|
||||
:show-label="false"
|
||||
/>
|
||||
|
||||
<h2 class="mt-4">{{ $t("recipe.tags") }}</h2>
|
||||
<v-combobox
|
||||
dense
|
||||
multiple
|
||||
chips
|
||||
deletable-chips
|
||||
<CategoryTagSelector
|
||||
:return-object="false"
|
||||
v-model="value.tags"
|
||||
hide-selected
|
||||
:items="allTags"
|
||||
:search-input.sync="tagsSearchInput"
|
||||
@change="tagssSearchInput = ''"
|
||||
>
|
||||
<template v-slot:selection="data">
|
||||
<v-chip
|
||||
class="ma-1"
|
||||
:input-value="data.selected"
|
||||
close
|
||||
label
|
||||
@click:close="removeTags(data.index)"
|
||||
color="accent"
|
||||
dark
|
||||
>
|
||||
{{ data.item }}
|
||||
</v-chip>
|
||||
</template>
|
||||
</v-combobox>
|
||||
:show-add="true"
|
||||
:tag-selector="true"
|
||||
:show-label="false"
|
||||
/>
|
||||
|
||||
<h2 class="my-4">{{ $t("recipe.notes") }}</h2>
|
||||
<v-card
|
||||
@@ -202,6 +161,7 @@
|
||||
<v-btn class="mt-1" color="secondary" fab dark small @click="addNote">
|
||||
<v-icon>mdi-plus</v-icon>
|
||||
</v-btn>
|
||||
<NutritionEditor v-model="value.nutrition" :edit="true" />
|
||||
<ExtrasEditor :extras="value.extras" @save="saveExtras" />
|
||||
</v-col>
|
||||
|
||||
@@ -235,6 +195,7 @@
|
||||
dense
|
||||
v-model="value.recipeInstructions[index]['text']"
|
||||
:key="generateKey('instructions', index)"
|
||||
rows="4"
|
||||
>
|
||||
</v-textarea>
|
||||
</v-card-text>
|
||||
@@ -258,15 +219,20 @@
|
||||
|
||||
<script>
|
||||
import draggable from "vuedraggable";
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
import BulkAdd from "./BulkAdd";
|
||||
import ExtrasEditor from "./ExtrasEditor";
|
||||
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
||||
import NutritionEditor from "./NutritionEditor";
|
||||
import ImageUploadBtn from "./ImageUploadBtn.vue";
|
||||
export default {
|
||||
components: {
|
||||
BulkAdd,
|
||||
ExtrasEditor,
|
||||
draggable,
|
||||
CategoryTagSelector,
|
||||
NutritionEditor,
|
||||
ImageUploadBtn,
|
||||
},
|
||||
props: {
|
||||
value: Object,
|
||||
@@ -282,27 +248,11 @@ export default {
|
||||
v.split(" ").length <= 1 ||
|
||||
this.$i18n.t("recipe.no-white-space-allowed"),
|
||||
},
|
||||
categoriesSearchInput: "",
|
||||
tagsSearchInput: "",
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
allCategories() {
|
||||
const categories = this.$store.getters.getAllCategories;
|
||||
return categories.map(cat => cat.name);
|
||||
},
|
||||
allTags() {
|
||||
const tags = this.$store.getters.getAllTags;
|
||||
return tags.map(cat => cat.name);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
uploadImage() {
|
||||
this.$emit("upload", this.fileObject);
|
||||
},
|
||||
async updateImage() {
|
||||
let slug = this.value.slug;
|
||||
api.recipes.updateImage(slug, this.fileObject);
|
||||
uploadImage(fileObject) {
|
||||
this.$emit("upload", fileObject);
|
||||
},
|
||||
toggleDisabled(stepIndex) {
|
||||
if (this.disabledSteps.includes(stepIndex)) {
|
||||
@@ -324,9 +274,6 @@ export default {
|
||||
generateKey(item, index) {
|
||||
return utils.generateUniqueKey(item, index);
|
||||
},
|
||||
deleteRecipe() {
|
||||
this.$emit("delete");
|
||||
},
|
||||
|
||||
appendIngredients(ingredients) {
|
||||
this.value.recipeIngredient.push(...ingredients);
|
||||
|
||||
@@ -162,6 +162,7 @@
|
||||
|
||||
<script>
|
||||
import utils from "@/utils";
|
||||
import { api } from "@/api";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -175,7 +176,7 @@ export default {
|
||||
methods: {
|
||||
getImage(image) {
|
||||
if (image) {
|
||||
return utils.getImageURL(image) + "?rnd=" + this.imageKey;
|
||||
return api.recipes.recipeImage(image) + "?rnd=" + this.imageKey;
|
||||
}
|
||||
},
|
||||
generateKey(item, index) {
|
||||
|
||||
@@ -1,27 +1,53 @@
|
||||
<template>
|
||||
<div>
|
||||
<h2 class="mb-4">{{ $t("recipe.ingredients") }}</h2>
|
||||
<div
|
||||
v-for="(ingredient, index) in ingredients"
|
||||
<v-list-item
|
||||
dense
|
||||
v-for="(ingredient, index) in displayIngredients"
|
||||
:key="generateKey('ingredient', index)"
|
||||
@click="ingredient.checked = !ingredient.checked"
|
||||
>
|
||||
<v-checkbox
|
||||
hide-details
|
||||
class="ingredients"
|
||||
:label="ingredient"
|
||||
v-model="ingredient.checked"
|
||||
class="pt-0 my-auto py-auto"
|
||||
color="secondary"
|
||||
:readonly="true"
|
||||
>
|
||||
</v-checkbox>
|
||||
</div>
|
||||
|
||||
<v-list-item-content>
|
||||
<vue-markdown
|
||||
class="ma-0 pa-0 text-subtitle-1 dense-markdown"
|
||||
:source="ingredient.text"
|
||||
>
|
||||
</vue-markdown>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import VueMarkdown from "@adapttive/vue-markdown";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
components: {
|
||||
VueMarkdown,
|
||||
},
|
||||
props: {
|
||||
ingredients: Array,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
displayIngredients: [],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.displayIngredients = this.ingredients.map(x => ({
|
||||
text: x,
|
||||
checked: false,
|
||||
}));
|
||||
},
|
||||
methods: {
|
||||
generateKey(item, index) {
|
||||
return utils.generateUniqueKey(item, index);
|
||||
@@ -30,5 +56,8 @@ export default {
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
<style >
|
||||
.dense-markdown p {
|
||||
margin: auto !important;
|
||||
}
|
||||
</style>
|
||||
@@ -1,13 +1,14 @@
|
||||
<template>
|
||||
<div v-if="items && items.length > 0">
|
||||
<h2 class="mt-4">{{ title }}</h2>
|
||||
<div v-if="items.length > 0">
|
||||
<h2 v-if="title" class="mt-4">{{ title }}</h2>
|
||||
<v-chip
|
||||
:to="`/recipes/${getSlug(category)}`"
|
||||
label
|
||||
class="ma-1"
|
||||
color="accent"
|
||||
:small="small"
|
||||
dark
|
||||
v-for="category in items"
|
||||
v-for="category in items.slice(0, limit)"
|
||||
:to="`/recipes/${urlParam}/${getSlug(category)}`"
|
||||
:key="category"
|
||||
>
|
||||
{{ category }}
|
||||
@@ -18,21 +19,43 @@
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
items: Array,
|
||||
title: String,
|
||||
category: {
|
||||
items: {
|
||||
default: [],
|
||||
},
|
||||
title: {
|
||||
default: null,
|
||||
},
|
||||
isCategory: {
|
||||
default: true,
|
||||
},
|
||||
limit: {
|
||||
default: 999,
|
||||
},
|
||||
small: {
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
allCategories() {
|
||||
return this.$store.getters.getAllCategories;
|
||||
},
|
||||
allTags() {
|
||||
return this.$store.getters.getAllTags;
|
||||
},
|
||||
urlParam() {
|
||||
return this.isCategory ? "category" : "tag";
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getSlug(name) {
|
||||
if (this.category) {
|
||||
return this.allCategories.filter(x => x.name == name)[0].slug;
|
||||
if (!name) return;
|
||||
|
||||
if (this.isCategory) {
|
||||
const matches = this.allCategories.filter(x => x.name == name);
|
||||
if (matches.length > 0) return matches[0].slug;
|
||||
} else {
|
||||
const matches = this.allTags.filter(x => x.name == name);
|
||||
if (matches.length > 0) return matches[0].slug;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -34,8 +34,13 @@
|
||||
<Ingredients :ingredients="ingredients" />
|
||||
<div v-if="medium">
|
||||
<RecipeChips :title="$t('recipe.categories')" :items="categories" />
|
||||
<RecipeChips :title="$t('recipe.tags')" :items="tags" />
|
||||
<RecipeChips
|
||||
:title="$t('recipe.tags')"
|
||||
:items="tags"
|
||||
:isCategory="false"
|
||||
/>
|
||||
<Notes :notes="notes" />
|
||||
<NutritionEditor :value="nutrition" :edit="false" />
|
||||
</div>
|
||||
</v-col>
|
||||
<v-divider
|
||||
@@ -52,6 +57,7 @@
|
||||
<RecipeChips :title="$t('recipe.categories')" :items="categories" />
|
||||
<RecipeChips :title="$t('recipe.tags')" :items="tags" />
|
||||
<Notes :notes="notes" />
|
||||
<NutritionEditor :value="nutrition" :edit="false" />
|
||||
</div>
|
||||
<v-row class="mt-2 mb-1">
|
||||
<v-col></v-col>
|
||||
@@ -76,6 +82,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import NutritionEditor from "@/components/Recipe/RecipeEditor/NutritionEditor";
|
||||
import VueMarkdown from "@adapttive/vue-markdown";
|
||||
import utils from "@/utils";
|
||||
import RecipeChips from "./RecipeChips";
|
||||
@@ -89,6 +96,7 @@ export default {
|
||||
Steps,
|
||||
Notes,
|
||||
Ingredients,
|
||||
NutritionEditor,
|
||||
},
|
||||
props: {
|
||||
name: String,
|
||||
@@ -101,6 +109,7 @@ export default {
|
||||
rating: Number,
|
||||
yields: String,
|
||||
orgURL: String,
|
||||
nutrition: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<v-row v-if="title != null">
|
||||
<v-col>
|
||||
<v-btn-toggle group>
|
||||
<v-btn text :to="`/recipes/${title.toLowerCase()}`">
|
||||
<v-btn text>
|
||||
{{ title.toUpperCase() }}
|
||||
</v-btn>
|
||||
</v-btn-toggle>
|
||||
@@ -15,9 +15,9 @@
|
||||
<v-menu offset-y v-if="sortable">
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-btn-toggle group>
|
||||
<v-btn text v-bind="attrs" v-on="on">{{
|
||||
$t("general.sort")
|
||||
}}</v-btn>
|
||||
<v-btn text v-bind="attrs" v-on="on">
|
||||
{{ $t("general.sort") }}
|
||||
</v-btn>
|
||||
</v-btn-toggle>
|
||||
</template>
|
||||
<v-list>
|
||||
@@ -53,6 +53,7 @@
|
||||
:slug="recipe.slug"
|
||||
:rating="recipe.rating"
|
||||
:image="recipe.image"
|
||||
:tags="recipe.tags"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
@@ -51,20 +51,14 @@ export default {
|
||||
to: "/recipes/all",
|
||||
title: this.$t("page.all-recipes"),
|
||||
},
|
||||
{
|
||||
icon: "mdi-magnify",
|
||||
to: "/search",
|
||||
title: this.$t('search.search'),
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
allCategories() {
|
||||
return this.$store.getters.getCategories;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
allCategories() {
|
||||
this.buildSidebar();
|
||||
},
|
||||
showSidebar() {},
|
||||
},
|
||||
mounted() {
|
||||
this.buildSidebar();
|
||||
this.mobile = this.viewScale();
|
||||
@@ -76,14 +70,27 @@ export default {
|
||||
this.links = [];
|
||||
this.links.push(...this.baseLinks);
|
||||
const pages = await api.siteSettings.getPages();
|
||||
pages.sort((a, b) => a.position - b.position);
|
||||
pages.forEach(async element => {
|
||||
this.links.push({
|
||||
title: element.name,
|
||||
to: `/pages/${element.slug}`,
|
||||
icon: "mdi-tag",
|
||||
if(pages.length > 0) {
|
||||
pages.sort((a, b) => a.position - b.position);
|
||||
pages.forEach(async element => {
|
||||
this.links.push({
|
||||
title: element.name,
|
||||
to: `/pages/${element.slug}`,
|
||||
icon: "mdi-tag",
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
const categories = await api.categories.getAll();
|
||||
categories.forEach(async element => {
|
||||
this.links.push({
|
||||
title: element.name,
|
||||
to: `/recipes/category/${element.slug}`,
|
||||
icon: "mdi-tag",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
viewScale() {
|
||||
switch (this.$vuetify.breakpoint.name) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-btn icon @click="dialog = true">
|
||||
<v-icon color="white">mdi-plus</v-icon>
|
||||
<v-btn icon @click="dialog = true" class="mt-n1">
|
||||
<v-icon :color="color">mdi-plus</v-icon>
|
||||
</v-btn>
|
||||
<v-dialog v-model="dialog" width="500">
|
||||
<v-card>
|
||||
@@ -11,7 +11,7 @@
|
||||
</v-icon>
|
||||
|
||||
<v-toolbar-title class="headline">
|
||||
Create a Category
|
||||
{{ title }}
|
||||
</v-toolbar-title>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
@@ -21,8 +21,8 @@
|
||||
<v-card-text>
|
||||
<v-text-field
|
||||
dense
|
||||
label="Category Name"
|
||||
v-model="categoryName"
|
||||
:label="inputLabel"
|
||||
v-model="itemName"
|
||||
:rules="[rules.required]"
|
||||
></v-text-field>
|
||||
</v-card-text>
|
||||
@@ -31,7 +31,7 @@
|
||||
<v-btn color="grey" text @click="dialog = false">
|
||||
{{ $t("general.cancel") }}
|
||||
</v-btn>
|
||||
<v-btn color="success" text type="submit" :disabled="!categoryName">
|
||||
<v-btn color="success" text type="submit" :disabled="!itemName">
|
||||
{{ $t("general.create") }}
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
@@ -43,31 +43,55 @@
|
||||
|
||||
<script>
|
||||
import { api } from "@/api";
|
||||
const CREATED_ITEM_EVENT = "created-item";
|
||||
export default {
|
||||
props: {
|
||||
buttonText: String,
|
||||
value: String,
|
||||
color: {
|
||||
default: null,
|
||||
},
|
||||
tagDialog: {
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialog: false,
|
||||
categoryName: "",
|
||||
itemName: "",
|
||||
rules: {
|
||||
required: val =>
|
||||
!!val || this.$t("settings.theme.theme-name-is-required"),
|
||||
required: val => !!val || "A Name is Required",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
title() {
|
||||
return this.tagDialog ? "Create a Tag" : "Create a Category";
|
||||
},
|
||||
inputLabel() {
|
||||
return this.tagDialog ? "Tag Name" : "Category Name";
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
dialog(val) {
|
||||
if (!val) this.categoryName = "";
|
||||
if (!val) this.itemName = "";
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
async select() {
|
||||
await api.categories.create(this.categoryName);
|
||||
this.$emit("new-category", this.categoryName);
|
||||
const newItem = await (async () => {
|
||||
if (this.tagDialog) {
|
||||
const newItem = await api.tags.create(this.itemName);
|
||||
return newItem;
|
||||
} else {
|
||||
const newItem = await api.categories.create(this.itemName);
|
||||
return newItem;
|
||||
}
|
||||
})();
|
||||
|
||||
this.$emit(CREATED_ITEM_EVENT, newItem);
|
||||
this.dialog = false;
|
||||
},
|
||||
},
|
||||
@@ -16,18 +16,25 @@
|
||||
>
|
||||
</v-text-field>
|
||||
</template>
|
||||
<v-card v-if="showResults" max-height="500" :max-width="maxWidth">
|
||||
<v-card-text class="py-1">Results</v-card-text>
|
||||
<v-card v-if="showResults" max-height="500" :max-width="maxWidth">
|
||||
<v-card-text class="flex row mx-auto">
|
||||
<div class="mr-auto">
|
||||
Results
|
||||
</div>
|
||||
<router-link to="/search">
|
||||
Advanced Search
|
||||
</router-link>
|
||||
</v-card-text>
|
||||
<v-divider></v-divider>
|
||||
<v-list scrollable>
|
||||
<v-list scrollable v-if="autoResults">
|
||||
<v-list-item
|
||||
v-for="(item, index) in autoResults"
|
||||
v-for="(item, index) in autoResults.slice(0, 15)"
|
||||
:key="index"
|
||||
:to="navOnClick ? `/recipe/${item.item.slug}` : null"
|
||||
@click="navOnClick ? null : selected(item.item.slug, item.item.name)"
|
||||
>
|
||||
<v-list-item-avatar>
|
||||
<v-img :src="getImage(item.item.image)"></v-img>
|
||||
<v-img :src="getImage(item.item.slug)"></v-img>
|
||||
</v-list-item-avatar>
|
||||
<v-list-item-content
|
||||
@click="
|
||||
@@ -54,7 +61,7 @@
|
||||
|
||||
<script>
|
||||
import Fuse from "fuse.js";
|
||||
import utils from "@/utils";
|
||||
import { api } from "@/api";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -136,6 +143,7 @@ export default {
|
||||
this.fuseResults = this.result;
|
||||
}
|
||||
},
|
||||
|
||||
searchSlug() {
|
||||
this.selected(this.searchSlug);
|
||||
},
|
||||
@@ -151,10 +159,9 @@ export default {
|
||||
);
|
||||
},
|
||||
getImage(image) {
|
||||
return utils.getImageURL(image);
|
||||
return api.recipes.recipeTinyImage(image);
|
||||
},
|
||||
selected(slug, name) {
|
||||
console.log("Selected", slug, name);
|
||||
this.$emit("selected", slug, name);
|
||||
},
|
||||
async onFocus() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="text-center">
|
||||
<v-dialog v-model="dialog" width="600px" height="0">
|
||||
<div class="text-center ">
|
||||
<v-dialog v-model="dialog" width="600px" height="0" :fullscreen="isMobile">
|
||||
<v-card>
|
||||
<v-app-bar dark color="primary">
|
||||
<v-toolbar-title class="headline">Search a Recipe</v-toolbar-title>
|
||||
@@ -9,13 +9,27 @@
|
||||
<SearchBar
|
||||
@results="updateResults"
|
||||
@selected="emitSelect"
|
||||
:show-results="true"
|
||||
:show-results="!isMobile"
|
||||
max-width="550px"
|
||||
:dense="false"
|
||||
:nav-on-click="false"
|
||||
:reset-search="dialog"
|
||||
:solo="false"
|
||||
/>
|
||||
<div v-if="isMobile">
|
||||
<div v-for="recipe in searchResults.slice(0, 7)" :key="recipe.name">
|
||||
<MobileRecipeCard
|
||||
class="ma-1 px-0"
|
||||
:name="recipe.item.name"
|
||||
:description="recipe.item.description"
|
||||
:slug="recipe.item.slug"
|
||||
:rating="recipe.item.rating"
|
||||
:image="recipe.item.image"
|
||||
:route="true"
|
||||
@selected="dialog = false"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
@@ -24,16 +38,32 @@
|
||||
|
||||
<script>
|
||||
import SearchBar from "./SearchBar";
|
||||
import MobileRecipeCard from "@/components/Recipe/MobileRecipeCard";
|
||||
export default {
|
||||
components: {
|
||||
SearchBar,
|
||||
MobileRecipeCard,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
searchResults: null,
|
||||
searchResults: [],
|
||||
dialog: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return this.$vuetify.breakpoint.name === "xs";
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
"$route.hash"(newHash, oldHash) {
|
||||
if (newHash === "#mobile-search") {
|
||||
this.dialog = true;
|
||||
} else if (oldHash === "#mobile-search") {
|
||||
this.dialog = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
updateResults(results) {
|
||||
this.searchResults = results;
|
||||
@@ -44,15 +74,22 @@ export default {
|
||||
},
|
||||
open() {
|
||||
this.dialog = true;
|
||||
this.$router.push("#mobile-search");
|
||||
},
|
||||
toggleDialog(open) {
|
||||
if (open) {
|
||||
this.$router.push("#mobile-search");
|
||||
} else {
|
||||
this.$router.back(); // 😎 back button click
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.v-dialog__content {
|
||||
margin-top: 10%;
|
||||
<style scope>
|
||||
.mobile-dialog {
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
</style>
|
||||
114
frontend/src/components/UI/TheAppBar.vue
Normal file
114
frontend/src/components/UI/TheAppBar.vue
Normal file
@@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-app-bar
|
||||
v-if="!isMobile"
|
||||
clipped-left
|
||||
dense
|
||||
app
|
||||
color="primary"
|
||||
dark
|
||||
class="d-print-none"
|
||||
>
|
||||
<router-link v-if="!(isMobile && search)" to="/">
|
||||
<v-btn icon>
|
||||
<v-icon size="40"> mdi-silverware-variant </v-icon>
|
||||
</v-btn>
|
||||
</router-link>
|
||||
|
||||
<div v-if="!isMobile" btn class="pl-2">
|
||||
<v-toolbar-title style="cursor: pointer" @click="$router.push('/')"
|
||||
>Mealie
|
||||
</v-toolbar-title>
|
||||
</div>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
<v-expand-x-transition>
|
||||
<SearchBar
|
||||
ref="mainSearchBar"
|
||||
v-if="search"
|
||||
:show-results="true"
|
||||
@selected="navigateFromSearch"
|
||||
:max-width="isMobile ? '100%' : '450px'"
|
||||
/>
|
||||
</v-expand-x-transition>
|
||||
<v-btn icon @click="search = !search">
|
||||
<v-icon>mdi-magnify</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<SiteMenu />
|
||||
</v-app-bar>
|
||||
<v-app-bar
|
||||
v-else
|
||||
bottom
|
||||
clipped-left
|
||||
dense
|
||||
app
|
||||
color="primary"
|
||||
dark
|
||||
class="d-print-none"
|
||||
>
|
||||
<router-link to="/">
|
||||
<v-btn icon>
|
||||
<v-icon size="40"> mdi-silverware-variant </v-icon>
|
||||
</v-btn>
|
||||
</router-link>
|
||||
|
||||
<div v-if="!isMobile" btn class="pl-2">
|
||||
<v-toolbar-title style="cursor: pointer" @click="$router.push('/')"
|
||||
>Mealie
|
||||
</v-toolbar-title>
|
||||
</div>
|
||||
|
||||
<v-spacer></v-spacer>
|
||||
<v-expand-x-transition>
|
||||
<SearchDialog ref="mainSearchDialog" />
|
||||
</v-expand-x-transition>
|
||||
<v-btn icon @click="$refs.mainSearchDialog.open()">
|
||||
<v-icon>mdi-magnify</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<SiteMenu />
|
||||
</v-app-bar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SiteMenu from "@/components/UI/SiteMenu";
|
||||
import SearchBar from "@/components/UI/Search/SearchBar";
|
||||
import SearchDialog from "@/components/UI/Search/SearchDialog";
|
||||
import { user } from "@/mixins/user";
|
||||
export default {
|
||||
name: "AppBar",
|
||||
|
||||
mixins: [user],
|
||||
components: {
|
||||
SiteMenu,
|
||||
SearchBar,
|
||||
SearchDialog,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
search: false,
|
||||
isMobile: false,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
$route() {
|
||||
this.search = false;
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
// isMobile() {
|
||||
// return this.$vuetify.breakpoint.name === "xs";
|
||||
// },
|
||||
},
|
||||
methods: {
|
||||
navigateFromSearch(slug) {
|
||||
this.$router.push(`/recipe/${slug}`);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
51
frontend/src/components/UI/TheDownloadBtn.vue
Normal file
51
frontend/src/components/UI/TheDownloadBtn.vue
Normal file
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<v-btn color="accent" text :loading="downloading" @click="downloadFile">
|
||||
{{ showButtonText }}
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* The download button used for the entire site
|
||||
* pass a URL to the endpoint that will return a
|
||||
* file_token which will then be used to request the file
|
||||
* from the server and open that link in a new tab
|
||||
*/
|
||||
import { apiReq } from "@/api/api-utils";
|
||||
export default {
|
||||
props: {
|
||||
/**
|
||||
* URL to get token from
|
||||
*/
|
||||
downloadUrl: {
|
||||
default: "",
|
||||
},
|
||||
/**
|
||||
* Override button text. Defaults to "Download"
|
||||
*/
|
||||
buttonText: {
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
downloading: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
showButtonText() {
|
||||
return this.buttonText || this.$t("general.download");
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async downloadFile() {
|
||||
this.downloading = true;
|
||||
await apiReq.download(this.downloadUrl);
|
||||
this.downloading = false;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
@@ -1,7 +1,12 @@
|
||||
<template>
|
||||
<v-form ref="file">
|
||||
<input ref="uploader" class="d-none" type="file" @change="onFileChanged" />
|
||||
<v-btn :loading="isSelecting" @click="onButtonClick" color="accent" text>
|
||||
<v-btn
|
||||
:loading="isSelecting"
|
||||
@click="onButtonClick"
|
||||
color="accent"
|
||||
:text="textBtn"
|
||||
>
|
||||
<v-icon left> {{ icon }}</v-icon>
|
||||
{{ text ? text : defaultText }}
|
||||
</v-btn>
|
||||
@@ -13,10 +18,17 @@ const UPLOAD_EVENT = "uploaded";
|
||||
import { api } from "@/api";
|
||||
export default {
|
||||
props: {
|
||||
post: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
url: String,
|
||||
text: { default: "Upload" },
|
||||
icon: { default: "mdi-cloud-upload" },
|
||||
fileName: { default: "archive" },
|
||||
textBtn: {
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
data: () => ({
|
||||
file: null,
|
||||
@@ -33,6 +45,12 @@ export default {
|
||||
async upload() {
|
||||
if (this.file != null) {
|
||||
this.isSelecting = true;
|
||||
|
||||
if (this.post) {
|
||||
this.$emit(UPLOAD_EVENT, this.file);
|
||||
this.isSelecting = false;
|
||||
return;
|
||||
}
|
||||
let formData = new FormData();
|
||||
formData.append(this.fileName, this.file);
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
"groups": "Gruppen",
|
||||
"could-not-validate-credentials": "Anmeldeinformationen konnten nicht validiert werden",
|
||||
"login": "Anmeldung",
|
||||
"groups-can-only-be-set-by-administrators": "Groups can only be set by administrators",
|
||||
"groups-can-only-be-set-by-administrators": "Gruppen können nur durch einen Administrator gesetzt werden",
|
||||
"upload-photo": "Foto hochladen",
|
||||
"reset-password": "Passwort zurücksetzen",
|
||||
"current-password": "Aktuelles Passwort",
|
||||
|
||||
@@ -48,7 +48,8 @@
|
||||
"apply": "Apply",
|
||||
"current-parenthesis": "(Current)",
|
||||
"users": "Users",
|
||||
"groups": "Groups"
|
||||
"groups": "Groups",
|
||||
"about": "About"
|
||||
},
|
||||
"page": {
|
||||
"home-page": "Home Page",
|
||||
@@ -145,7 +146,16 @@
|
||||
"delete-confirmation": "Are you sure you want to delete this recipe?"
|
||||
},
|
||||
"search": {
|
||||
"search-mealie": "Search Mealie"
|
||||
"search-mealie": "Search Mealie",
|
||||
"search-placeholder": "Search...",
|
||||
"max-results": "Max Results",
|
||||
"category-filter": "Category Filter",
|
||||
"tag-filter": "Tag Filter",
|
||||
"include": "Include",
|
||||
"exclude": "Exclude",
|
||||
"and": "And",
|
||||
"or": "Or",
|
||||
"search": "Search"
|
||||
},
|
||||
"settings": {
|
||||
"general-settings": "General Settings",
|
||||
@@ -215,7 +225,11 @@
|
||||
"site-settings": "Site Settings",
|
||||
"manage-users": "Manage Users",
|
||||
"migrations": "Migrations",
|
||||
"profile": "Profile"
|
||||
"profile": "Profile",
|
||||
"custom-pages": "Custom Pages",
|
||||
"new-page": "New Page",
|
||||
"edit-page": "Edit Page",
|
||||
"page-name": "Page Name"
|
||||
},
|
||||
"migration": {
|
||||
"recipe-migration": "Recipe Migration",
|
||||
|
||||
@@ -46,7 +46,10 @@
|
||||
"token": "Jeton",
|
||||
"field-required": "Champ obligatoire",
|
||||
"apply": "Appliquer",
|
||||
"current-parenthesis": "(Actuel)"
|
||||
"current-parenthesis": "(Actuel)",
|
||||
"groups": "Groupes",
|
||||
"users": "Utilisateurs",
|
||||
"about": "À propos"
|
||||
},
|
||||
"page": {
|
||||
"home-page": "Accueil",
|
||||
@@ -120,7 +123,7 @@
|
||||
"categories": "Catégories",
|
||||
"tags": "Tags",
|
||||
"instructions": "Instructions",
|
||||
"step-index": "Etape: {step}",
|
||||
"step-index": "Étape : {step}",
|
||||
"recipe-name": "Nom de la recette",
|
||||
"servings": "Portions",
|
||||
"ingredient": "Ingrédient",
|
||||
@@ -143,7 +146,16 @@
|
||||
"delete-confirmation": "Êtes-vous sûr(e) de vouloir supprimer cette recette ?"
|
||||
},
|
||||
"search": {
|
||||
"search-mealie": "Rechercher dans Mealie"
|
||||
"search-mealie": "Rechercher dans Mealie",
|
||||
"search-placeholder": "Rechercher...",
|
||||
"and": "Et",
|
||||
"category-filter": "Filtre par catégories",
|
||||
"exclude": "Exclure",
|
||||
"include": "Inclure",
|
||||
"max-results": "Résultats max",
|
||||
"or": "Ou",
|
||||
"tag-filter": "Filtre par tags",
|
||||
"search": "Rechercher"
|
||||
},
|
||||
"settings": {
|
||||
"general-settings": "Paramètres généraux",
|
||||
@@ -185,7 +197,7 @@
|
||||
},
|
||||
"webhooks": {
|
||||
"meal-planner-webhooks": "Webhooks du planificateur de repas",
|
||||
"the-urls-listed-below-will-recieve-webhooks-containing-the-recipe-data-for-the-meal-plan-on-its-scheduled-day-currently-webhooks-will-execute-at": "Les liens dans cette liste recevront les webhooks contenant les recettes pour le plan de menu du jour défini. Actuellement, les webhooks s'executeront à <strong>{ time }</strong>",
|
||||
"the-urls-listed-below-will-recieve-webhooks-containing-the-recipe-data-for-the-meal-plan-on-its-scheduled-day-currently-webhooks-will-execute-at": "Les liens dans cette liste recevront les webhooks contenant les recettes pour le plan de menu du jour défini. Actuellement, les webhooks s'exécuteront à",
|
||||
"test-webhooks": "Tester les webhooks",
|
||||
"webhook-url": "Lien du webhook"
|
||||
},
|
||||
@@ -213,7 +225,11 @@
|
||||
"manage-users": "Utilisateurs",
|
||||
"migrations": "Migrations",
|
||||
"profile": "Profil",
|
||||
"site-settings": "Paramètres site"
|
||||
"site-settings": "Paramètres site",
|
||||
"custom-pages": "Pages personnalisées",
|
||||
"edit-page": "Modifier la page",
|
||||
"new-page": "Nouvelle page",
|
||||
"page-name": "Nom de la page"
|
||||
},
|
||||
"migration": {
|
||||
"recipe-migration": "Migrer les recettes",
|
||||
|
||||
160
frontend/src/locales/pt-PT.json
Normal file
160
frontend/src/locales/pt-PT.json
Normal file
@@ -0,0 +1,160 @@
|
||||
{
|
||||
"404": {
|
||||
"page-not-found": "404 Página não encontrada",
|
||||
"take-me-home": "Voltar ao início"
|
||||
},
|
||||
"new-recipe": {
|
||||
"from-url": "Do URL",
|
||||
"recipe-url": "URL da Receita",
|
||||
"error-message": "Ocorreu um erro ao ler o URL. Verifica os registos e o debug/last_recipe.json para perceber o que correu mal." ,
|
||||
"bulk-add": "Adicionar Vários",
|
||||
"paste-in-your-recipe-data-each-line-will-be-treated-as-an-item-in-a-list": "Insira os dados da sua receita. Cada linha será tratada como um item numa lista."
|
||||
},
|
||||
"general": {
|
||||
"upload": "Enviar",
|
||||
"submit": "Submeter",
|
||||
"name": "Nome",
|
||||
"settings": "Definições",
|
||||
"close": "Fechar",
|
||||
"save": "Guardar",
|
||||
"image-file": "Ficheiro de Imagem",
|
||||
"update": "Atualizar",
|
||||
"edit": "Editar",
|
||||
"delete": "Eliminar",
|
||||
"select": "Seleccionar",
|
||||
"random": "Aleatório",
|
||||
"new": "Novo",
|
||||
"create": "Criar",
|
||||
"cancel": "Cancelar",
|
||||
"ok": "OK",
|
||||
"enabled": "Ativado",
|
||||
"download": "Transferir",
|
||||
"import": "Importar",
|
||||
"options": "Opções",
|
||||
"templates": "Templates",
|
||||
"recipes": "Receitas",
|
||||
"themes": "Temas",
|
||||
"confirm": "Confirmar"
|
||||
},
|
||||
"login": {
|
||||
"stay-logged-in": "Manter a sessão iniciada?",
|
||||
"email": "Email",
|
||||
"password": "Password",
|
||||
"sign-in": "Iniciar Sessão",
|
||||
"sign-up": "Criar Conta"
|
||||
},
|
||||
"meal-plan": {
|
||||
"shopping-list": "Lista de Compras",
|
||||
"dinner-this-week": "Jantar esta semana",
|
||||
"meal-planner": "Planeador de Refeições",
|
||||
"dinner-today": "Jantar Hoje",
|
||||
"planner": "Planeador",
|
||||
"edit-meal-plan": "Editar Plano de Refeições",
|
||||
"meal-plans": "Planos de Refeições",
|
||||
"create-a-new-meal-plan": "Criar novo Plano de Refeições",
|
||||
"start-date": "Data de Inicio",
|
||||
"end-date": "Data de Fim"
|
||||
},
|
||||
"recipe": {
|
||||
"description": "Descrição",
|
||||
"ingredients": "Ingredientes",
|
||||
"categories": "Categorias",
|
||||
"tags": "Etiquetas",
|
||||
"instructions": "Instruções",
|
||||
"step-index": "Passo: {step}",
|
||||
"recipe-name": "Nome da Receita",
|
||||
"servings": "Porções",
|
||||
"ingredient": "Ingrediente",
|
||||
"notes": "Notas",
|
||||
"note": "Nota",
|
||||
"original-url": "URL Original",
|
||||
"view-recipe": "Ver Receita",
|
||||
"title": "Título",
|
||||
"total-time": "Tempo Total",
|
||||
"prep-time": "Tempo de Preparação",
|
||||
"perform-time": "Tempo de Cozedura",
|
||||
"api-extras": "Extras API",
|
||||
"object-key": "Chave do Objeto",
|
||||
"object-value": "Valor do Objeto",
|
||||
"new-key-name": "Novo nome da Chave",
|
||||
"add-key": "Adicionar Chave",
|
||||
"key-name-required": "Nome da Chave é Obrigatório",
|
||||
"no-white-space-allowed": "Espaço em Branco não Permitido",
|
||||
"delete-recipe": "Eliminar Receita",
|
||||
"delete-confirmation": "Tem a certeza que deseja eliminar esta receita?"
|
||||
},
|
||||
"search": {
|
||||
"search-mealie": "Pesquisar Mealie"
|
||||
},
|
||||
"settings": {
|
||||
"general-settings": "Definições Gerais",
|
||||
"local-api": "API Local",
|
||||
"language": "Língua",
|
||||
"add-a-new-theme": "Adicionar novo tema",
|
||||
"set-new-time": "Definir hora",
|
||||
"current": "Versão:",
|
||||
"latest": "Mais Recente",
|
||||
"explore-the-docs": "Explorar Documentação",
|
||||
"contribute": "Contribuir",
|
||||
"backup-and-exports": "Backups",
|
||||
"backup-info": "Backups are exported in standard JSON format along with all the images stored on the file system. In your backup folder you'll find a .zip file that contains all of the recipe JSON and images from the database. Additionally, if you selected a markdown file, those will also be stored in the .zip file. To import a backup, it must be located in your backups folder. Automated backups are done each day at 3:00 AM.",
|
||||
"available-backups": "Backups Disponíveis",
|
||||
"theme": {
|
||||
"theme-name": "Nome do Tema",
|
||||
"theme-settings": "Definições do Tema",
|
||||
"select-a-theme-from-the-dropdown-or-create-a-new-theme-note-that-the-default-theme-will-be-served-to-all-users-who-have-not-set-a-theme-preference": "Selecione um tema da lista ou crie um novo tema. Note que o tema por defeito será utilizado por todos os utilizadores que não selecionaram um tema preferido.",
|
||||
"dark-mode": "Modo Escuro",
|
||||
"theme-is-required": "Tema é Obrigatório",
|
||||
"primary": "Primário",
|
||||
"secondary": "Secondário",
|
||||
"accent": "Accent",
|
||||
"success": "Successo",
|
||||
"info": "Info",
|
||||
"warning": "Aviso",
|
||||
"error": "Erro",
|
||||
"default-to-system": "Mesmo do Sistema",
|
||||
"light": "Claro",
|
||||
"dark": "Escuro",
|
||||
"theme": "Tema",
|
||||
"saved-color-theme": "Cor de Tema Guardado",
|
||||
"delete-theme": "Eliminar Tema",
|
||||
"are-you-sure-you-want-to-delete-this-theme": "Tem a certeza que deseja eliminar este tema?",
|
||||
"choose-how-mealie-looks-to-you-set-your-theme-preference-to-follow-your-system-settings-or-choose-to-use-the-light-or-dark-theme": "Escolha como o Mealie estará visivel. Escolha o Mesmo do sistema para seguir o tema do seu dispositivo, ou selecione claro ou escuro.",
|
||||
"theme-name-is-required": "Nome do Tema é Obrigatório."
|
||||
},
|
||||
"webhooks": {
|
||||
"meal-planner-webhooks": "Webhooks do Organizador de Refeições",
|
||||
"the-urls-listed-below-will-recieve-webhooks-containing-the-recipe-data-for-the-meal-plan-on-its-scheduled-day-currently-webhooks-will-execute-at": "Os URLs apresentados abaixo receberão webhooks que contêm os dados da receita para o plano de refeições no dia marcado. Atualmente, os webhooks serão executados a ",
|
||||
"test-webhooks": "Webhooks de Teste",
|
||||
"webhook-url": "Webhook URL"
|
||||
},
|
||||
"new-version-available": "Uma nova versão do Mealie está disponível, <a {aContents}> Visite o Repo </a>",
|
||||
"backup": {
|
||||
"import-recipes": "Importar Receitas",
|
||||
"import-themes": "Importar Temas",
|
||||
"import-settings": "Importa Definições",
|
||||
"create-heading": "Criar um Backup",
|
||||
"backup-tag": "Etiqueta do Backup",
|
||||
"full-backup": "Backup Completo",
|
||||
"partial-backup": "Backup Parcial",
|
||||
"backup-restore-report": "Análise do Resultado do Backup",
|
||||
"successfully-imported": "Importado com Sucesso",
|
||||
"failed-imports": "Importações falhadas"
|
||||
}
|
||||
},
|
||||
"migration": {
|
||||
"recipe-migration": "Migração da Receita",
|
||||
"failed-imports": "Importações Falhadas",
|
||||
"migration-report": "Análise das Migrações",
|
||||
"successful-imports": "Importações Bem sucedidas",
|
||||
"no-migration-data-available": "Não há dados de migração disponíveis",
|
||||
"nextcloud": {
|
||||
"title": "Nextcloud Cookbook",
|
||||
"description": "Migraar dados de uma instância do Nextcloud CookBook"
|
||||
},
|
||||
"chowdown": {
|
||||
"title": "Chowdown",
|
||||
"description": "Migrar dados do Chowdown"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,20 @@ const router = new VueRouter({
|
||||
mode: process.env.NODE_ENV === "production" ? "history" : "hash",
|
||||
});
|
||||
|
||||
const DEFAULT_TITLE = 'Mealie';
|
||||
const TITLE_SEPARATOR = '🍴';
|
||||
const TITLE_SUFFIX = " " + TITLE_SEPARATOR + " " + DEFAULT_TITLE;
|
||||
router.afterEach( (to) => {
|
||||
Vue.nextTick( async () => {
|
||||
if(typeof to.meta.title === 'function' ) {
|
||||
const title = await to.meta.title(to);
|
||||
document.title = title + TITLE_SUFFIX;
|
||||
} else {
|
||||
document.title = to.meta.title ? to.meta.title + TITLE_SUFFIX : DEFAULT_TITLE;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const vueApp = new Vue({
|
||||
vuetify,
|
||||
store,
|
||||
|
||||
7
frontend/src/mixins/utilMixins.js
Normal file
7
frontend/src/mixins/utilMixins.js
Normal file
@@ -0,0 +1,7 @@
|
||||
export const utilMixins = {
|
||||
commputed: {
|
||||
isMobile() {
|
||||
return this.$vuetify.breakpoint.name === "xs";
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -3,7 +3,7 @@ export const validators = {
|
||||
return {
|
||||
emailRule: v =>
|
||||
!v ||
|
||||
/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) ||
|
||||
/^[^@\s]+@[^@\s.]+.[^@.\s]+$/.test(v) ||
|
||||
this.$t('user.e-mail-must-be-valid'),
|
||||
|
||||
existsRule: value => !!value || this.$t('general.field-required'),
|
||||
|
||||
104
frontend/src/pages/Admin/About/index.vue
Normal file
104
frontend/src/pages/Admin/About/index.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-card class="mt-3">
|
||||
<v-card-title class="headline">
|
||||
About Mealie
|
||||
</v-card-title>
|
||||
<v-divider></v-divider>
|
||||
<v-card-text>
|
||||
<v-list-item-group color="primary">
|
||||
<v-list-item v-for="property in prettyInfo" :key="property.name">
|
||||
<v-list-item-icon>
|
||||
<v-icon> {{ property.icon || "mdi-account" }} </v-icon>
|
||||
</v-list-item-icon>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title class="pl-4 flex row justify-space-between">
|
||||
<div>{{ property.name }}</div>
|
||||
<div>{{ property.value }}</div>
|
||||
</v-list-item-title>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
</v-list-item-group>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<TheDownloadBtn
|
||||
button-text="Download Recipe JSON"
|
||||
download-url="/api/debug/last-recipe-json"
|
||||
/>
|
||||
<TheDownloadBtn
|
||||
button-text="Download Log"
|
||||
download-url="/api/debug/log"
|
||||
/>
|
||||
</v-card-actions>
|
||||
<v-divider></v-divider>
|
||||
</v-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { api } from "@/api";
|
||||
import TheDownloadBtn from "@/components/UI/TheDownloadBtn";
|
||||
export default {
|
||||
components: { TheDownloadBtn },
|
||||
data() {
|
||||
return {
|
||||
prettyInfo: [],
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
await this.getInfo();
|
||||
},
|
||||
methods: {
|
||||
async getInfo() {
|
||||
const debugInfo = await api.meta.getDebugInfo();
|
||||
|
||||
this.prettyInfo = [
|
||||
{
|
||||
name: "Version",
|
||||
icon: "mdi-information",
|
||||
value: debugInfo.version,
|
||||
},
|
||||
{
|
||||
name: "Application Mode",
|
||||
icon: "mdi-dev-to",
|
||||
value: debugInfo.production ? "Production" : "Development",
|
||||
},
|
||||
{
|
||||
name: "Demo Status",
|
||||
icon: "mdi-test-tube",
|
||||
value: debugInfo.demoStatus ? "Demo" : "Not Demo",
|
||||
},
|
||||
{
|
||||
name: "API Port",
|
||||
icon: "mdi-api",
|
||||
value: debugInfo.apiPort,
|
||||
},
|
||||
{
|
||||
name: "API Docs",
|
||||
icon: "mdi-file-document",
|
||||
value: debugInfo.apiDocs ? "Enabled" : "Disabled",
|
||||
},
|
||||
{
|
||||
name: "Database Type",
|
||||
icon: "mdi-database",
|
||||
value: debugInfo.dbType,
|
||||
},
|
||||
{
|
||||
name: "SQLite File",
|
||||
icon: "mdi-file-cabinet",
|
||||
value: debugInfo.sqliteFile,
|
||||
},
|
||||
{
|
||||
name: "Default Group",
|
||||
icon: "mdi-account-group",
|
||||
value: debugInfo.defaultGroup,
|
||||
},
|
||||
];
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
@@ -7,41 +7,19 @@
|
||||
<v-card-text>
|
||||
<h2 class="mt-1">{{ $t("recipe.categories") }}</h2>
|
||||
|
||||
<v-row>
|
||||
<v-col sm="12" md="6">
|
||||
<v-select
|
||||
outlined
|
||||
:flat="isFlat"
|
||||
elavation="0"
|
||||
v-model="groupSettings.categories"
|
||||
:items="categories"
|
||||
item-text="name"
|
||||
return-object
|
||||
multiple
|
||||
chips
|
||||
:hint="
|
||||
$t(
|
||||
'meal-plan.only-recipes-with-these-categories-will-be-used-in-meal-plans'
|
||||
)
|
||||
"
|
||||
class="mt-2"
|
||||
persistent-hint
|
||||
>
|
||||
<template v-slot:selection="data">
|
||||
<v-chip
|
||||
outlined
|
||||
:input-value="data.selected"
|
||||
close
|
||||
@click:close="removeCategory(data.index)"
|
||||
color="secondary"
|
||||
dark
|
||||
>
|
||||
{{ data.item.name }}
|
||||
</v-chip>
|
||||
</template>
|
||||
</v-select>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<CategoryTagSelector
|
||||
class="mt-4"
|
||||
:solo="true"
|
||||
:dense="false"
|
||||
v-model="groupSettings.categories"
|
||||
:return-object="true"
|
||||
:show-add="true"
|
||||
:hint="
|
||||
$t(
|
||||
'meal-plan.only-recipes-with-these-categories-will-be-used-in-meal-plans'
|
||||
)
|
||||
"
|
||||
/>
|
||||
</v-card-text>
|
||||
<v-divider> </v-divider>
|
||||
<v-card-text>
|
||||
@@ -57,28 +35,23 @@
|
||||
<strong>{{ groupSettings.webhookTime }}</strong>
|
||||
</p>
|
||||
|
||||
<v-row dense align="center">
|
||||
<v-col cols="12" md="2" sm="5">
|
||||
<v-switch
|
||||
v-model="groupSettings.webhookEnable"
|
||||
:label="$t('general.enabled')"
|
||||
></v-switch>
|
||||
</v-col>
|
||||
<v-col cols="12" md="3" sm="5">
|
||||
<TimePickerDialog @save-time="saveTime" />
|
||||
</v-col>
|
||||
<v-col cols="12" md="4" sm="5">
|
||||
<v-btn text color="info" @click="testWebhooks">
|
||||
<v-icon left> mdi-webhook </v-icon>
|
||||
{{ $t("settings.webhooks.test-webhooks") }}
|
||||
</v-btn>
|
||||
</v-col>
|
||||
<v-row dense class="flex align-center">
|
||||
<v-switch
|
||||
class="mx-2"
|
||||
v-model="groupSettings.webhookEnable"
|
||||
:label="$t('general.enabled')"
|
||||
></v-switch>
|
||||
<TimePickerDialog @save-time="saveTime" class="ma-2" />
|
||||
<v-btn class="ma-2" color="info" @click="testWebhooks">
|
||||
<v-icon left> mdi-webhook </v-icon>
|
||||
{{ $t("settings.webhooks.test-webhooks") }}
|
||||
</v-btn>
|
||||
</v-row>
|
||||
|
||||
<v-row
|
||||
v-for="(url, index) in groupSettings.webhookUrls"
|
||||
:key="index"
|
||||
align="center"
|
||||
align=" center"
|
||||
dense
|
||||
>
|
||||
<v-col cols="1">
|
||||
@@ -110,9 +83,11 @@
|
||||
<script>
|
||||
import { api } from "@/api";
|
||||
import TimePickerDialog from "@/components/Admin/MealPlanner/TimePickerDialog";
|
||||
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
||||
export default {
|
||||
components: {
|
||||
TimePickerDialog,
|
||||
CategoryTagSelector,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -160,6 +135,7 @@ 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();
|
||||
@@ -167,9 +143,6 @@ export default {
|
||||
testWebhooks() {
|
||||
api.settings.testWebhooks();
|
||||
},
|
||||
removeCategory(index) {
|
||||
this.groupSettings.categories.splice(index, 1);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -36,7 +36,6 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
siteSettings() {
|
||||
console.log(this.$store.getters.getSiteSettings);
|
||||
return this.$store.getters.getSiteSettings;
|
||||
},
|
||||
recentRecipes() {
|
||||
@@ -54,7 +53,6 @@ export default {
|
||||
this.siteSettings.categories.forEach(async element => {
|
||||
let recipes = await this.getRecipeByCategory(element.slug);
|
||||
if (recipes.recipes.length < 0) recipes.recipes = [];
|
||||
console.log(recipes);
|
||||
this.recipeByCategory.push(recipes);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -117,7 +117,7 @@ export default {
|
||||
return utils.getDateAsTextAlt(dateObject);
|
||||
},
|
||||
getImage(image) {
|
||||
return utils.getImageURL(image);
|
||||
return api.recipes.recipeTinyImage(image);
|
||||
},
|
||||
|
||||
editPlan(id) {
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
|
||||
<script>
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -68,7 +67,7 @@ export default {
|
||||
else return 0;
|
||||
},
|
||||
getImage(image) {
|
||||
return utils.getImageURL(image);
|
||||
return api.recipes.recipeImage(image);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<v-card v-else id="myRecipe">
|
||||
<v-img
|
||||
height="400"
|
||||
:src="getImage(recipeDetails.image)"
|
||||
:src="getImage(recipeDetails.slug)"
|
||||
class="d-print-none"
|
||||
:key="imageKey"
|
||||
>
|
||||
@@ -50,6 +50,7 @@
|
||||
:rating="recipeDetails.rating"
|
||||
:yields="recipeDetails.recipeYield"
|
||||
:orgURL="recipeDetails.orgURL"
|
||||
:nutrition="recipeDetails.nutrition"
|
||||
/>
|
||||
<VJsoneditor
|
||||
@error="logError()"
|
||||
@@ -71,7 +72,6 @@
|
||||
|
||||
<script>
|
||||
import { api } from "@/api";
|
||||
import utils from "@/utils";
|
||||
import VJsoneditor from "v-jsoneditor";
|
||||
import RecipeViewer from "@/components/Recipe/RecipeViewer";
|
||||
import RecipeEditor from "@/components/Recipe/RecipeEditor";
|
||||
@@ -152,6 +152,7 @@ export default {
|
||||
methods: {
|
||||
getImageFile(fileObject) {
|
||||
this.fileObject = fileObject;
|
||||
this.saveImage();
|
||||
},
|
||||
async getRecipeDetails() {
|
||||
this.recipeDetails = await api.recipes.requestDetails(this.currentRecipe);
|
||||
@@ -160,7 +161,7 @@ export default {
|
||||
},
|
||||
getImage(image) {
|
||||
if (image) {
|
||||
return utils.getImageURL(image) + "?rnd=" + this.imageKey;
|
||||
return api.recipes.recipeImage(image) + "&rnd=" + this.imageKey;
|
||||
}
|
||||
},
|
||||
deleteRecipe() {
|
||||
@@ -173,19 +174,21 @@ export default {
|
||||
return this.$refs.recipeEditor.validateRecipe();
|
||||
}
|
||||
},
|
||||
async saveImage() {
|
||||
if (this.fileObject) {
|
||||
await api.recipes.updateImage(this.recipeDetails.slug, this.fileObject);
|
||||
}
|
||||
this.imageKey += 1;
|
||||
},
|
||||
async saveRecipe() {
|
||||
if (this.validateRecipe()) {
|
||||
let slug = await api.recipes.update(this.recipeDetails);
|
||||
|
||||
if (this.fileObject) {
|
||||
await api.recipes.updateImage(
|
||||
this.recipeDetails.slug,
|
||||
this.fileObject
|
||||
);
|
||||
this.saveImage();
|
||||
}
|
||||
|
||||
this.form = false;
|
||||
this.imageKey += 1;
|
||||
if (slug != this.recipeDetails.slug) {
|
||||
this.$router.push(`/recipe/${slug}`);
|
||||
}
|
||||
|
||||
60
frontend/src/pages/Recipes/TagPage.vue
Normal file
60
frontend/src/pages/Recipes/TagPage.vue
Normal file
@@ -0,0 +1,60 @@
|
||||
<template>
|
||||
<v-container>
|
||||
<CategorySidebar />
|
||||
<CardSection
|
||||
:sortable="true"
|
||||
:title="title"
|
||||
:recipes="recipes"
|
||||
:card-limit="9999"
|
||||
@sort="sortAZ"
|
||||
@sort-recent="sortRecent"
|
||||
/>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { api } from "@/api";
|
||||
import CardSection from "@/components/UI/CardSection";
|
||||
import CategorySidebar from "@/components/UI/CategorySidebar";
|
||||
export default {
|
||||
components: {
|
||||
CardSection,
|
||||
CategorySidebar,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: "",
|
||||
recipes: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
currentTag() {
|
||||
return this.$route.params.tag;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
async currentTag() {
|
||||
this.getRecipes();
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getRecipes();
|
||||
},
|
||||
methods: {
|
||||
async getRecipes() {
|
||||
let data = await api.tags.getRecipesInTag(this.currentTag);
|
||||
this.title = data.name;
|
||||
this.recipes = data.recipes;
|
||||
},
|
||||
sortAZ() {
|
||||
this.recipes.sort((a, b) => (a.name > b.name ? 1 : -1));
|
||||
},
|
||||
sortRecent() {
|
||||
this.recipes.sort((a, b) => (a.dateAdded > b.dateAdded ? -1 : 1));
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
@@ -1,58 +0,0 @@
|
||||
<template>
|
||||
<v-container>
|
||||
<v-row justify="center">
|
||||
<v-col cols="1"> </v-col>
|
||||
<v-col>
|
||||
<SearchBar @results="updateResults" :show-results="false" />
|
||||
</v-col>
|
||||
<v-col cols="2">
|
||||
<v-btn icon>
|
||||
<v-icon large> mdi-filter </v-icon>
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row v-if="searchResults">
|
||||
<v-col
|
||||
:sm="6"
|
||||
:md="6"
|
||||
:lg="4"
|
||||
:xl="3"
|
||||
v-for="item in searchResults.slice(0, 10)"
|
||||
:key="item.item.name"
|
||||
>
|
||||
<RecipeCard
|
||||
:name="item.item.name"
|
||||
:description="item.item.description"
|
||||
:slug="item.item.slug"
|
||||
:rating="item.item.rating"
|
||||
:image="item.item.image"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SearchBar from "../components/UI/Search/SearchBar";
|
||||
import RecipeCard from "../components/Recipe/RecipeCard";
|
||||
export default {
|
||||
components: {
|
||||
SearchBar,
|
||||
RecipeCard,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
searchResults: [],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
updateResults(results) {
|
||||
this.searchResults = results;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
69
frontend/src/pages/SearchPage/FilterSelector.vue
Normal file
69
frontend/src/pages/SearchPage/FilterSelector.vue
Normal file
@@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<v-toolbar dense flat>
|
||||
<v-btn-toggle
|
||||
dense
|
||||
v-model="selected"
|
||||
tile
|
||||
color="primary accent-3"
|
||||
@change="emitMulti"
|
||||
group
|
||||
mandatory
|
||||
>
|
||||
<v-btn :value="false">
|
||||
{{$t('search.include')}}
|
||||
</v-btn>
|
||||
|
||||
<v-btn :value="true">
|
||||
{{$t('search.exclude')}}
|
||||
</v-btn>
|
||||
</v-btn-toggle>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn-toggle
|
||||
dense
|
||||
v-model="match"
|
||||
tile
|
||||
color="primary accent-3"
|
||||
@change="emitMulti"
|
||||
group
|
||||
mandatory
|
||||
>
|
||||
<v-btn :value="false">
|
||||
{{$t('search.and')}}
|
||||
</v-btn>
|
||||
<v-btn :value="true">
|
||||
{{$t('search.or')}}
|
||||
</v-btn>
|
||||
</v-btn-toggle>
|
||||
</v-toolbar>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
default: "include", // Optionas: "include", "exclude", "any"
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selected: false,
|
||||
match: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
emitChange() {
|
||||
this.$emit("input", this.selected);
|
||||
},
|
||||
emitMulti() {
|
||||
const updateData = {
|
||||
exclude: this.selected,
|
||||
matchAny: this.match,
|
||||
};
|
||||
this.$emit("update", updateData);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
178
frontend/src/pages/SearchPage/index.vue
Normal file
178
frontend/src/pages/SearchPage/index.vue
Normal file
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<v-container>
|
||||
<CategorySidebar />
|
||||
<v-card flat>
|
||||
<v-row dense>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
v-model="searchString"
|
||||
outlined
|
||||
color="primary accent-3"
|
||||
:placeholder="$t('search.search-placeholder')"
|
||||
append-icon="mdi-magnify"
|
||||
>
|
||||
</v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" md="2" sm="12">
|
||||
<v-text-field
|
||||
class="mt-0 pt-0"
|
||||
:label="$t('search.max-results')"
|
||||
v-model="maxResults"
|
||||
type="number"
|
||||
outlined
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row dense class="mt-0 flex-row align-center justify-space-around">
|
||||
<v-col>
|
||||
<h3 class="pl-2 text-center headline">{{$t('search.category-filter')}}</h3>
|
||||
<FilterSelector class="mb-1" @update="updateCatParams" />
|
||||
<CategoryTagSelector
|
||||
:solo="true"
|
||||
:dense="false"
|
||||
v-model="includeCategories"
|
||||
:return-object="false"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<h3 class="pl-2 text-center headline">{{$t('search.tag-filter')}}</h3>
|
||||
<FilterSelector class="mb-1" @update="updateTagParams" />
|
||||
|
||||
<CategoryTagSelector
|
||||
:solo="true"
|
||||
:dense="false"
|
||||
v-model="includeTags"
|
||||
:return-object="false"
|
||||
:tag-selector="true"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row v-if="fuzzyRecipes">
|
||||
<v-col
|
||||
:sm="6"
|
||||
:md="6"
|
||||
:lg="4"
|
||||
:xl="3"
|
||||
v-for="item in fuzzyRecipes.slice(0, maxResults)"
|
||||
:key="item.name"
|
||||
>
|
||||
<RecipeCard
|
||||
:name="item.item.name"
|
||||
:description="item.item.description"
|
||||
:slug="item.item.slug"
|
||||
:rating="item.item.rating"
|
||||
:image="item.item.image"
|
||||
:tags="item.item.tags"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Fuse from "fuse.js";
|
||||
import RecipeCard from "@/components/Recipe/RecipeCard";
|
||||
import CategorySidebar from "@/components/UI/CategorySidebar";
|
||||
import CategoryTagSelector from "@/components/FormHelpers/CategoryTagSelector";
|
||||
import FilterSelector from "./FilterSelector.vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
RecipeCard,
|
||||
CategorySidebar,
|
||||
CategoryTagSelector,
|
||||
FilterSelector,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
searchString: "",
|
||||
maxResults: 21,
|
||||
searchResults: [],
|
||||
catFilter: {
|
||||
exclude: false,
|
||||
matchAny: false,
|
||||
},
|
||||
tagFilter: {
|
||||
exclude: false,
|
||||
matchAny: false,
|
||||
},
|
||||
includeCategories: [],
|
||||
includeTags: [],
|
||||
options: {
|
||||
shouldSort: true,
|
||||
threshold: 0.6,
|
||||
location: 0,
|
||||
distance: 100,
|
||||
findAllMatches: true,
|
||||
maxPatternLength: 32,
|
||||
minMatchCharLength: 2,
|
||||
keys: ["name", "description"],
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
allRecipes() {
|
||||
return this.$store.getters.getRecentRecipes;
|
||||
},
|
||||
filteredRecipes() {
|
||||
return this.allRecipes.filter(recipe => {
|
||||
const includesTags = this.check(
|
||||
this.includeTags,
|
||||
recipe.tags,
|
||||
this.tagFilter.matchAny,
|
||||
this.tagFilter.exclude
|
||||
);
|
||||
const includesCats = this.check(
|
||||
this.includeCategories,
|
||||
recipe.recipeCategory,
|
||||
this.catFilter.matchAny,
|
||||
this.catFilter.exclude
|
||||
);
|
||||
return [includesTags, includesCats].every(x => x === true);
|
||||
});
|
||||
},
|
||||
fuse() {
|
||||
return new Fuse(this.filteredRecipes, this.options);
|
||||
},
|
||||
fuzzyRecipes() {
|
||||
if (this.searchString.trim() === "") {
|
||||
return this.filteredRecipes.map(x => ({ item: x }));
|
||||
}
|
||||
const result = this.fuse.search(this.searchString.trim());
|
||||
return result;
|
||||
},
|
||||
isSearching() {
|
||||
return this.searchString && this.searchString.length > 0;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
check(filterBy, recipeList, matchAny, exclude) {
|
||||
let isMatch = true;
|
||||
if (filterBy.length === 0) return isMatch;
|
||||
|
||||
if (recipeList) {
|
||||
if (matchAny) {
|
||||
isMatch = filterBy.some(t => recipeList.includes(t)); // Checks if some items are a match
|
||||
} else {
|
||||
isMatch = filterBy.every(t => recipeList.includes(t)); // Checks if every items is a match
|
||||
}
|
||||
return exclude ? !isMatch : isMatch;
|
||||
} else;
|
||||
return false;
|
||||
},
|
||||
|
||||
updateTagParams(params) {
|
||||
this.tagFilter = params;
|
||||
},
|
||||
updateCatParams(params) {
|
||||
this.catFilter = params;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
@@ -6,7 +6,9 @@ import Migration from "@/pages/Admin/Migration";
|
||||
import Profile from "@/pages/Admin/Profile";
|
||||
import ManageUsers from "@/pages/Admin/ManageUsers";
|
||||
import Settings from "@/pages/Admin/Settings";
|
||||
import About from "@/pages/Admin/About";
|
||||
import { store } from "../store";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
export default {
|
||||
path: "/admin",
|
||||
@@ -24,31 +26,59 @@ export default {
|
||||
{
|
||||
path: "profile",
|
||||
component: Profile,
|
||||
meta: {
|
||||
title: i18n.t('settings.profile'),
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
path: "backups",
|
||||
component: Backup,
|
||||
meta: {
|
||||
title: i18n.t('settings.backup-and-exports'),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "themes",
|
||||
component: Theme,
|
||||
meta: {
|
||||
title: i18n.t('general.themes'),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "meal-planner",
|
||||
component: MealPlanner,
|
||||
meta: {
|
||||
title: i18n.t('meal-plan.meal-planner'),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "migrations",
|
||||
component: Migration,
|
||||
meta: {
|
||||
title: i18n.t('settings.migrations'),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "manage-users",
|
||||
component: ManageUsers,
|
||||
meta: {
|
||||
title: i18n.t('settings.manage-users'),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "settings",
|
||||
component: Settings,
|
||||
meta: {
|
||||
title: i18n.t('settings.site-settings'),
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "about",
|
||||
component: About,
|
||||
meta: {
|
||||
title: i18n.t('general.about'),
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@ import NewRecipe from "@/pages/Recipe/NewRecipe";
|
||||
import CustomPage from "@/pages/Recipes/CustomPage";
|
||||
import AllRecipes from "@/pages/Recipes/AllRecipes";
|
||||
import CategoryPage from "@/pages/Recipes/CategoryPage";
|
||||
import TagPage from "@/pages/Recipes/TagPage";
|
||||
import Planner from "@/pages/MealPlan/Planner";
|
||||
import Debug from "@/pages/Debug";
|
||||
import LoginPage from "@/pages/LoginPage";
|
||||
@@ -14,6 +15,7 @@ import ThisWeek from "@/pages/MealPlan/ThisWeek";
|
||||
import { api } from "@/api";
|
||||
import Admin from "./admin";
|
||||
import { store } from "../store";
|
||||
import i18n from '@/i18n.js';
|
||||
|
||||
export const routes = [
|
||||
{ path: "/", name: "home", component: HomePage },
|
||||
@@ -30,14 +32,43 @@ export const routes = [
|
||||
{ path: "/sign-up", redirect: "/" },
|
||||
{ path: "/sign-up/:token", component: SignUpPage },
|
||||
{ path: "/debug", component: Debug },
|
||||
{ path: "/search", component: SearchPage },
|
||||
{
|
||||
path: "/search",
|
||||
component: SearchPage,
|
||||
meta: {
|
||||
title: i18n.t('search.search'),
|
||||
},
|
||||
},
|
||||
{ path: "/recipes/all", component: AllRecipes },
|
||||
{ path: "/pages/:customPage", component: CustomPage },
|
||||
{ path: "/recipes/:category", component: CategoryPage },
|
||||
{ path: "/recipe/:recipe", component: ViewRecipe },
|
||||
{ path: "/recipes/tag/:tag", component: TagPage },
|
||||
{ path: "/recipes/category/:category", component: CategoryPage },
|
||||
{
|
||||
path: "/recipe/:recipe",
|
||||
component: ViewRecipe,
|
||||
meta: {
|
||||
title: async route => {
|
||||
const recipe = await api.recipes.requestDetails(route.params.recipe);
|
||||
return recipe.name;
|
||||
},
|
||||
}
|
||||
},
|
||||
{ path: "/new/", component: NewRecipe },
|
||||
{ path: "/meal-plan/planner", component: Planner },
|
||||
{ path: "/meal-plan/this-week", component: ThisWeek },
|
||||
{
|
||||
path: "/meal-plan/planner",
|
||||
component: Planner,
|
||||
meta: {
|
||||
title: i18n.t('meal-plan.meal-planner'),
|
||||
}
|
||||
},
|
||||
{
|
||||
path: "/meal-plan/this-week",
|
||||
component: ThisWeek,
|
||||
meta: {
|
||||
title: i18n.t('meal-plan.dinner-this-week'),
|
||||
}
|
||||
|
||||
},
|
||||
Admin,
|
||||
{
|
||||
path: "/meal-plan/today",
|
||||
|
||||
@@ -28,6 +28,10 @@ const store = new Vuex.Store({
|
||||
mealPlanCategories: [],
|
||||
allCategories: [],
|
||||
allTags: [],
|
||||
appInfo: {
|
||||
version: "",
|
||||
demoStatus: false,
|
||||
},
|
||||
},
|
||||
|
||||
mutations: {
|
||||
@@ -43,19 +47,22 @@ const store = new Vuex.Store({
|
||||
setAllTags(state, payload) {
|
||||
state.allTags = payload;
|
||||
},
|
||||
setAppInfo(state, payload) {
|
||||
state.appInfo = payload;
|
||||
},
|
||||
},
|
||||
|
||||
actions: {
|
||||
async requestRecentRecipes() {
|
||||
const keys = [
|
||||
"name",
|
||||
"slug",
|
||||
"image",
|
||||
"description",
|
||||
"dateAdded",
|
||||
"rating",
|
||||
];
|
||||
const payload = await api.recipes.allByKeys(keys);
|
||||
// const keys = [
|
||||
// "name",
|
||||
// "slug",
|
||||
// "image",
|
||||
// "description",
|
||||
// "dateAdded",
|
||||
// "rating",
|
||||
// ];
|
||||
const payload = await api.recipes.allSummary();
|
||||
|
||||
this.commit("setRecentRecipes", payload);
|
||||
},
|
||||
@@ -67,6 +74,11 @@ const store = new Vuex.Store({
|
||||
const tags = await api.tags.getAll();
|
||||
commit("setAllTags", tags);
|
||||
},
|
||||
|
||||
async requestAppInfo({ commit }) {
|
||||
const response = await api.meta.getAppInfo();
|
||||
commit("setAppInfo", response);
|
||||
},
|
||||
},
|
||||
|
||||
getters: {
|
||||
@@ -76,6 +88,7 @@ const store = new Vuex.Store({
|
||||
state.allCategories.sort((a, b) => (a.slug > b.slug ? 1 : -1)),
|
||||
getAllTags: state =>
|
||||
state.allTags.sort((a, b) => (a.slug > b.slug ? 1 : -1)),
|
||||
getAppInfo: state => state.appInfo,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ const state = {
|
||||
name: "German",
|
||||
value: "de",
|
||||
},
|
||||
{
|
||||
name: "Português",
|
||||
value: "pt-PT",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -48,13 +52,13 @@ const mutations = {
|
||||
const actions = {
|
||||
initLang({ getters }, { currentVueComponent }) {
|
||||
VueI18n.locale = getters.getActiveLang;
|
||||
currentVueComponent.$vuetify.lang.current = getters.getActiveLang;
|
||||
currentVueComponent.$vuetify.lang.current = getters.getActiveLang;
|
||||
},
|
||||
};
|
||||
|
||||
const getters = {
|
||||
getActiveLang: (state) => state.lang,
|
||||
getAllLangs: (state) => state.allLangs,
|
||||
getActiveLang: state => state.lang,
|
||||
getAllLangs: state => state.allLangs,
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
@@ -70,7 +70,7 @@ const actions = {
|
||||
|
||||
async refreshToken({ commit, getters }) {
|
||||
if (!getters.getIsLoggedIn) {
|
||||
commit("setIsLoggedIn", false); // This is to be here... for some reasons? ¯\_(ツ)_/¯
|
||||
commit("setIsLoggedIn", false); // This has to be here... for some reasons? ¯\_(ツ)_/¯
|
||||
console.log("Not Logged In");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ const monthsShort = [
|
||||
|
||||
export default {
|
||||
getImageURL(image) {
|
||||
return `/api/recipes/${image}/image`;
|
||||
return `/api/recipes/${image}/image?image_type=small`;
|
||||
},
|
||||
generateUniqueKey(item, index) {
|
||||
const uniqueKey = `${item}-${index}`;
|
||||
|
||||
1
makefile
1
makefile
@@ -54,6 +54,7 @@ setup: ## Setup Development Instance
|
||||
|
||||
backend: ## Start Mealie Backend Development Server
|
||||
poetry run python mealie/db/init_db.py && \
|
||||
poetry run python mealie/services/image/minify.py && \
|
||||
poetry run python mealie/app.py
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from fastapi.logger import logger
|
||||
|
||||
from mealie.core import root_logger
|
||||
|
||||
# import utils.startup as startup
|
||||
from mealie.core.config import APP_VERSION, settings
|
||||
from mealie.routes import backup_routes, debug_routes, migration_routes, theme_routes
|
||||
from mealie.routes import backup_routes, debug_routes, migration_routes, theme_routes, utility_routes
|
||||
from mealie.routes.groups import groups
|
||||
from mealie.routes.mealplans import mealplans
|
||||
from mealie.routes.recipe import all_recipe_routes, category_routes, recipe_crud_routes, tag_routes
|
||||
from mealie.routes.site_settings import all_settings
|
||||
from mealie.routes.users import users
|
||||
|
||||
logger = root_logger.get_logger()
|
||||
|
||||
app = FastAPI(
|
||||
title="Mealie",
|
||||
description="A place for all your recipes",
|
||||
@@ -26,6 +29,7 @@ def start_scheduler():
|
||||
|
||||
def api_routers():
|
||||
# Authentication
|
||||
app.include_router(utility_routes.router)
|
||||
app.include_router(users.router)
|
||||
app.include_router(groups.router)
|
||||
# Recipes
|
||||
@@ -33,7 +37,6 @@ def api_routers():
|
||||
app.include_router(category_routes.router)
|
||||
app.include_router(tag_routes.router)
|
||||
app.include_router(recipe_crud_routes.router)
|
||||
|
||||
# Meal Routes
|
||||
app.include_router(mealplans.router)
|
||||
# Settings Routes
|
||||
@@ -50,6 +53,13 @@ api_routers()
|
||||
start_scheduler()
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
def system_startup():
|
||||
logger.info("-----SYSTEM STARTUP----- \n")
|
||||
logger.info("------APP SETTINGS------")
|
||||
logger.info(settings.json(indent=4, exclude={"SECRET", "DEFAULT_PASSWORD", "SFTP_PASSWORD", "SFTP_USERNAME"}))
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
uvicorn.run(
|
||||
@@ -60,11 +70,11 @@ def main():
|
||||
reload_dirs=["mealie"],
|
||||
debug=True,
|
||||
log_level="info",
|
||||
log_config=None,
|
||||
workers=1,
|
||||
forwarded_allow_ips="*",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger.info("-----SYSTEM STARTUP-----")
|
||||
main()
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import os
|
||||
import secrets
|
||||
from pathlib import Path
|
||||
from typing import Optional, Union
|
||||
|
||||
import dotenv
|
||||
from pydantic import BaseSettings, Field, validator
|
||||
|
||||
APP_VERSION = "v0.4.0"
|
||||
APP_VERSION = "v0.4.2"
|
||||
DB_VERSION = "v0.4.0"
|
||||
|
||||
CWD = Path(__file__).parent
|
||||
BASE_DIR = CWD.parent.parent
|
||||
|
||||
ENV = BASE_DIR.joinpath(".env")
|
||||
|
||||
dotenv.load_dotenv(ENV)
|
||||
PRODUCTION = os.environ.get("ENV")
|
||||
PRODUCTION = os.getenv("PRODUCTION", "True").lower() in ["true", "1"]
|
||||
|
||||
|
||||
def determine_data_dir(production: bool) -> Path:
|
||||
@@ -38,21 +41,25 @@ def determine_secrets(data_dir: Path, production: bool) -> str:
|
||||
return new_secret
|
||||
|
||||
|
||||
# General
|
||||
DATA_DIR = determine_data_dir(PRODUCTION)
|
||||
|
||||
|
||||
class AppDirectories:
|
||||
def __init__(self, cwd, data_dir) -> None:
|
||||
self.DATA_DIR = data_dir
|
||||
self.WEB_PATH = cwd.joinpath("dist")
|
||||
self.IMG_DIR = data_dir.joinpath("img")
|
||||
self.BACKUP_DIR = data_dir.joinpath("backups")
|
||||
self.DEBUG_DIR = data_dir.joinpath("debug")
|
||||
self.MIGRATION_DIR = data_dir.joinpath("migration")
|
||||
self.NEXTCLOUD_DIR = self.MIGRATION_DIR.joinpath("nextcloud")
|
||||
self.CHOWDOWN_DIR = self.MIGRATION_DIR.joinpath("chowdown")
|
||||
self.TEMPLATE_DIR = data_dir.joinpath("templates")
|
||||
self.USER_DIR = data_dir.joinpath("users")
|
||||
self.SQLITE_DIR = data_dir.joinpath("db")
|
||||
self.RECIPE_DATA_DIR = data_dir.joinpath("recipes")
|
||||
self.TEMP_DIR = data_dir.joinpath(".temp")
|
||||
self.DATA_DIR: Path = data_dir
|
||||
self.WEB_PATH: Path = cwd.joinpath("dist")
|
||||
self.IMG_DIR: Path = data_dir.joinpath("img")
|
||||
self.BACKUP_DIR: Path = data_dir.joinpath("backups")
|
||||
self.DEBUG_DIR: Path = data_dir.joinpath("debug")
|
||||
self.MIGRATION_DIR: Path = data_dir.joinpath("migration")
|
||||
self.NEXTCLOUD_DIR: Path = self.MIGRATION_DIR.joinpath("nextcloud")
|
||||
self.CHOWDOWN_DIR: Path = self.MIGRATION_DIR.joinpath("chowdown")
|
||||
self.TEMPLATE_DIR: Path = data_dir.joinpath("templates")
|
||||
self.USER_DIR: Path = data_dir.joinpath("users")
|
||||
self.SQLITE_DIR: Path = data_dir.joinpath("db")
|
||||
self.RECIPE_DATA_DIR: Path = data_dir.joinpath("recipes")
|
||||
self.TEMP_DIR: Path = data_dir.joinpath(".temp")
|
||||
|
||||
self.ensure_directories()
|
||||
|
||||
@@ -74,36 +81,51 @@ class AppDirectories:
|
||||
dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
class AppSettings:
|
||||
def __init__(self, app_dirs: AppDirectories) -> None:
|
||||
global DB_VERSION
|
||||
self.PRODUCTION = bool(os.environ.get("ENV"))
|
||||
self.IS_DEMO = os.getenv("DEMO", "False") == "True"
|
||||
self.API_PORT = int(os.getenv("API_PORT", 9000))
|
||||
self.API = os.getenv("API_DOCS", "False") == "True"
|
||||
self.DOCS_URL = "/docs" if self.API else None
|
||||
self.REDOC_URL = "/redoc" if self.API else None
|
||||
self.SECRET = determine_secrets(app_dirs.DATA_DIR, self.PRODUCTION)
|
||||
self.DATABASE_TYPE = os.getenv("DB_TYPE", "sqlite")
|
||||
|
||||
# Used to Set SQLite File Version
|
||||
self.SQLITE_FILE = None
|
||||
if self.DATABASE_TYPE == "sqlite":
|
||||
self.SQLITE_FILE = app_dirs.SQLITE_DIR.joinpath(f"mealie_{DB_VERSION}.sqlite")
|
||||
else:
|
||||
raise Exception("Unable to determine database type. Acceptible options are 'sqlite'")
|
||||
|
||||
self.DEFAULT_GROUP = os.getenv("DEFAULT_GROUP", "Home")
|
||||
self.DEFAULT_PASSWORD = os.getenv("DEFAULT_PASSWORD", "MyPassword")
|
||||
|
||||
# Not Used!
|
||||
self.SFTP_USERNAME = os.getenv("SFTP_USERNAME", None)
|
||||
self.SFTP_PASSWORD = os.getenv("SFTP_PASSWORD", None)
|
||||
|
||||
|
||||
# General
|
||||
DATA_DIR = determine_data_dir(PRODUCTION)
|
||||
LOGGER_FILE = DATA_DIR.joinpath("mealie.log")
|
||||
|
||||
app_dirs = AppDirectories(CWD, DATA_DIR)
|
||||
settings = AppSettings(app_dirs)
|
||||
|
||||
|
||||
class AppSettings(BaseSettings):
|
||||
global DATA_DIR
|
||||
PRODUCTION: bool = Field(True, env="PRODUCTION")
|
||||
IS_DEMO: bool = False
|
||||
API_PORT: int = 9000
|
||||
API_DOCS: bool = True
|
||||
|
||||
@property
|
||||
def DOCS_URL(self) -> str:
|
||||
return "/docs" if self.API_DOCS else None
|
||||
|
||||
@property
|
||||
def REDOC_URL(self) -> str:
|
||||
return "/redoc" if self.API_DOCS else None
|
||||
|
||||
SECRET: str = determine_secrets(DATA_DIR, PRODUCTION)
|
||||
DATABASE_TYPE: str = Field("sqlite", env="DB_TYPE")
|
||||
|
||||
@validator("DATABASE_TYPE", pre=True)
|
||||
def validate_db_type(cls, v: str) -> Optional[str]:
|
||||
if v != "sqlite":
|
||||
raise ValueError("Unable to determine database type. Acceptible options are 'sqlite'")
|
||||
else:
|
||||
return v
|
||||
|
||||
# Used to Set SQLite File Version
|
||||
SQLITE_FILE: Optional[Union[str, Path]]
|
||||
|
||||
@validator("SQLITE_FILE", pre=True)
|
||||
def identify_sqlite_file(cls, v: str) -> Optional[str]:
|
||||
return app_dirs.SQLITE_DIR.joinpath(f"mealie_{DB_VERSION}.sqlite")
|
||||
|
||||
DEFAULT_GROUP: str = "Home"
|
||||
DEFAULT_PASSWORD: str = "MyPassword"
|
||||
|
||||
# Not Used!
|
||||
SFTP_USERNAME: Optional[str]
|
||||
SFTP_PASSWORD: Optional[str]
|
||||
|
||||
class Config:
|
||||
env_file = BASE_DIR.joinpath(".env")
|
||||
env_file_encoding = "utf-8"
|
||||
|
||||
|
||||
settings = AppSettings()
|
||||
|
||||
43
mealie/core/root_logger.py
Normal file
43
mealie/core/root_logger.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from mealie.core.config import DATA_DIR
|
||||
|
||||
LOGGER_FILE = DATA_DIR.joinpath("mealie.log")
|
||||
LOGGER_FORMAT = "%(levelname)s: \t%(message)s"
|
||||
DATE_FORMAT = "%d-%b-%y %H:%M:%S"
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format=LOGGER_FORMAT, datefmt="%d-%b-%y %H:%M:%S")
|
||||
|
||||
|
||||
def logger_init() -> logging.Logger:
|
||||
""" Returns the Root Loggin Object for Mealie """
|
||||
logger = logging.getLogger("mealie")
|
||||
logger.propagate = False
|
||||
|
||||
# File Handler
|
||||
output_file_handler = logging.FileHandler(LOGGER_FILE)
|
||||
handler_format = logging.Formatter(LOGGER_FORMAT, datefmt=DATE_FORMAT)
|
||||
output_file_handler.setFormatter(handler_format)
|
||||
|
||||
# Stdout
|
||||
stdout_handler = logging.StreamHandler(sys.stdout)
|
||||
stdout_handler.setFormatter(handler_format)
|
||||
|
||||
logger.addHandler(output_file_handler)
|
||||
logger.addHandler(stdout_handler)
|
||||
|
||||
return logger
|
||||
|
||||
|
||||
def get_logger(module=None) -> logging.Logger:
|
||||
""" Returns a child logger for mealie """
|
||||
global root_logger
|
||||
|
||||
if module is None:
|
||||
return root_logger
|
||||
|
||||
return root_logger.getChild(module)
|
||||
|
||||
|
||||
root_logger = logger_init()
|
||||
@@ -1,9 +1,10 @@
|
||||
from datetime import datetime, timedelta
|
||||
from mealie.schema.user import UserInDB
|
||||
from pathlib import Path
|
||||
|
||||
from jose import jwt
|
||||
from mealie.core.config import settings
|
||||
from mealie.db.database import db
|
||||
from mealie.schema.user import UserInDB
|
||||
from passlib.context import CryptContext
|
||||
|
||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
@@ -20,6 +21,11 @@ def create_access_token(data: dict(), expires_delta: timedelta = None) -> str:
|
||||
return jwt.encode(to_encode, settings.SECRET, algorithm=ALGORITHM)
|
||||
|
||||
|
||||
def create_file_token(file_path: Path) -> bool:
|
||||
token_data = {"file": str(file_path)}
|
||||
return create_access_token(token_data, expires_delta=timedelta(minutes=30))
|
||||
|
||||
|
||||
def authenticate_user(session, email: str, password: str) -> UserInDB:
|
||||
user: UserInDB = db.users.get(session, email, "email")
|
||||
if not user:
|
||||
|
||||
@@ -9,7 +9,8 @@ from mealie.db.models.users import User
|
||||
from mealie.schema.category import RecipeCategoryResponse, RecipeTagResponse
|
||||
from mealie.schema.meal import MealPlanInDB
|
||||
from mealie.schema.recipe import Recipe
|
||||
from mealie.schema.settings import CustomPageOut, SiteSettings as SiteSettingsSchema
|
||||
from mealie.schema.settings import CustomPageOut
|
||||
from mealie.schema.settings import SiteSettings as SiteSettingsSchema
|
||||
from mealie.schema.sign_up import SignUpOut
|
||||
from mealie.schema.theme import SiteTheme
|
||||
from mealie.schema.user import GroupInDB, UserInDB
|
||||
|
||||
@@ -15,17 +15,10 @@ class BaseDocument:
|
||||
self.schema: BaseModel
|
||||
|
||||
# TODO: Improve Get All Query Functionality
|
||||
def get_all(self, session: Session, limit: int = None, order_by: str = None) -> List[dict]:
|
||||
def get_all(self, session: Session, limit: int = None, order_by: str = None, override_schema=None) -> List[dict]:
|
||||
eff_schema = override_schema or self.schema
|
||||
|
||||
if self.orm_mode:
|
||||
return [self.schema.from_orm(x) for x in session.query(self.sql_model).limit(limit).all()]
|
||||
|
||||
# list = [x.dict() for x in session.query(self.sql_model).limit(limit).all()]
|
||||
|
||||
# if limit == 1:
|
||||
# return list[0]
|
||||
|
||||
# return list
|
||||
return [eff_schema.from_orm(x) for x in session.query(self.sql_model).limit(limit).all()]
|
||||
|
||||
def get_all_limit_columns(self, session: Session, fields: List[str], limit: int = None) -> List[SqlAlchemyBase]:
|
||||
"""Queries the database for the selected model. Restricts return responses to the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from fastapi.logger import logger
|
||||
from mealie.core import root_logger
|
||||
from mealie.core.config import settings
|
||||
from mealie.core.security import get_password_hash
|
||||
from mealie.db.database import db
|
||||
@@ -7,6 +7,8 @@ from mealie.schema.settings import SiteSettings
|
||||
from mealie.schema.theme import SiteTheme
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
logger = root_logger.get_logger("init_db")
|
||||
|
||||
|
||||
def init_db(db: Session = None) -> None:
|
||||
if not db:
|
||||
@@ -48,10 +50,13 @@ def default_user_init(session: Session):
|
||||
db.users.create(session, default_user)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
if sql_exists:
|
||||
print("Database Exists")
|
||||
exit()
|
||||
else:
|
||||
print("Database Doesn't Exists, Initializing...")
|
||||
init_db()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import sqlalchemy as sa
|
||||
import sqlalchemy.orm as orm
|
||||
from fastapi.logger import logger
|
||||
from mealie.core import root_logger
|
||||
from mealie.db.models.model_base import SqlAlchemyBase
|
||||
from slugify import slugify
|
||||
from sqlalchemy.orm import validates
|
||||
|
||||
logger = root_logger.get_logger()
|
||||
|
||||
site_settings2categories = sa.Table(
|
||||
"site_settings2categoories",
|
||||
SqlAlchemyBase.metadata,
|
||||
@@ -59,8 +61,8 @@ class Category(SqlAlchemyBase):
|
||||
test_slug = slugify(name)
|
||||
result = session.query(Category).filter(Category.slug == test_slug).one_or_none()
|
||||
if result:
|
||||
logger.info("Category exists, associating recipe")
|
||||
logger.debug("Category exists, associating recipe")
|
||||
return result
|
||||
else:
|
||||
logger.info("Category doesn't exists, creating tag")
|
||||
logger.debug("Category doesn't exists, creating tag")
|
||||
return Category(name=name)
|
||||
|
||||
@@ -60,7 +60,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
||||
|
||||
@validates("name")
|
||||
def validate_name(self, key, name):
|
||||
assert not name == ""
|
||||
assert name != ""
|
||||
return name
|
||||
|
||||
def __init__(
|
||||
@@ -92,11 +92,7 @@ class RecipeModel(SqlAlchemyBase, BaseMixins):
|
||||
self.image = image
|
||||
self.recipeCuisine = recipeCuisine
|
||||
|
||||
if self.nutrition:
|
||||
self.nutrition = Nutrition(**nutrition)
|
||||
else:
|
||||
self.nutrition = Nutrition()
|
||||
|
||||
self.nutrition = Nutrition(**nutrition) if self.nutrition else Nutrition()
|
||||
self.tools = [Tool(tool=x) for x in tools] if tools else []
|
||||
|
||||
self.recipeYield = recipeYield
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import sqlalchemy as sa
|
||||
import sqlalchemy.orm as orm
|
||||
from mealie.core import root_logger
|
||||
from mealie.db.models.model_base import SqlAlchemyBase
|
||||
from fastapi.logger import logger
|
||||
from slugify import slugify
|
||||
from sqlalchemy.orm import validates
|
||||
|
||||
logger = root_logger.get_logger()
|
||||
|
||||
recipes2tags = sa.Table(
|
||||
"recipes2tags",
|
||||
SqlAlchemyBase.metadata,
|
||||
@@ -25,7 +27,7 @@ class Tag(SqlAlchemyBase):
|
||||
assert name != ""
|
||||
return name
|
||||
|
||||
def __init__(self, name) -> None:
|
||||
def __init__(self, name, session=None) -> None:
|
||||
self.name = name.strip()
|
||||
self.slug = slugify(self.name)
|
||||
|
||||
@@ -35,8 +37,8 @@ class Tag(SqlAlchemyBase):
|
||||
result = session.query(Tag).filter(Tag.slug == test_slug).one_or_none()
|
||||
|
||||
if result:
|
||||
logger.info("Tag exists, associating recipe")
|
||||
logger.debug("Tag exists, associating recipe")
|
||||
return result
|
||||
else:
|
||||
logger.info("Tag doesn't exists, creating tag")
|
||||
logger.debug("Tag doesn't exists, creating tag")
|
||||
return Tag(name=name)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import operator
|
||||
import shutil
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, File, HTTPException, UploadFile
|
||||
from mealie.core.config import app_dirs
|
||||
from mealie.core.security import create_file_token
|
||||
from mealie.db.db_setup import generate_session
|
||||
from mealie.routes.deps import get_current_user
|
||||
from mealie.routes.deps import get_current_user, validate_file_token
|
||||
from mealie.schema.backup import BackupJob, ImportJob, Imports, LocalBackup
|
||||
from mealie.schema.snackbar import SnackResponse
|
||||
from mealie.services.backups import imports
|
||||
@@ -68,13 +70,10 @@ def upload_backup_file(archive: UploadFile = File(...)):
|
||||
|
||||
@router.get("/{file_name}/download")
|
||||
async def download_backup_file(file_name: str):
|
||||
""" Upload a .zip File to later be imported into Mealie """
|
||||
""" Returns a token to download a file """
|
||||
file = app_dirs.BACKUP_DIR.joinpath(file_name)
|
||||
|
||||
if file.is_file:
|
||||
return FileResponse(file, media_type="application/octet-stream", filename=file_name)
|
||||
else:
|
||||
return SnackResponse.error("No File Found")
|
||||
return {"fileToken": create_file_token(file)}
|
||||
|
||||
|
||||
@router.post("/{file_name}/import", status_code=200)
|
||||
|
||||
@@ -1,30 +1,45 @@
|
||||
import json
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from mealie.core.config import APP_VERSION, LOGGER_FILE, app_dirs, settings
|
||||
from mealie.core.config import APP_VERSION, app_dirs, settings
|
||||
from mealie.core.root_logger import LOGGER_FILE
|
||||
from mealie.core.security import create_file_token
|
||||
from mealie.routes.deps import get_current_user
|
||||
from mealie.schema.debug import AppInfo, DebugInfo
|
||||
|
||||
router = APIRouter(prefix="/api/debug", tags=["Debug"])
|
||||
|
||||
|
||||
@router.get("")
|
||||
async def get_debug_info(current_user=Depends(get_current_user)):
|
||||
""" Returns general information about the application for debugging """
|
||||
|
||||
return DebugInfo(
|
||||
production=settings.PRODUCTION,
|
||||
version=APP_VERSION,
|
||||
demo_status=settings.IS_DEMO,
|
||||
api_port=settings.API_PORT,
|
||||
api_docs=settings.API_DOCS,
|
||||
db_type=settings.DATABASE_TYPE,
|
||||
sqlite_file=settings.SQLITE_FILE,
|
||||
default_group=settings.DEFAULT_GROUP,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/version")
|
||||
async def get_mealie_version(current_user=Depends(get_current_user)):
|
||||
async def get_mealie_version():
|
||||
""" Returns the current version of mealie"""
|
||||
return {"version": APP_VERSION}
|
||||
|
||||
|
||||
@router.get("/is-demo")
|
||||
async def get_demo_status():
|
||||
print(settings.IS_DEMO)
|
||||
return {"demoStatus": settings.IS_DEMO}
|
||||
return AppInfo(
|
||||
version=APP_VERSION,
|
||||
demo_status=settings.IS_DEMO,
|
||||
production=settings.PRODUCTION,
|
||||
)
|
||||
|
||||
|
||||
@router.get("/last-recipe-json")
|
||||
async def get_last_recipe_json(current_user=Depends(get_current_user)):
|
||||
""" Doc Str """
|
||||
|
||||
with open(app_dirs.DEBUG_DIR.joinpath("last_recipe.json"), "r") as f:
|
||||
return json.loads(f.read())
|
||||
""" Returns a token to download a file """
|
||||
return {"fileToken": create_file_token(app_dirs.DEBUG_DIR.joinpath("last_recipe.json"))}
|
||||
|
||||
|
||||
@router.get("/log/{num}")
|
||||
@@ -35,6 +50,12 @@ async def get_log(num: int, current_user=Depends(get_current_user)):
|
||||
return log_text
|
||||
|
||||
|
||||
@router.get("/log")
|
||||
async def get_log_file():
|
||||
""" Returns a token to download a file """
|
||||
return {"fileToken": create_file_token(LOGGER_FILE)}
|
||||
|
||||
|
||||
def tail(f, lines=20):
|
||||
total_lines_wanted = lines
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import Depends, HTTPException, status
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
from jose import JWTError, jwt
|
||||
@@ -25,7 +28,25 @@ async def get_current_user(token: str = Depends(oauth2_scheme), session=Depends(
|
||||
token_data = TokenData(username=username)
|
||||
except JWTError:
|
||||
raise credentials_exception
|
||||
|
||||
user = db.users.get(session, token_data.username, "email")
|
||||
if user is None:
|
||||
raise credentials_exception
|
||||
return user
|
||||
|
||||
|
||||
async def validate_file_token(token: Optional[str] = None) -> Path:
|
||||
credentials_exception = HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="could not validate file token",
|
||||
)
|
||||
if not token:
|
||||
return None
|
||||
|
||||
try:
|
||||
payload = jwt.decode(token, settings.SECRET, algorithms=[ALGORITHM])
|
||||
file_path = Path(payload.get("file"))
|
||||
except JWTError:
|
||||
raise credentials_exception
|
||||
|
||||
return file_path
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from mealie.db.database import db
|
||||
from mealie.db.db_setup import generate_session
|
||||
from mealie.routes.deps import get_current_user
|
||||
from mealie.schema.meal import MealPlanIn, MealPlanInDB
|
||||
from mealie.schema.snackbar import SnackResponse
|
||||
from mealie.schema.user import GroupInDB, UserInDB
|
||||
from mealie.services.image import image
|
||||
from mealie.services.meal_services import get_todays_meal, process_meals
|
||||
from sqlalchemy.orm.session import Session
|
||||
from starlette.responses import FileResponse
|
||||
|
||||
router = APIRouter(prefix="/api/meal-plans", tags=["Meal Plan"])
|
||||
|
||||
@@ -74,3 +76,22 @@ def get_today(session: Session = Depends(generate_session), current_user: UserIn
|
||||
recipe = get_todays_meal(session, group_in_db)
|
||||
|
||||
return recipe.slug
|
||||
|
||||
|
||||
@router.get("/today/image", tags=["Meal Plan"])
|
||||
def get_todays_image(session: Session = Depends(generate_session), group_name: str = "Home"):
|
||||
"""
|
||||
Returns the image for todays meal-plan.
|
||||
"""
|
||||
|
||||
group_in_db: GroupInDB = db.groups.get(session, group_name, "name")
|
||||
recipe = get_todays_meal(session, group_in_db)
|
||||
|
||||
if recipe:
|
||||
recipe_image = image.read_image(recipe.slug, image_type=image.IMG_OPTIONS.ORIGINAL_IMAGE)
|
||||
else:
|
||||
raise HTTPException(404, "no meal for today")
|
||||
if recipe_image:
|
||||
return FileResponse(recipe_image)
|
||||
else:
|
||||
raise HTTPException(404, "file not found")
|
||||
|
||||
@@ -8,15 +8,14 @@ from mealie.db.db_setup import generate_session
|
||||
from mealie.routes.deps import get_current_user
|
||||
from mealie.schema.migration import MigrationFile, Migrations
|
||||
from mealie.schema.snackbar import SnackResponse
|
||||
from mealie.services.migrations.chowdown import chowdown_migrate as chowdow_migrate
|
||||
from mealie.services.migrations.nextcloud import migrate as nextcloud_migrate
|
||||
from mealie.services.migrations import migration
|
||||
from sqlalchemy.orm.session import Session
|
||||
|
||||
router = APIRouter(prefix="/api/migrations", tags=["Migration"], dependencies=[Depends(get_current_user)])
|
||||
|
||||
|
||||
@router.get("", response_model=List[Migrations])
|
||||
def get_avaiable_nextcloud_imports():
|
||||
def get_all_migration_options():
|
||||
""" Returns a list of avaiable directories that can be imported into Mealie """
|
||||
response_data = []
|
||||
migration_dirs = [
|
||||
@@ -36,23 +35,18 @@ def get_avaiable_nextcloud_imports():
|
||||
return response_data
|
||||
|
||||
|
||||
@router.post("/{type}/{file_name}/import")
|
||||
def import_nextcloud_directory(type: str, file_name: str, session: Session = Depends(generate_session)):
|
||||
@router.post("/{import_type}/{file_name}/import")
|
||||
def import_migration(import_type: migration.Migration, file_name: str, session: Session = Depends(generate_session)):
|
||||
""" Imports all the recipes in a given directory """
|
||||
file_path = app_dirs.MIGRATION_DIR.joinpath(type, file_name)
|
||||
if type == "nextcloud":
|
||||
return nextcloud_migrate(session, file_path)
|
||||
elif type == "chowdown":
|
||||
return chowdow_migrate(session, file_path)
|
||||
else:
|
||||
return SnackResponse.error("Incorrect Migration Type Selected")
|
||||
file_path = app_dirs.MIGRATION_DIR.joinpath(import_type.value, file_name)
|
||||
return migration.migrate(import_type, file_path, session)
|
||||
|
||||
|
||||
@router.delete("/{type}/{file_name}/delete")
|
||||
def delete_migration_data(type: str, file_name: str):
|
||||
@router.delete("/{import_type}/{file_name}/delete")
|
||||
def delete_migration_data(import_type: migration.Migration, file_name: str):
|
||||
""" Removes migration data from the file system """
|
||||
|
||||
remove_path = app_dirs.MIGRATION_DIR.joinpath(type, file_name)
|
||||
remove_path = app_dirs.MIGRATION_DIR.joinpath(import_type.value, file_name)
|
||||
|
||||
if remove_path.is_file():
|
||||
remove_path.unlink()
|
||||
@@ -64,10 +58,10 @@ def delete_migration_data(type: str, file_name: str):
|
||||
return SnackResponse.error(f"Migration Data Remove: {remove_path.absolute()}")
|
||||
|
||||
|
||||
@router.post("/{type}/upload")
|
||||
def upload_nextcloud_zipfile(type: str, archive: UploadFile = File(...)):
|
||||
@router.post("/{import_type}/upload")
|
||||
def upload_nextcloud_zipfile(import_type: migration.Migration, archive: UploadFile = File(...)):
|
||||
""" Upload a .zip File to later be imported into Mealie """
|
||||
dir = app_dirs.MIGRATION_DIR.joinpath(type)
|
||||
dir = app_dirs.MIGRATION_DIR.joinpath(import_type.value)
|
||||
dir.mkdir(parents=True, exist_ok=True)
|
||||
dest = dir.joinpath(archive.filename)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user