Compare commits
7
Commits
d613f8c1d7
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eec69819e9 | ||
|
|
8998752865 | ||
|
|
fc349a418b | ||
|
|
058deacd32 | ||
|
|
6980a2acc0 | ||
|
|
0d7770a446 | ||
|
|
c53d842c34 |
No files matched your search
Generated
+5
-5
@@ -395,7 +395,7 @@ checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -1144,7 +1144,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "label_editor"
|
name = "label_editor"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"common",
|
"common",
|
||||||
"server",
|
"server",
|
||||||
@@ -1573,7 +1573,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "server"
|
name = "server"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"common",
|
"common",
|
||||||
@@ -1969,9 +1969,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.53.1"
|
version = "1.53.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed"
|
checksum = "e95f91fcc7a621e8b030f6aa23c71fe9838ae2fb4d8118b75602a328f5144044"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"libc",
|
"libc",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "label_editor"
|
name = "label_editor"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Matthias Lodner <matthias@lodner.de>"]
|
authors = ["Matthias Lodner <matthias@lodner.de>"]
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -92,3 +92,59 @@ ORDER BY a.name, v.weight ASC
|
|||||||
|
|
||||||
## Lodner kleines Etikett
|
## Lodner kleines Etikett
|
||||||
|
|
||||||
|
## Käfer Essen im Glas
|
||||||
|
### SQL Abfrage
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
a.name AS product,
|
||||||
|
CONCAT(a.topm_id, v.topm_row) AS aritcle_number,
|
||||||
|
COALESCE(v.name, a.name) AS name,
|
||||||
|
COALESCE(a.additional_name, COALESCE(v.name, a.name)) AS sigel_name,
|
||||||
|
CONCAT(CONCAT(v.weight, ' '), u.display) AS weight,
|
||||||
|
v.ean AS ean,
|
||||||
|
COALESCE(v.description, a.description) AS description,
|
||||||
|
COALESCE(v.ingredients, a.ingredients) AS ingredients,
|
||||||
|
COALESCE(a.mhd, s.mhd) AS mhd,
|
||||||
|
COALESCE(a.allergens_text, s.allergens_text) AS allergens_info,
|
||||||
|
CONCAT(
|
||||||
|
CONCAT(n.calorific_value_kj, ' kJ<br>'),
|
||||||
|
CONCAT(n.calorific_value_kcal, ' kcal')
|
||||||
|
) AS energy,
|
||||||
|
n.fat,
|
||||||
|
n.saturated_fat,
|
||||||
|
n.carbohydrates,
|
||||||
|
n.sugar,
|
||||||
|
n.fibers,
|
||||||
|
n.protein,
|
||||||
|
n.salt
|
||||||
|
FROM article AS a
|
||||||
|
INNER JOIN variant AS v ON v.article_id = a.id
|
||||||
|
INNER JOIN settings AS s ON v.article_id = v.article_id
|
||||||
|
INNER JOIN unit AS u ON v.unit_id = u.id
|
||||||
|
INNER JOIN label AS l ON v.label_id = l.id
|
||||||
|
INNER JOIN nutrition AS n ON n.id = a.nutrition_id
|
||||||
|
WHERE v.label_id = 3
|
||||||
|
ORDER BY a.name, v.weight ASC
|
||||||
|
```
|
||||||
|
|
||||||
|
### HTML settings for label
|
||||||
|
|
||||||
|
#### Product title
|
||||||
|
```html
|
||||||
|
<div style="text-align: center; font-size: 16pt; font-family: Optima LT Std;">
|
||||||
|
</div><div style="text-align: center; font-size: 8pt; font-family: Optima nova LT Pro Titling Init;">- HANDGEMACHT -</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### MHD
|
||||||
|
```html
|
||||||
|
<div style="text-align: center; font-size: 7pt; font-family: Optima LT Std;">Ungeöffnet bei 4°C - 7°C mindestens haltbar bis:
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Impressum
|
||||||
|
```html
|
||||||
|
<div style="text-align: center; font-size: 7pt; font-family: Optima LT Std;">
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Matthias Lodner <matthias@lodner.de>"]
|
authors = ["Matthias Lodner <matthias@lodner.de>"]
|
||||||
|
|
||||||
|
|||||||
@@ -290,8 +290,10 @@ pub async fn article_add_nutrition(article_id: i64, pool: PgPool) -> Option<Arti
|
|||||||
|
|
||||||
match res {
|
match res {
|
||||||
Ok(record) => {
|
Ok(record) => {
|
||||||
let article = from_postgres_row_small(record);
|
match load_article(article_id, pool).await {
|
||||||
Some(article)
|
Some(article) => Some(article),
|
||||||
|
None => None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("Error while adding nutrition to article: {}", article_id);
|
error!("Error while adding nutrition to article: {}", article_id);
|
||||||
|
|||||||
@@ -129,9 +129,9 @@ pub async fn update_nutrition(nutrition_id: i64, nutrition: &Nutrition, pool: Pg
|
|||||||
args.add(&nutrition.protein);
|
args.add(&nutrition.protein);
|
||||||
args.add(&nutrition.salt);
|
args.add(&nutrition.salt);
|
||||||
let statement = format!(
|
let statement = format!(
|
||||||
"UPDATE {} SET calorific_value_kj = $3, calorific_value_kcal = $4, fat = $5,\
|
"UPDATE {} SET calorific_value_kj = $2, calorific_value_kcal = $3, fat = $4,\
|
||||||
saturated_fat = $6, carbohydrates = $7, sugar = $8, fibers = $9, protein = $10,\
|
saturated_fat = $5, carbohydrates = $6, sugar = $7, fibers = $8, protein = $9,\
|
||||||
salt = $11 WHERE id = $1 RETURNING *",
|
salt = $10 WHERE id = $1 RETURNING *",
|
||||||
"nutrition",
|
"nutrition",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import {useLabelEditorStore} from "~/store/labelEditorStore";
|
import {useLabelEditorStore} from "~/store/labelEditorStore";
|
||||||
import type {Ref} from "vue";
|
import type {Ref} from "vue";
|
||||||
import DeleteConfirm from "~/components/ui/deleteConfirm.vue";
|
import DeleteConfirm from "~/components/ui/deleteConfirm.vue";
|
||||||
import type {Nutrition} from "~/types/nutrition.ts";
|
import {Nutrition} from "~/types/nutrition.ts";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
nutrition: {type: Object as PropType<Nutrition | null>, required: true},
|
nutrition: {type: Object as PropType<Nutrition | null>, required: true},
|
||||||
@@ -11,22 +11,70 @@
|
|||||||
let store = useLabelEditorStore();
|
let store = useLabelEditorStore();
|
||||||
let loading: Ref<boolean> = ref<boolean>(false);
|
let loading: Ref<boolean> = ref<boolean>(false);
|
||||||
let dialog: Ref<boolean> = ref<boolean>(false);
|
let dialog: Ref<boolean> = ref<boolean>(false);
|
||||||
|
|
||||||
|
let calorific_value_kj: Ref<number> = ref<number>(JSON.parse(JSON.stringify(0)));
|
||||||
|
let calorific_value_kcal: Ref<number> = ref<number>(JSON.parse(JSON.stringify(0)));
|
||||||
|
let fat: Ref<number> = ref<number>(JSON.parse(JSON.stringify(0)));
|
||||||
|
let saturated_fat: Ref<number> = ref<number>(JSON.parse(JSON.stringify(0)));
|
||||||
|
let carbohydrates: Ref<number> = ref<number>(JSON.parse(JSON.stringify(0)));
|
||||||
|
let sugar: Ref<number> = ref<number>(JSON.parse(JSON.stringify(0)));
|
||||||
|
let fibers: Ref<number> = ref<number>(JSON.parse(JSON.stringify(0)));
|
||||||
|
let protein: Ref<number> = ref<number>(JSON.parse(JSON.stringify(0)));
|
||||||
|
let salt: Ref<number> = ref<number>(JSON.parse(JSON.stringify(0)));
|
||||||
|
|
||||||
|
watch(dialog, async (oldDialog) => {
|
||||||
|
if (oldDialog) {
|
||||||
|
if (props.nutrition != null) {
|
||||||
|
calorific_value_kj.value = props.nutrition.calorific_value_kj;
|
||||||
|
calorific_value_kcal.value = props.nutrition.calorific_value_kcal;
|
||||||
|
fat.value = props.nutrition.fat;
|
||||||
|
saturated_fat.value = props.nutrition.saturated_fat;
|
||||||
|
carbohydrates.value = props.nutrition.carbohydrates;
|
||||||
|
sugar.value = props.nutrition.sugar;
|
||||||
|
fibers.value = props.nutrition.fibers;
|
||||||
|
protein.value = props.nutrition.protein;
|
||||||
|
salt.value = props.nutrition.salt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
async function createNutrition() {
|
async function createNutrition() {
|
||||||
if (store.article != null) {
|
if (store.article != null) {
|
||||||
await store.createArticleNutrition(store.article.id);
|
await store.createArticleNutrition(store.article.id);
|
||||||
|
|
||||||
|
calorific_value_kj.value = 0;
|
||||||
|
calorific_value_kcal.value = 0;
|
||||||
|
fat.value = 0;
|
||||||
|
saturated_fat.value = 0;
|
||||||
|
carbohydrates.value = 0;
|
||||||
|
sugar.value = 0;
|
||||||
|
fibers.value = 0;
|
||||||
|
protein.value = 0;
|
||||||
|
salt.value = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateNutrition() {
|
async function updateNutrition() {
|
||||||
if (props.nutrition != null) {
|
if (props.nutrition != null) {
|
||||||
await store.updateNutrition(props.nutrition);
|
let nutrition = new Nutrition(props.nutrition.id,
|
||||||
|
parseFloat(calorific_value_kj.value.toString()),
|
||||||
|
parseFloat(calorific_value_kcal.value.toString()),
|
||||||
|
parseFloat(fat.value.toString()),
|
||||||
|
parseFloat(saturated_fat.value.toString()),
|
||||||
|
parseFloat(carbohydrates.value.toString()),
|
||||||
|
parseFloat(sugar.value.toString()),
|
||||||
|
parseFloat(fibers.value.toString()),
|
||||||
|
parseFloat(protein.value.toString()),
|
||||||
|
parseFloat(salt.value.toString()),
|
||||||
|
);
|
||||||
|
|
||||||
|
await store.updateNutrition(nutrition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteNutrition() {
|
async function deleteNutrition() {
|
||||||
if (props.nutrition != null) {
|
if (props.nutrition != null) {
|
||||||
await store.deleteNutrition(props.nutrition)
|
await store.deleteArticleNutrition(props.nutrition);
|
||||||
}
|
}
|
||||||
|
|
||||||
closeDialog();
|
closeDialog();
|
||||||
@@ -91,7 +139,7 @@
|
|||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="props.nutrition.calorific_value_kcal"
|
v-model="calorific_value_kcal"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
hint="Brennwert in kcal"
|
hint="Brennwert in kcal"
|
||||||
label="Brennwert"
|
label="Brennwert"
|
||||||
@@ -102,7 +150,7 @@
|
|||||||
|
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="props.nutrition.calorific_value_kj"
|
v-model="calorific_value_kj"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
hint="Brennwert in kj"
|
hint="Brennwert in kj"
|
||||||
label="Brennwert"
|
label="Brennwert"
|
||||||
@@ -113,7 +161,7 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="props.nutrition.fat"
|
v-model="fat"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
hint="Fett in g"
|
hint="Fett in g"
|
||||||
label="Fett"
|
label="Fett"
|
||||||
@@ -122,7 +170,7 @@
|
|||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="props.nutrition.saturated_fat"
|
v-model="saturated_fat"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
hint="Gesättigte Fettsäuren in g"
|
hint="Gesättigte Fettsäuren in g"
|
||||||
label="Gesättigte Fettsäuren"
|
label="Gesättigte Fettsäuren"
|
||||||
@@ -131,7 +179,7 @@
|
|||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="props.nutrition.carbohydrates"
|
v-model="carbohydrates"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
hint="Kohlenhydrate in g"
|
hint="Kohlenhydrate in g"
|
||||||
label="Kohlenhydrate"
|
label="Kohlenhydrate"
|
||||||
@@ -140,7 +188,7 @@
|
|||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="props.nutrition.sugar"
|
v-model="sugar"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
hint="Zucker in g"
|
hint="Zucker in g"
|
||||||
label="Zucker"
|
label="Zucker"
|
||||||
@@ -149,7 +197,7 @@
|
|||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="props.nutrition.fibers"
|
v-model="fibers"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
hint="Ballaststoffe in g"
|
hint="Ballaststoffe in g"
|
||||||
label="Ballaststoffe"
|
label="Ballaststoffe"
|
||||||
@@ -158,7 +206,7 @@
|
|||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="props.nutrition.protein"
|
v-model="protein"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
hint="Eiweiß in g"
|
hint="Eiweiß in g"
|
||||||
label="Eiweiß"
|
label="Eiweiß"
|
||||||
@@ -167,7 +215,7 @@
|
|||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="props.nutrition.salt"
|
v-model="salt"
|
||||||
:disabled="loading"
|
:disabled="loading"
|
||||||
hint="Salz in g"
|
hint="Salz in g"
|
||||||
label="Salz"
|
label="Salz"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {defineStore} from "pinia";
|
import {defineStore} from "pinia";
|
||||||
import type {Article} from "~/types/article";
|
import {Article} from "~/types/article";
|
||||||
import {NotificationMessage} from "~/types/notificationMessage";
|
import {NotificationMessage} from "~/types/notificationMessage";
|
||||||
import type {RuntimeConfig} from "nuxt/schema";
|
import type {RuntimeConfig} from "nuxt/schema";
|
||||||
import {Origin} from "~/types/origin";
|
import {Origin} from "~/types/origin";
|
||||||
@@ -489,17 +489,22 @@ export const useLabelEditorStore = defineStore('label_editor_store', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async deleteNutrition(nutrition: Nutrition): Promise<Nutrition | null> {
|
async deleteArticleNutrition(nutrition: Nutrition): Promise<Nutrition | null> {
|
||||||
try {
|
if (this.article != null) {
|
||||||
await $fetch(this.config.public.url + '/nutrition/' + nutrition.id, {
|
try {
|
||||||
method: 'DELETE',
|
await $fetch(this.config.public.url + '/article/' + this.article.id + '/nutrition', {
|
||||||
});
|
method: 'DELETE',
|
||||||
|
});
|
||||||
|
|
||||||
this.addNotification(false, 'Nährwert gelöscht.');
|
this.addNotification(false, 'Nährwert gelöscht.');
|
||||||
return null;
|
this.article.nutrition = null;
|
||||||
} catch {
|
return null;
|
||||||
this.addNotification(true, 'Fehler beim löschen des Nährwerts.');
|
} catch {
|
||||||
return nutrition
|
this.addNotification(true, 'Fehler beim löschen des Nährwerts.');
|
||||||
|
return nutrition
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nutrition;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
|
"version": "0.4.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -13,14 +14,14 @@
|
|||||||
"@fontsource/roboto": "5.3.0",
|
"@fontsource/roboto": "5.3.0",
|
||||||
"@mdi/font": "7.4.47",
|
"@mdi/font": "7.4.47",
|
||||||
"@pinia/nuxt": "1.0.2",
|
"@pinia/nuxt": "1.0.2",
|
||||||
"nuxt": "4.5.2",
|
"nuxt": "4.6.1",
|
||||||
"pinia": "4.0.3",
|
"pinia": "4.0.3",
|
||||||
"vue": "3.5.43",
|
"vue": "3.5.43",
|
||||||
"vue-router": "5.3.1",
|
"vue-router": "5.4.0",
|
||||||
"vuetify-pro-tiptap": "3.0.0"
|
"vuetify-pro-tiptap": "3.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"vite-plugin-vuetify": "2.1.3",
|
"vite-plugin-vuetify": "2.1.3",
|
||||||
"vuetify": "4.2.2"
|
"vuetify": "4.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "server"
|
name = "server"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Matthias Lodner <matthias@lodner.de>"]
|
authors = ["Matthias Lodner <matthias@lodner.de>"]
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ path = "src/main.rs"
|
|||||||
common = {path = "../common"}
|
common = {path = "../common"}
|
||||||
|
|
||||||
axum = "0.8.9"
|
axum = "0.8.9"
|
||||||
tokio = { version = "1.53.1", default-features = false, features = ["full"] }
|
tokio = { version = "1.53.2", default-features = false, features = ["full"] }
|
||||||
http = "1.5.0"
|
http = "1.5.0"
|
||||||
tower-http = {version = "0.7.1", features = ["cors"]}
|
tower-http = {version = "0.7.1", features = ["cors"]}
|
||||||
tracing = "=0.1.44"
|
tracing = "=0.1.44"
|
||||||
|
|||||||
Reference in new issue
Block a user