From 3e55e04fbde995e14b6c28560d92dd76d5fbf191 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Mon, 13 Jan 2025 17:56:56 +0100 Subject: [PATCH] tweak limit warnings --- vue3/src/apps/tandoor/Tandoor.vue | 9 +++++++- .../components/model_editors/RecipeEditor.vue | 19 ++++++++++++---- .../src/components/settings/SpaceSettings.vue | 7 +++--- vue3/src/locales/ar.json | 2 ++ vue3/src/locales/bg.json | 2 ++ vue3/src/locales/ca.json | 2 ++ vue3/src/locales/cs.json | 2 ++ vue3/src/locales/da.json | 2 ++ vue3/src/locales/de.json | 2 ++ vue3/src/locales/el.json | 2 ++ vue3/src/locales/en.json | 2 ++ vue3/src/locales/es.json | 2 ++ vue3/src/locales/fi.json | 2 ++ vue3/src/locales/fr.json | 2 ++ vue3/src/locales/he.json | 2 ++ vue3/src/locales/hu.json | 2 ++ vue3/src/locales/hy.json | 2 ++ vue3/src/locales/id.json | 2 ++ vue3/src/locales/is.json | 2 ++ vue3/src/locales/it.json | 2 ++ vue3/src/locales/lt.json | 2 ++ vue3/src/locales/nb_NO.json | 2 ++ vue3/src/locales/nl.json | 2 ++ vue3/src/locales/pl.json | 2 ++ vue3/src/locales/pt.json | 2 ++ vue3/src/locales/pt_BR.json | 2 ++ vue3/src/locales/ro.json | 2 ++ vue3/src/locales/ru.json | 2 ++ vue3/src/locales/sl.json | 2 ++ vue3/src/locales/sv.json | 2 ++ vue3/src/locales/tr.json | 2 ++ vue3/src/locales/uk.json | 2 ++ vue3/src/locales/zh_Hans.json | 2 ++ vue3/src/locales/zh_Hant.json | 2 ++ vue3/src/utils/logic_utils.ts | 22 +++++++++++++------ 35 files changed, 104 insertions(+), 15 deletions(-) diff --git a/vue3/src/apps/tandoor/Tandoor.vue b/vue3/src/apps/tandoor/Tandoor.vue index 4428578506..68d40d76f0 100644 --- a/vue3/src/apps/tandoor/Tandoor.vue +++ b/vue3/src/apps/tandoor/Tandoor.vue @@ -78,12 +78,18 @@ - +

{{ $t('HostedFreeVersion') }} {{ $t('UpgradeNow') }}

+ +

+ {{ $t('SpaceLimitExceeded') }} + {{ $t('SpaceSettings') }} +

+

@@ -172,6 +178,7 @@ import {useDjangoUrls} from "@/composables/useDjangoUrls"; import {onMounted, ref} from "vue"; import {ErrorMessageType, useMessageStore} from "@/stores/MessageStore"; import {ApiApi, Space} from "@/openapi"; +import {isSpaceAboveLimit, isSpaceAtLimit} from "@/utils/logic_utils"; const {lgAndUp} = useDisplay() const {getDjangoUrl} = useDjangoUrls() diff --git a/vue3/src/components/model_editors/RecipeEditor.vue b/vue3/src/components/model_editors/RecipeEditor.vue index 47e9bea0a8..30727e6317 100644 --- a/vue3/src/components/model_editors/RecipeEditor.vue +++ b/vue3/src/components/model_editors/RecipeEditor.vue @@ -17,7 +17,7 @@ {{ $t('Settings') }} - + @@ -26,7 +26,7 @@ - + - {{ $t('Delete') }} + {{ + $t('Delete') + }} + @@ -97,12 +100,18 @@ + append-to-body> + + + {{$t('SpaceLimitReached')}} + {{ $t('SpaceSettings') }} + + @@ -139,6 +148,8 @@ import {useFileApi} from "@/composables/useFileApi"; import {VFileUpload} from 'vuetify/labs/VFileUpload' import ClosableHelpAlert from "@/components/display/ClosableHelpAlert.vue"; import {useDisplay} from "vuetify"; +import {isSpaceAtRecipeLimit} from "@/utils/logic_utils"; +import {useUserPreferenceStore} from "@/stores/UserPreferenceStore"; const props = defineProps({ diff --git a/vue3/src/components/settings/SpaceSettings.vue b/vue3/src/components/settings/SpaceSettings.vue index 4ea6aacd12..b621feb56a 100644 --- a/vue3/src/components/settings/SpaceSettings.vue +++ b/vue3/src/components/settings/SpaceSettings.vue @@ -8,7 +8,7 @@ {{ $t('Recipes') }} {{ $n(space.recipeCount) }} / {{ space.maxRecipes == 0 ? '∞' : $n(space.maxRecipes) }} - + @@ -16,7 +16,7 @@ {{ $t('Users') }} {{ $n(space.userCount) }} / {{ space.maxUsers == 0 ? '∞' : $n(space.maxUsers) }} - + @@ -26,7 +26,7 @@ MB {{ $t('file_upload_disabled') }} - @@ -108,6 +108,7 @@ import {ApiApi, Space} from "@/openapi"; import {ErrorMessageType, PreparedMessage, useMessageStore} from "@/stores/MessageStore"; import UserFileField from "@/components/inputs/UserFileField.vue"; import ModelSelect from "@/components/inputs/ModelSelect.vue"; +import {isSpaceAboveRecipeLimit, isSpaceAboveStorageLimit, isSpaceAboveUserLimit} from "@/utils/logic_utils"; const space = ref({} as Space) diff --git a/vue3/src/locales/ar.json b/vue3/src/locales/ar.json index 15ed4f26ba..e382bb5273 100644 --- a/vue3/src/locales/ar.json +++ b/vue3/src/locales/ar.json @@ -306,6 +306,8 @@ "Size": "", "Social_Authentication": "", "Sort_by_new": "", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/bg.json b/vue3/src/locales/bg.json index 2520a3b5bc..c2e84af2ec 100644 --- a/vue3/src/locales/bg.json +++ b/vue3/src/locales/bg.json @@ -299,6 +299,8 @@ "Size": "Размер", "Social_Authentication": "", "Sort_by_new": "Сортиране по ново", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/ca.json b/vue3/src/locales/ca.json index 1cd5474427..860b6a8056 100644 --- a/vue3/src/locales/ca.json +++ b/vue3/src/locales/ca.json @@ -383,6 +383,8 @@ "Size": "", "Social_Authentication": "", "Sort_by_new": "Ordenar a partir del més nou", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/cs.json b/vue3/src/locales/cs.json index db03666923..15d11d506c 100644 --- a/vue3/src/locales/cs.json +++ b/vue3/src/locales/cs.json @@ -379,6 +379,8 @@ "Size": "Velikost", "Social_Authentication": "Přihlašování pomocí účtů sociálních sítí", "Sort_by_new": "Seřadit od nejnovějšího", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/da.json b/vue3/src/locales/da.json index 806a24158d..415377cd30 100644 --- a/vue3/src/locales/da.json +++ b/vue3/src/locales/da.json @@ -358,6 +358,8 @@ "Size": "Størrelse", "Social_Authentication": "Social authenticering", "Sort_by_new": "Sorter efter nylige", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/de.json b/vue3/src/locales/de.json index 11bf966345..8455745f1b 100644 --- a/vue3/src/locales/de.json +++ b/vue3/src/locales/de.json @@ -386,6 +386,8 @@ "Size": "Größe", "Social_Authentication": "Login über Drittanbieter", "Sort_by_new": "Nach Neueste sortieren", + "SpaceLimitExceeded": "Dein Space hat ein Limit überschritten, manche Funktionen wurden eingeschränkt.", + "SpaceLimitReached": "Dieser Space hat ein Limit erreicht. Es können keine neuen Objekte von diesem Typ angelegt werden.", "SpaceMemberHelp": "Füge Benutzer hinzu indem du Einladungen erstellst und Sie an die gewünschte Person sendest.", "SpaceMembers": "Space Mitglieder", "SpaceSettings": "Space Einstellungen", diff --git a/vue3/src/locales/el.json b/vue3/src/locales/el.json index 23a942f17c..b09aa5910e 100644 --- a/vue3/src/locales/el.json +++ b/vue3/src/locales/el.json @@ -350,6 +350,8 @@ "Size": "Μέγεθος", "Social_Authentication": "Ταυτοποίηση μέσω κοινωνικών δικτύων", "Sort_by_new": "Ταξινόμηση κατά νέο", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/en.json b/vue3/src/locales/en.json index 024606f324..8e8049899d 100644 --- a/vue3/src/locales/en.json +++ b/vue3/src/locales/en.json @@ -385,6 +385,8 @@ "Size": "Size", "Social_Authentication": "Social Authentication", "Sort_by_new": "Sort by new", + "SpaceLimitExceeded": "Your space has surpassed one of its limits, some functions might be restricted.", + "SpaceLimitReached": "This Space has reached a limit. No more objects of this type can be created.", "SpaceMemberHelp": "Add users to your space by creating an Invite Link and sending it to the person you want to add.", "SpaceMembers": "Space Members", "SpaceSettings": "Space Settings", diff --git a/vue3/src/locales/es.json b/vue3/src/locales/es.json index 9e4d11118e..c313f3c305 100644 --- a/vue3/src/locales/es.json +++ b/vue3/src/locales/es.json @@ -382,6 +382,8 @@ "Size": "Tamaño", "Social_Authentication": "Autenticación Social", "Sort_by_new": "Ordenar por novedades", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/fi.json b/vue3/src/locales/fi.json index 2236056497..aa58500609 100644 --- a/vue3/src/locales/fi.json +++ b/vue3/src/locales/fi.json @@ -228,6 +228,8 @@ "Size": "Koko", "Social_Authentication": "", "Sort_by_new": "Lajittele uusien mukaan", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/fr.json b/vue3/src/locales/fr.json index d961f21973..e07db57d5c 100644 --- a/vue3/src/locales/fr.json +++ b/vue3/src/locales/fr.json @@ -383,6 +383,8 @@ "Size": "Taille", "Social_Authentication": "Authentification Sociale", "Sort_by_new": "Trier par nouveautés", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/he.json b/vue3/src/locales/he.json index b893c34168..4c38a46606 100644 --- a/vue3/src/locales/he.json +++ b/vue3/src/locales/he.json @@ -384,6 +384,8 @@ "Size": "גודל", "Social_Authentication": "אימות חברתי", "Sort_by_new": "סדר ע\"י חדש", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/hu.json b/vue3/src/locales/hu.json index 0caeaaa2f9..f03a2f5067 100644 --- a/vue3/src/locales/hu.json +++ b/vue3/src/locales/hu.json @@ -352,6 +352,8 @@ "Size": "Méret", "Social_Authentication": "", "Sort_by_new": "Rendezés legújabbak szerint", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/hy.json b/vue3/src/locales/hy.json index e757e67bc4..4d0b4912c8 100644 --- a/vue3/src/locales/hy.json +++ b/vue3/src/locales/hy.json @@ -169,6 +169,8 @@ "Size": "", "Social_Authentication": "", "Sort_by_new": "Տեսակավորել ըստ նորերի", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/id.json b/vue3/src/locales/id.json index ab93dbfe9d..2a02e4495a 100644 --- a/vue3/src/locales/id.json +++ b/vue3/src/locales/id.json @@ -328,6 +328,8 @@ "Size": "Ukuran", "Social_Authentication": "", "Sort_by_new": "Urutkan berdasarkan baru", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/is.json b/vue3/src/locales/is.json index 6cbc135918..aef596e7ea 100644 --- a/vue3/src/locales/is.json +++ b/vue3/src/locales/is.json @@ -382,6 +382,8 @@ "Size": "", "Social_Authentication": "", "Sort_by_new": "", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/it.json b/vue3/src/locales/it.json index 2eccefdf4d..8e41dd50d7 100644 --- a/vue3/src/locales/it.json +++ b/vue3/src/locales/it.json @@ -336,6 +336,8 @@ "Size": "Dimensione", "Social_Authentication": "Autenticazione social", "Sort_by_new": "Prima i nuovi", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/lt.json b/vue3/src/locales/lt.json index 344c092199..56f451c671 100644 --- a/vue3/src/locales/lt.json +++ b/vue3/src/locales/lt.json @@ -356,6 +356,8 @@ "Size": "", "Social_Authentication": "", "Sort_by_new": "Rūšiuoti pagal naujumą", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/nb_NO.json b/vue3/src/locales/nb_NO.json index 72aea96c72..29d671577b 100644 --- a/vue3/src/locales/nb_NO.json +++ b/vue3/src/locales/nb_NO.json @@ -348,6 +348,8 @@ "Size": "Størrelse", "Social_Authentication": "", "Sort_by_new": "Sorter etter nyest", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/nl.json b/vue3/src/locales/nl.json index 046a168ba2..3d2b8604be 100644 --- a/vue3/src/locales/nl.json +++ b/vue3/src/locales/nl.json @@ -352,6 +352,8 @@ "Size": "Grootte", "Social_Authentication": "Authenticeren met sociale media-account", "Sort_by_new": "Sorteer op nieuw", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/pl.json b/vue3/src/locales/pl.json index 78820710f9..bd5ccd475e 100644 --- a/vue3/src/locales/pl.json +++ b/vue3/src/locales/pl.json @@ -385,6 +385,8 @@ "Size": "Rozmiar", "Social_Authentication": "Uwierzytelnianie społecznościowe", "Sort_by_new": "Sortuj według nowych", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/pt.json b/vue3/src/locales/pt.json index 5482b9c006..4e96febe01 100644 --- a/vue3/src/locales/pt.json +++ b/vue3/src/locales/pt.json @@ -293,6 +293,8 @@ "Size": "Tamanho", "Social_Authentication": "", "Sort_by_new": "Ordenar por mais recente", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/pt_BR.json b/vue3/src/locales/pt_BR.json index 7d2a07a606..d04961dd02 100644 --- a/vue3/src/locales/pt_BR.json +++ b/vue3/src/locales/pt_BR.json @@ -370,6 +370,8 @@ "Size": "Tamanho", "Social_Authentication": "", "Sort_by_new": "Ordenar por novos", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/ro.json b/vue3/src/locales/ro.json index fccec14ba5..a13e909f8f 100644 --- a/vue3/src/locales/ro.json +++ b/vue3/src/locales/ro.json @@ -340,6 +340,8 @@ "Size": "Marime", "Social_Authentication": "Autentificare socială", "Sort_by_new": "Sortare după nou", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/ru.json b/vue3/src/locales/ru.json index 333f1a6811..80d2b5c4db 100644 --- a/vue3/src/locales/ru.json +++ b/vue3/src/locales/ru.json @@ -278,6 +278,8 @@ "Size": "Размер", "Social_Authentication": "", "Sort_by_new": "Сортировка по новизне", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/sl.json b/vue3/src/locales/sl.json index 4b5becead0..ea02fc1c6b 100644 --- a/vue3/src/locales/sl.json +++ b/vue3/src/locales/sl.json @@ -268,6 +268,8 @@ "Size": "Velikost", "Social_Authentication": "", "Sort_by_new": "Razvrsti po novih", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/sv.json b/vue3/src/locales/sv.json index 14d0a48c7d..618868dd68 100644 --- a/vue3/src/locales/sv.json +++ b/vue3/src/locales/sv.json @@ -385,6 +385,8 @@ "Size": "Storlek", "Social_Authentication": "Social autentisering", "Sort_by_new": "Sortera efter ny", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/tr.json b/vue3/src/locales/tr.json index 7bba9d0eca..39cfd4371c 100644 --- a/vue3/src/locales/tr.json +++ b/vue3/src/locales/tr.json @@ -384,6 +384,8 @@ "Size": "Boyut", "Social_Authentication": "Sosyal Kimlik Doğrulama", "Sort_by_new": "Yeniye göre sırala", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/uk.json b/vue3/src/locales/uk.json index cc80c97d38..09c5711780 100644 --- a/vue3/src/locales/uk.json +++ b/vue3/src/locales/uk.json @@ -314,6 +314,8 @@ "Size": "Розмір", "Social_Authentication": "", "Sort_by_new": "", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/zh_Hans.json b/vue3/src/locales/zh_Hans.json index 449a607764..e0db01c090 100644 --- a/vue3/src/locales/zh_Hans.json +++ b/vue3/src/locales/zh_Hans.json @@ -378,6 +378,8 @@ "Size": "大小", "Social_Authentication": "社交认证", "Sort_by_new": "按新旧排序", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/locales/zh_Hant.json b/vue3/src/locales/zh_Hant.json index 9accc1ee7d..ff8e86aef9 100644 --- a/vue3/src/locales/zh_Hant.json +++ b/vue3/src/locales/zh_Hant.json @@ -139,6 +139,8 @@ "Size": "", "Social_Authentication": "", "Sort_by_new": "按最新排序", + "SpaceLimitExceeded": "", + "SpaceLimitReached": "", "SpaceMemberHelp": "", "SpaceMembers": "", "SpaceSettings": "", diff --git a/vue3/src/utils/logic_utils.ts b/vue3/src/utils/logic_utils.ts index f3f7359d0f..8b50fbe53e 100644 --- a/vue3/src/utils/logic_utils.ts +++ b/vue3/src/utils/logic_utils.ts @@ -26,30 +26,38 @@ export function isShoppingListFoodDelayed(slf: IShoppingListFood) { * checks if the given space is above any of the configured limits * @param space space to check limit for */ -export function isSpaceAtLimit(space: Space) { - return isSpaceAtUserLimit(space) || isSpaceAtRecipeLimit(space) || isSpaceAtStorageLimit(space) +export function isSpaceAboveLimit(space: Space) { + return isSpaceAboveUserLimit(space) || isSpaceAboveRecipeLimit(space) || isSpaceAboveStorageLimit(space) } /** * checks if the given space is above the user limit * @param space space to check limit for */ -export function isSpaceAtUserLimit(space: Space) { - return space.maxUsers > space.userCount && space.maxUsers > 0 +export function isSpaceAboveUserLimit(space: Space) { + return space.userCount > space.maxUsers && space.maxUsers > 0 } /** * checks if the given space is above the recipe limit * @param space space to check limit for */ +export function isSpaceAboveRecipeLimit(space: Space) { + return space.recipeCount > space.maxRecipes && space.maxRecipes > 0 +} + +/** + * checks if the given space is at the recipe limit + * @param space space to check limit for + */ export function isSpaceAtRecipeLimit(space: Space) { - return space.maxRecipes > space.recipeCount && space.maxRecipes > 0 + return space.recipeCount >= space.maxRecipes && space.maxRecipes > 0 } /** * checks if the given space is above the file storage limit * @param space space to check limit for */ -export function isSpaceAtStorageLimit(space: Space) { - return space.maxFileStorageMb > space.fileSizeMb && space.maxFileStorageMb > 0 +export function isSpaceAboveStorageLimit(space: Space) { + return space.fileSizeMb > space.maxFileStorageMb && space.maxFileStorageMb > 0 } \ No newline at end of file