mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
Gabinete digital offline complete
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
</ion-refresher>
|
||||
|
||||
<app-task-list class="height-100"
|
||||
[taskList] = pendentesstore.list
|
||||
[taskList] = listToPresent
|
||||
[skeletonLoader] = skeletonLoader
|
||||
(viewTaskDetail)="viewTaskDetails($event)"
|
||||
> </app-task-list>
|
||||
|
||||
@@ -10,6 +10,10 @@ import { LoginUserRespose } from 'src/app/models/user.model';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
|
||||
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { synchro } from 'src/app/services/socket/synchro.service';
|
||||
import { Platform } from '@ionic/angular';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-pendentes',
|
||||
@@ -20,46 +24,37 @@ export class PendentesPage implements OnInit {
|
||||
@ViewChild(CalendarComponent) myCal: CalendarComponent;
|
||||
|
||||
taskType: string;
|
||||
serialNumber:string;
|
||||
totalDocs:any;
|
||||
serialNumber: string;
|
||||
totalDocs: any;
|
||||
showLoader: boolean;
|
||||
loggeduser: LoginUserRespose;
|
||||
|
||||
@Input() profile:string;
|
||||
segment:string;
|
||||
@Input() profile: string;
|
||||
segment: string;
|
||||
skeletonLoader = true
|
||||
pendentesstore = PendentesStore;
|
||||
customTaskPipe = new CustomTaskPipe()
|
||||
listToPresent = [];
|
||||
|
||||
synch = synchro
|
||||
|
||||
constructor(
|
||||
private processes:ProcessesService,
|
||||
private processes: ProcessesService,
|
||||
private alertService: AlertService,
|
||||
private router: Router,
|
||||
private authService: AuthService,
|
||||
private activatedRoute: ActivatedRoute,
|
||||
) {
|
||||
this.loggeduser = authService.ValidatedUser;
|
||||
this.profile = 'mdgpr';
|
||||
}
|
||||
private sqliteservice: SqliteService,
|
||||
private platform: Platform
|
||||
) {
|
||||
this.loggeduser = authService.ValidatedUser;
|
||||
this.profile = 'mdgpr';
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
//Inicializar segment
|
||||
this.segment = "despachos";
|
||||
|
||||
const location = window.location
|
||||
const pathname = location.pathname + location.search
|
||||
|
||||
this.LoadList()
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationEnd && event.url.startsWith(pathname)) {
|
||||
if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
||||
this.refreshing()
|
||||
} else {
|
||||
this.LoadList()
|
||||
}
|
||||
}
|
||||
});
|
||||
this.getFromDb();
|
||||
|
||||
}
|
||||
|
||||
@@ -87,20 +82,69 @@ export class PendentesPage implements OnInit {
|
||||
pendentesList.push(task);
|
||||
});
|
||||
|
||||
pendentesList = removeDuplicate( pendentesList)
|
||||
pendentesList = removeDuplicate(pendentesList)
|
||||
pendentesList = this.sortArrayISODate(pendentesList);
|
||||
|
||||
this.pendentesstore.reset(pendentesList);
|
||||
this.listToPresent = pendentesList;
|
||||
this.skeletonLoader = false;
|
||||
|
||||
}
|
||||
|
||||
sortArrayISODate(myArray: any) {
|
||||
return myArray.sort(function(a, b) {
|
||||
return myArray.sort(function (a, b) {
|
||||
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
|
||||
});
|
||||
}
|
||||
|
||||
getFromDb() {
|
||||
|
||||
if (synchro.connected === true) {
|
||||
const location = window.location
|
||||
const pathname = location.pathname + location.search
|
||||
|
||||
this.LoadList()
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationEnd && event.url.startsWith(pathname)) {
|
||||
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
||||
this.refreshing()
|
||||
} else {
|
||||
this.LoadList()
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
synchro.registerCallback('Offline', () => {
|
||||
this.platform.ready().then(() => {
|
||||
this.sqliteservice.getAllProcess().then((process: any[]) => {
|
||||
var pendingList = []
|
||||
process.forEach(element => {
|
||||
var workflow = JSON.parse(element.workflowInstanceDataFields);
|
||||
if (workflow.Status === "Pending") {
|
||||
let task = {
|
||||
"CreateDate": element.taskStartDate,
|
||||
"DocumentsQty": element.totalDocuments,
|
||||
"FolderID": workflow.FolderID,
|
||||
"Folio": workflow.Subject,
|
||||
"Senders": workflow.Sender,
|
||||
"SerialNumber": element.serialNumber,
|
||||
"Status": workflow.Status,
|
||||
"WorkflowName": element.workflowDisplayName
|
||||
|
||||
}
|
||||
pendingList.push(task)
|
||||
}
|
||||
});
|
||||
|
||||
pendingList = this.sortArrayISODate(pendingList);
|
||||
this.listToPresent = pendingList;
|
||||
console.log('pendentes', pendingList)
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async refreshing() {
|
||||
setTimeout(() => {
|
||||
this.LoadList();
|
||||
@@ -115,24 +159,24 @@ export class PendentesPage implements OnInit {
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
async viewTaskDetails({ SerialNumber, WorkflowName, activityInstanceName }:customTask) {
|
||||
if(WorkflowName == 'Despacho') {
|
||||
this.router.navigate(['/home/gabinete-digital/despachos',SerialNumber,'gabinete-digital']);
|
||||
async viewTaskDetails({ SerialNumber, WorkflowName, activityInstanceName }: customTask) {
|
||||
if (WorkflowName == 'Despacho') {
|
||||
this.router.navigate(['/home/gabinete-digital/despachos', SerialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else if(WorkflowName == 'Pedido de Parecer' || WorkflowName == 'Pedido de Deferimento' || WorkflowName == 'Pedido de Parecer do Presidente') {
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos',SerialNumber,'gabinete-digital']);
|
||||
else if (WorkflowName == 'Pedido de Parecer' || WorkflowName == 'Pedido de Deferimento' || WorkflowName == 'Pedido de Parecer do Presidente') {
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos', SerialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else if(WorkflowName == 'Expediente') {
|
||||
this.router.navigate(['/home/gabinete-digital/expediente',SerialNumber,'gabinete-digital']);
|
||||
else if (WorkflowName == 'Expediente') {
|
||||
this.router.navigate(['/home/gabinete-digital/expediente', SerialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else if(WorkflowName == 'Expediente' && this.loggeduser.Profile == 'PR') {
|
||||
this.router.navigate(['/home/gabinete-digital/expedientes-pr',SerialNumber,'gabinete-digital']);
|
||||
else if (WorkflowName == 'Expediente' && this.loggeduser.Profile == 'PR') {
|
||||
this.router.navigate(['/home/gabinete-digital/expedientes-pr', SerialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else if (activityInstanceName == "Tarefa de Parecer") {
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos',SerialNumber,'gabinete-digital']);
|
||||
this.router.navigate(['/home/gabinete-digital/pedidos', SerialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else if(activityInstanceName == "Tarefa de Despacho") {
|
||||
this.router.navigate(['/home/gabinete-digital/despachos',SerialNumber,'gabinete-digital']);
|
||||
else if (activityInstanceName == "Tarefa de Despacho") {
|
||||
this.router.navigate(['/home/gabinete-digital/despachos', SerialNumber, 'gabinete-digital']);
|
||||
}
|
||||
else {
|
||||
console.log('cant find page for this task', WorkflowName, activityInstanceName)
|
||||
@@ -144,4 +188,4 @@ export class PendentesPage implements OnInit {
|
||||
return new Date(e).toDateString()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user