1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 05:25:26 +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:
Hayden 2022-01-09 21:04:24 -09:00 committed by GitHub
parent 50a341ed3f
commit 190773c5d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
74 changed files with 1992 additions and 1229 deletions

View file

@ -1,41 +0,0 @@
import { BaseCRUDAPI } from "../_base";
export type EventCategory = "general" | "recipe" | "backup" | "scheduled" | "migration" | "group" | "user";
export type DeclaredTypes = "General" | "Discord" | "Gotify" | "Pushover" | "Home Assistant";
export type GotifyPriority = "low" | "moderate" | "normal" | "high";
export interface EventNotification {
id?: number;
name?: string;
type?: DeclaredTypes & string;
general?: boolean;
recipe?: boolean;
backup?: boolean;
scheduled?: boolean;
migration?: boolean;
group?: boolean;
user?: boolean;
}
export interface CreateEventNotification extends EventNotification {
notificationUrl?: string;
}
const prefix = "/api";
const routes = {
aboutEventsNotifications: `${prefix}/about/events/notifications`,
aboutEventsNotificationsTest: `${prefix}/about/events/notifications/test`,
aboutEventsNotificationsId: (id: number) => `${prefix}/about/events/notifications/${id}`,
};
export class NotificationsAPI extends BaseCRUDAPI<EventNotification, CreateEventNotification> {
baseRoute = routes.aboutEventsNotifications;
itemRoute = routes.aboutEventsNotificationsId;
/** Returns the Group Data for the Current User
*/
async testNotification(id: number | null = null, testUrl: string | null = null) {
return await this.requests.post(routes.aboutEventsNotificationsTest, { id, testUrl });
}
}

View file

@ -0,0 +1,18 @@
import { BaseCRUDAPI } from "../_base";
import { GroupEventNotifierCreate, GroupEventNotifierOut } from "~/types/api-types/group";
const prefix = "/api";
const routes = {
eventNotifier: `${prefix}/groups/events/notifications`,
eventNotifierId: (id: string | number) => `${prefix}/groups/events/notifications/${id}`,
};
export class GroupEventNotifierApi extends BaseCRUDAPI<GroupEventNotifierOut, GroupEventNotifierCreate> {
baseRoute = routes.eventNotifier;
itemRoute = routes.eventNotifierId;
async test(itemId: string) {
return await this.requests.post(`${this.baseRoute}/${itemId}/test`, {});
}
}

View file

@ -7,7 +7,6 @@ import { UploadFile } from "./class-interfaces/upload";
import { CategoriesAPI } from "./class-interfaces/categories";
import { TagsAPI } from "./class-interfaces/tags";
import { UtilsAPI } from "./class-interfaces/utils";
import { NotificationsAPI } from "./class-interfaces/event-notifications";
import { FoodAPI } from "./class-interfaces/recipe-foods";
import { UnitAPI } from "./class-interfaces/recipe-units";
import { CookbookAPI } from "./class-interfaces/group-cookbooks";
@ -23,10 +22,10 @@ import { GroupMigrationApi } from "./class-interfaces/group-migrations";
import { GroupReportsApi } from "./class-interfaces/group-reports";
import { ShoppingApi } from "./class-interfaces/group-shopping-lists";
import { MultiPurposeLabelsApi } from "./class-interfaces/group-multiple-purpose-labels";
import { GroupEventNotifierApi } from "./class-interfaces/group-event-notifier";
import { ApiRequestInstance } from "~/types/api";
class Api {
// private static instance: Api;
public recipes: RecipeAPI;
public users: UserApi;
public groups: GroupAPI;
@ -35,7 +34,6 @@ class Api {
public categories: CategoriesAPI;
public tags: TagsAPI;
public utils: UtilsAPI;
public notifications: NotificationsAPI;
public foods: FoodAPI;
public units: UnitAPI;
public cookbooks: CookbookAPI;
@ -50,14 +48,10 @@ class Api {
public tools: ToolsApi;
public shopping: ShoppingApi;
public multiPurposeLabels: MultiPurposeLabelsApi;
// Utils
public groupEventNotifier: GroupEventNotifierApi;
public upload: UploadFile;
constructor(requests: ApiRequestInstance) {
// if (Api.instance instanceof Api) {
// return Api.instance;
// }
// Recipes
this.recipes = new RecipeAPI(requests);
this.categories = new CategoriesAPI(requests);
@ -84,7 +78,6 @@ class Api {
// Admin
this.events = new EventsAPI(requests);
this.backups = new BackupAPI(requests);
this.notifications = new NotificationsAPI(requests);
// Utils
this.upload = new UploadFile(requests);
@ -92,9 +85,9 @@ class Api {
this.email = new EmailAPI(requests);
this.bulk = new BulkActionsAPI(requests);
this.groupEventNotifier = new GroupEventNotifierApi(requests);
Object.freeze(this);
// Api.instance = this;
}
}