mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
103 lines
2.5 KiB
TypeScript
103 lines
2.5 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { NavigationStart, Router } from '@angular/router';
|
|
import { DespachoService } from 'src/app/Rules/despacho.service';
|
|
import { DespachoStore } from 'src/app/store/despacho-store.service';
|
|
|
|
import { SqliteService } from 'src/app/services/sqlite.service';
|
|
import { Platform } from '@ionic/angular';
|
|
import { BackgroundService } from 'src/app/services/background.service';
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
import { TaskService } from 'src/app/services/task.service'
|
|
|
|
@Component({
|
|
selector: 'app-despachos',
|
|
templateUrl: './despachos.page.html',
|
|
styleUrls: ['./despachos.page.scss'],
|
|
})
|
|
|
|
export class DespachosPage implements OnInit {
|
|
|
|
despachoStore = DespachoStore;
|
|
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos'
|
|
|
|
constructor(
|
|
private router: Router,
|
|
private despachoRule: DespachoService,
|
|
private sqliteservice: SqliteService,
|
|
private platform: Platform,
|
|
private backgroundservice: BackgroundService,
|
|
public ThemeService: ThemeService,
|
|
public TaskService: TaskService
|
|
) {}
|
|
|
|
ngOnInit() {
|
|
|
|
const location = window.location
|
|
const pathname = location.pathname + location.search
|
|
|
|
this.LoadList()
|
|
|
|
this.router.events.forEach((event) => {
|
|
if (event instanceof NavigationStart && event.url.startsWith(pathname)) {
|
|
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
|
this.refreshing()
|
|
} else {
|
|
this.LoadList()
|
|
}
|
|
}
|
|
});
|
|
|
|
this.backgroundservice.registerBackService('Online', () => {
|
|
this.LoadList();
|
|
});
|
|
|
|
}
|
|
|
|
async refreshing() {
|
|
setTimeout(() => {
|
|
this.LoadList();
|
|
}, 1000);
|
|
}
|
|
|
|
segmentChanged(ev: any) {
|
|
this.LoadList();
|
|
}
|
|
|
|
async LoadList() {
|
|
|
|
await this.despachoRule.getList({ updateStore: true }).then((pre) => {
|
|
//
|
|
}).catch(() => {
|
|
})
|
|
|
|
}
|
|
|
|
get skeletonLoader(): boolean {
|
|
return this.despachoRule.LoaderService.loading
|
|
}
|
|
|
|
doRefresh(event) {
|
|
this.LoadList();
|
|
|
|
setTimeout(() => {
|
|
try {
|
|
event?.target?.complete();
|
|
} catch(error) {}
|
|
}, 2000);
|
|
}
|
|
|
|
async GoToDespacho(serialNumber: any) {
|
|
this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']);
|
|
}
|
|
|
|
|
|
goBack() {
|
|
this.router.navigate(['/home/gabinete-digital']);
|
|
}
|
|
|
|
goToList() {
|
|
this.router.navigate(['/home/gabinete-digital/despachos']);
|
|
}
|
|
|
|
}
|