Notifications fix (#5)
This commit is contained in:
@@ -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">;
|
||||
}>
|
||||
}
|
||||
@@ -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: [
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
export const environment = {
|
||||
apiEndpoint: "http://localhost:12230",
|
||||
version: "testing",
|
||||
vapid: {
|
||||
pubkey: ""
|
||||
},
|
||||
production: false
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
export const environment = {
|
||||
apiEndpoint: `${window.location.origin}/api`,
|
||||
version: "v1.0.0",
|
||||
vapid: { pubkey: "" },
|
||||
production: true
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user