|
|
|
@ -37,11 +37,12 @@ export class AppComponent implements OnInit {
|
|
|
|
|
public username: string;
|
|
|
|
|
|
|
|
|
|
private checkedForUpdate: boolean;
|
|
|
|
|
private hubConnected: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@HostBinding('class') public componentCssClass;
|
|
|
|
|
|
|
|
|
|
private scheduleHubConnection: HubConnection | undefined;
|
|
|
|
|
private notificationHubConnection: HubConnection | undefined;
|
|
|
|
|
|
|
|
|
|
constructor(public notificationService: NotificationService,
|
|
|
|
|
public authService: AuthService,
|
|
|
|
@ -117,27 +118,28 @@ export class AppComponent implements OnInit {
|
|
|
|
|
},
|
|
|
|
|
err => this.checkedForUpdate = true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.scheduleHubConnection = new signalR.HubConnectionBuilder().withUrl("/hubs/schedules", {
|
|
|
|
|
if (this.authService.loggedIn() && !this.hubConnected) {
|
|
|
|
|
this.notificationHubConnection = new signalR.HubConnectionBuilder().withUrl("/hubs/notification", {
|
|
|
|
|
accessTokenFactory: () => {
|
|
|
|
|
return this.authService.getToken();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.configureLogging(signalR.LogLevel.Information).build();
|
|
|
|
|
}).configureLogging(signalR.LogLevel.Information).build();
|
|
|
|
|
|
|
|
|
|
this.scheduleHubConnection
|
|
|
|
|
this.notificationHubConnection
|
|
|
|
|
.start()
|
|
|
|
|
.then(() => console.info('Connection started!'))
|
|
|
|
|
.then(() => this.hubConnected = true)
|
|
|
|
|
.catch(err => console.error(err));
|
|
|
|
|
this.scheduleHubConnection.on("Send", (data: any) => {
|
|
|
|
|
this.notificationHubConnection.on("Notification", (data: any) => {
|
|
|
|
|
this.snackBar.open(data, "OK", {
|
|
|
|
|
duration: 3000
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public openMobileApp(event: any) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|