Notifications fix (#5)
This commit is contained in:
@@ -29,7 +29,7 @@ export class NotificationsComponent implements OnInit {
|
|||||||
uname: new FormControl<string>(''),
|
uname: new FormControl<string>(''),
|
||||||
room: new FormControl<string|null>(null),
|
room: new FormControl<string|null>(null),
|
||||||
group: new FormControl<string>(''),
|
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}),
|
title: new FormControl('', {nonNullable: true}),
|
||||||
body: new FormControl('', {nonNullable: true})
|
body: new FormControl('', {nonNullable: true})
|
||||||
@@ -49,6 +49,6 @@ interface NotificationForm {
|
|||||||
uname: FormControl<string | null>;
|
uname: FormControl<string | null>;
|
||||||
room: FormControl<string | null>;
|
room: FormControl<string | null>;
|
||||||
group: 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 { SummaryComponent } from './admin-view/grades/summary/summary.component';
|
||||||
import { SettingsComponent } from './admin-view/settings/settings.component';
|
import { SettingsComponent } from './admin-view/settings/settings.component';
|
||||||
import { AttendenceSummaryComponent } from './admin-view/grades/attendence-summary/attendence-summary.component';
|
import { AttendenceSummaryComponent } from './admin-view/grades/attendence-summary/attendence-summary.component';
|
||||||
|
import { NotificationsComponent } from './admin-view/notifications/notifications.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{path: "", redirectTo: "login", pathMatch: "full"},
|
{path: "", redirectTo: "login", pathMatch: "full"},
|
||||||
@@ -32,7 +33,7 @@ const routes: Routes = [
|
|||||||
{path: "news", title: "Edytowanie wiadomości", component: NewsEditComponent},
|
{path: "news", title: "Edytowanie wiadomości", component: NewsEditComponent},
|
||||||
{path: "menu", title: "Edytowanie jadłospisu", component: MenuNewComponent},
|
{path: "menu", title: "Edytowanie jadłospisu", component: MenuNewComponent},
|
||||||
{path: "accounts", title: "Użytkownicy", component: AccountMgmtComponent},
|
{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: "groups", title: "Grupy", component: GroupsComponent},
|
||||||
{path: "keys", title: "Klucze", component: AdminKeyComponent},
|
{path: "keys", title: "Klucze", component: AdminKeyComponent},
|
||||||
{path: "grades", children: [
|
{path: "grades", children: [
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { AuthClient } from '../services/auth.client';
|
import { AuthClient } from '../services/auth.client';
|
||||||
import { SwPush } from '@angular/service-worker';
|
import { SwPush } from '@angular/service-worker';
|
||||||
import { environment } from 'src/environments/environment';
|
|
||||||
import { UpdatesService } from '../services/updates.service';
|
import { UpdatesService } from '../services/updates.service';
|
||||||
import { Link } from '../types/link';
|
import { Link } from '../types/link';
|
||||||
import { LocalStorageService } from '../services/local-storage.service';
|
import { LocalStorageService } from '../services/local-storage.service';
|
||||||
@@ -14,7 +13,6 @@ import { MatSnackBar } from '@angular/material/snack-bar';
|
|||||||
styleUrls: ['./app-view.component.scss']
|
styleUrls: ['./app-view.component.scss']
|
||||||
})
|
})
|
||||||
export class AppViewComponent implements OnInit {
|
export class AppViewComponent implements OnInit {
|
||||||
readonly VAPID_PUK = environment.vapid.pubkey
|
|
||||||
private readonly _LINKS: Link[] = [
|
private readonly _LINKS: Link[] = [
|
||||||
{ title: "Jadłospis", href: "menu", icon: "restaurant_menu", enabled: this.ls.capCheck(2) },
|
{ 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) },
|
{ title: "Wiadomości", href: "news", icon: "newspaper", enabled: this.ls.capCheck(1) },
|
||||||
@@ -32,7 +30,7 @@ export class AppViewComponent implements OnInit {
|
|||||||
subscribeToNotif() {
|
subscribeToNotif() {
|
||||||
if (this.swPush.isEnabled && this.ls.capCheck(4)) {
|
if (this.swPush.isEnabled && this.ls.capCheck(4)) {
|
||||||
this.swPush.requestSubscription({
|
this.swPush.requestSubscription({
|
||||||
serverPublicKey: this.VAPID_PUK
|
serverPublicKey: this.ls.vapid
|
||||||
}).then(sub => {
|
}).then(sub => {
|
||||||
this.us.postNotif(sub)
|
this.us.postNotif(sub)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export class AuthClient {
|
|||||||
document.location.reload()
|
document.location.reload()
|
||||||
}
|
}
|
||||||
this.ls.room = data.room
|
this.ls.room = data.room
|
||||||
|
this.ls.vapid = data.vapid
|
||||||
if (data.menu.defaultItems) {
|
if (data.menu.defaultItems) {
|
||||||
this.ls.defaultItems = data.menu.defaultItems
|
this.ls.defaultItems = data.menu.defaultItems
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,4 +135,11 @@ export class LocalStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public newsflag: number | false = false;
|
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 = {
|
export const environment = {
|
||||||
apiEndpoint: "http://localhost:12230",
|
apiEndpoint: "http://localhost:12230",
|
||||||
version: "testing",
|
version: "testing",
|
||||||
vapid: {
|
|
||||||
pubkey: ""
|
|
||||||
},
|
|
||||||
production: false
|
production: false
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
apiEndpoint: `${window.location.origin}/api`,
|
apiEndpoint: `${window.location.origin}/api`,
|
||||||
version: "v1.0.0",
|
version: "v1.0.0",
|
||||||
vapid: { pubkey: "" },
|
|
||||||
production: true
|
production: true
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user