mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Inicio page is offline
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
<ion-list>
|
||||
<div
|
||||
class="expediente ion-no-padding ion-no-margin cursor-pointer"
|
||||
*ngFor = "let task of expedienteGdStore.list"
|
||||
*ngFor = "let task of listToPresent"
|
||||
(click)="goToExpediente(task.SerialNumber)"
|
||||
>
|
||||
<div class="item width-100">
|
||||
|
||||
@@ -4,6 +4,9 @@ import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
|
||||
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { synchro } from '../../../services/socket/synchro.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-expediente',
|
||||
@@ -12,22 +15,25 @@ import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
|
||||
})
|
||||
export class ExpedientePage implements OnInit {
|
||||
|
||||
segment:string;
|
||||
segment: string;
|
||||
skeletonLoader = true
|
||||
//profile:string;
|
||||
showLoader:boolean;
|
||||
showLoader: boolean;
|
||||
|
||||
taskslist = [];
|
||||
serialNumber:string;
|
||||
serialNumber: string;
|
||||
|
||||
expedienteGdStore = ExpedienteGdStore
|
||||
expedienteTaskPipe = new ExpedienteTaskPipe()
|
||||
|
||||
listToPresent;
|
||||
synch = synchro
|
||||
constructor(
|
||||
private processes:ProcessesService,
|
||||
private processes: ProcessesService,
|
||||
private router: Router,
|
||||
private toastService: ToastService
|
||||
) {}
|
||||
private toastService: ToastService,
|
||||
public platform: Platform,
|
||||
private sqliteservice: SqliteService,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -35,17 +41,19 @@ export class ExpedientePage implements OnInit {
|
||||
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')) {
|
||||
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
||||
this.refreshing()
|
||||
} else {
|
||||
this.LoadList()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.getEventsFromLocalDb();
|
||||
|
||||
}
|
||||
|
||||
async LoadList() {
|
||||
@@ -54,16 +62,17 @@ export class ExpedientePage implements OnInit {
|
||||
try {
|
||||
const expediente: object[] = await this.processes.GetTaskListExpediente(false).toPromise()
|
||||
const result = expediente
|
||||
|
||||
|
||||
this.taskslist = new Array();
|
||||
let res = result.reverse().filter((data: any) => data.workflowInstanceDataFields.Status == "Active");
|
||||
|
||||
res.forEach((element: any) => {
|
||||
|
||||
let task = this.expedienteTaskPipe.transform(element)
|
||||
let task = this.expedienteTaskPipe.transform(element)
|
||||
this.taskslist.push(task);
|
||||
});
|
||||
|
||||
|
||||
this.SqliteAddExpediente(this.taskslist)
|
||||
this.expedienteGdStore.reset(this.taskslist);
|
||||
|
||||
} catch (error) {
|
||||
@@ -92,9 +101,56 @@ export class ExpedientePage implements OnInit {
|
||||
this.router.navigate(['/home/gabinete-digital']);
|
||||
}
|
||||
|
||||
goToExpediente(serialNumber:any){
|
||||
goToExpediente(serialNumber: any) {
|
||||
//console.log('ABRE');
|
||||
this.router.navigate(['/home/gabinete-digital/expediente',serialNumber,'gabinete-digital']);
|
||||
this.router.navigate(['/home/gabinete-digital/expediente', serialNumber, 'gabinete-digital']);
|
||||
}
|
||||
|
||||
SqliteAddExpediente(list) {
|
||||
list.forEach((expediente) => {
|
||||
let data = {
|
||||
serialNumber: expediente.serialNumber,
|
||||
workflowInstanceFolio: expediente.workflowInstanceFolio,
|
||||
Documents: expediente.Documents,
|
||||
actions: expediente.actions,
|
||||
activityInstanceName: expediente.activityInstanceName,
|
||||
formURL: expediente.formURL,
|
||||
originator: expediente.originator,
|
||||
taskStartDate: expediente.taskStartDate,
|
||||
totalDocuments: expediente.totalDocuments,
|
||||
workflowDisplayName: expediente.workflowDisplayName,
|
||||
workflowID: expediente.workflowID,
|
||||
workflowInstanceDataFields: expediente.workflowInstanceDataFields,
|
||||
workflowInstanceID: expediente.workflowInstanceID,
|
||||
workflowName: expediente.workflowName
|
||||
}
|
||||
|
||||
this.sqliteservice.addExpediente(data);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
getEventsFromLocalDb() {
|
||||
|
||||
|
||||
|
||||
synchro.registerCallback('Online', () => {
|
||||
this.listToPresent = this.expedienteGdStore.list;
|
||||
console.log('Onlineee')
|
||||
|
||||
})
|
||||
|
||||
|
||||
synchro.registerCallback('Offline', () => {
|
||||
this.platform.ready().then(() => {
|
||||
this.sqliteservice.getAllExpedientes().then((expediente) => {
|
||||
this.listToPresent = expediente
|
||||
console.log("All expedientes from local,", expediente)
|
||||
})
|
||||
console.log('Offlineee')
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user