mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
save
This commit is contained in:
@@ -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 = '') {
|
||||
|
||||
Reference in New Issue
Block a user