diff --git a/packages/backend/src/notifications/notification-targets.controller.ts b/packages/backend/src/notifications/notification-targets.controller.ts new file mode 100644 index 0000000..da9cbb1 --- /dev/null +++ b/packages/backend/src/notifications/notification-targets.controller.ts @@ -0,0 +1,33 @@ +import { + Body, + Controller, + Delete, + Get, + Inject, + Param, + Post, +} from "@nestjs/common" +import { NotificationsService } from "./notifications.service" + +@Controller("notification-targets") +export class NotificationTargetsController { + constructor( + @Inject(NotificationsService) + private readonly notificationsService: NotificationsService, + ) {} + + @Get() + list() { + return this.notificationsService.listTargets() + } + + @Post() + create(@Body("appriseUrl") appriseUrl: string) { + return this.notificationsService.createTarget(appriseUrl) + } + + @Delete(":id") + delete(@Param("id") id: number) { + return this.notificationsService.deleteTarget(id) + } +} diff --git a/packages/backend/src/notifications/notifications.module.ts b/packages/backend/src/notifications/notifications.module.ts index 0c2105e..aaaf8c0 100644 --- a/packages/backend/src/notifications/notifications.module.ts +++ b/packages/backend/src/notifications/notifications.module.ts @@ -3,10 +3,11 @@ import { NotificationsService } from "./notifications.service" import { TypeOrmModule } from "@nestjs/typeorm" import { NotificationTarget } from "./notification-target.entity" import { NotificationsController } from "./notifications.controller" +import { NotificationTargetsController } from "./notification-targets.controller" @Module({ imports: [TypeOrmModule.forFeature([NotificationTarget])], - controllers: [NotificationsController], + controllers: [NotificationsController, NotificationTargetsController], providers: [NotificationsService], exports: [NotificationsService], }) diff --git a/packages/backend/src/notifications/notifications.service.ts b/packages/backend/src/notifications/notifications.service.ts index f550556..72290c5 100644 --- a/packages/backend/src/notifications/notifications.service.ts +++ b/packages/backend/src/notifications/notifications.service.ts @@ -21,10 +21,18 @@ export class NotificationsService { private readonly eventEmitter: EventEmitter2, ) {} + listTargets() { + return this.notificationTargetRepository.find() + } + createTarget(appriseUrl: string) { return this.notificationTargetRepository.save({ appriseUrl }) } + deleteTarget(id: number) { + return this.notificationTargetRepository.delete(id) + } + async sendNotification( title: string, message: string, diff --git a/packages/frontend/src/app.css b/packages/frontend/src/app.css index 4b4d1db..0bd8d59 100644 --- a/packages/frontend/src/app.css +++ b/packages/frontend/src/app.css @@ -89,6 +89,10 @@ p { @apply leading-7 [&:not(:first-child)]:mt-6; } +p a { + @apply font-medium text-blue-600 dark:text-blue-500 hover:underline; +} + body, html { margin: 0; diff --git a/packages/frontend/src/lib/components/NotificationTargetConfig/NotificationTargetConfig.svelte b/packages/frontend/src/lib/components/NotificationTargetConfig/NotificationTargetConfig.svelte new file mode 100644 index 0000000..00d1bab --- /dev/null +++ b/packages/frontend/src/lib/components/NotificationTargetConfig/NotificationTargetConfig.svelte @@ -0,0 +1,81 @@ + + +