mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
unified notifications
This commit is contained in:
parent
17307c42d1
commit
c81fa9d8a9
14 changed files with 89 additions and 62 deletions
|
@ -63,11 +63,6 @@ export default {
|
||||||
this.$store.dispatch("initLang");
|
this.$store.dispatch("initLang");
|
||||||
this.darkModeSystemCheck();
|
this.darkModeSystemCheck();
|
||||||
this.darkModeAddEventListener();
|
this.darkModeAddEventListener();
|
||||||
|
|
||||||
this.flashMessage.success({
|
|
||||||
title: "Success Message Title",
|
|
||||||
message: "Hoorah, it is my fist npm package and it works!",
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
data: () => ({
|
data: () => ({
|
||||||
|
@ -100,4 +95,34 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.notify-info-color {
|
||||||
|
border: 1px, solid, var(--v-info-base) !important;
|
||||||
|
border-left: 3px, solid, var(--v-info-base) !important;
|
||||||
|
background-color: var(--v-info-base) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notify-warning-color {
|
||||||
|
border: 1px, solid, var(--v-warning-base) !important;
|
||||||
|
border-left: 3px, solid, var(--v-warning-base) !important;
|
||||||
|
background-color: var(--v-warning-base) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notify-error-color {
|
||||||
|
border: 1px, solid, var(--v-error-base) !important;
|
||||||
|
border-left: 3px, solid, var(--v-error-base) !important;
|
||||||
|
background-color: var(--v-error-base) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notify-success-color {
|
||||||
|
border: 1px, solid, var(--v-success-base) !important;
|
||||||
|
border-left: 3px, solid, var(--v-success-base) !important;
|
||||||
|
background-color: var(--v-success-base) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notify-base {
|
||||||
|
color: white !important;
|
||||||
|
margin-right: 60px;
|
||||||
|
margin-bottom: -5px;
|
||||||
|
opacity: 0.9 !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,20 +1,14 @@
|
||||||
const baseURL = "/api/";
|
const baseURL = "/api/";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { vueApp } from "../main";
|
import utils from "../utils";
|
||||||
|
|
||||||
// look for data.snackbar in response
|
// look for data.snackbar in response
|
||||||
function processResponse(response) {
|
function processResponse(response) {
|
||||||
try {
|
try {
|
||||||
vueApp.flashMessage.show({
|
utils.notify.show(response.data.snackbar.text, response.data.snackbar.type);
|
||||||
status: response.data.snackbar.type,
|
|
||||||
title: 'Error Message Title',
|
|
||||||
message: response.data.snackbar.text
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +31,7 @@ const apiReq = {
|
||||||
return response;
|
return response;
|
||||||
} else return;
|
} else return;
|
||||||
});
|
});
|
||||||
// processResponse(response);
|
processResponse(response);
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { baseURL } from "./api-utils";
|
import { baseURL } from "./api-utils";
|
||||||
import { apiReq } from "./api-utils";
|
import { apiReq } from "./api-utils";
|
||||||
|
|
||||||
const prefix = baseURL + "themes/";
|
const prefix = baseURL + "themes";
|
||||||
|
|
||||||
const settingsURLs = {
|
const settingsURLs = {
|
||||||
allThemes: `${baseURL}themes`,
|
allThemes: `${baseURL}themes`,
|
||||||
specificTheme: themeName => `${prefix}${themeName}`,
|
specificTheme: themeName => `${prefix}/${themeName}`,
|
||||||
createTheme: `${prefix}create`,
|
createTheme: `${prefix}/create`,
|
||||||
updateTheme: themeName => `${prefix}${themeName}`,
|
updateTheme: themeName => `${prefix}/${themeName}`,
|
||||||
deleteTheme: themeName => `${prefix}${themeName}`,
|
deleteTheme: themeName => `${prefix}/${themeName}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -33,6 +33,7 @@ export default {
|
||||||
colors: colors,
|
colors: colors,
|
||||||
};
|
};
|
||||||
let response = await apiReq.put(settingsURLs.updateTheme(themeName), body);
|
let response = await apiReq.put(settingsURLs.updateTheme(themeName), body);
|
||||||
|
console.log(response.data);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -158,12 +158,6 @@ export default {
|
||||||
disabledSteps: [],
|
disabledSteps: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
this.flashMessage.success({
|
|
||||||
title: "Success Message Recipe",
|
|
||||||
message: "Hoorah, it is my fist npm package and it works!",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
toggleDisabled(stepIndex) {
|
toggleDisabled(stepIndex) {
|
||||||
if (this.disabledSteps.includes(stepIndex)) {
|
if (this.disabledSteps.includes(stepIndex)) {
|
||||||
|
|
|
@ -6,6 +6,8 @@ Vue.use(Vuetify);
|
||||||
const vuetify = new Vuetify({
|
const vuetify = new Vuetify({
|
||||||
theme: {
|
theme: {
|
||||||
dark: false,
|
dark: false,
|
||||||
|
options: { customProperties: true },
|
||||||
|
|
||||||
themes: {
|
themes: {
|
||||||
light: {
|
light: {
|
||||||
primary: "#E58325",
|
primary: "#E58325",
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
// import utils from "../../utils";
|
// import utils from "../../utils";
|
||||||
// import Vue from "vue";
|
// import Vue from "vue";
|
||||||
// import Vuetify from "./plugins/vuetify";
|
// import Vuetify from "./plugins/vuetify";
|
||||||
|
import { vueApp } from "./main";
|
||||||
|
|
||||||
|
const notifyHelpers = {
|
||||||
|
baseCSS: "notify-base",
|
||||||
|
error: "notify-error-color",
|
||||||
|
warning: "notify-warning-color",
|
||||||
|
success: "notify-success-color",
|
||||||
|
info: "notify-info-color",
|
||||||
|
};
|
||||||
|
|
||||||
const days = [
|
const days = [
|
||||||
"Sunday",
|
"Sunday",
|
||||||
|
@ -72,4 +81,28 @@ export default {
|
||||||
|
|
||||||
return `${year}-${month}-${day}`;
|
return `${year}-${month}-${day}`;
|
||||||
},
|
},
|
||||||
|
notify: {
|
||||||
|
show: function(text, type = "info", title = null) {
|
||||||
|
vueApp.flashMessage.show({
|
||||||
|
status: type,
|
||||||
|
title: title,
|
||||||
|
message: text,
|
||||||
|
time: 3000,
|
||||||
|
blockClass: `${notifyHelpers.baseCSS} ${notifyHelpers[type]}`,
|
||||||
|
contentClass: `${notifyHelpers.baseCSS} ${notifyHelpers[type]}`,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
info: function(text, title = null) {
|
||||||
|
this.show(text, "info", title);
|
||||||
|
},
|
||||||
|
success: function(text, title = null) {
|
||||||
|
this.show(text, "success", title);
|
||||||
|
},
|
||||||
|
error: function(text, title = null) {
|
||||||
|
this.show(text, "error", title);
|
||||||
|
},
|
||||||
|
warning: function(text, title = null) {
|
||||||
|
this.show(text, "warning", title);
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -110,4 +110,4 @@ def delete_backup(file_name: str):
|
||||||
detail=SnackResponse.error("Unable to Delete Backup. See Log File"),
|
detail=SnackResponse.error("Unable to Delete Backup. See Log File"),
|
||||||
)
|
)
|
||||||
|
|
||||||
return SnackResponse.success(f"{file_name} Deleted")
|
return SnackResponse.error(f"{file_name} Deleted")
|
||||||
|
|
|
@ -53,7 +53,7 @@ def update_meal_plan(
|
||||||
# detail=SnackResponse.error("Unable to Update Mealplan"),
|
# detail=SnackResponse.error("Unable to Update Mealplan"),
|
||||||
# )
|
# )
|
||||||
|
|
||||||
return SnackResponse.success("Mealplan Updated")
|
return SnackResponse.info("Mealplan Updated")
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/{plan_id}")
|
@router.delete("/{plan_id}")
|
||||||
|
@ -62,7 +62,7 @@ def delete_meal_plan(plan_id, db: Session = Depends(generate_session)):
|
||||||
|
|
||||||
MealPlan.delete(db, plan_id)
|
MealPlan.delete(db, plan_id)
|
||||||
|
|
||||||
return SnackResponse.success("Mealplan Deleted")
|
return SnackResponse.error("Mealplan Deleted")
|
||||||
|
|
||||||
|
|
||||||
@router.get("/today", tags=["Meal Plan"])
|
@router.get("/today", tags=["Meal Plan"])
|
||||||
|
|
|
@ -62,7 +62,7 @@ def delete_migration_data(type: str, file_name: str):
|
||||||
else:
|
else:
|
||||||
SnackResponse.error("File/Folder not found.")
|
SnackResponse.error("File/Folder not found.")
|
||||||
|
|
||||||
return SnackResponse.info(f"Migration Data Remove: {remove_path.absolute()}")
|
return SnackResponse.error(f"Migration Data Remove: {remove_path.absolute()}")
|
||||||
|
|
||||||
|
|
||||||
@router.post("/{type}/upload")
|
@router.post("/{type}/upload")
|
||||||
|
|
|
@ -4,6 +4,8 @@ from fastapi import APIRouter, Depends
|
||||||
from models.category_models import RecipeCategoryResponse
|
from models.category_models import RecipeCategoryResponse
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
|
from utils.snackbar import SnackResponse
|
||||||
|
|
||||||
router = APIRouter(
|
router = APIRouter(
|
||||||
prefix="/api/categories",
|
prefix="/api/categories",
|
||||||
tags=["Recipe Categories"],
|
tags=["Recipe Categories"],
|
||||||
|
@ -33,3 +35,5 @@ async def delete_recipe_category(
|
||||||
from any recipes that contain it """
|
from any recipes that contain it """
|
||||||
|
|
||||||
db.categories.delete(session, category)
|
db.categories.delete(session, category)
|
||||||
|
|
||||||
|
return SnackResponse(f"Category Deleted: {category}")
|
||||||
|
|
|
@ -62,7 +62,7 @@ def delete_recipe(recipe_slug: str, db: Session = Depends(generate_session)):
|
||||||
status_code=404, detail=SnackResponse.error("Unable to Delete Recipe")
|
status_code=404, detail=SnackResponse.error("Unable to Delete Recipe")
|
||||||
)
|
)
|
||||||
|
|
||||||
return SnackResponse.success("Recipe Deleted")
|
return SnackResponse.error(f"Recipe {recipe_slug} Deleted")
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{recipe_slug}/image")
|
@router.get("/{recipe_slug}/image")
|
||||||
|
|
|
@ -3,6 +3,8 @@ from db.db_setup import generate_session
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
from sqlalchemy.orm.session import Session
|
from sqlalchemy.orm.session import Session
|
||||||
|
|
||||||
|
from utils.snackbar import SnackResponse
|
||||||
|
|
||||||
router = APIRouter(tags=["Recipes"])
|
router = APIRouter(tags=["Recipes"])
|
||||||
|
|
||||||
router = APIRouter(
|
router = APIRouter(
|
||||||
|
@ -30,3 +32,5 @@ async def delete_recipe_tag(tag: str, session: Session = Depends(generate_sessio
|
||||||
from any recipes that contain it"""
|
from any recipes that contain it"""
|
||||||
|
|
||||||
db.tags.delete(session, tag)
|
db.tags.delete(session, tag)
|
||||||
|
|
||||||
|
return SnackResponse.error(f"Tag Deleted: {tag}")
|
||||||
|
|
|
@ -18,12 +18,6 @@ def get_all_themes(db: Session = Depends(generate_session)):
|
||||||
def create_theme(data: SiteTheme, db: Session = Depends(generate_session)):
|
def create_theme(data: SiteTheme, db: Session = Depends(generate_session)):
|
||||||
""" Creates a site color theme database entry """
|
""" Creates a site color theme database entry """
|
||||||
data.save_to_db(db)
|
data.save_to_db(db)
|
||||||
# try:
|
|
||||||
# data.save_to_db()
|
|
||||||
# except:
|
|
||||||
# raise HTTPException(
|
|
||||||
# status_code=400, detail=SnackResponse.error("Unable to Save Theme")
|
|
||||||
# )
|
|
||||||
|
|
||||||
return SnackResponse.success("Theme Saved")
|
return SnackResponse.success("Theme Saved")
|
||||||
|
|
||||||
|
@ -41,24 +35,12 @@ def update_theme(
|
||||||
""" Update a theme database entry """
|
""" Update a theme database entry """
|
||||||
data.update_document(db)
|
data.update_document(db)
|
||||||
|
|
||||||
# try:
|
return SnackResponse.info(f"Theme Updated: {theme_name}")
|
||||||
# except:
|
|
||||||
# raise HTTPException(
|
|
||||||
# status_code=400, detail=SnackResponse.error("Unable to Update Theme")
|
|
||||||
# )
|
|
||||||
|
|
||||||
return SnackResponse.success("Theme Updated")
|
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/themes/{theme_name}")
|
@router.delete("/themes/{theme_name}")
|
||||||
def delete_theme(theme_name: str, db: Session = Depends(generate_session)):
|
def delete_theme(theme_name: str, db: Session = Depends(generate_session)):
|
||||||
""" Deletes theme from the database """
|
""" Deletes theme from the database """
|
||||||
SiteTheme.delete_theme(db, theme_name)
|
SiteTheme.delete_theme(db, theme_name)
|
||||||
# try:
|
|
||||||
# SiteTheme.delete_theme(theme_name)
|
|
||||||
# except:
|
|
||||||
# raise HTTPException(
|
|
||||||
# status_code=400, detail=SnackResponse.error("Unable to Delete Theme")
|
|
||||||
# )
|
|
||||||
|
|
||||||
return SnackResponse.success("Theme Deleted")
|
return SnackResponse.error(f"Theme Deleted: {theme_name}")
|
||||||
|
|
|
@ -9,18 +9,6 @@ class SnackResponse:
|
||||||
|
|
||||||
return snackbar
|
return snackbar
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def primary(message: str, additional_data: dict = None) -> dict:
|
|
||||||
return SnackResponse._create_response(message, "primary", additional_data)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def accent(message: str, additional_data: dict = None) -> dict:
|
|
||||||
return SnackResponse._create_response(message, "accent", additional_data)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def secondary(message: str, additional_data: dict = None) -> dict:
|
|
||||||
return SnackResponse._create_response(message, "secondary", additional_data)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def success(message: str, additional_data: dict = None) -> dict:
|
def success(message: str, additional_data: dict = None) -> dict:
|
||||||
return SnackResponse._create_response(message, "success", additional_data)
|
return SnackResponse._create_response(message, "success", additional_data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue