Notifications fix (#5)

This commit is contained in:
2025-05-09 12:47:01 +02:00
committed by GitHub
parent b7f9ee572e
commit 53bfeab116
7 changed files with 13 additions and 10 deletions

View File

@@ -29,7 +29,7 @@ export class NotificationsComponent implements OnInit {
uname: new FormControl<string>(''),
room: new FormControl<string|null>(null),
group: new FormControl<string>(''),
type: new FormControl<"all" | "room" | "uname" | "group">('uname', {nonNullable: true})
type: new FormControl<"room" | "uname" | "group">('uname', {nonNullable: true})
}),
title: new FormControl('', {nonNullable: true}),
body: new FormControl('', {nonNullable: true})
@@ -49,6 +49,6 @@ interface NotificationForm {
uname: FormControl<string | null>;
room: FormControl<string | null>;
group: FormControl<string | null>;
type: FormControl<"all" | "room" | "uname" | "group">;
type: FormControl<"room" | "uname" | "group">;
}>
}

View File

@@ -18,6 +18,7 @@ import { GradesComponent } from './admin-view/grades/grades.component';
import { SummaryComponent } from './admin-view/grades/summary/summary.component';
import { SettingsComponent } from './admin-view/settings/settings.component';
import { AttendenceSummaryComponent } from './admin-view/grades/attendence-summary/attendence-summary.component';
import { NotificationsComponent } from './admin-view/notifications/notifications.component';
const routes: Routes = [
{path: "", redirectTo: "login", pathMatch: "full"},
@@ -32,7 +33,7 @@ const routes: Routes = [
{path: "news", title: "Edytowanie wiadomości", component: NewsEditComponent},
{path: "menu", title: "Edytowanie jadłospisu", component: MenuNewComponent},
{path: "accounts", title: "Użytkownicy", component: AccountMgmtComponent},
// {path: "notifications", title: "Powiadomienia", component: NotificationsComponent},
{path: "notifications", title: "Powiadomienia", component: NotificationsComponent},
{path: "groups", title: "Grupy", component: GroupsComponent},
{path: "keys", title: "Klucze", component: AdminKeyComponent},
{path: "grades", children: [

View File

@@ -1,7 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { AuthClient } from '../services/auth.client';
import { SwPush } from '@angular/service-worker';
import { environment } from 'src/environments/environment';
import { UpdatesService } from '../services/updates.service';
import { Link } from '../types/link';
import { LocalStorageService } from '../services/local-storage.service';
@@ -14,7 +13,6 @@ import { MatSnackBar } from '@angular/material/snack-bar';
styleUrls: ['./app-view.component.scss']
})
export class AppViewComponent implements OnInit {
readonly VAPID_PUK = environment.vapid.pubkey
private readonly _LINKS: Link[] = [
{ title: "Jadłospis", href: "menu", icon: "restaurant_menu", enabled: this.ls.capCheck(2) },
{ title: "Wiadomości", href: "news", icon: "newspaper", enabled: this.ls.capCheck(1) },
@@ -32,7 +30,7 @@ export class AppViewComponent implements OnInit {
subscribeToNotif() {
if (this.swPush.isEnabled && this.ls.capCheck(4)) {
this.swPush.requestSubscription({
serverPublicKey: this.VAPID_PUK
serverPublicKey: this.ls.vapid
}).then(sub => {
this.us.postNotif(sub)
})

View File

@@ -38,6 +38,7 @@ export class AuthClient {
document.location.reload()
}
this.ls.room = data.room
this.ls.vapid = data.vapid
if (data.menu.defaultItems) {
this.ls.defaultItems = data.menu.defaultItems
}

View File

@@ -135,4 +135,11 @@ export class LocalStorageService {
}
public newsflag: number | false = false;
public get vapid(): string {
return localStorage.getItem('vapid')!
}
public set vapid(value: string) {
localStorage.setItem("vapid", value)
}
}

View File

@@ -1,8 +1,5 @@
export const environment = {
apiEndpoint: "http://localhost:12230",
version: "testing",
vapid: {
pubkey: ""
},
production: false
};

View File

@@ -1,6 +1,5 @@
export const environment = {
apiEndpoint: `${window.location.origin}/api`,
version: "v1.0.0",
vapid: { pubkey: "" },
production: true
};