This commit is contained in:
Peter Maquiran
2022-12-13 17:21:48 +01:00
parent 2beb3d4387
commit 9116ac4d06
14 changed files with 68 additions and 63 deletions
+30 -12
View File
@@ -1,6 +1,8 @@
import { Injectable } from '@angular/core';
import { ThemeService } from 'src/app/services/theme.service';
import { StorageService} from 'src/app/services/storage.service';
import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
@@ -15,7 +17,8 @@ export class BackgroundService {
constructor(
private themeservice: ThemeService,
private storageservice: StorageService
private storageservice: StorageService,
private http: HttpClient,
) { }
online() {
@@ -54,18 +57,33 @@ export class BackgroundService {
}
}
offline() {
document.body.style.setProperty(`--color`, "#ffb703");
document.body.style.setProperty(`--color2`, "#ffb703");
document.body.style.setProperty(`--color3`, "#ffb703");
document.body.style.setProperty(`--color4`, "#ffb703");
document.body.style.setProperty(`--color5`, "#ffb703");
this.storageservice.store('networkCheckStore','offline');
this.callBacks.forEach((e) => {
if (e.type == 'Offline') {
e.funx()
async offline() {
let opts = {
headers: {},
}
try {
await this.http.post(environment.apiURL + "UserAuthentication/Login", '', opts).toPromise();
} catch (error) {
if(error.status != 400) {
document.body.style.setProperty(`--color`, "#ffb703");
document.body.style.setProperty(`--color2`, "#ffb703");
document.body.style.setProperty(`--color3`, "#ffb703");
document.body.style.setProperty(`--color4`, "#ffb703");
document.body.style.setProperty(`--color5`, "#ffb703");
this.storageservice.store('networkCheckStore','offline');
this.callBacks.forEach((e) => {
if (e.type == 'Offline') {
e.funx()
}
})
}
})
}
}
registerBackService(type: 'Offline' | 'Online' | 'Notification', funx: Function, object = '') {