mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-04 21:15:22 +02:00
Feature/group based notifications (#918)
* fix group page * setup group notification for backend * update type generators * script to auto-generate schema exports * setup frontend CRUD interface * remove old notifications UI * drop old events api * add test functionality * update naming for fields * add event dispatcher functionality * bump to python 3.10 * bump python version * purge old event code * use-async apprise * set mealie logo as image * unify styles for buttons rows * add links to banners
This commit is contained in:
parent
50a341ed3f
commit
190773c5d7
74 changed files with 1992 additions and 1229 deletions
|
@ -1,89 +0,0 @@
|
|||
import { useAsync, ref } from "@nuxtjs/composition-api";
|
||||
import { useAsyncKey } from "./use-utils";
|
||||
import { CreateEventNotification } from "@/api/class-interfaces/event-notifications";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
|
||||
const notificationTypes = ["General", "Discord", "Gotify", "Pushover", "Home Assistant"];
|
||||
|
||||
export const useNotifications = function () {
|
||||
const api = useUserApi();
|
||||
const loading = ref(false);
|
||||
|
||||
const createNotificationData = ref<CreateEventNotification>({
|
||||
name: "",
|
||||
type: "General",
|
||||
general: true,
|
||||
recipe: true,
|
||||
backup: true,
|
||||
scheduled: true,
|
||||
migration: true,
|
||||
group: true,
|
||||
user: true,
|
||||
notificationUrl: "",
|
||||
});
|
||||
|
||||
const deleteTarget = ref(0);
|
||||
|
||||
function getNotifications() {
|
||||
loading.value = true;
|
||||
const notifications = useAsync(async () => {
|
||||
const { data } = await api.notifications.getAll();
|
||||
return data;
|
||||
}, useAsyncKey());
|
||||
loading.value = false;
|
||||
return notifications;
|
||||
}
|
||||
|
||||
async function refreshNotifications() {
|
||||
loading.value = true;
|
||||
const { data } = await api.notifications.getAll();
|
||||
if (data) {
|
||||
notifications.value = data;
|
||||
}
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
async function createNotification() {
|
||||
if (createNotificationData.value.name === "" || createNotificationData.value.notificationUrl === "") {
|
||||
return;
|
||||
}
|
||||
const { response } = await api.notifications.createOne(createNotificationData.value);
|
||||
|
||||
if (response?.status === 200) {
|
||||
refreshNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteNotification() {
|
||||
const { response } = await api.notifications.deleteOne(deleteTarget.value);
|
||||
if (response?.status === 200) {
|
||||
refreshNotifications();
|
||||
}
|
||||
}
|
||||
|
||||
async function testById(id: number) {
|
||||
const { data } = await api.notifications.testNotification(id, null);
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
async function testByUrl(testUrl: string) {
|
||||
const { data } = await api.notifications.testNotification(null, testUrl);
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
const notifications = getNotifications();
|
||||
|
||||
return {
|
||||
createNotification,
|
||||
deleteNotification,
|
||||
refreshNotifications,
|
||||
getNotifications,
|
||||
testById,
|
||||
testByUrl,
|
||||
notifications,
|
||||
loading,
|
||||
createNotificationData,
|
||||
notificationTypes,
|
||||
deleteTarget,
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue