diff --git a/config.xml b/config.xml
index 2e850bb20..ea0586ed8 100644
--- a/config.xml
+++ b/config.xml
@@ -3,7 +3,7 @@
gabinete digital
An awesome Ionic/Cordova app.
Ionic Framework Team
-
+
@@ -81,7 +81,7 @@
0
- 8.0.0.00-20210905-154328
+ 8.0.0.00-20210308-063916
diff --git a/package-lock.json b/package-lock.json
index e7ef6064f..1f90ffb86 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -23619,9 +23619,9 @@
}
},
"typescript": {
- "version": "4.4.3",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz",
- "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==",
+ "version": "4.3.5",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz",
+ "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==",
"dev": true
},
"ua-parser-js": {
diff --git a/src/app/Rules/despacho.service.ts b/src/app/Rules/despacho.service.ts
index 1cae14ef4..3dade3928 100644
--- a/src/app/Rules/despacho.service.ts
+++ b/src/app/Rules/despacho.service.ts
@@ -253,7 +253,10 @@ export class DespachoService {
});
- despachoList = this.sortService.sortArrayByDate(despachoList).reverse();
+ console.log(despachoList);
+
+
+ despachoList = this.sortService.sortArrayISODate(despachoList).reverse();
if(updateStore) {
this.despachoStore.reset(despachoList);
diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts
index baae9d136..3f2b921b2 100644
--- a/src/app/home/home.page.ts
+++ b/src/app/home/home.page.ts
@@ -10,7 +10,6 @@ import { AlertController, Platform } from '@ionic/angular';
import { Router, ActivatedRoute } from '@angular/router';
import { ToDayEventStorage } from '../store/to-day-event-storage.service';
import { TotalDocumentStore } from '../store/total-document.service';
-import { synchro } from '../services/socket/synchro.service';
import { DespachoService } from '../Rules/despacho.service';
import { ExpedienteGdStore } from '../store/expedientegd-store.service';
import { InativityService } from '../services/inativity.service';
@@ -22,6 +21,9 @@ import { DocumentCounterService } from '../services/worker/document-counter.serv
import { PermissionService } from '../services/worker/permission.service';
import { Network } from '@ionic-native/network/ngx';
import { BackgroundService } from 'src/app/services/background.service';
+import { OfflineManagerService } from 'src/app/services/offline-manager.service';
+import { Storage } from '@ionic/storage';
+import { EventsService} from 'src/app/services/events.service';
@Component({
@@ -63,8 +65,6 @@ export class HomePage implements OnInit {
postEvent: any;
folderId: string;
- synchro = synchro
-
status: string = "";
audioName: string = "";
constructor(
@@ -82,7 +82,10 @@ export class HomePage implements OnInit {
private storageService: StorageService,
private webNotificationPopupService: WebNotificationPopupService,
private network: Network,
- private backgroundservice: BackgroundService) {
+ private backgroundservice: BackgroundService,
+ private offlinemanager: OfflineManagerService,
+ private storage: Storage,
+ private eventservice: EventsService ) {
this.webNotificationPopupService.askNotificationPermission()
@@ -112,18 +115,36 @@ export class HomePage implements OnInit {
ngOnInit() {
+ window.addEventListener('online', () => {
+ console.log('Became online')
+ this.backgroundservice.online()
+ });
+ window.addEventListener('offline', () => {
+ console.log('Became offline')
+ this.backgroundservice.offline()
+ });
+
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
- window.addEventListener('online', () => {
- console.log('Became online')
- this.backgroundservice.online()
- });
- window.addEventListener('offline', () => {
- console.log('Became offline')
- this.backgroundservice.offline()
- });
this.webnotification.webconnection();
this.webnotification.register();
} else {
+ window.addEventListener('online', (on) => {
+ console.log('Became online',on)
+ this.storage.get('storedreq').then((req) =>{
+ console.log('STORED REQUEST', req)
+ req.forEach(element => {
+ this.eventservice.editEvent(element,2,3).subscribe((res) =>{
+ console.log('REQUEST RESULT', res)
+ })
+ });
+
+ })
+ this.backgroundservice.online()
+ });
+ window.addEventListener('offline', (off) => {
+ console.log('Became offline',off)
+ this.backgroundservice.offline()
+ });
this.mobilefirstConnect();
this.notificationsService.onReceviNotification();
}
@@ -185,37 +206,6 @@ export class HomePage implements OnInit {
}
)
-
- synchro.registerCallback('Online', () => {
- console.log('Onlineee')
-
- })
-
-
- synchro.registerCallback('Offline',()=>{
-
- })
-
- synchro.conected
-
- synchro.registerCallback('Notification', (DataArray) => {
-
- this.webNotificationPopupService.sendNotification(DataArray)
-
- this.storageService.get('Notifications').then((data:any)=>{
- data.push(DataArray)
- this.storageService.store("Notifications", data)
- }).catch(() => {
-
- const a = []
- a.push(DataArray)
- this.storageService.store("Notifications", a)
- })
-
- }, 'any')
-
-
-
document.addEventListener('pause', function () {
// console.log('App going to background');
});
diff --git a/src/app/modals/create-process/create-process.page.ts b/src/app/modals/create-process/create-process.page.ts
index f1dfce511..a566bfdcc 100644
--- a/src/app/modals/create-process/create-process.page.ts
+++ b/src/app/modals/create-process/create-process.page.ts
@@ -382,7 +382,7 @@ export class CreateProcessPage implements OnInit {
}
else{
this.validateField = true;
- this.toastService.badRequest('Por favor adicione uma nota');
+ this.toastService.badRequest('Por favor adicione uma descrição');
}
loader.remove();
break;
diff --git a/src/app/modals/view-document/view-document.page.ts b/src/app/modals/view-document/view-document.page.ts
index 3b122f16a..cb5b52480 100644
--- a/src/app/modals/view-document/view-document.page.ts
+++ b/src/app/modals/view-document/view-document.page.ts
@@ -15,9 +15,6 @@ import { DocumentSetUpMeetingPage } from '../document-set-up-meeting/document-se
})
export class ViewDocumentPage implements OnInit {
- url: string;
- a:string = "https://equilibrium.dyndns.info/FileShare/pdfjs/web/viewer.html?file=";
- viewerUrl: string;
trustedUrl: any;
file: any;
applicationId: any;
@@ -49,11 +46,11 @@ export class ViewDocumentPage implements OnInit {
ngOnInit() {
this.processes.GetViewer(this.docId, this.applicationId).subscribe(res=> {
- const link: string = res
+ const link: string = res;
this.trustedUrl = this.sanitazer.bypassSecurityTrustResourceUrl(link);
}, ()=>{
- this.close()
- })
+ this.close();
+ });
}
diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts
index 39c75e824..68d481431 100644
--- a/src/app/pages/agenda/agenda.page.ts
+++ b/src/app/pages/agenda/agenda.page.ts
@@ -30,7 +30,7 @@ import { ListBoxService } from 'src/app/services/agenda/list-box.service';
import { ChangeProfileService } from 'src/app/services/change-profile.service';
import { SqliteService } from 'src/app/services/sqlite.service';
-import { synchro } from 'src/app/services/socket/synchro.service';
+import { BackgroundService } from 'src/app/services/background.service';
@Component({
@@ -175,7 +175,8 @@ export class AgendaPage implements OnInit {
private listBoxService: ListBoxService,
private changeProfileService: ChangeProfileService,
private sqliteservice: SqliteService,
- private platform: Platform
+ private platform: Platform,
+ private backgroundservice: BackgroundService
) {
this.dateAdapter.setLocale('es');
@@ -229,7 +230,23 @@ export class AgendaPage implements OnInit {
ngOnInit() {
- this.getFromDB()
+ const pathname = window.location.pathname
+ let realoadCounter = 0
+ this.router.events.forEach((event) => {
+ if (event instanceof NavigationEnd && event.url == pathname) {
+ if (this.segment == null) {
+ this.segment = "Combinado";
+ }
+ if (realoadCounter != 0) {
+ this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
+ }
+ realoadCounter++;
+ }
+ });
+
+ this.backgroundservice.registerBackService('Online', () => {
+ this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
+ });
window.onresize = (event) => {
// if not table remove all component
@@ -490,7 +507,7 @@ export class AgendaPage implements OnInit {
// loop
this.CalendarStore.pushEvent(response, 'md');
- console.log('CALENDAR STORE',this.CalendarStore.eventSource)
+ console.log('CALENDAR STORE', this.CalendarStore.eventSource)
let array = []
response.forEach(element => {
@@ -507,7 +524,7 @@ export class AgendaPage implements OnInit {
});
this.listToPresent = array;
- console.log('LIST TO PRESET',this.listToPresent)
+ console.log('LIST TO PRESET', this.listToPresent)
this.TimelineMDList = this.listBoxService.list(this.listToPresent, 'md', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
@@ -517,13 +534,16 @@ export class AgendaPage implements OnInit {
this.showLoader = false;
this.showTimeline = true;
- }).finally(() => {
+ }).catch((error) => {
+ this.getFromDB();
+ })
+ .finally(() => {
this.showLoader = false;
})
}
// view PR calendar with MDGPR profile
- else if(this.profile == "pr" && this.loggeduser.Profile == 'MDGPR') {
+ else if (this.profile == "pr" && this.loggeduser.Profile == 'MDGPR') {
this.eventService.getAllSharedEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => {
@@ -556,7 +576,7 @@ export class AgendaPage implements OnInit {
// startTime = 1, endTime = 31
this.CalendarStore.removeRange(startTime, endTime, 'pr')
this.CalendarStore.pushEvent(response, 'pr');
- let array = []
+ let array = []
response.array.forEach(element => {
let event = {
startTime: new Date(element.StartDate),
@@ -585,7 +605,10 @@ export class AgendaPage implements OnInit {
this.showTimeline = true;
- }).finally(() => {
+ }).catch((error) => {
+ this.getFromDB()
+ })
+ .finally(() => {
this.showLoader = false;
})
}
@@ -596,7 +619,7 @@ export class AgendaPage implements OnInit {
let counter = 0;
// view MDGPR calendar with MDGPR profile
- if(this.loggeduser.Profile == 'MDGPR') {
+ if (this.loggeduser.Profile == 'MDGPR') {
this.eventService.getAllMdEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => {
@@ -633,9 +656,9 @@ export class AgendaPage implements OnInit {
let eventsList = response;
// clear the current month only
- this.CalendarStore.removeRange(startTime, endTime, 'pr')
+ /* this.CalendarStore.removeRange(startTime, endTime, 'pr')
- this.CalendarStore.pushEvent(eventsList, 'pr');
+ this.CalendarStore.pushEvent(eventsList, 'pr'); */
this.listToPresent = eventsList;
this.TimelinePRList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate })
@@ -660,8 +683,8 @@ export class AgendaPage implements OnInit {
} else {
- // view PR calendar with PR profile
- this.eventService.getAllPrEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((response:any) => {
+ // view PR calendar with PR profile
+ this.eventService.getAllPrEvents(momentG(new Date(startTime), 'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime), 'yyyy-MM-dd 23:59:59')).then((response: any) => {
let eventsList;
if (this.segment == 'Oficial') {
@@ -729,44 +752,34 @@ export class AgendaPage implements OnInit {
}
getFromDB() {
-
- if (synchro.connected === true) {
- const pathname = window.location.pathname
- let realoadCounter = 0
- this.router.events.forEach((event) => {
- if (event instanceof NavigationEnd && event.url == pathname) {
- if (this.segment == null) {
- this.segment = "Combinado";
- }
- if (realoadCounter != 0) {
- this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
- }
- realoadCounter++;
+ console.log('ALL EVENTS FROM DB AGENDA OFFLINE')
+ this.sqliteservice.getAllEvents().then((events: any[]) => {
+ console.log('ALL EVENTS FROM DB', events)
+ let eventArray = [];
+ events.forEach(element => {
+ let event = {
+ startTime: new Date(element.StartDate),
+ endTime: new Date(element.EndDate),
+ allDay: false,
+ event: element,
+ calendarName: element.CalendarName,
+ profile: element.Profile,
+ id: element.EventId,
}
+ eventArray.push(event);
});
- console.log('LISTTOPRESENT', this.listToPresent)
- } else {
- console.log('ALL EVENTS FROM DB AGENDA OFFLINE')
- this.sqliteservice.getAllEvents().then((events: any[]) => {
- let eventArray = [];
- events.forEach(element => {
- let event = {
- startTime: new Date(element.StartDate),
- endTime: new Date(element.EndDate),
- allDay: false,
- event: element,
- calendarName: element.CalendarName,
- profile: element.profile,
- id: element.EventId,
- }
- eventArray.push(event);
- });
- console.log('ALL EVENTS FROM DB', events)
- this.listToPresent = eventArray
+ this.listToPresent = eventArray
+ this.updateEventListBox()
- })
- }
+ this.myCal.update();
+ this.myCal.loadEvents();
+
+ this.showLoader = false;
+ this.showTimeline = true;
+
+
+ })
}
updateEventListBox() {
diff --git a/src/app/pages/agenda/view-event/view-event.page.ts b/src/app/pages/agenda/view-event/view-event.page.ts
index 25775dc21..1a1b16934 100644
--- a/src/app/pages/agenda/view-event/view-event.page.ts
+++ b/src/app/pages/agenda/view-event/view-event.page.ts
@@ -13,11 +13,11 @@ import { ToastService } from 'src/app/services/toast.service';
import { EliminateEventPage } from 'src/app/modals/eliminate-event/eliminate-event.page';
import { Location } from '@angular/common'
import { SqliteService } from 'src/app/services/sqlite.service';
-import { synchro } from '../../../services/socket/synchro.service';
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
import { DocumentSetUpMeetingPage } from 'src/app/modals/document-set-up-meeting/document-set-up-meeting.page';
import { ExpedientTaskModalPage } from '../../gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
+import { BackgroundService } from 'src/app/services/background.service';
@Component({
selector: 'app-view-event',
@@ -30,17 +30,17 @@ export class ViewEventPage implements OnInit {
loadedEvent: Event;
isEventEdited: boolean;
eventBody: EventBody;
- loadedAttachments:any;
+ loadedAttachments: any;
pageId: string;
showLoader: boolean;
minDate: Date;
- profile:string;
- eventId:string;
- caller:string;
- customDate:any;
- today:any;
+ profile: string;
+ eventId: string;
+ caller: string;
+ customDate: any;
+ today: any;
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
@@ -48,13 +48,12 @@ export class ViewEventPage implements OnInit {
dicIndex = 0;
isModal = false
header = true
- synch = synchro;
task: ExpedientTaskModalPageNavParamsTask;
- LoadedDocument:any = null;
+ LoadedDocument: any = null;
constructor(
private modalController: ModalController,
- /* private navParams: NavParams, */
+ /* private navParams: NavParams, */
private eventsService: EventsService,
private attachmentsService: AttachmentsService,
public alertController: AlertController,
@@ -66,26 +65,24 @@ export class ViewEventPage implements OnInit {
private toastService: ToastService,
private location: Location,
public platform: Platform,
- private sqliteservice: SqliteService
-
-
- )
- {
+ private sqliteservice: SqliteService,
+ private backgroundservice: BackgroundService
+ ) {
this.isEventEdited = false;
this.loadedEvent = new Event();
- this.eventBody = { BodyType : "1", Text : ""};
+ this.eventBody = { BodyType: "1", Text: "" };
this.loadedEvent.Body = this.eventBody;
- this.activatedRoute.paramMap.subscribe(params =>{
+ this.activatedRoute.paramMap.subscribe(params => {
this.eventId = params['params'].eventId;
- if(params["params"].caller){
+ if (params["params"].caller) {
this.caller = (params["params"].caller);
}
- if(params["params"].isModal) {
+ if (params["params"].isModal) {
this.isModal = params["params"].isModal
}
- if(params["params"].header) {
+ if (params["params"].header) {
this.header = params["params"].header
}
});
@@ -100,56 +97,44 @@ export class ViewEventPage implements OnInit {
}
ngOnInit() {
- if(synchro.connected === true) {
- this.loadEvent();
- console.log('Onlineee view-event')
- } else {
- this.sqliteservice.getEventById(this.eventId).then((event) => {
- this.loadedEvent = event[0];
- console.log("Event ditails local,", event[0])
- })
- console.log('Offlineee')
- }
+ this.loadEvent();
- /* this.sqliteservice.getEventById(this.eventId).then((event) => {
- this.loadedEvent = event[0];
- console.log("Event ditails local,", event[0])
- })
- this.loadEvent(); */
-
+ this.backgroundservice.registerBackService('Online', () => {
+ this.loadEvent();
+ });
window.onresize = (event) => {
// if not mobile remove all component
- if( window.innerWidth >= 1024) {
+ if (window.innerWidth >= 1024) {
this.modalController.dismiss(this.isEventEdited);
}
};
}
- close(){
+ close() {
this.modalController.dismiss(this.isEventEdited);
}
goBack() {
- if(this.isModal) {
+ if (this.isModal) {
this.close()
} else {
- this.activatedRoute.paramMap.subscribe(params => {
- if(params["params"].caller == 'expediente'){
- window.history.back();
- }
- else{
- this.router.navigate(['/home',params["params"].caller]);
- }
+ this.activatedRoute.paramMap.subscribe(params => {
+ if (params["params"].caller == 'expediente') {
+ window.history.back();
+ }
+ else {
+ this.router.navigate(['/home', params["params"].caller]);
+ }
});
}
}
- doRefresh(ev){
+ doRefresh(ev) {
this.loadEvent();
ev.target.complete();
}
@@ -158,44 +143,45 @@ export class ViewEventPage implements OnInit {
const loader = this.toastService.loading();
this.eventsService.getEvent(this.eventId).subscribe(res => {
this.loadedEvent = res;
- this.sqliteservice.addEvent(res);
+ this.addEventToDb(res);
console.log('Loaded one event', res)
/* this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */
loader.remove()
- }, (error)=>{
+ }, (error) => {
- if(error.status == 0) {
- this.toastService.badRequest('Não é possível vizualizar este evento no modo offline')
+ console.log('errorstatus',error.status)
+
+ if (error.status == 0) {
+ this.getFromDb();
} else {
this.toastService.badRequest('Este evento já não existe na sua agenda')
+ loader.remove()
+ this.modalController.dismiss('Eevent not Foud');
+ this.location.back();
}
-
loader.remove()
- this.modalController.dismiss('Eevent not Foud');
- this.location.back();
});
}
- deleteEvent(){
+ deleteEvent() {
const loader = this.toastService.loading()
- this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () =>
- {
- const alert = await this.alertController.create({
- cssClass: 'my-custom-class',
- header: 'Evento removido',
- buttons: ['OK']
- });
+ this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => {
+ const alert = await this.alertController.create({
+ cssClass: 'my-custom-class',
+ header: 'Evento removido',
+ buttons: ['OK']
+ });
- setTimeout(()=>{
- alert.dismiss();
- }, 1500);
- this.goBack();
- this.toastService.successMessage('Evento apagado');
- }, ()=>{},
- ()=>{
+ setTimeout(() => {
+ alert.dismiss();
+ }, 1500);
+ this.goBack();
+ this.toastService.successMessage('Evento apagado');
+ }, () => { },
+ () => {
loader.remove();
});
}
@@ -216,7 +202,7 @@ export class ViewEventPage implements OnInit {
modal.onDidDismiss().then((res) => {
console.log(res);
- if(res){
+ if (res) {
setTimeout(() => {
/* this.loadEvent(); */
this.loadEvent()
@@ -243,7 +229,7 @@ export class ViewEventPage implements OnInit {
modal.onDidDismiss().then((res) => {
console.log(res);
- if(res){
+ if (res) {
setTimeout(() => {
/* this.loadEvent(); */
this.loadEvent()
@@ -258,15 +244,15 @@ export class ViewEventPage implements OnInit {
console.log(this.loadedEvent);
let classs;
- if( window.innerWidth <= 800){
+ if (window.innerWidth <= 800) {
classs = 'modal modal-desktop'
- } else {
+ } else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: EditEventPage,
- componentProps:{
+ componentProps: {
event: this.loadedEvent,
caller: this.caller,
},
@@ -276,7 +262,7 @@ export class ViewEventPage implements OnInit {
modal.onDidDismiss().then((res) => {
console.log(res);
- if(res){
+ if (res) {
setTimeout(() => {
/* this.loadEvent(); */
this.loadEvent()
@@ -286,15 +272,15 @@ export class ViewEventPage implements OnInit {
});
}
- docIndex(index: number){
+ docIndex(index: number) {
this.dicIndex = index
}
async LoadDocumentDetails() {
-
- const docId = this.loadedEvent.Attachments[ this.dicIndex].SourceId
- const applicationId: any = this.loadedEvent.Attachments[ this.dicIndex].ApplicationId
- const selectedDoc = this.loadedEvent.Attachments[ this.dicIndex]
+
+ const docId = this.loadedEvent.Attachments[this.dicIndex].SourceId
+ const applicationId: any = this.loadedEvent.Attachments[this.dicIndex].ApplicationId
+ const selectedDoc = this.loadedEvent.Attachments[this.dicIndex]
console.log('selectedDoc', selectedDoc)
@@ -322,7 +308,7 @@ export class ViewEventPage implements OnInit {
url: '',
title_link: '',
},
- Document: this.loadedEvent.Attachments[ this.dicIndex],
+ Document: this.loadedEvent.Attachments[this.dicIndex],
applicationId: this.task.workflowInstanceDataFields.SourceSecFsID,
docId: selectedDoc.SourceId,
folderId: '',
@@ -336,33 +322,33 @@ export class ViewEventPage implements OnInit {
async openBookMeetingModal() {
let classs;
- if( window.innerWidth < 701) {
+ if (window.innerWidth < 701) {
classs = 'book-meeting-modal modal modal-desktop'
- } else {
+ } else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: DocumentSetUpMeetingPage,
componentProps: {
subject: this.task.workflowInstanceDataFields.Subject,
- document: this.loadedEvent.Attachments[ this.dicIndex],
+ document: this.loadedEvent.Attachments[this.dicIndex],
},
cssClass: classs,
backdropDismiss: false
});
await modal.present();
- modal.onDidDismiss().then(res=>{
+ modal.onDidDismiss().then(res => {
//this.location.back();
});
}
// efetuar despacho
- async openExpedientActionsModal( taskAction: any) {
+ async openExpedientActionsModal(taskAction: any) {
let classs;
- if( window.innerWidth < 701) {
+ if (window.innerWidth < 701) {
classs = 'modal modal-desktop'
- } else {
+ } else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
@@ -370,35 +356,74 @@ export class ViewEventPage implements OnInit {
componentProps: {
taskAction: taskAction,
task: this.task,
- seachDocuments: this.loadedEvent.Attachments[ this.dicIndex],
- aplicationId: this.loadedEvent.Attachments[ this.dicIndex].ApplicationId || this.loadedEvent.Attachments[ this.dicIndex]['ApplicationID']
+ seachDocuments: this.loadedEvent.Attachments[this.dicIndex],
+ aplicationId: this.loadedEvent.Attachments[this.dicIndex].ApplicationId || this.loadedEvent.Attachments[this.dicIndex]['ApplicationID']
},
cssClass: classs,
});
await modal.present();
- modal.onDidDismiss().then( async(res)=>{});
+ modal.onDidDismiss().then(async (res) => { });
}
- getEventsFromLocalDb() {
- console.log("event id details ", this.eventId)
+ addEventToDb(data) {
+ if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
+ } else {
+ let event = {
+ Attendees: JSON.stringify(data.Attendees) || JSON.stringify(''),
+ Body: JSON.stringify(data.Body) || JSON.stringify(''),
+ CalendarId: data.CalendarId,
+ CalendarName: data.CalendarName,
+ Category: data.Category,
+ EndDate: data.EndDate,
+ EventId: data.EventId,
+ EventRecurrence: JSON.stringify(data.EventRecurrence) || JSON.stringify(''),
+ EventType: data.EventType,
+ HasAttachments: data.HasAttachments,
+ IsAllDayEvent: data.IsAllDayEvent,
+ IsMeeting: data.IsMeeting,
+ IsRecurring: data.IsRecurring,
+ Location: data.Location,
+ Organizer: JSON.stringify(data.Organizer) || JSON.stringify(''),
+ StartDate: data.StartDate,
+ Subject: data.Subject,
+ TimeZone: data.TimeZone
+ }
- synchro.registerCallback('Online', () => {
- this.loadEvent();
- console.log('Onlineee view-event')
-
- })
-
- synchro.registerCallback('Offline', () => {
- this.platform.ready().then(() => {
- this.sqliteservice.getEventById(this.eventId).then((event) => {
- this.loadedEvent = event[0];
- console.log("Event ditails local,", event[0])
- })
- console.log('Offlineee')
- })
+ this.sqliteservice.updateEvent(event);
+ }
+ }
+
+ getFromDb() {
+ const loader = this.toastService.loading();
+ this.sqliteservice.getEventById(this.eventId).then((event) => {
+ let arrayevent = [];
+ let elemet = {
+ Attendees: JSON.parse(event[0].Attendees) || "",
+ Body: JSON.parse(event[0].Body) || "",
+ CalendarId: event[0].CalendarId,
+ CalendarName: event[0].CalendarName,
+ Category: event[0].Category,
+ EndDate: event[0].EndDate,
+ EventId: event[0].EventId,
+ EventRecurrence: JSON.parse(event[0].EventRecurrence) || "",
+ EventType: event[0].EventType,
+ HasAttachments: event[0].HasAttachments,
+ IsAllDayEvent: event[0].IsAllDayEvent,
+ IsMeeting: event[0].IsMeeting,
+ IsRecurring: event[0].IsRecurring,
+ Location: event[0].Location,
+ Organizer: JSON.parse(event[0].Organizer) || "",
+ StartDate: event[0].StartDate,
+ Subject: event[0].Subject,
+ TimeZone: event[0].TimeZone
+ }
+ arrayevent.push(elemet);
+ this.loadedEvent = arrayevent[0];
+ console.log("Event ditails local,", elemet)
})
+ loader.remove()
}
}
diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts
index 2b4c147e7..0c01a9ea7 100644
--- a/src/app/pages/chat/messages/messages.page.ts
+++ b/src/app/pages/chat/messages/messages.page.ts
@@ -12,7 +12,6 @@ import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service';
import { FileService } from 'src/app/services/functions/file.service';
import { ProcessesService } from 'src/app/services/processes.service';
-import { synchro } from 'src/app/services/socket/synchro.service';
import { ToastService } from 'src/app/services/toast.service';
import { NewEventPage } from 'src/app/shared/agenda/new-event/new-event.page';
import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popover/chat-options-popover.page';
@@ -45,7 +44,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
members:any;
scrollingOnce:boolean = true;
- synchro = synchro;
chatMessageStore = ChatMessageStore
chatUserStorage = ChatUserStorage
diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts
index ffcc423df..360f71d8c 100644
--- a/src/app/pages/events/events.page.ts
+++ b/src/app/pages/events/events.page.ts
@@ -17,8 +17,8 @@ import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
import { SqliteService } from 'src/app/services/sqlite.service';
-import { synchro } from '../../services/socket/synchro.service';
-import { BackgroundService } from 'src/app/services/background.service'
+import { NetworkConnectionService } from 'src/app/services/network-connection.service'
+import { BackgroundService } from 'src/app/services/background.service';
@Component({
selector: 'app-events',
@@ -69,7 +69,7 @@ export class EventsPage implements OnInit {
expedienteGdStore = ExpedienteGdStore
listToPresent = [];
- listToPresentexpediente =[]
+ listToPresentexpediente = []
expedienteTaskPipe = new ExpedienteTaskPipe()
@@ -78,7 +78,6 @@ export class EventsPage implements OnInit {
loggeduser: LoginUserRespose;
existingScreenOrientation: string;
- synch = synchro
constructor(
private eventService: EventsService,
@@ -93,7 +92,8 @@ export class EventsPage implements OnInit {
private screenOrientation: ScreenOrientation,
public platform: Platform,
private sqliteservice: SqliteService,
- private backgroundservice: BackgroundService
+ private networkconnection: NetworkConnectionService,
+ private backgroundservice: BackgroundService,
) {
this.existingScreenOrientation = this.screenOrientation.type;
console.log(this.existingScreenOrientation);
@@ -108,15 +108,14 @@ export class EventsPage implements OnInit {
});
- /* if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
+ if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
try {
this.sqliteservice.databaseConn();
} catch (error) {
console.log("Error creating local database: ", error)
}
- } */
-
+ }
}
ngOnInit() {
@@ -124,21 +123,26 @@ export class EventsPage implements OnInit {
this.segment = "Combinada";
this.profile = "mdgpr";
- if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
+ this.showGreeting();
+
+ this.router.events.forEach((event) => {
+ if (event instanceof NavigationEnd && event.url == '/home/events') {
+ this.RefreshEvents();
+ setTimeout(() => {
+ this.LoadList();
+ }, 1500)
+ }
+ });
+ this.hideSearch();
+
+ this.backgroundservice.registerBackService('Online', () => {
this.showGreeting();
-
- this.router.events.forEach((event) => {
- if (event instanceof NavigationEnd && event.url == '/home/events') {
- this.RefreshEvents();
- setTimeout(() => {
- this.LoadList();
- }, 1500)
- }
- });
+ this.RefreshEvents();
+ this.LoadList();
this.hideSearch();
- }
+ });
- this.getEventsFromLocalDb();
+ //this.getEventsFromLocalDb();
//this.checkScreenOrientation();
@@ -206,7 +210,7 @@ export class EventsPage implements OnInit {
console.log("getAllMdOficialPessoalEvents", list)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
- if(list.length > 0) {
+ if (list.length > 0) {
list.forEach(element => {
this.sqliteservice.addEvent(element)
});
@@ -234,7 +238,7 @@ export class EventsPage implements OnInit {
console.log("getAllPrOficialPessoalEvents", list)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
- if(list.length > 0) {
+ if (list.length > 0) {
list.forEach(element => {
this.sqliteservice.addEvent(element)
});
@@ -324,21 +328,26 @@ export class EventsPage implements OnInit {
getEventsFromLocalDb() {
- if (synchro.connected === true) {
- this.showGreeting();
+ /* window.addEventListener('online', (on) => {
+ this.showGreeting();
+
+ this.router.events.forEach((event) => {
+ if (event instanceof NavigationEnd && event.url == '/home/events') {
+ this.RefreshEvents();
+ setTimeout(() => {
+ this.LoadList();
+
+ }, 1500)
+ }
+ });
+ this.hideSearch();
+ }); */
- this.router.events.forEach((event) => {
- if (event instanceof NavigationEnd && event.url == '/home/events') {
- this.RefreshEvents();
- setTimeout(() => {
- this.LoadList();
- }, 1500)
- }
- });
- this.hideSearch();
- } else {
- this.platform.ready().then(async () => {
- this.sqliteservice.getAllEvents().then((event:any[]) => {
+ // window.addEventListener('offline', (off) => {
+ if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
+
+ } else {
+ this.sqliteservice.getAllEvents().then((event: any[]) => {
this.listToPresent = event
this.totalEvent = this.listToPresent.length
this.currentEvent = this.listToPresent[0].Subject
@@ -346,29 +355,39 @@ export class EventsPage implements OnInit {
console.log("All events from local,", event)
})
- this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[]) => {
- var expedientlist = [];
- process.forEach((element) => {
- let task = {
- CreateDate: element.taskStartDate,
- DocumentsQty: element.totalDocuments,
- Senders: JSON.parse(element.workflowInstanceDataFields).Sender,
- SerialNumber: element.serialNumber,
- Status: JSON.parse(element.workflowInstanceDataFields).Status,
- Subject: JSON.parse(element.workflowInstanceDataFields).Subject,
- WorkflowName: element.workflowDisplayName,
- activityInstanceName: element.activityInstanceName,
- taskStartDate: element.taskStartDate,
- }
- expedientlist.push(task);
- })
- const ExpedienteTask = expedientlist.map(e => this.expedienteTaskPipe.transform(e))
- this.listToPresentexpediente = ExpedienteTask;
-
-
+ this.sqliteservice.getAllProcess().then((res) => {
+ console.log('INICION ALL EVENTs', res)
+ })
+ this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[]) => {
+
+ console.log('OFOFOFOOF', process)
+
+ if (process.length > 0 || process != undefined) {
+
+ var expedientlist: any = new Array();
+ process.forEach((element) => {
+ let task = {
+ activityInstanceName: element.activityInstanceName,
+ deadline: null,
+ serialNumber: element.serialNumber,
+ taskStartDate: element.taskStartDate,
+ totalDocuments: element.totalDocuments,
+ workflowDisplayName: element.workflowDisplayName,
+ workflowInstanceDataFields: JSON.parse(element.workflowInstanceDataFields)
+ }
+ expedientlist.push(task);
+ })
+
+ console.log('OFOFOFOOF22222', expedientlist)
+ const ExpedienteTask = expedientlist.map(e => this.expedienteTaskPipe.transform(e))
+ this.listToPresentexpediente = ExpedienteTask;
+
+ }
+
+ this.showLoader = false;
})
- });
}
+ // });
}
@@ -426,10 +445,13 @@ export class EventsPage implements OnInit {
LoadList() {
this.processes.GetTaskListExpediente(false).subscribe(result => {
console.log("Expediente", result);
+
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
-
+
} else {
- this.sqliteservice.addProcess(result)
+ result.forEach((element) => {
+ this.sqliteservice.addProcess(element)
+ })
}
const ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e))
@@ -437,7 +459,10 @@ export class EventsPage implements OnInit {
console.log("Expediente 2", ExpedienteTask);
this.listToPresentexpediente = ExpedienteTask;
- });
+ }, ((error) => {
+ console.log('Getlist error', error)
+ this.getEventsFromLocalDb();
+ }));
}
sortArrayISODate(myArray: any) {
diff --git a/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts b/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts
index f79123fd6..516c1c439 100644
--- a/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts
+++ b/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts
@@ -21,7 +21,7 @@ import { DespachoService } from 'src/app/Rules/despacho.service';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { SqliteService } from 'src/app/services/sqlite.service';
-import { synchro } from 'src/app/services/socket/synchro.service';
+import { BackgroundService } from 'src/app/services/background.service';
@Component({
selector: 'app-despacho-pr',
@@ -56,7 +56,8 @@ export class DespachoPrPage implements OnInit {
private toastService: ToastService,
private location: Location,
private despachoService: DespachoService,
- private sqliteservice: SqliteService
+ private sqliteservice: SqliteService,
+ private backgroundservice: BackgroundService
) {
this.activatedRoute.paramMap.subscribe(params => {
if (params["params"].SerialNumber) {
@@ -73,7 +74,21 @@ export class DespachoPrPage implements OnInit {
ngOnInit() {
this.profile = "mdgpr";
console.log(this.serialNumber);
- this.getFromDB();
+
+ this.activateRoute.paramMap.subscribe(paramMap => {
+ if (!paramMap.has('SerialNumber')) {
+ return;
+ }
+ /* this.serialNumber = paramMap.get('SerialNumber'); */
+ this.LoadTaskDetail(this.serialNumber);
+ // this.LoadRelatedEvents(this.serialNumber);
+ });
+ this.LoadTaskDetail(this.serialNumber);
+ // this.LoadRelatedEvents(this.serialNumber);
+
+ this.backgroundservice.registerBackService('Online', () => {
+ this.LoadTaskDetail(this.serialNumber);
+ });
}
close() {
@@ -125,93 +140,81 @@ export class DespachoPrPage implements OnInit {
return user.Type == 'CC';
}) || []
- if(!this.cc) {
+ if (!this.cc) {
this.cc = []
}
});
}, (error) => {
- try {
- this.goBack()
- } catch (e) {
- window.history.back();
- } finally {
- if (error.status == 0) {
- this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
- } else {
- this.toastService.badRequest('Processo não encontrado')
+
+ if (error.status == 0) {
+ this.getFromDB()
+ } else {
+ try {
+ this.goBack()
+ } catch (e) {
+ window.history.back();
}
+ this.toastService.badRequest('Processo não encontrado')
+
}
});
}
getFromDB() {
- if (synchro.connected === true) {
- this.activateRoute.paramMap.subscribe(paramMap => {
- if (!paramMap.has('SerialNumber')) {
- return;
- }
- /* this.serialNumber = paramMap.get('SerialNumber'); */
- this.LoadTaskDetail(this.serialNumber);
- // this.LoadRelatedEvents(this.serialNumber);
+
+ this.sqliteservice.getProcessById(this.serialNumber).then((process: any[]) => {
+ console.log('OFFLINE', process)
+ this.task = {
+ "SerialNumber": process[0].serialNumber,
+ "Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
+ "Senders": JSON.parse(process[0].originator).email,
+ "CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
+ "DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
+ "Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
+ "Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage || JSON.parse(process[0].workflowInstanceDataFields).Note,
+ "FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
+ "FsId": '361',
+ "DocId": JSON.parse(process[0].workflowInstanceDataFields).DispatchDocId,
+ "WorkflowName": process[0].workflowDisplayName,
+ "DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
+ "activityInstanceName": process[0].activityInstanceName,
+ }
+ console.log("OFFLINE TASK", this.task)
+ let fulltak = {
+ Documents: JSON.parse(process[0].Documents),
+ actions: JSON.parse(process[0].actions),
+ activityInstanceName: process[0].activityInstanceName,
+ formURL: process[0].formURL,
+ originator: JSON.parse(process[0].originator),
+ serialNumber: process[0].serialNumber,
+ taskStartDate: process[0].taskStartDate,
+ totalDocuments: process[0].totalDocuments,
+ workflowDisplayName: process[0].workflowDisplayName,
+ workflowID: process[0].workflowID,
+ workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
+ workflowInstanceFolio: process[0].workflowInstanceFolio,
+ workflowInstanceID: process[0].workflowInstanceID,
+ workflowName: process[0].workflowName
+ }
+ this.fulltask = fulltak;
+ console.log(this.task);
+
+ let thedate = new Date(this.task.CreateDate);
+ this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
+
+ this.intervenientes = JSON.parse(process[0].interveners).filter(user => {
+ return user.Type == 'I';
+ });
+ this.cc = JSON.parse(process[0].interveners).filter(user => {
+ return user.Type == 'CC';
});
- this.LoadTaskDetail(this.serialNumber);
- // this.LoadRelatedEvents(this.serialNumber);
- } else {
- this.sqliteservice.getProcessById(this.serialNumber).then((process: any[]) => {
- console.log('OFFLINE', process)
- this.task = {
- "SerialNumber": process[0].serialNumber,
- "Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
- "Senders": JSON.parse(process[0].originator).email,
- "CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
- "DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
- "Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
- "Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage || JSON.parse(process[0].workflowInstanceDataFields).Note,
- "FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
- "FsId": '361',
- "DocId": JSON.parse(process[0].workflowInstanceDataFields).DispatchDocId,
- "WorkflowName": process[0].workflowDisplayName,
- "DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
- "activityInstanceName": process[0].activityInstanceName,
- }
- console.log("OFFLINE TASK", this.task)
- let fulltak = {
- Documents: JSON.parse(process[0].Documents),
- actions: JSON.parse(process[0].actions),
- activityInstanceName: process[0].activityInstanceName,
- formURL: process[0].formURL,
- originator: JSON.parse(process[0].originator),
- serialNumber: process[0].serialNumber,
- taskStartDate: process[0].taskStartDate,
- totalDocuments: process[0].totalDocuments,
- workflowDisplayName: process[0].workflowDisplayName,
- workflowID: process[0].workflowID,
- workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
- workflowInstanceFolio: process[0].workflowInstanceFolio,
- workflowInstanceID: process[0].workflowInstanceID,
- workflowName: process[0].workflowName
- }
- this.fulltask = fulltak;
- console.log(this.task);
-
- let thedate = new Date(this.task.CreateDate);
- this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
-
- this.intervenientes = JSON.parse(process[0].interveners).filter(user => {
- return user.Type == 'I';
- });
- this.cc = JSON.parse(process[0].interveners).filter(user => {
- return user.Type == 'CC';
- });
-
- })
- }
+ })
}
- async viewDocument(DocId:string, Document) {
+ async viewDocument(DocId: string, Document) {
const modal = await this.modalController.create({
component: ViewDocumentPage,
diff --git a/src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.ts b/src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.ts
index 6938ce759..2b621b25f 100644
--- a/src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.ts
+++ b/src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.ts
@@ -18,7 +18,7 @@ import { __awaiter } from 'tslib';
import { DespachosprStore } from 'src/app/store/despachospr-store.service';
import { SqliteService } from 'src/app/services/sqlite.service';
-import { synchro } from 'src/app/services/socket/synchro.service';
+import { BackgroundService } from 'src/app/services/background.service';
import { SortService } from 'src/app/services/functions/sort.service';
@Component({
@@ -61,6 +61,7 @@ export class DespachosPrPage implements OnInit {
private authService: AuthService,
private router: Router,
private sqliteservice: SqliteService,
+ private backgroundservice: BackgroundService,
private sortService: SortService,
) {
@@ -72,7 +73,25 @@ export class DespachosPrPage implements OnInit {
ngOnInit() {
//Inicializar segment
this.segment = "despachos";
- this.getFromDB();
+
+ 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.doRefresh()
+ } else {
+ this.LoadList()
+ }
+ }
+ });
+
+ this.backgroundservice.registerBackService('Online', () => {
+ this.LoadList()
+ });
}
segmentChanged(ev: any) {
@@ -94,115 +113,104 @@ export class DespachosPrPage implements OnInit {
async LoadList() {
- this.skeletonLoader = true
+ this.processes.GetTasksList("Despacho do Presidente da República", false).subscribe(async res => {
+ this.skeletonLoader = true
- let result = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
- this.despachoList = [];
- this.skeletonLoader = false;
- console.log(result);
+ let result = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
+ this.despachoList = [];
+ this.skeletonLoader = false;
+ console.log(result);
- let despachosPr;
- let despachos = this.sortService.sortArrayByDate(result);
- switch (this.loggeduser.Profile) {
- case 'MDGPR':
- despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho");
- break;
- case 'PR':
- despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Concluir Despacho");
- break;
- }
-
- console.log(despachosPr);
- despachosPr = despachosPr.filter(data => data.workflowInstanceDataFields.Status == "Active");
-
- despachosPr.forEach((element, index) => {
-
- let date = new Date(element.taskStartDate);
- date.setMonth(date.getMonth() + 1);
- let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
-
- let task = {
- "SerialNumber": element.serialNumber,
- "Folio": element.workflowInstanceDataFields.Subject,
- "Senders": element.workflowInstanceDataFields.Sender,
- "CreateDate": taskDate,
- "DocumentURL": element.workflowInstanceDataFields.ViewerRequest,
- "Remetente": element.workflowInstanceDataFields.Remetente,
- "DocumentsQty": element.totalDocuments,
- "DocId": element.workflowInstanceDataFields.DocIdDiferimento,
- "WorkflowName": element.workflowDisplayName,
- "activityInstanceName": element.activityInstanceName,
+ let despachosPr;
+ let despachos = this.sortService.sortArrayByDate(result);
+ switch (this.loggeduser.Profile) {
+ case 'MDGPR':
+ despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho");
+ break;
+ case 'PR':
+ despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Concluir Despacho");
+ break;
}
- this.despachoList.push(task);
- console.log(this.despachoList);
- });
- this.listToPresent = this.despachoList
+ console.log(despachosPr);
+ despachosPr = despachosPr.filter(data => data.workflowInstanceDataFields.Status == "Active");
+
+ despachosPr.forEach((element, index) => {
+
+ let date = new Date(element.taskStartDate);
+ date.setMonth(date.getMonth() + 1);
+ let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
+
+ let task = {
+ "SerialNumber": element.serialNumber,
+ "Folio": element.workflowInstanceDataFields.Subject,
+ "Senders": element.workflowInstanceDataFields.Sender,
+ "CreateDate": new Date(element.taskStartDate),
+ "DocumentURL": element.workflowInstanceDataFields.ViewerRequest,
+ "Remetente": element.workflowInstanceDataFields.Remetente,
+ "DocumentsQty": element.totalDocuments,
+ "DocId": element.workflowInstanceDataFields.DocIdDiferimento,
+ "WorkflowName": element.workflowDisplayName,
+ "activityInstanceName": element.activityInstanceName,
+ }
+
+ this.despachoList.push(task);
+ console.log(this.despachoList);
+ });
+ this.listToPresent = this.despachoList
+
+ }, (error) => {
+ this.getFromDB()
+ })
}
getFromDB() {
- if (synchro.connected === true) {
- const location = window.location
- const pathname = location.pathname + location.search
- this.LoadList()
+ this.sqliteservice.getAllProcess().then((all) => {
+ console.log('DESPACHO PR ALL', all)
+ })
+ this.sqliteservice.getprocessByworkflow('Despacho do Presidente da República').then(async (process: any[]) => {
+ console.log('DESPACHO PR', process)
- 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.doRefresh()
- } else {
- this.LoadList()
- }
+ let despachosPr;
+ switch (this.loggeduser.Profile) {
+ case 'MDGPR':
+ despachosPr = await process.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho");
+ break;
+ case 'PR':
+ console.log(process);
+
+ despachosPr = await process.reverse().filter(data => data.activityInstanceName == "Concluir Despacho");
+ break;
+ }
+
+ despachosPr = despachosPr.filter(data => JSON.parse(data.workflowInstanceDataFields).Status == "Active");
+ despachosPr.forEach((element, index) => {
+
+ let date = new Date(element.taskStartDate);
+ date.setMonth(date.getMonth() + 1);
+ let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
+
+ let task = {
+ "SerialNumber": element.serialNumber,
+ "Folio": JSON.parse(element.workflowInstanceDataFields).Subject,
+ "Senders": JSON.parse(element.workflowInstanceDataFields).Sender,
+ "CreateDate": new Date(element.taskStartDate),
+ "DocumentURL": JSON.parse(element.workflowInstanceDataFields).ViewerRequest,
+ "Remetente": JSON.parse(element.workflowInstanceDataFields).Remetente,
+ "DocumentsQty": element.totalDocuments,
+ "DocId": JSON.parse(element.workflowInstanceDataFields).DocIdDiferimento,
+ "WorkflowName": element.workflowDisplayName,
+ "activityInstanceName": element.activityInstanceName,
}
+
+ this.despachoList.push(task);
+ console.log(this.despachoList);
});
- } else {
- this.sqliteservice.getAllProcess().then((all) => {
- console.log('DESPACHO PR ALL', all)
- })
- this.sqliteservice.getprocessByworkflow('Despacho do Presidente da República').then(async (process: any[]) => {
- console.log('DESPACHO PR', process)
+ this.listToPresent = this.despachoList;
- let despachosPr;
- switch (this.loggeduser.Profile) {
- case 'MDGPR':
- despachosPr = await process.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho");
- break;
- case 'PR':
- console.log(process);
-
- despachosPr = await process.reverse().filter(data => data.activityInstanceName == "Concluir Despacho");
- break;
- }
-
- despachosPr = despachosPr.filter(data => JSON.parse(data.workflowInstanceDataFields).Status == "Active");
- despachosPr.forEach((element, index) => {
-
- let date = new Date(element.taskStartDate);
- date.setMonth(date.getMonth() + 1);
- let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
-
- let task = {
- "SerialNumber": element.serialNumber,
- "Folio": JSON.parse(element.workflowInstanceDataFields).Subject,
- "Senders": JSON.parse(element.workflowInstanceDataFields).Sender,
- "CreateDate": taskDate,
- "DocumentURL": JSON.parse(element.workflowInstanceDataFields).ViewerRequest,
- "Remetente": JSON.parse(element.workflowInstanceDataFields).Remetente,
- "DocumentsQty": element.totalDocuments,
- "DocId": JSON.parse(element.workflowInstanceDataFields).DocIdDiferimento,
- "WorkflowName": element.workflowDisplayName,
- "activityInstanceName": element.activityInstanceName,
- }
-
- this.despachoList.push(task);
- console.log(this.despachoList);
- });
- this.listToPresent = this.despachoList;
-
- })
- }
+ })
}
doRefresh() {
diff --git a/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts b/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts
index c43a12e9d..fe7b6f9f5 100644
--- a/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts
+++ b/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts
@@ -19,9 +19,9 @@ import { AttachmentList } from 'src/app/models/Excludetask';
import { PermissionService } from 'src/app/services/worker/permission.service';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
-import { synchro } from 'src/app/services/socket/synchro.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { Platform } from '@ionic/angular';
+import { BackgroundService } from 'src/app/services/background.service';
@Component({
selector: 'app-despacho',
@@ -46,8 +46,6 @@ export class DespachoPage implements OnInit {
intervenientes: any;
cc: any = [];
- synch = synchro;
-
constructor(private activateRoute: ActivatedRoute,
private processes: ProcessesService,
private iab: InAppBrowser,
@@ -60,7 +58,8 @@ export class DespachoPage implements OnInit {
private location: Location,
public p: PermissionService,
private sqliteservice: SqliteService,
- private platform: Platform
+ private platform: Platform,
+ private backgroundservice: BackgroundService
) {
@@ -81,7 +80,10 @@ export class DespachoPage implements OnInit {
return;
}
});
- this.getFromDb()
+ this.LoadTaskDetail(this.serialnumber)
+ this.backgroundservice.registerBackService('Online', () => {
+ this.LoadTaskDetail(this.serialnumber)
+ });
}
@@ -162,95 +164,89 @@ export class DespachoPage implements OnInit {
});
});
}, (error) => {
- try {
- this.goBack()
- } catch (e) {
- this.location.back();
- } finally {
- if (error.status == 0) {
- this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
- } else {
- this.toastService.badRequest('Processo não encontrado')
+ if (error.status == 0) {
+ this.getFromDb();
+ } else {
+ try {
+ this.goBack()
+ } catch (e) {
+ this.location.back();
}
+ this.toastService.badRequest('Processo não encontrado')
}
});
}
getFromDb() {
- if (synchro.connected === true) {
- this.LoadTaskDetail(this.serialnumber)
- }
- if (synchro.connected === false) {
- this.platform.ready().then(() => {
- this.sqliteservice.getProcessById(this.serialnumber).then((process) => {
+ this.platform.ready().then(() => {
+ this.sqliteservice.getProcessById(this.serialnumber).then((process) => {
- var workflow = JSON.parse(process[0].workflowInstanceDataFields);
- var intervine = JSON.parse(process[0].interveners)
- var origina
- if (process[0].originator === "undefined") {
- origina = ""
- } else {
- origina = JSON.parse(process[0].originator)
- }
+ var workflow = JSON.parse(process[0].workflowInstanceDataFields);
+ var intervine = JSON.parse(process[0].interveners)
+ var origina
+ if (process[0].originator === "undefined") {
+ origina = ""
+ } else {
+ origina = JSON.parse(process[0].originator)
+ }
- console.log('sqlite', process)
+ console.log('sqlite', process)
- this.task = {
- "SerialNumber": process[0].serialNumber,
- "Folio": workflow.Subject,
- "Senders": origina.email || process[0].originator,
- "CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
- "DocumentURL": workflow.ViewerRequest,
- "Remetente": workflow.Sender,
- "Note": workflow.TaskMessage || workflow.Note,
- "FolderId": workflow.FolderID,
- "FsId": workflow.FsId,
- "DocId": workflow.DocID,
- "DocumentsQty": process[0].DocumentsQty,
- "WorkflowName": process[0].workflowDisplayName,
- "DeadlineType": workflow.DeadlineType,
- "activityInstanceName": process[0].activityInstanceName,
- "Status": workflow.Status,
- }
+ this.task = {
+ "SerialNumber": process[0].serialNumber,
+ "Folio": workflow.Subject,
+ "Senders": origina.email || process[0].originator,
+ "CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
+ "DocumentURL": workflow.ViewerRequest,
+ "Remetente": workflow.Sender,
+ "Note": workflow.TaskMessage || workflow.Note,
+ "FolderId": workflow.FolderID,
+ "FsId": workflow.FsId,
+ "DocId": workflow.DocID,
+ "DocumentsQty": process[0].DocumentsQty,
+ "WorkflowName": process[0].workflowDisplayName,
+ "DeadlineType": workflow.DeadlineType,
+ "activityInstanceName": process[0].activityInstanceName,
+ "Status": workflow.Status,
+ }
- let thedate = new Date(this.task.CreateDate);
- this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
+ let thedate = new Date(this.task.CreateDate);
+ this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
- let fulltak = {
- Documents: JSON.parse(process[0].Documents),
- actions: JSON.parse(process[0].actions),
- activityInstanceName: process[0].activityInstanceName,
- formURL: process[0].formURL,
- originator: JSON.parse(process[0].originator),
- serialNumber: process[0].serialNumber,
- taskStartDate: process[0].taskStartDate,
- totalDocuments: process[0].totalDocuments,
- workflowDisplayName: process[0].workflowDisplayName,
- workflowID: process[0].workflowID,
- workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
- workflowInstanceFolio: process[0].workflowInstanceFolio,
- workflowInstanceID: process[0].workflowInstanceID,
- workflowName: process[0].workflowName
- }
- this.fulltask = fulltak;
+ let fulltak = {
+ Documents: JSON.parse(process[0].Documents),
+ actions: JSON.parse(process[0].actions),
+ activityInstanceName: process[0].activityInstanceName,
+ formURL: process[0].formURL,
+ originator: JSON.parse(process[0].originator),
+ serialNumber: process[0].serialNumber,
+ taskStartDate: process[0].taskStartDate,
+ totalDocuments: process[0].totalDocuments,
+ workflowDisplayName: process[0].workflowDisplayName,
+ workflowID: process[0].workflowID,
+ workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
+ workflowInstanceFolio: process[0].workflowInstanceFolio,
+ workflowInstanceID: process[0].workflowInstanceID,
+ workflowName: process[0].workflowName
+ }
+ this.fulltask = fulltak;
- console.log('interveniers offline', intervine)
- this.intervenientes = intervine.filter(user => {
- console.log('interveniers offline 2', user)
- return user.Type == 'I';
- });
- this.cc = intervine.filter(user => {
- console.log('interveniers offline 3', user)
- return user.Type == 'CC';
- });
+ console.log('interveniers offline', intervine)
+ this.intervenientes = intervine.filter(user => {
+ console.log('interveniers offline 2', user)
+ return user.Type == 'I';
+ });
+ this.cc = intervine.filter(user => {
+ console.log('interveniers offline 3', user)
+ return user.Type == 'CC';
+ });
- })
})
- }
+ })
}
- async viewDocument(docId:string, Document) {
+ async viewDocument(docId: string, Document) {
console.log(this.fulltask)
diff --git a/src/app/pages/gabinete-digital/despachos/despachos.page.ts b/src/app/pages/gabinete-digital/despachos/despachos.page.ts
index f8e1e4b60..cf1beeaa0 100644
--- a/src/app/pages/gabinete-digital/despachos/despachos.page.ts
+++ b/src/app/pages/gabinete-digital/despachos/despachos.page.ts
@@ -4,9 +4,9 @@ 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 { synchro } from 'src/app/services/socket/synchro.service';
import { Platform } from '@ionic/angular';
import { isThisHour } from 'date-fns';
+import { BackgroundService } from 'src/app/services/background.service';
@Component({
selector: 'app-despachos',
@@ -17,21 +17,39 @@ import { isThisHour } from 'date-fns';
export class DespachosPage implements OnInit {
despachoStore = DespachoStore;
- synch = synchro;
listToPresent = [];
constructor(
private router: Router,
private despachoRule: DespachoService,
private sqliteservice: SqliteService,
- private platform: Platform
+ private platform: Platform,
+ private backgroundservice: BackgroundService
) {
}
ngOnInit() {
- this.getFromDb()
+ 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() {
@@ -49,57 +67,42 @@ export class DespachosPage implements OnInit {
await this.despachoRule.getList({ updateStore: true }).then((pre) => {
this.listToPresent = pre;
console.log('despachooo', pre)
+ }).catch(() => {
+ this.getFromDb()
})
}
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 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.platform.ready().then(() => {
+ this.sqliteservice.getprocessByworkflow('Despacho').then((process: any[]) => {
+ var listtopresent = [];
+ process.forEach(element => {
+ var workflow = JSON.parse(element.workflowInstanceDataFields);
+ let task = {
+ "CreateDate": element.taskStartDate,
+ "DocId": workflow.DispatchDocID,
+ "DocumentURL": undefined,
+ "DocumentsQty": element.totalDocuments,
+ "FolderID": workflow.FolderID,
+ "Folio": workflow.Subject,
+ "Remetente": undefined,
+ "Senders": workflow.Sender,
+ "SerialNumber": element.serialNumber,
+ "Status": workflow.Status,
+ "WorkflowName": element.workflowDisplayName
}
- }
- });
- }
- if (synchro.connected === false) {
- this.platform.ready().then(() => {
- this.sqliteservice.getDespachosProcess('Tarefa de Despacho').then((process: any[]) => {
- var listtopresent = [];
- process.forEach(element => {
- var workflow = JSON.parse(element.workflowInstanceDataFields);
- let task = {
- "CreateDate": element.taskStartDate,
- "DocId": workflow.DispatchDocID,
- "DocumentURL": undefined,
- "DocumentsQty": element.totalDocuments,
- "FolderID": workflow.FolderID,
- "Folio": workflow.Subject,
- "Remetente": undefined,
- "Senders": workflow.Sender,
- "SerialNumber": element.serialNumber,
- "Status": workflow.Status,
- "WorkflowName": element.workflowDisplayName
- }
+ listtopresent.push(task);
- listtopresent.push(task);
+ });
- });
+ this.listToPresent = listtopresent;
+ console.log('Tarefas de despach', this.listToPresent)
- this.listToPresent = listtopresent;
-
- })
})
- }
+ })
}
get skeletonLoader(): boolean {
diff --git a/src/app/pages/gabinete-digital/diplomas-assinar/diplomas-assinar.page.ts b/src/app/pages/gabinete-digital/diplomas-assinar/diplomas-assinar.page.ts
index af0a19575..690222b2a 100644
--- a/src/app/pages/gabinete-digital/diplomas-assinar/diplomas-assinar.page.ts
+++ b/src/app/pages/gabinete-digital/diplomas-assinar/diplomas-assinar.page.ts
@@ -80,7 +80,7 @@ export class DiplomasAssinarPage implements OnInit {
this.diplomasList = [];
let diplomasAssinar = diplomas.reverse().filter(data => data.activityInstanceName == "Assinar Diploma");
- diplomasAssinar = this.sortService.sortArrayByDate(diplomasAssinar);
+ diplomasAssinar = this.sortService.sortArrayISODate(diplomasAssinar);
diplomasAssinar.forEach(element => {
let task: customTask = this.customTaskPipe.transform(element)
this.diplomasList.push(task);
diff --git a/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts b/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts
index cc62c2de5..ae310da3d 100644
--- a/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts
+++ b/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts
@@ -3,7 +3,7 @@ import { AnimationController, ModalController, PopoverController } from '@ionic/
import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
import { ProcessesService } from 'src/app/services/processes.service';
import { OptsExpedientePage } from 'src/app/shared/popover/opts-expediente/opts-expediente.page';
-import { momentG } from 'src/plugin/momentG';
+import { momentG } from 'src/plugin/momentG';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
@@ -14,7 +14,7 @@ import { Location } from '@angular/common';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { SqliteService } from 'src/app/services/sqlite.service';
-import { synchro } from 'src/app/services/socket/synchro.service';
+import { BackgroundService } from 'src/app/services/background.service';
@Component({
selector: 'app-diploma',
@@ -27,13 +27,13 @@ export class DiplomaPage implements OnInit {
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
serialNumber: string;
- caller:string;
+ caller: string;
profile: string;
task: any
fulltask: any
intervenientes: any;
cc: any = [];
- attachments:any;
+ attachments: any;
customDate: any
constructor(
@@ -46,15 +46,16 @@ export class DiplomaPage implements OnInit {
private animationController: AnimationController,
private toastService: ToastService,
private location: Location,
- private sqliteservice: SqliteService
+ private sqliteservice: SqliteService,
+ private backgroundservice: BackgroundService
) {
this.activatedRoute.paramMap.subscribe(params => {
// console.log(params["params"]);
- if(params["params"].SerialNumber) {
+ if (params["params"].SerialNumber) {
this.serialNumber = params["params"].SerialNumber;
}
- if(params["params"].caller) {
+ if (params["params"].caller) {
this.caller = params["params"].caller;
}
@@ -64,7 +65,10 @@ export class DiplomaPage implements OnInit {
ngOnInit() {
this.profile = "mdgpr";
- this.getFromDb();
+ this.LoadTaskDetail(this.serialNumber);
+ this.backgroundservice.registerBackService('Online', () => {
+ this.LoadTaskDetail(this.serialNumber);
+ });
}
goBack() {
@@ -104,7 +108,7 @@ export class DiplomaPage implements OnInit {
serialNumber: this.serialNumber,
task: this.task,
fulltask: this.fulltask,
- taskAction:taskAction,
+ taskAction: taskAction,
showEnviarPendentes: false
},
translucent: true
@@ -118,7 +122,7 @@ export class DiplomaPage implements OnInit {
"SerialNumber": res.serialNumber,
"Folio": res.workflowInstanceDataFields.Subject,
"Senders": res.originator.email,
- "CreateDate": momentG(new Date(res.taskStartDate),'yyyy-MM-dd HH:mm:ss'),
+ "CreateDate": momentG(new Date(res.taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": res.workflowInstanceDataFields.ViewerRequest,
"Remetente": res.workflowInstanceDataFields.Sender,
"Note": res.workflowInstanceDataFields.TaskMessage || res.workflowInstanceDataFields.Note,
@@ -133,94 +137,90 @@ export class DiplomaPage implements OnInit {
this.sqliteservice.updateProcess(res)
let thedate = new Date(this.task.CreateDate);
- this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]);
+ this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
- this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users=>{
+ this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users => {
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialNumber), JSON.stringify(users)).then(() => {
console.log('internen diploma ')
})
- this.intervenientes = users.filter(user=>{
+ this.intervenientes = users.filter(user => {
return user.Type == 'I';
});
- this.cc = users.filter(user=>{
+ this.cc = users.filter(user => {
return user.Type == 'CC';
});
});
this.getDocumentDetails(this.task.FolderId, '361');
- }, (error)=>{
- try {
- this.goBack()
- } catch (e) {
- window.history.back();
- } finally {
- if(error.status == 0) {
- this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
- } else {
- this.toastService.badRequest('Processo não encontrado')
+ }, (error) => {
+ if (error.status == 0) {
+ this.getFromDb();
+ } else {
+ try {
+ this.goBack()
+ } catch (e) {
+ window.history.back();
}
+ this.toastService.badRequest('Processo não encontrado')
}
});
}
getFromDb() {
- if(synchro.connected === true) {
- this.LoadTaskDetail(this.serialNumber);
- } else {
- this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
- this.task = {
- "SerialNumber": process[0].serialNumber,
- "Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
- "Senders": JSON.parse(process[0].originator).email,
- "CreateDate": momentG(new Date(process[0].taskStartDate),'yyyy-MM-dd HH:mm:ss'),
- "DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
- "Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
- "Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage || JSON.parse(process[0].workflowInstanceDataFields).Note,
- "FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
- "FsId": '361',
- "DocId": JSON.parse(process[0].workflowInstanceDataFields).DispatchDocId,
- "WorkflowName": process[0].workflowDisplayName,
- "DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
- "activityInstanceName": process[0].activityInstanceName,
- }
+ this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
- let fulltak = {
- Documents: JSON.parse(process[0].Documents),
- actions: JSON.parse(process[0].actions),
- activityInstanceName: process[0].activityInstanceName,
- formURL: process[0].formURL,
- originator: JSON.parse(process[0].originator),
- serialNumber: process[0].serialNumber,
- taskStartDate: process[0].taskStartDate,
- totalDocuments: process[0].totalDocuments,
- workflowDisplayName: process[0].workflowDisplayName,
- workflowID: process[0].workflowID,
- workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
- workflowInstanceFolio: process[0].workflowInstanceFolio,
- workflowInstanceID: process[0].workflowInstanceID,
- workflowName: process[0].workflowName
- }
- this.fulltask = fulltak
+ this.task = {
+ "SerialNumber": process[0].serialNumber,
+ "Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
+ "Senders": JSON.parse(process[0].originator).email,
+ "CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
+ "DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
+ "Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
+ "Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage || JSON.parse(process[0].workflowInstanceDataFields).Note,
+ "FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
+ "FsId": '361',
+ "DocId": JSON.parse(process[0].workflowInstanceDataFields).DispatchDocId,
+ "WorkflowName": process[0].workflowDisplayName,
+ "DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
+ "activityInstanceName": process[0].activityInstanceName,
+ }
- let thedate = new Date(this.task.CreateDate);
- this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]);
+ let fulltak = {
+ Documents: JSON.parse(process[0].Documents),
+ actions: JSON.parse(process[0].actions),
+ activityInstanceName: process[0].activityInstanceName,
+ formURL: process[0].formURL,
+ originator: JSON.parse(process[0].originator),
+ serialNumber: process[0].serialNumber,
+ taskStartDate: process[0].taskStartDate,
+ totalDocuments: process[0].totalDocuments,
+ workflowDisplayName: process[0].workflowDisplayName,
+ workflowID: process[0].workflowID,
+ workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
+ workflowInstanceFolio: process[0].workflowInstanceFolio,
+ workflowInstanceID: process[0].workflowInstanceID,
+ workflowName: process[0].workflowName
+ }
+ this.fulltask = fulltak
- this.intervenientes = JSON.parse(process[0].interveners).filter(user=>{
+ let thedate = new Date(this.task.CreateDate);
+ this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
+
+ this.intervenientes = JSON.parse(process[0].interveners).filter(user => {
return user.Type == 'I';
});
- this.cc = JSON.parse(process[0].interveners).filter(user=>{
+ this.cc = JSON.parse(process[0].interveners).filter(user => {
return user.Type == 'CC';
});
this.attachments = JSON.parse(process[0].Documents)
- })
- }
+ })
}
- async viewDocument(DocId:string, Document) {
+ async viewDocument(DocId: string, Document) {
const modal = await this.modalController.create({
component: ViewDocumentPage,
@@ -243,15 +243,15 @@ export class DiplomaPage implements OnInit {
}
- getDocumentDetails(forlderId:string, applicationId:string) {
- this.processes.GetDocumentDetails(forlderId,applicationId).subscribe(res=>{
+ getDocumentDetails(forlderId: string, applicationId: string) {
+ this.processes.GetDocumentDetails(forlderId, applicationId).subscribe(res => {
this.attachments = res.Documents;
console.log(res['Documents']);
console.log(this.attachments);
})
}
- async askSignature(note:string, documents:any){
+ async askSignature(note: string, documents: any) {
let body = {
"serialNumber": this.serialNumber,
"action": "Aprovar",
@@ -259,7 +259,7 @@ export class DiplomaPage implements OnInit {
"dataFields": {
"ReviewUserComment": note,
},
- "AttachmentList" :documents,
+ "AttachmentList": documents,
}
const loader = this.toastService.loading()
@@ -267,7 +267,7 @@ export class DiplomaPage implements OnInit {
try {
await this.processes.CompleteTask(body).toPromise()
- this.toastService.successMessage(false, ()=>{
+ this.toastService.successMessage(false, () => {
this.close();
})
@@ -279,7 +279,7 @@ export class DiplomaPage implements OnInit {
}
}
- async askToChange(note:string, documents:any){
+ async askToChange(note: string, documents: any) {
let body = {
"serialNumber": this.serialNumber,
"action": "Retificar",
@@ -287,7 +287,7 @@ export class DiplomaPage implements OnInit {
"dataFields": {
"ReviewUserComment": note,
},
- "AttachmentList" :documents,
+ "AttachmentList": documents,
}
const loader = this.toastService.loading()
@@ -303,7 +303,7 @@ export class DiplomaPage implements OnInit {
}
- async finish(note:string, documents:any){
+ async finish(note: string, documents: any) {
let body = {
"serialNumber": this.serialNumber,
@@ -312,7 +312,7 @@ export class DiplomaPage implements OnInit {
"dataFields": {
"ReviewUserComment": note,
},
- "AttachmentList" :documents,
+ "AttachmentList": documents,
}
const loader = this.toastService.loading()
@@ -333,16 +333,16 @@ export class DiplomaPage implements OnInit {
return new Date(e).toDateString()
}
- async openAddNoteModal(actionName:string) {
+ async openAddNoteModal(actionName: string) {
let classs;
- if( window.innerWidth <= 800){
+ if (window.innerWidth <= 800) {
classs = 'modal modal-desktop'
- } else {
+ } else {
classs = 'add-note-modal'
}
const modal = await this.modalController.create({
component: AddNotePage,
- componentProps:{
+ componentProps: {
},
cssClass: classs,
backdropDismiss: true
@@ -351,7 +351,7 @@ export class DiplomaPage implements OnInit {
await modal.present();
modal.onDidDismiss().then(async (res) => {
- if(res.data){
+ if (res.data) {
const DocumentToSave = res.data.documents.map((e) => {
@@ -367,15 +367,15 @@ export class DiplomaPage implements OnInit {
}
- if(actionName == 'Solicitar assinatura'){
+ if (actionName == 'Solicitar assinatura') {
await this.askSignature(res.data.note, docs);
this.goBack();
}
- else if(actionName == 'Solicitar alteração'){
+ else if (actionName == 'Solicitar alteração') {
await this.askToChange(res.data.note, docs);
this.goBack();
}
- else if(actionName == 'Concluir diploma'){
+ else if (actionName == 'Concluir diploma') {
await this.finish(res.data.note, docs);
this.goBack();
}
@@ -385,9 +385,9 @@ export class DiplomaPage implements OnInit {
async openBookMeetingModal(task: any) {
let classs;
- if( window.innerWidth <= 800){
+ if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop'
- } else {
+ } else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
@@ -402,7 +402,7 @@ export class DiplomaPage implements OnInit {
modal.onDidDismiss();
}
- close(){
+ close() {
this.modalController.dismiss();
}
diff --git a/src/app/pages/gabinete-digital/diplomas/diplomas.page.ts b/src/app/pages/gabinete-digital/diplomas/diplomas.page.ts
index ff6849091..804d5554c 100644
--- a/src/app/pages/gabinete-digital/diplomas/diplomas.page.ts
+++ b/src/app/pages/gabinete-digital/diplomas/diplomas.page.ts
@@ -4,7 +4,7 @@ import { DailyWorkTask } from '../../../models/dailyworktask.model';
import { ProcessesService } from 'src/app/services/processes.service';
import { SqliteService } from 'src/app/services/sqlite.service';
-import { synchro } from 'src/app/services/socket/synchro.service';
+import { BackgroundService } from 'src/app/services/background.service';
import { SortService } from 'src/app/services/functions/sort.service';
@Component({
@@ -29,11 +29,10 @@ export class DiplomasPage implements OnInit, OnDestroy {
private router: Router,
private activatedRoute: ActivatedRoute,
private sqliteservice: SqliteService,
+ private backgroundservice: BackgroundService,
private sortService: SortService,
) {
- this.diplomasList = [];
//Inicializar segment
- this.segment = 'validar';
this.activatedRoute.queryParams.subscribe(params => {
if (params['validar'] == 'true') {
@@ -56,7 +55,24 @@ export class DiplomasPage implements OnInit, OnDestroy {
}
});
- this.getFromDb()
+ 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();
+ });
}
@@ -154,78 +170,68 @@ export class DiplomasPage implements OnInit, OnDestroy {
async LoadList() {
- this.skeletonLoader = true
+ this.processes.GetTasksList("Despacho do Presidente da República", false).subscribe(async res => {
- let diplomas = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
+ this.skeletonLoader = true
- this.skeletonLoader = false
- this.showLoader = false;
+ let diplomas = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
+
+ this.skeletonLoader = false
+ this.showLoader = false;
- let diplomasValidar = diplomas.filter(data => data.activityInstanceName == "Revisar Diploma");
- let diplomasList = [];
- diplomasValidar.forEach(async element => {
+ let diplomasValidar = diplomas.filter(data => data.activityInstanceName == "Revisar Diploma");
+ let diplomasList = [];
+ diplomasValidar.forEach(async element => {
- let task = this.pipeTask(element)
- diplomasList.push(task);
+ let task = this.pipeTask(element)
+ diplomasList.push(task);
- });
- this.diplomasList = this.sortService.sortArrayByDate(diplomasList).reverse();
+ });
+ this.diplomasList = this.sortService.sortArrayByDate(diplomasList.reverse());
- let diplomasAssinados = diplomas.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
- let diplomasAssinadoList = []
- diplomasAssinados.forEach(async element => {
+ let diplomasAssinados = diplomas.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
+ let diplomasAssinadoList = []
+ diplomasAssinados.forEach(async element => {
- let task = this.pipeTask(element)
- diplomasAssinadoList.push(task);
- });
- console.log('diplomasAssinados', diplomasAssinados)
- this.diplomasAssinadoList = this.sortService.sortArrayByDate(diplomasAssinadoList).reverse();
+ let task = this.pipeTask(element)
+ diplomasAssinadoList.push(task);
+ });
+ console.log('diplomasAssinados', diplomasAssinados)
+ this.diplomasAssinadoList = this.sortService.sortArrayByDate(diplomasAssinadoList).reverse();
+
+ }, (error) => {
+ this.getFromDb()
+ })
}
getFromDb() {
- if (synchro.connected === true) {
- const location = window.location
- const pathname = location.pathname + location.search
- this.LoadList()
+ this.sqliteservice.getprocessByworkflow("Despacho do Presidente da República").then((process: any[]) => {
- 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()
- }
- }
- });
- } else {
- this.sqliteservice.getprocessByworkflow("Despacho do Presidente da República").then((process: any[]) => {
+ let diplomasValidar = process.filter(data => data.activityInstanceName == "Revisar Diploma");
+ let diplomasList = [];
+ diplomasValidar.forEach(async element => {
- let diplomasValidar = process.filter(data => data.activityInstanceName == "Revisar Diploma");
- let diplomasList = [];
- diplomasValidar.forEach(async element => {
-
- let task = this.pipeTaskOffline(element)
- diplomasList.push(task);
+ let task = this.pipeTaskOffline(element)
+ diplomasList.push(task);
});
- this.diplomasList = this.sortService.sortArrayByDate(diplomasList).reverse();
+ this.diplomasList = this.sortService.sortArrayISODate(diplomasList).reverse();
- let diplomasAssinados = process.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
- let diplomasAssinadoList = []
- diplomasAssinados.forEach(async element => {
+ let diplomasAssinados = process.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
+ let diplomasAssinadoList = []
+ diplomasAssinados.forEach(async element => {
let task = this.pipeTaskOffline(element)
diplomasAssinadoList.push(task);
});
console.log('diplomasAssinados', diplomasAssinados)
- this.diplomasAssinadoList = this.sortService.sortArrayByDate(diplomasAssinadoList).reverse();
+ this.diplomasAssinadoList = this.sortService.sortArrayISODate(diplomasAssinadoList).reverse();
- })
- }
+ })
}
pipeTask(element) {
diff --git a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts
index a5a0ae399..3d0f93cf1 100644
--- a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts
+++ b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts
@@ -14,7 +14,7 @@ import { Location } from '@angular/common';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { SqliteService } from '../../../../services/sqlite.service';
-import { synchro } from '../../../../services/socket/synchro.service';
+import { BackgroundService } from '../../../../services/background.service';
import { Platform } from '@ionic/angular';
@Component({
@@ -33,18 +33,16 @@ export class ApproveEventPage implements OnInit {
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
- serialNumber:string;
- caller:string;
- attachments:any;
+ serialNumber: string;
+ caller: string;
+ attachments: any;
- @Input() InstanceId:string;
+ @Input() InstanceId: string;
@Output() approveEventDismiss = new EventEmitter();
@Output() closeEventToApprove = new EventEmitter();
@Output() AproveEventEditEvent = new EventEmitter();
- synch = synchro;
-
constructor(
private router: Router,
private activatedRoute: ActivatedRoute,
@@ -59,7 +57,8 @@ export class ApproveEventPage implements OnInit {
private toastService: ToastService,
private location: Location,
private sqliteservice: SqliteService,
- private platform: Platform
+ private platform: Platform,
+ private backgroundservice: BackgroundService
) {
this.activatedRoute.paramMap.subscribe(params => {
// console.log(params["params"]);
@@ -81,7 +80,11 @@ export class ApproveEventPage implements OnInit {
ngOnInit() {
console.log(this.serialNumber);
console.log(this.caller);
- this.getProcessFromDB();
+
+ this.getTask();
+ this.backgroundservice.registerBackService('Online', () => {
+ this.getTask();
+ });
}
@@ -102,91 +105,91 @@ export class ApproveEventPage implements OnInit {
addProcessToDB(data) {
this.platform.ready().then(() => {
- this.sqliteservice.updateProcess(data);
+ this.sqliteservice.updateProcess(data);
});
}
getProcessFromDB() {
- if (synchro.connected === true) {
- this.getTask();
- }
+ this.platform.ready().then(() => {
- synchro.registerCallback('Offline', () => {
- this.platform.ready().then(() => {
+ this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
+ console.log('event aprove serial', process)
- this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
- console.log('event aprove serial', process)
+ var doc;
+ var action = [];
+ var origi = [];
+ var wordafi = {};
+ if (process[0].Documents === "null" || process[0].Documents === "undefined") {
+ doc = []
+ } else {
+ doc = JSON.parse(process[0].Documents)
+ }
- var doc;
- var action = [];
- var origi = [];
- var wordafi = {};
- if (process[0].Documents === "null" || process[0].Documents === "undefined") {
- doc = []
- } else {
- doc = JSON.parse(process[0].Documents)
- }
+ if (process[0].actions === "null" || process[0].actions === "undefined") {
+ action = []
+ } else {
+ action = JSON.parse(process[0].Documents)
+ }
- if (process[0].actions === "null" || process[0].actions === "undefined") {
- action = []
- } else {
- action = JSON.parse(process[0].Documents)
- }
+ if (process[0].originator === "null" || process[0].originator === "undefined") {
+ origi = []
+ } else {
+ origi = JSON.parse(process[0].Documents)
+ }
+ if (process[0].workflowInstanceDataFields === "null" || process[0].workflowInstanceDataFields === "undefined") {
+ wordafi = []
+ } else {
+ wordafi = JSON.parse(process[0].workflowInstanceDataFields)
+ }
- if (process[0].originator === "null" || process[0].originator === "undefined") {
- origi = []
- } else {
- origi = JSON.parse(process[0].Documents)
- }
- if (process[0].workflowInstanceDataFields === "null" || process[0].workflowInstanceDataFields === "undefined") {
- wordafi = []
- } else {
- wordafi = JSON.parse(process[0].workflowInstanceDataFields)
- }
+ let task = {
+ "Documents": doc,
+ "actions": action,
+ "activityInstanceName": process[0].activityInstanceName,
+ "formURL": process[0].formURL,
+ "originator": origi,
+ "serialNumber": process[0].serialNumber,
+ "taskStartDate": process[0].taskStartDate,
+ "totalDocuments": process[0].totalDocuments,
+ "workflowDisplayName": process[0].workflowDisplayName,
+ "workflowID": process[0].workflowID,
+ "workflowInstanceDataFields": wordafi,
+ "workflowInstanceFolio": process[0].workflowInstanceFolio,
+ "workflowInstanceID": process[0].workflowInstanceID,
+ "workflowName": process[0].workflowInstanceID
- let task = {
- "Documents": doc,
- "actions": action,
- "activityInstanceName": process[0].activityInstanceName,
- "formURL": process[0].formURL,
- "originator": origi,
- "serialNumber": process[0].serialNumber,
- "taskStartDate": process[0].taskStartDate,
- "totalDocuments": process[0].totalDocuments,
- "workflowDisplayName": process[0].workflowDisplayName,
- "workflowID": process[0].workflowID,
- "workflowInstanceDataFields": wordafi,
- "workflowInstanceFolio": process[0].workflowInstanceFolio,
- "workflowInstanceID": process[0].workflowInstanceID,
- "workflowName": process[0].workflowInstanceID
+ }
- }
+ this.loadedEvent = task
+ console.log('offline event', this.loadedEvent);
- this.loadedEvent = task
- console.log('offline event',this.loadedEvent);
+ this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
- this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
+ this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
- this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
+ let instanceId = this.loadedEvent.workflowInstanceDataFields.InstanceId;
+ this.loadedAttachments = this.loadedEvent.Documents;
+ console.log('Attatara', this.loadedAttachments)
- let instanceId = this.loadedEvent.workflowInstanceDataFields.InstanceId;
- this.loadedAttachments = this.loadedEvent.Documents;
- console.log('Attatara', this.loadedAttachments)
-
- })
})
- console.log('Offlineee')
})
+ console.log('Offlineee')
}
async getTask() {
- this.loadedEvent = await this.processes.GetTask(this.serialNumber).toPromise();
- console.log(this.loadedEvent);
+ this.processes.GetTask(this.serialNumber).subscribe(async res => {
- this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
+ this.loadedEvent = await this.processes.GetTask(this.serialNumber).toPromise();
+ console.log(this.loadedEvent);
- this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
+ this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
+
+ this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
+
+ }, (error) => {
+ this.getProcessFromDB();
+ })
}
async approveTask(serialNumber: string) {
@@ -284,7 +287,7 @@ export class ApproveEventPage implements OnInit {
}
}
- async viewDocument(DocId:string, Document) {
+ async viewDocument(DocId: string, Document) {
const modal = await this.modalController.create({
component: ViewDocumentPage,
diff --git a/src/app/pages/gabinete-digital/event-list/event-list.page.ts b/src/app/pages/gabinete-digital/event-list/event-list.page.ts
index 884933d8e..765450313 100644
--- a/src/app/pages/gabinete-digital/event-list/event-list.page.ts
+++ b/src/app/pages/gabinete-digital/event-list/event-list.page.ts
@@ -9,7 +9,7 @@ import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.servic
import { Location } from '@angular/common';
import { SqliteService } from '../../../services/sqlite.service';
-import { synchro } from '../../../services/socket/synchro.service';
+import { BackgroundService } from '../../../services/background.service';
import { Platform } from '@ionic/angular';
import { SortService } from 'src/app/services/functions/sort.service';
@@ -21,40 +21,56 @@ import { SortService } from 'src/app/services/functions/sort.service';
export class EventListPage implements OnInit {
// [desktop] event list to approve
- profile:string;
- segment:string;
+ profile: string;
+ segment: string;
showLoader: boolean;
eventsPRList: any = []
eventsMDGPRList: any = []
eventPerson: EventPerson;
eventBody: EventBody;
categories: string[];
- serialnumber:string;
+ serialnumber: string;
skeletonLoader = true
eventaprovacaostore = EventoAprovacaoStore;
- synch = synchro;
-
-
constructor(
- private processes:ProcessesService,
+ private processes: ProcessesService,
private modalController: ModalController,
private router: Router,
private location: Location,
private sqliteservice: SqliteService,
private platform: Platform,
private sortService: SortService,
+ private backgroundservice: BackgroundService
) { }
ngOnInit() {
- this.segment = 'MDGPR';
- this.getEventToAproveFromDB();
+ this.segment = 'MDGPR';
+
+ const location = window.location
+ const pathname = location.pathname + location.search
+
+ this.LoadToApproveEvents()
+
+ 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.LoadToApproveEvents()
+ }
+ }
+ });
+
+ this.backgroundservice.registerBackService('Online', () => {
+ this.LoadToApproveEvents();
+ });
window.onresize = (event) => {
// if not mobile remove all component
- if( window.innerWidth <= 800){
+ if (window.innerWidth <= 800) {
this.modalController.dismiss();
}
};
@@ -63,73 +79,58 @@ export class EventListPage implements OnInit {
getEventToAproveFromDB() {
- if( synchro.connected === true) {
- const location = window.location
- const pathname = location.pathname + location.search
+ this.platform.ready().then(() => {
- this.LoadToApproveEvents()
-
- 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.LoadToApproveEvents()
- }
- }
- });
- }
-
- synchro.registerCallback('Offline', () => {
- this.platform.ready().then(() => {
-
- this.sqliteservice.getListOfEventAprove('Agenda Oficial MDGPR','Agenda Pessoal MDGPR' ).then((event: any[]) => {
- this.eventsMDGPRList = event
- console.log("All evento to aprove from db ", event)
- })
-
- this.sqliteservice.getListOfEventAprove('Agenda Oficial PR','Agenda Pessoal PR' ).then((event: any[]) => {
- this.eventsPRList = event
- console.log("All evento to aprove from db ", event)
- })
+ this.sqliteservice.getListOfEventAprove('Agenda Oficial MDGPR', 'Agenda Pessoal MDGPR').then((event: any[]) => {
+ this.eventsMDGPRList = this.sortService.sortArrayByDate(event).reverse()
+
+ console.log("All evento to aprove from db ", event)
+ })
+
+ this.sqliteservice.getListOfEventAprove('Agenda Oficial PR', 'Agenda Pessoal PR').then((event: any[]) => {
+ this.eventsPRList = this.sortService.sortArrayByDate(event).reverse()
+ console.log("All evento to aprove from db ", event)
})
- console.log('Offlineee')
})
+ console.log('Offlineee')
}
segmentChanged(ev: any) {
this.LoadToApproveEvents();
}
- async LoadToApproveEvents(){
- this.showLoader = true;
- this.skeletonLoader = true
+ async LoadToApproveEvents() {
+ this.processes.GetTasksList('Agenda Oficial MDGPR', false).subscribe(async res => {
+ this.showLoader = true;
+ this.skeletonLoader = true
- console.log(this.segment);
- if(this.segment == 'MDGPR'){
- let mdEventsOficial = await this.processes.GetTasksList('Agenda Oficial MDGPR', false).toPromise();
- let mdEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal MDGPR', false).toPromise();
- this.eventsMDGPRList = mdEventsOficial.concat(mdEventsPessoal);
- this.eventaprovacaostore.resetmd(this.sortService.sortArrayByDate(this.eventsMDGPRList).reverse());
- }
- else if(this.segment == 'PR'){
- let prEventsOficial = await this.processes.GetTasksList('Agenda Oficial PR', false).toPromise();
- let prEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal PR', false).toPromise();
- this.eventsPRList = prEventsOficial.concat(prEventsPessoal);
- this.eventaprovacaostore.resetpr(this.sortService.sortArrayByDate(this.eventsPRList).reverse());
- }
- this.showLoader = false;
- this.skeletonLoader = false
+ console.log(this.segment);
+ if (this.segment == 'MDGPR') {
+ let mdEventsOficial = await this.processes.GetTasksList('Agenda Oficial MDGPR', false).toPromise();
+ let mdEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal MDGPR', false).toPromise();
+ this.eventsMDGPRList = mdEventsOficial.concat(mdEventsPessoal);
+ this.eventsMDGPRList = this.sortService.sortArrayByDate(this.eventsMDGPRList).reverse()
+ this.eventaprovacaostore.resetmd(this.sortService.sortArrayByDate(this.eventsMDGPRList).reverse());
+ }
+ else if (this.segment == 'PR') {
+ let prEventsOficial = await this.processes.GetTasksList('Agenda Oficial PR', false).toPromise();
+ let prEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal PR', false).toPromise();
+ this.eventsPRList = prEventsOficial.concat(prEventsPessoal);
+ this.eventsPRList = this.sortService.sortArrayByDate(this.eventsPRList).reverse();
+ this.eventaprovacaostore.resetpr(this.sortService.sortArrayByDate(this.eventsPRList).reverse());
+ }
+ this.showLoader = false;
+ this.skeletonLoader = false
+
+ }, (error) => {
+ this.getEventToAproveFromDB();
+ })
}
- getEventToaproveFromDB() {
-
- }
-
- async openApproveModal(eventSerialNumber, event){
+ async openApproveModal(eventSerialNumber, event) {
const modal = await this.modalController.create({
component: ApproveEventModalPage,
- componentProps:{
+ componentProps: {
serialNumber: eventSerialNumber,
},
cssClass: 'event-list cal-modal modal modal-desktop',
@@ -138,7 +139,7 @@ export class EventListPage implements OnInit {
await modal.present();
}
- goToEventToApproveDetail(serialNumber:string){
+ goToEventToApproveDetail(serialNumber: string) {
console.log(serialNumber);
/* let navigationExtras: NavigationExtras = {
@@ -147,11 +148,11 @@ export class EventListPage implements OnInit {
}
}; */
- if(this.router.url == '/home/agenda/event-list'){
- this.router.navigate(['/home/agenda/event-list/approve-event',serialNumber, 'agenda'])
+ if (this.router.url == '/home/agenda/event-list') {
+ this.router.navigate(['/home/agenda/event-list/approve-event', serialNumber, 'agenda'])
}
- else if(this.router.url == '/home/gabinete-digital/event-list'){
- this.router.navigate(['/home/gabinete-digital/event-list/approve-event',serialNumber, 'gabinete-digital'])
+ else if (this.router.url == '/home/gabinete-digital/event-list') {
+ this.router.navigate(['/home/gabinete-digital/event-list/approve-event', serialNumber, 'gabinete-digital'])
}
//this.router.navigate(['/home/gabinete-digital/event-list/approve-event'], navigationExtras)
@@ -171,7 +172,7 @@ export class EventListPage implements OnInit {
}, 1000);
}
- close(){
+ close() {
this.modalController.dismiss(null);
}
goBack() {
diff --git a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.html b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.html
index 0f833aa42..3a830460c 100644
--- a/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.html
+++ b/src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page.html
@@ -28,7 +28,7 @@
-
@@ -50,7 +50,7 @@
-
+