This commit is contained in:
tiago.kayaya
2021-10-19 14:34:51 +01:00
34 changed files with 1795 additions and 1505 deletions
+33 -43
View File
@@ -10,7 +10,6 @@ import { AlertController, Platform } from '@ionic/angular';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { ToDayEventStorage } from '../store/to-day-event-storage.service'; import { ToDayEventStorage } from '../store/to-day-event-storage.service';
import { TotalDocumentStore } from '../store/total-document.service'; import { TotalDocumentStore } from '../store/total-document.service';
import { synchro } from '../services/socket/synchro.service';
import { DespachoService } from '../Rules/despacho.service'; import { DespachoService } from '../Rules/despacho.service';
import { ExpedienteGdStore } from '../store/expedientegd-store.service'; import { ExpedienteGdStore } from '../store/expedientegd-store.service';
import { InativityService } from '../services/inativity.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 { PermissionService } from '../services/worker/permission.service';
import { Network } from '@ionic-native/network/ngx'; import { Network } from '@ionic-native/network/ngx';
import { BackgroundService } from 'src/app/services/background.service'; 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({ @Component({
@@ -63,8 +65,6 @@ export class HomePage implements OnInit {
postEvent: any; postEvent: any;
folderId: string; folderId: string;
synchro = synchro
status: string = ""; status: string = "";
audioName: string = ""; audioName: string = "";
constructor( constructor(
@@ -82,7 +82,10 @@ export class HomePage implements OnInit {
private storageService: StorageService, private storageService: StorageService,
private webNotificationPopupService: WebNotificationPopupService, private webNotificationPopupService: WebNotificationPopupService,
private network: Network, private network: Network,
private backgroundservice: BackgroundService) { private backgroundservice: BackgroundService,
private offlinemanager: OfflineManagerService,
private storage: Storage,
private eventservice: EventsService ) {
this.webNotificationPopupService.askNotificationPermission() this.webNotificationPopupService.askNotificationPermission()
@@ -112,18 +115,36 @@ export class HomePage implements OnInit {
ngOnInit() { 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')) { 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.webconnection();
this.webnotification.register(); this.webnotification.register();
} else { } 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.mobilefirstConnect();
this.notificationsService.onReceviNotification(); 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 () { document.addEventListener('pause', function () {
// console.log('App going to background'); // console.log('App going to background');
}); });
+61 -48
View File
@@ -30,7 +30,7 @@ import { ListBoxService } from 'src/app/services/agenda/list-box.service';
import { ChangeProfileService } from 'src/app/services/change-profile.service'; import { ChangeProfileService } from 'src/app/services/change-profile.service';
import { SqliteService } from 'src/app/services/sqlite.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({ @Component({
@@ -175,7 +175,8 @@ export class AgendaPage implements OnInit {
private listBoxService: ListBoxService, private listBoxService: ListBoxService,
private changeProfileService: ChangeProfileService, private changeProfileService: ChangeProfileService,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private platform: Platform private platform: Platform,
private backgroundservice: BackgroundService
) { ) {
this.dateAdapter.setLocale('es'); this.dateAdapter.setLocale('es');
@@ -229,7 +230,23 @@ export class AgendaPage implements OnInit {
ngOnInit() { 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) => { window.onresize = (event) => {
// if not table remove all component // if not table remove all component
@@ -490,7 +507,7 @@ export class AgendaPage implements OnInit {
// loop // loop
this.CalendarStore.pushEvent(response, 'md'); this.CalendarStore.pushEvent(response, 'md');
console.log('CALENDAR STORE',this.CalendarStore.eventSource) console.log('CALENDAR STORE', this.CalendarStore.eventSource)
let array = [] let array = []
response.forEach(element => { response.forEach(element => {
@@ -507,7 +524,7 @@ export class AgendaPage implements OnInit {
}); });
this.listToPresent = array; 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 }) 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.showLoader = false;
this.showTimeline = true; this.showTimeline = true;
}).finally(() => { }).catch((error) => {
this.getFromDB();
})
.finally(() => {
this.showLoader = false; this.showLoader = false;
}) })
} }
// view PR calendar with MDGPR profile // 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) => { 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 // startTime = 1, endTime = 31
this.CalendarStore.removeRange(startTime, endTime, 'pr') this.CalendarStore.removeRange(startTime, endTime, 'pr')
this.CalendarStore.pushEvent(response, 'pr'); this.CalendarStore.pushEvent(response, 'pr');
let array = [] let array = []
response.array.forEach(element => { response.array.forEach(element => {
let event = { let event = {
startTime: new Date(element.StartDate), startTime: new Date(element.StartDate),
@@ -585,7 +605,10 @@ export class AgendaPage implements OnInit {
this.showTimeline = true; this.showTimeline = true;
}).finally(() => { }).catch((error) => {
this.getFromDB()
})
.finally(() => {
this.showLoader = false; this.showLoader = false;
}) })
} }
@@ -596,7 +619,7 @@ export class AgendaPage implements OnInit {
let counter = 0; let counter = 0;
// view MDGPR calendar with MDGPR profile // 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) => { 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; let eventsList = response;
// clear the current month only // 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.listToPresent = eventsList;
this.TimelinePRList = this.listBoxService.list(this.listToPresent, 'pr', this.rangeStartDate, this.rangeEndDate, { segment: this.segment, selectedDate: this.eventSelectedDate }) 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 { } else {
// view PR calendar with PR profile // 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) => { 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; let eventsList;
if (this.segment == 'Oficial') { if (this.segment == 'Oficial') {
@@ -729,44 +752,34 @@ export class AgendaPage implements OnInit {
} }
getFromDB() { getFromDB() {
console.log('ALL EVENTS FROM DB AGENDA OFFLINE')
if (synchro.connected === true) { this.sqliteservice.getAllEvents().then((events: any[]) => {
const pathname = window.location.pathname console.log('ALL EVENTS FROM DB', events)
let realoadCounter = 0 let eventArray = [];
this.router.events.forEach((event) => { events.forEach(element => {
if (event instanceof NavigationEnd && event.url == pathname) { let event = {
if (this.segment == null) { startTime: new Date(element.StartDate),
this.segment = "Combinado"; endTime: new Date(element.EndDate),
} allDay: false,
if (realoadCounter != 0) { event: element,
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate); calendarName: element.CalendarName,
} profile: element.Profile,
realoadCounter++; id: element.EventId,
} }
eventArray.push(event);
}); });
console.log('LISTTOPRESENT', this.listToPresent)
} else { this.listToPresent = eventArray
console.log('ALL EVENTS FROM DB AGENDA OFFLINE') this.updateEventListBox()
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.myCal.update();
} this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
})
} }
updateEventListBox() { updateEventListBox() {
+132 -107
View File
@@ -13,11 +13,11 @@ import { ToastService } from 'src/app/services/toast.service';
import { EliminateEventPage } from 'src/app/modals/eliminate-event/eliminate-event.page'; import { EliminateEventPage } from 'src/app/modals/eliminate-event/eliminate-event.page';
import { Location } from '@angular/common' import { Location } from '@angular/common'
import { SqliteService } from 'src/app/services/sqlite.service'; import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from '../../../services/socket/synchro.service';
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage'; import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
import { DocumentSetUpMeetingPage } from 'src/app/modals/document-set-up-meeting/document-set-up-meeting.page'; 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 { ExpedientTaskModalPage } from '../../gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page'; import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { BackgroundService } from 'src/app/services/background.service';
@Component({ @Component({
selector: 'app-view-event', selector: 'app-view-event',
@@ -30,17 +30,17 @@ export class ViewEventPage implements OnInit {
loadedEvent: Event; loadedEvent: Event;
isEventEdited: boolean; isEventEdited: boolean;
eventBody: EventBody; eventBody: EventBody;
loadedAttachments:any; loadedAttachments: any;
pageId: string; pageId: string;
showLoader: boolean; showLoader: boolean;
minDate: Date; minDate: Date;
profile:string; profile: string;
eventId:string; eventId: string;
caller:string; caller: string;
customDate:any; customDate: any;
today:any; today: any;
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; 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"]; 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; dicIndex = 0;
isModal = false isModal = false
header = true header = true
synch = synchro;
task: ExpedientTaskModalPageNavParamsTask; task: ExpedientTaskModalPageNavParamsTask;
LoadedDocument:any = null; LoadedDocument: any = null;
constructor( constructor(
private modalController: ModalController, private modalController: ModalController,
/* private navParams: NavParams, */ /* private navParams: NavParams, */
private eventsService: EventsService, private eventsService: EventsService,
private attachmentsService: AttachmentsService, private attachmentsService: AttachmentsService,
public alertController: AlertController, public alertController: AlertController,
@@ -66,26 +65,24 @@ export class ViewEventPage implements OnInit {
private toastService: ToastService, private toastService: ToastService,
private location: Location, private location: Location,
public platform: Platform, public platform: Platform,
private sqliteservice: SqliteService private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) {
)
{
this.isEventEdited = false; this.isEventEdited = false;
this.loadedEvent = new Event(); this.loadedEvent = new Event();
this.eventBody = { BodyType : "1", Text : ""}; this.eventBody = { BodyType: "1", Text: "" };
this.loadedEvent.Body = this.eventBody; this.loadedEvent.Body = this.eventBody;
this.activatedRoute.paramMap.subscribe(params =>{ this.activatedRoute.paramMap.subscribe(params => {
this.eventId = params['params'].eventId; this.eventId = params['params'].eventId;
if(params["params"].caller){ if (params["params"].caller) {
this.caller = (params["params"].caller); this.caller = (params["params"].caller);
} }
if(params["params"].isModal) { if (params["params"].isModal) {
this.isModal = params["params"].isModal this.isModal = params["params"].isModal
} }
if(params["params"].header) { if (params["params"].header) {
this.header = params["params"].header this.header = params["params"].header
} }
}); });
@@ -100,56 +97,44 @@ export class ViewEventPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
if(synchro.connected === true) { this.loadEvent();
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.sqliteservice.getEventById(this.eventId).then((event) => { this.backgroundservice.registerBackService('Online', () => {
this.loadedEvent = event[0]; this.loadEvent();
console.log("Event ditails local,", event[0]) });
})
this.loadEvent(); */
window.onresize = (event) => { window.onresize = (event) => {
// if not mobile remove all component // if not mobile remove all component
if( window.innerWidth >= 1024) { if (window.innerWidth >= 1024) {
this.modalController.dismiss(this.isEventEdited); this.modalController.dismiss(this.isEventEdited);
} }
}; };
} }
close(){ close() {
this.modalController.dismiss(this.isEventEdited); this.modalController.dismiss(this.isEventEdited);
} }
goBack() { goBack() {
if(this.isModal) { if (this.isModal) {
this.close() this.close()
} else { } else {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
if(params["params"].caller == 'expediente'){ if (params["params"].caller == 'expediente') {
window.history.back(); window.history.back();
} }
else{ else {
this.router.navigate(['/home',params["params"].caller]); this.router.navigate(['/home', params["params"].caller]);
} }
}); });
} }
} }
doRefresh(ev){ doRefresh(ev) {
this.loadEvent(); this.loadEvent();
ev.target.complete(); ev.target.complete();
} }
@@ -158,44 +143,45 @@ export class ViewEventPage implements OnInit {
const loader = this.toastService.loading(); const loader = this.toastService.loading();
this.eventsService.getEvent(this.eventId).subscribe(res => { this.eventsService.getEvent(this.eventId).subscribe(res => {
this.loadedEvent = res; this.loadedEvent = res;
this.sqliteservice.addEvent(res); this.addEventToDb(res);
console.log('Loaded one event', res) console.log('Loaded one event', res)
/* this.today = new Date(res.StartDate); /* this.today = new Date(res.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()]); */
loader.remove() loader.remove()
}, (error)=>{ }, (error) => {
if(error.status == 0) { console.log('errorstatus',error.status)
this.toastService.badRequest('Não é possível vizualizar este evento no modo offline')
if (error.status == 0) {
this.getFromDb();
} else { } else {
this.toastService.badRequest('Este evento já não existe na sua agenda') 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() loader.remove()
this.modalController.dismiss('Eevent not Foud');
this.location.back();
}); });
} }
deleteEvent(){ deleteEvent() {
const loader = this.toastService.loading() const loader = this.toastService.loading()
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => {
{ const alert = await this.alertController.create({
const alert = await this.alertController.create({ cssClass: 'my-custom-class',
cssClass: 'my-custom-class', header: 'Evento removido',
header: 'Evento removido', buttons: ['OK']
buttons: ['OK'] });
});
setTimeout(()=>{ setTimeout(() => {
alert.dismiss(); alert.dismiss();
}, 1500); }, 1500);
this.goBack(); this.goBack();
this.toastService.successMessage('Evento apagado'); this.toastService.successMessage('Evento apagado');
}, ()=>{}, }, () => { },
()=>{ () => {
loader.remove(); loader.remove();
}); });
} }
@@ -216,7 +202,7 @@ export class ViewEventPage implements OnInit {
modal.onDidDismiss().then((res) => { modal.onDidDismiss().then((res) => {
console.log(res); console.log(res);
if(res){ if (res) {
setTimeout(() => { setTimeout(() => {
/* this.loadEvent(); */ /* this.loadEvent(); */
this.loadEvent() this.loadEvent()
@@ -243,7 +229,7 @@ export class ViewEventPage implements OnInit {
modal.onDidDismiss().then((res) => { modal.onDidDismiss().then((res) => {
console.log(res); console.log(res);
if(res){ if (res) {
setTimeout(() => { setTimeout(() => {
/* this.loadEvent(); */ /* this.loadEvent(); */
this.loadEvent() this.loadEvent()
@@ -258,15 +244,15 @@ export class ViewEventPage implements OnInit {
console.log(this.loadedEvent); console.log(this.loadedEvent);
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
} }
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: EditEventPage, component: EditEventPage,
componentProps:{ componentProps: {
event: this.loadedEvent, event: this.loadedEvent,
caller: this.caller, caller: this.caller,
}, },
@@ -276,7 +262,7 @@ export class ViewEventPage implements OnInit {
modal.onDidDismiss().then((res) => { modal.onDidDismiss().then((res) => {
console.log(res); console.log(res);
if(res){ if (res) {
setTimeout(() => { setTimeout(() => {
/* this.loadEvent(); */ /* this.loadEvent(); */
this.loadEvent() this.loadEvent()
@@ -286,15 +272,15 @@ export class ViewEventPage implements OnInit {
}); });
} }
docIndex(index: number){ docIndex(index: number) {
this.dicIndex = index this.dicIndex = index
} }
async LoadDocumentDetails() { async LoadDocumentDetails() {
const docId = this.loadedEvent.Attachments[ this.dicIndex].SourceId const docId = this.loadedEvent.Attachments[this.dicIndex].SourceId
const applicationId: any = this.loadedEvent.Attachments[ this.dicIndex].ApplicationId const applicationId: any = this.loadedEvent.Attachments[this.dicIndex].ApplicationId
const selectedDoc = this.loadedEvent.Attachments[ this.dicIndex] const selectedDoc = this.loadedEvent.Attachments[this.dicIndex]
console.log('selectedDoc', selectedDoc) console.log('selectedDoc', selectedDoc)
@@ -322,7 +308,7 @@ export class ViewEventPage implements OnInit {
url: '', url: '',
title_link: '', title_link: '',
}, },
Document: this.loadedEvent.Attachments[ this.dicIndex], Document: this.loadedEvent.Attachments[this.dicIndex],
applicationId: this.task.workflowInstanceDataFields.SourceSecFsID, applicationId: this.task.workflowInstanceDataFields.SourceSecFsID,
docId: selectedDoc.SourceId, docId: selectedDoc.SourceId,
folderId: '', folderId: '',
@@ -336,33 +322,33 @@ export class ViewEventPage implements OnInit {
async openBookMeetingModal() { async openBookMeetingModal() {
let classs; let classs;
if( window.innerWidth < 701) { if (window.innerWidth < 701) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
} }
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: DocumentSetUpMeetingPage, component: DocumentSetUpMeetingPage,
componentProps: { componentProps: {
subject: this.task.workflowInstanceDataFields.Subject, subject: this.task.workflowInstanceDataFields.Subject,
document: this.loadedEvent.Attachments[ this.dicIndex], document: this.loadedEvent.Attachments[this.dicIndex],
}, },
cssClass: classs, cssClass: classs,
backdropDismiss: false backdropDismiss: false
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then(res=>{ modal.onDidDismiss().then(res => {
//this.location.back(); //this.location.back();
}); });
} }
// efetuar despacho // efetuar despacho
async openExpedientActionsModal( taskAction: any) { async openExpedientActionsModal(taskAction: any) {
let classs; let classs;
if( window.innerWidth < 701) { if (window.innerWidth < 701) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
} }
const modal = await this.modalController.create({ const modal = await this.modalController.create({
@@ -370,35 +356,74 @@ export class ViewEventPage implements OnInit {
componentProps: { componentProps: {
taskAction: taskAction, taskAction: taskAction,
task: this.task, task: this.task,
seachDocuments: this.loadedEvent.Attachments[ this.dicIndex], seachDocuments: this.loadedEvent.Attachments[this.dicIndex],
aplicationId: this.loadedEvent.Attachments[ this.dicIndex].ApplicationId || this.loadedEvent.Attachments[ this.dicIndex]['ApplicationID'] aplicationId: this.loadedEvent.Attachments[this.dicIndex].ApplicationId || this.loadedEvent.Attachments[this.dicIndex]['ApplicationID']
}, },
cssClass: classs, cssClass: classs,
}); });
await modal.present(); await modal.present();
modal.onDidDismiss().then( async(res)=>{}); modal.onDidDismiss().then(async (res) => { });
} }
getEventsFromLocalDb() { addEventToDb(data) {
console.log("event id details ", this.eventId) 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.sqliteservice.updateEvent(event);
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')
})
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()
} }
} }
@@ -12,7 +12,6 @@ import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service'; import { ChatService } from 'src/app/services/chat.service';
import { FileService } from 'src/app/services/functions/file.service'; import { FileService } from 'src/app/services/functions/file.service';
import { ProcessesService } from 'src/app/services/processes.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 { ToastService } from 'src/app/services/toast.service';
import { NewEventPage } from 'src/app/shared/agenda/new-event/new-event.page'; 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'; 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; members:any;
scrollingOnce:boolean = true; scrollingOnce:boolean = true;
synchro = synchro;
chatMessageStore = ChatMessageStore chatMessageStore = ChatMessageStore
chatUserStorage = ChatUserStorage chatUserStorage = ChatUserStorage
+85 -60
View File
@@ -17,8 +17,8 @@ import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe'; import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service'; import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
import { SqliteService } from 'src/app/services/sqlite.service'; import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from '../../services/socket/synchro.service'; import { NetworkConnectionService } from 'src/app/services/network-connection.service'
import { BackgroundService } from 'src/app/services/background.service' import { BackgroundService } from 'src/app/services/background.service';
@Component({ @Component({
selector: 'app-events', selector: 'app-events',
@@ -69,7 +69,7 @@ export class EventsPage implements OnInit {
expedienteGdStore = ExpedienteGdStore expedienteGdStore = ExpedienteGdStore
listToPresent = []; listToPresent = [];
listToPresentexpediente =[] listToPresentexpediente = []
expedienteTaskPipe = new ExpedienteTaskPipe() expedienteTaskPipe = new ExpedienteTaskPipe()
@@ -78,7 +78,6 @@ export class EventsPage implements OnInit {
loggeduser: LoginUserRespose; loggeduser: LoginUserRespose;
existingScreenOrientation: string; existingScreenOrientation: string;
synch = synchro
constructor( constructor(
private eventService: EventsService, private eventService: EventsService,
@@ -93,7 +92,8 @@ export class EventsPage implements OnInit {
private screenOrientation: ScreenOrientation, private screenOrientation: ScreenOrientation,
public platform: Platform, public platform: Platform,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private backgroundservice: BackgroundService private networkconnection: NetworkConnectionService,
private backgroundservice: BackgroundService,
) { ) {
this.existingScreenOrientation = this.screenOrientation.type; this.existingScreenOrientation = this.screenOrientation.type;
console.log(this.existingScreenOrientation); 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 { } else {
try { try {
this.sqliteservice.databaseConn(); this.sqliteservice.databaseConn();
} catch (error) { } catch (error) {
console.log("Error creating local database: ", error) console.log("Error creating local database: ", error)
} }
} */ }
} }
ngOnInit() { ngOnInit() {
@@ -124,21 +123,26 @@ export class EventsPage implements OnInit {
this.segment = "Combinada"; this.segment = "Combinada";
this.profile = "mdgpr"; 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.showGreeting();
this.RefreshEvents();
this.router.events.forEach((event) => { this.LoadList();
if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents();
setTimeout(() => {
this.LoadList();
}, 1500)
}
});
this.hideSearch(); this.hideSearch();
} });
this.getEventsFromLocalDb(); //this.getEventsFromLocalDb();
//this.checkScreenOrientation(); //this.checkScreenOrientation();
@@ -206,7 +210,7 @@ export class EventsPage implements OnInit {
console.log("getAllMdOficialPessoalEvents", list) console.log("getAllMdOficialPessoalEvents", list)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) { if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else { } else {
if(list.length > 0) { if (list.length > 0) {
list.forEach(element => { list.forEach(element => {
this.sqliteservice.addEvent(element) this.sqliteservice.addEvent(element)
}); });
@@ -234,7 +238,7 @@ export class EventsPage implements OnInit {
console.log("getAllPrOficialPessoalEvents", list) console.log("getAllPrOficialPessoalEvents", list)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) { if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else { } else {
if(list.length > 0) { if (list.length > 0) {
list.forEach(element => { list.forEach(element => {
this.sqliteservice.addEvent(element) this.sqliteservice.addEvent(element)
}); });
@@ -324,21 +328,26 @@ export class EventsPage implements OnInit {
getEventsFromLocalDb() { getEventsFromLocalDb() {
if (synchro.connected === true) { /* window.addEventListener('online', (on) => {
this.showGreeting(); 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) => { // window.addEventListener('offline', (off) => {
if (event instanceof NavigationEnd && event.url == '/home/events') { if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.RefreshEvents();
setTimeout(() => { } else {
this.LoadList(); this.sqliteservice.getAllEvents().then((event: any[]) => {
}, 1500)
}
});
this.hideSearch();
} else {
this.platform.ready().then(async () => {
this.sqliteservice.getAllEvents().then((event:any[]) => {
this.listToPresent = event this.listToPresent = event
this.totalEvent = this.listToPresent.length this.totalEvent = this.listToPresent.length
this.currentEvent = this.listToPresent[0].Subject this.currentEvent = this.listToPresent[0].Subject
@@ -346,29 +355,39 @@ export class EventsPage implements OnInit {
console.log("All events from local,", event) console.log("All events from local,", event)
}) })
this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[]) => { this.sqliteservice.getAllProcess().then((res) => {
var expedientlist = []; console.log('INICION ALL EVENTs', res)
process.forEach((element) => { })
let task = { this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[]) => {
CreateDate: element.taskStartDate,
DocumentsQty: element.totalDocuments, console.log('OFOFOFOOF', process)
Senders: JSON.parse(element.workflowInstanceDataFields).Sender,
SerialNumber: element.serialNumber, if (process.length > 0 || process != undefined) {
Status: JSON.parse(element.workflowInstanceDataFields).Status,
Subject: JSON.parse(element.workflowInstanceDataFields).Subject, var expedientlist: any = new Array();
WorkflowName: element.workflowDisplayName, process.forEach((element) => {
activityInstanceName: element.activityInstanceName, let task = {
taskStartDate: element.taskStartDate, activityInstanceName: element.activityInstanceName,
} deadline: null,
expedientlist.push(task); serialNumber: element.serialNumber,
}) taskStartDate: element.taskStartDate,
const ExpedienteTask = expedientlist.map(e => this.expedienteTaskPipe.transform(e)) totalDocuments: element.totalDocuments,
this.listToPresentexpediente = ExpedienteTask; 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() { LoadList() {
this.processes.GetTaskListExpediente(false).subscribe(result => { this.processes.GetTaskListExpediente(false).subscribe(result => {
console.log("Expediente", result); console.log("Expediente", result);
if (this.platform.is('desktop') || this.platform.is('mobileweb')) { if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else { } else {
this.sqliteservice.addProcess(result) result.forEach((element) => {
this.sqliteservice.addProcess(element)
})
} }
const ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e)) const ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e))
@@ -437,7 +459,10 @@ export class EventsPage implements OnInit {
console.log("Expediente 2", ExpedienteTask); console.log("Expediente 2", ExpedienteTask);
this.listToPresentexpediente = ExpedienteTask; this.listToPresentexpediente = ExpedienteTask;
}); }, ((error) => {
console.log('Getlist error', error)
this.getEventsFromLocalDb();
}));
} }
sortArrayISODate(myArray: any) { sortArrayISODate(myArray: any) {
@@ -21,7 +21,7 @@ import { DespachoService } from 'src/app/Rules/despacho.service';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page'; import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { SqliteService } from 'src/app/services/sqlite.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({ @Component({
selector: 'app-despacho-pr', selector: 'app-despacho-pr',
@@ -56,7 +56,8 @@ export class DespachoPrPage implements OnInit {
private toastService: ToastService, private toastService: ToastService,
private location: Location, private location: Location,
private despachoService: DespachoService, private despachoService: DespachoService,
private sqliteservice: SqliteService private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) { ) {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
if (params["params"].SerialNumber) { if (params["params"].SerialNumber) {
@@ -73,7 +74,21 @@ export class DespachoPrPage implements OnInit {
ngOnInit() { ngOnInit() {
this.profile = "mdgpr"; this.profile = "mdgpr";
console.log(this.serialNumber); 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() { close() {
@@ -123,93 +138,81 @@ export class DespachoPrPage implements OnInit {
return user.Type == 'CC'; return user.Type == 'CC';
}) || [] }) || []
if(!this.cc) { if (!this.cc) {
this.cc = [] this.cc = []
} }
}); });
}, (error) => { }, (error) => {
try {
this.goBack() if (error.status == 0) {
} catch (e) { this.getFromDB()
window.history.back(); } else {
} finally { try {
if (error.status == 0) { this.goBack()
this.toastService.badRequest('Não é possível visualizar este processo no modo offline') } catch (e) {
} else { window.history.back();
this.toastService.badRequest('Processo não encontrado')
} }
this.toastService.badRequest('Processo não encontrado')
} }
}); });
} }
getFromDB() { getFromDB() {
if (synchro.connected === true) {
this.activateRoute.paramMap.subscribe(paramMap => { this.sqliteservice.getProcessById(this.serialNumber).then((process: any[]) => {
if (!paramMap.has('SerialNumber')) { console.log('OFFLINE', process)
return; this.task = {
} "SerialNumber": process[0].serialNumber,
/* this.serialNumber = paramMap.get('SerialNumber'); */ "Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
this.LoadTaskDetail(this.serialNumber); "Senders": JSON.parse(process[0].originator).email,
// this.LoadRelatedEvents(this.serialNumber); "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({ const modal = await this.modalController.create({
component: ViewDocumentPage, component: ViewDocumentPage,
@@ -17,9 +17,9 @@ import { NavigationEnd, NavigationExtras, NavigationStart, Router } from '@angul
import { __awaiter } from 'tslib'; import { __awaiter } from 'tslib';
import { DespachosprStore } from 'src/app/store/despachospr-store.service'; import { DespachosprStore } from 'src/app/store/despachospr-store.service';
import { synchro } from 'src/app/services/socket/synchro.service';
import { SortService } from 'src/app/services/functions/sort.service';
import { SqliteService } from 'src/app/services/sqlite.service'; import { SqliteService } from 'src/app/services/sqlite.service';
import { BackgroundService } from 'src/app/services/background.service';
import { SortService } from 'src/app/services/functions/sort.service';
@Component({ @Component({
selector: 'app-despachos-pr', selector: 'app-despachos-pr',
@@ -61,6 +61,7 @@ export class DespachosPrPage implements OnInit {
private authService: AuthService, private authService: AuthService,
private router: Router, private router: Router,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private backgroundservice: BackgroundService,
private sortService: SortService, private sortService: SortService,
) { ) {
@@ -72,7 +73,25 @@ export class DespachosPrPage implements OnInit {
ngOnInit() { ngOnInit() {
//Inicializar segment //Inicializar segment
this.segment = "despachos"; 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) { segmentChanged(ev: any) {
@@ -94,115 +113,104 @@ export class DespachosPrPage implements OnInit {
async LoadList() { 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(); let result = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
this.despachoList = []; this.despachoList = [];
this.skeletonLoader = false; this.skeletonLoader = false;
console.log(result); console.log(result);
let despachosPr; let despachosPr;
let despachos = this.sortService.sortArrayByDate(result); let despachos = this.sortService.sortArrayByDate(result);
switch (this.loggeduser.Profile) { switch (this.loggeduser.Profile) {
case 'MDGPR': case 'MDGPR':
despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho"); despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho");
break; break;
case 'PR': case 'PR':
despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Concluir Despacho"); despachosPr = await despachos.reverse().filter(data => data.activityInstanceName == "Concluir Despacho");
break; 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": 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(despachosPr);
console.log(this.despachoList); despachosPr = despachosPr.filter(data => data.workflowInstanceDataFields.Status == "Active");
});
this.listToPresent = this.despachoList 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() { 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) => { let despachosPr;
if (event instanceof NavigationStart && event.url.startsWith(pathname)) { switch (this.loggeduser.Profile) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { case 'MDGPR':
this.doRefresh() despachosPr = await process.reverse().filter(data => data.activityInstanceName == "Tarefa de Despacho");
} else { break;
this.LoadList() 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.listToPresent = this.despachoList;
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)
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);
});
this.listToPresent = this.despachoList;
})
}
} }
doRefresh() { doRefresh() {
@@ -19,9 +19,9 @@ import { AttachmentList } from 'src/app/models/Excludetask';
import { PermissionService } from 'src/app/services/worker/permission.service'; import { PermissionService } from 'src/app/services/worker/permission.service';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page'; 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 { SqliteService } from 'src/app/services/sqlite.service';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { BackgroundService } from 'src/app/services/background.service';
@Component({ @Component({
selector: 'app-despacho', selector: 'app-despacho',
@@ -46,8 +46,6 @@ export class DespachoPage implements OnInit {
intervenientes: any; intervenientes: any;
cc: any = []; cc: any = [];
synch = synchro;
constructor(private activateRoute: ActivatedRoute, constructor(private activateRoute: ActivatedRoute,
private processes: ProcessesService, private processes: ProcessesService,
private iab: InAppBrowser, private iab: InAppBrowser,
@@ -60,7 +58,8 @@ export class DespachoPage implements OnInit {
private location: Location, private location: Location,
public p: PermissionService, public p: PermissionService,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private platform: Platform private platform: Platform,
private backgroundservice: BackgroundService
) { ) {
@@ -81,7 +80,10 @@ export class DespachoPage implements OnInit {
return; 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) => { }, (error) => {
try { if (error.status == 0) {
this.goBack() this.getFromDb();
} catch (e) { } else {
this.location.back(); try {
} finally { this.goBack()
if (error.status == 0) { } catch (e) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline') this.location.back();
} else {
this.toastService.badRequest('Processo não encontrado')
} }
this.toastService.badRequest('Processo não encontrado')
} }
}); });
} }
getFromDb() { getFromDb() {
if (synchro.connected === true) {
this.LoadTaskDetail(this.serialnumber)
}
if (synchro.connected === false) { this.platform.ready().then(() => {
this.platform.ready().then(() => { this.sqliteservice.getProcessById(this.serialnumber).then((process) => {
this.sqliteservice.getProcessById(this.serialnumber).then((process) => {
var workflow = JSON.parse(process[0].workflowInstanceDataFields); var workflow = JSON.parse(process[0].workflowInstanceDataFields);
var intervine = JSON.parse(process[0].interveners) var intervine = JSON.parse(process[0].interveners)
var origina var origina
if (process[0].originator === "undefined") { if (process[0].originator === "undefined") {
origina = "" origina = ""
} else { } else {
origina = JSON.parse(process[0].originator) origina = JSON.parse(process[0].originator)
} }
console.log('sqlite', process) console.log('sqlite', process)
this.task = { this.task = {
"SerialNumber": process[0].serialNumber, "SerialNumber": process[0].serialNumber,
"Folio": workflow.Subject, "Folio": workflow.Subject,
"Senders": origina.email || process[0].originator, "Senders": origina.email || process[0].originator,
"CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'), "CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
"DocumentURL": workflow.ViewerRequest, "DocumentURL": workflow.ViewerRequest,
"Remetente": workflow.Sender, "Remetente": workflow.Sender,
"Note": workflow.TaskMessage || workflow.Note, "Note": workflow.TaskMessage || workflow.Note,
"FolderId": workflow.FolderID, "FolderId": workflow.FolderID,
"FsId": workflow.FsId, "FsId": workflow.FsId,
"DocId": workflow.DocID, "DocId": workflow.DocID,
"DocumentsQty": process[0].DocumentsQty, "DocumentsQty": process[0].DocumentsQty,
"WorkflowName": process[0].workflowDisplayName, "WorkflowName": process[0].workflowDisplayName,
"DeadlineType": workflow.DeadlineType, "DeadlineType": workflow.DeadlineType,
"activityInstanceName": process[0].activityInstanceName, "activityInstanceName": process[0].activityInstanceName,
"Status": workflow.Status, "Status": workflow.Status,
} }
let thedate = new Date(this.task.CreateDate); 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()]);
let fulltak = { let fulltak = {
Documents: JSON.parse(process[0].Documents), Documents: JSON.parse(process[0].Documents),
actions: JSON.parse(process[0].actions), actions: JSON.parse(process[0].actions),
activityInstanceName: process[0].activityInstanceName, activityInstanceName: process[0].activityInstanceName,
formURL: process[0].formURL, formURL: process[0].formURL,
originator: JSON.parse(process[0].originator), originator: JSON.parse(process[0].originator),
serialNumber: process[0].serialNumber, serialNumber: process[0].serialNumber,
taskStartDate: process[0].taskStartDate, taskStartDate: process[0].taskStartDate,
totalDocuments: process[0].totalDocuments, totalDocuments: process[0].totalDocuments,
workflowDisplayName: process[0].workflowDisplayName, workflowDisplayName: process[0].workflowDisplayName,
workflowID: process[0].workflowID, workflowID: process[0].workflowID,
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields), workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
workflowInstanceFolio: process[0].workflowInstanceFolio, workflowInstanceFolio: process[0].workflowInstanceFolio,
workflowInstanceID: process[0].workflowInstanceID, workflowInstanceID: process[0].workflowInstanceID,
workflowName: process[0].workflowName workflowName: process[0].workflowName
} }
this.fulltask = fulltak; this.fulltask = fulltak;
console.log('interveniers offline', intervine) console.log('interveniers offline', intervine)
this.intervenientes = intervine.filter(user => { this.intervenientes = intervine.filter(user => {
console.log('interveniers offline 2', user) console.log('interveniers offline 2', user)
return user.Type == 'I'; return user.Type == 'I';
}); });
this.cc = intervine.filter(user => { this.cc = intervine.filter(user => {
console.log('interveniers offline 3', user) console.log('interveniers offline 3', user)
return user.Type == 'CC'; return user.Type == 'CC';
}); });
})
}) })
} })
} }
async viewDocument(docId:string, Document) { async viewDocument(docId: string, Document) {
console.log(this.fulltask) console.log(this.fulltask)
@@ -4,9 +4,9 @@ import { DespachoService } from 'src/app/Rules/despacho.service';
import { DespachoStore } from 'src/app/store/despacho-store.service'; import { DespachoStore } from 'src/app/store/despacho-store.service';
import { SqliteService } from 'src/app/services/sqlite.service'; import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from 'src/app/services/socket/synchro.service';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { isThisHour } from 'date-fns'; import { isThisHour } from 'date-fns';
import { BackgroundService } from 'src/app/services/background.service';
@Component({ @Component({
selector: 'app-despachos', selector: 'app-despachos',
@@ -17,21 +17,39 @@ import { isThisHour } from 'date-fns';
export class DespachosPage implements OnInit { export class DespachosPage implements OnInit {
despachoStore = DespachoStore; despachoStore = DespachoStore;
synch = synchro;
listToPresent = []; listToPresent = [];
constructor( constructor(
private router: Router, private router: Router,
private despachoRule: DespachoService, private despachoRule: DespachoService,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private platform: Platform private platform: Platform,
private backgroundservice: BackgroundService
) { ) {
} }
ngOnInit() { 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() { async refreshing() {
@@ -49,57 +67,42 @@ export class DespachosPage implements OnInit {
await this.despachoRule.getList({ updateStore: true }).then((pre) => { await this.despachoRule.getList({ updateStore: true }).then((pre) => {
this.listToPresent = pre; this.listToPresent = pre;
console.log('despachooo', pre) console.log('despachooo', pre)
}).catch(() => {
this.getFromDb()
}) })
} }
getFromDb() { getFromDb() {
if (synchro.connected === true) {
const location = window.location
const pathname = location.pathname + location.search
this.LoadList() this.platform.ready().then(() => {
this.sqliteservice.getprocessByworkflow('Despacho').then((process: any[]) => {
this.router.events.forEach((event) => { var listtopresent = [];
if (event instanceof NavigationStart && event.url.startsWith(pathname)) { process.forEach(element => {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { var workflow = JSON.parse(element.workflowInstanceDataFields);
this.refreshing() let task = {
} else { "CreateDate": element.taskStartDate,
this.LoadList() "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) { listtopresent.push(task);
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); });
}); this.listToPresent = listtopresent;
console.log('Tarefas de despach', this.listToPresent)
this.listToPresent = listtopresent;
})
}) })
} })
} }
get skeletonLoader(): boolean { get skeletonLoader(): boolean {
@@ -3,7 +3,7 @@ import { AnimationController, ModalController, PopoverController } from '@ionic/
import { AddNotePage } from 'src/app/modals/add-note/add-note.page'; import { AddNotePage } from 'src/app/modals/add-note/add-note.page';
import { ProcessesService } from 'src/app/services/processes.service'; import { ProcessesService } from 'src/app/services/processes.service';
import { OptsExpedientePage } from 'src/app/shared/popover/opts-expediente/opts-expediente.page'; 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 { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router'; 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 { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { SqliteService } from 'src/app/services/sqlite.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({ @Component({
selector: 'app-diploma', 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"]; days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
serialNumber: string; serialNumber: string;
caller:string; caller: string;
profile: string; profile: string;
task: any task: any
fulltask: any fulltask: any
intervenientes: any; intervenientes: any;
cc: any = []; cc: any = [];
attachments:any; attachments: any;
customDate: any customDate: any
constructor( constructor(
@@ -46,15 +46,16 @@ export class DiplomaPage implements OnInit {
private animationController: AnimationController, private animationController: AnimationController,
private toastService: ToastService, private toastService: ToastService,
private location: Location, private location: Location,
private sqliteservice: SqliteService private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) { ) {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
// console.log(params["params"]); // console.log(params["params"]);
if(params["params"].SerialNumber) { if (params["params"].SerialNumber) {
this.serialNumber = params["params"].SerialNumber; this.serialNumber = params["params"].SerialNumber;
} }
if(params["params"].caller) { if (params["params"].caller) {
this.caller = params["params"].caller; this.caller = params["params"].caller;
} }
@@ -64,7 +65,10 @@ export class DiplomaPage implements OnInit {
ngOnInit() { ngOnInit() {
this.profile = "mdgpr"; this.profile = "mdgpr";
this.getFromDb(); this.LoadTaskDetail(this.serialNumber);
this.backgroundservice.registerBackService('Online', () => {
this.LoadTaskDetail(this.serialNumber);
});
} }
goBack() { goBack() {
@@ -104,7 +108,7 @@ export class DiplomaPage implements OnInit {
serialNumber: this.serialNumber, serialNumber: this.serialNumber,
task: this.task, task: this.task,
fulltask: this.fulltask, fulltask: this.fulltask,
taskAction:taskAction, taskAction: taskAction,
showEnviarPendentes: false showEnviarPendentes: false
}, },
translucent: true translucent: true
@@ -118,7 +122,7 @@ export class DiplomaPage implements OnInit {
"SerialNumber": res.serialNumber, "SerialNumber": res.serialNumber,
"Folio": res.workflowInstanceDataFields.Subject, "Folio": res.workflowInstanceDataFields.Subject,
"Senders": res.originator.email, "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, "DocumentURL": res.workflowInstanceDataFields.ViewerRequest,
"Remetente": res.workflowInstanceDataFields.Sender, "Remetente": res.workflowInstanceDataFields.Sender,
"Note": res.workflowInstanceDataFields.TaskMessage || res.workflowInstanceDataFields.Note, "Note": res.workflowInstanceDataFields.TaskMessage || res.workflowInstanceDataFields.Note,
@@ -133,94 +137,90 @@ export class DiplomaPage implements OnInit {
this.sqliteservice.updateProcess(res) this.sqliteservice.updateProcess(res)
let thedate = new Date(this.task.CreateDate); 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(() => { this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialNumber), JSON.stringify(users)).then(() => {
console.log('internen diploma ') console.log('internen diploma ')
}) })
this.intervenientes = users.filter(user=>{ this.intervenientes = users.filter(user => {
return user.Type == 'I'; return user.Type == 'I';
}); });
this.cc = users.filter(user=>{ this.cc = users.filter(user => {
return user.Type == 'CC'; return user.Type == 'CC';
}); });
}); });
this.getDocumentDetails(this.task.FolderId, '361'); this.getDocumentDetails(this.task.FolderId, '361');
}, (error)=>{ }, (error) => {
try { if (error.status == 0) {
this.goBack() this.getFromDb();
} catch (e) { } else {
window.history.back(); try {
} finally { this.goBack()
if(error.status == 0) { } catch (e) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline') window.history.back();
} else {
this.toastService.badRequest('Processo não encontrado')
} }
this.toastService.badRequest('Processo não encontrado')
} }
}); });
} }
getFromDb() { getFromDb() {
if(synchro.connected === true) {
this.LoadTaskDetail(this.serialNumber);
} else {
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
this.task = { this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
"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 fulltak = { this.task = {
Documents: JSON.parse(process[0].Documents), "SerialNumber": process[0].serialNumber,
actions: JSON.parse(process[0].actions), "Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
activityInstanceName: process[0].activityInstanceName, "Senders": JSON.parse(process[0].originator).email,
formURL: process[0].formURL, "CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
originator: JSON.parse(process[0].originator), "DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
serialNumber: process[0].serialNumber, "Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
taskStartDate: process[0].taskStartDate, "Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage || JSON.parse(process[0].workflowInstanceDataFields).Note,
totalDocuments: process[0].totalDocuments, "FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
workflowDisplayName: process[0].workflowDisplayName, "FsId": '361',
workflowID: process[0].workflowID, "DocId": JSON.parse(process[0].workflowInstanceDataFields).DispatchDocId,
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields), "WorkflowName": process[0].workflowDisplayName,
workflowInstanceFolio: process[0].workflowInstanceFolio, "DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
workflowInstanceID: process[0].workflowInstanceID, "activityInstanceName": process[0].activityInstanceName,
workflowName: process[0].workflowName }
}
this.fulltask = fulltak
let thedate = new Date(this.task.CreateDate); let fulltak = {
this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]); 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'; 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'; return user.Type == 'CC';
}); });
this.attachments = JSON.parse(process[0].Documents) this.attachments = JSON.parse(process[0].Documents)
}) })
}
} }
async viewDocument(DocId:string, Document) { async viewDocument(DocId: string, Document) {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: ViewDocumentPage, component: ViewDocumentPage,
@@ -243,15 +243,15 @@ export class DiplomaPage implements OnInit {
} }
getDocumentDetails(forlderId:string, applicationId:string) { getDocumentDetails(forlderId: string, applicationId: string) {
this.processes.GetDocumentDetails(forlderId,applicationId).subscribe(res=>{ this.processes.GetDocumentDetails(forlderId, applicationId).subscribe(res => {
this.attachments = res.Documents; this.attachments = res.Documents;
console.log(res['Documents']); console.log(res['Documents']);
console.log(this.attachments); console.log(this.attachments);
}) })
} }
async askSignature(note:string, documents:any){ async askSignature(note: string, documents: any) {
let body = { let body = {
"serialNumber": this.serialNumber, "serialNumber": this.serialNumber,
"action": "Aprovar", "action": "Aprovar",
@@ -259,7 +259,7 @@ export class DiplomaPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -267,7 +267,7 @@ export class DiplomaPage implements OnInit {
try { try {
await this.processes.CompleteTask(body).toPromise() await this.processes.CompleteTask(body).toPromise()
this.toastService.successMessage(false, ()=>{ this.toastService.successMessage(false, () => {
this.close(); 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 = { let body = {
"serialNumber": this.serialNumber, "serialNumber": this.serialNumber,
"action": "Retificar", "action": "Retificar",
@@ -287,7 +287,7 @@ export class DiplomaPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() 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 = { let body = {
"serialNumber": this.serialNumber, "serialNumber": this.serialNumber,
@@ -312,7 +312,7 @@ export class DiplomaPage implements OnInit {
"dataFields": { "dataFields": {
"ReviewUserComment": note, "ReviewUserComment": note,
}, },
"AttachmentList" :documents, "AttachmentList": documents,
} }
const loader = this.toastService.loading() const loader = this.toastService.loading()
@@ -333,16 +333,16 @@ export class DiplomaPage implements OnInit {
return new Date(e).toDateString() return new Date(e).toDateString()
} }
async openAddNoteModal(actionName:string) { async openAddNoteModal(actionName: string) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'modal modal-desktop' classs = 'modal modal-desktop'
} else { } else {
classs = 'add-note-modal' classs = 'add-note-modal'
} }
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: AddNotePage, component: AddNotePage,
componentProps:{ componentProps: {
}, },
cssClass: classs, cssClass: classs,
backdropDismiss: true backdropDismiss: true
@@ -351,7 +351,7 @@ export class DiplomaPage implements OnInit {
await modal.present(); await modal.present();
modal.onDidDismiss().then(async (res) => { modal.onDidDismiss().then(async (res) => {
if(res.data){ if (res.data) {
const DocumentToSave = res.data.documents.map((e) => { 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); await this.askSignature(res.data.note, docs);
this.goBack(); this.goBack();
} }
else if(actionName == 'Solicitar alteração'){ else if (actionName == 'Solicitar alteração') {
await this.askToChange(res.data.note, docs); await this.askToChange(res.data.note, docs);
this.goBack(); this.goBack();
} }
else if(actionName == 'Concluir diploma'){ else if (actionName == 'Concluir diploma') {
await this.finish(res.data.note, docs); await this.finish(res.data.note, docs);
this.goBack(); this.goBack();
} }
@@ -385,9 +385,9 @@ export class DiplomaPage implements OnInit {
async openBookMeetingModal(task: any) { async openBookMeetingModal(task: any) {
let classs; let classs;
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
classs = 'book-meeting-modal modal modal-desktop' classs = 'book-meeting-modal modal modal-desktop'
} else { } else {
classs = 'modal modal-desktop showAsideOptions' classs = 'modal modal-desktop showAsideOptions'
} }
const modal = await this.modalController.create({ const modal = await this.modalController.create({
@@ -402,7 +402,7 @@ export class DiplomaPage implements OnInit {
modal.onDidDismiss(); modal.onDidDismiss();
} }
close(){ close() {
this.modalController.dismiss(); this.modalController.dismiss();
} }
@@ -4,7 +4,7 @@ import { DailyWorkTask } from '../../../models/dailyworktask.model';
import { ProcessesService } from 'src/app/services/processes.service'; import { ProcessesService } from 'src/app/services/processes.service';
import { SqliteService } from 'src/app/services/sqlite.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'; import { SortService } from 'src/app/services/functions/sort.service';
@Component({ @Component({
@@ -29,11 +29,10 @@ export class DiplomasPage implements OnInit, OnDestroy {
private router: Router, private router: Router,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private backgroundservice: BackgroundService,
private sortService: SortService, private sortService: SortService,
) { ) {
this.diplomasList = [];
//Inicializar segment //Inicializar segment
this.segment = 'validar';
this.activatedRoute.queryParams.subscribe(params => { this.activatedRoute.queryParams.subscribe(params => {
if (params['validar'] == 'true') { 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,69 +170,60 @@ export class DiplomasPage implements OnInit, OnDestroy {
async LoadList() { 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 let diplomas = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
this.showLoader = false;
this.skeletonLoader = false
this.showLoader = false;
let diplomasValidar = diplomas.filter(data => data.activityInstanceName == "Revisar Diploma"); let diplomasValidar = diplomas.filter(data => data.activityInstanceName == "Revisar Diploma");
let diplomasList = []; let diplomasList = [];
diplomasValidar.forEach(async element => { diplomasValidar.forEach(async element => {
let task = this.pipeTask(element) let task = this.pipeTask(element)
diplomasList.push(task); diplomasList.push(task);
}); });
this.diplomasList = this.sortService.sortArrayISODate(diplomasList).reverse(); this.diplomasList = this.sortService.sortArrayByDate(diplomasList.reverse());
let diplomasAssinados = diplomas.reverse().filter(data => data.activityInstanceName == "Diploma Assinado"); let diplomasAssinados = diplomas.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
let diplomasAssinadoList = [] let diplomasAssinadoList = []
diplomasAssinados.forEach(async element => { diplomasAssinados.forEach(async element => {
let task = this.pipeTask(element) let task = this.pipeTask(element)
diplomasAssinadoList.push(task); diplomasAssinadoList.push(task);
}); });
console.log('diplomasAssinados', diplomasAssinados) console.log('diplomasAssinados', diplomasAssinados)
this.diplomasAssinadoList = this.sortService.sortArrayISODate(diplomasAssinadoList).reverse(); this.diplomasAssinadoList = this.sortService.sortArrayByDate(diplomasAssinadoList).reverse();
}, (error) => {
this.getFromDb()
})
} }
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) => { let diplomasValidar = process.filter(data => data.activityInstanceName == "Revisar Diploma");
if (event instanceof NavigationStart && event.url.startsWith(pathname)) { let diplomasList = [];
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { diplomasValidar.forEach(async element => {
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 task = this.pipeTaskOffline(element)
let diplomasList = []; diplomasList.push(task);
diplomasValidar.forEach(async element => {
let task = this.pipeTaskOffline(element)
diplomasList.push(task);
}); });
this.diplomasList = this.sortService.sortArrayISODate(diplomasList).reverse(); this.diplomasList = this.sortService.sortArrayISODate(diplomasList).reverse();
let diplomasAssinados = process.reverse().filter(data => data.activityInstanceName == "Diploma Assinado"); let diplomasAssinados = process.reverse().filter(data => data.activityInstanceName == "Diploma Assinado");
let diplomasAssinadoList = [] let diplomasAssinadoList = []
diplomasAssinados.forEach(async element => { diplomasAssinados.forEach(async element => {
let task = this.pipeTaskOffline(element) let task = this.pipeTaskOffline(element)
diplomasAssinadoList.push(task); diplomasAssinadoList.push(task);
@@ -224,8 +231,7 @@ export class DiplomasPage implements OnInit, OnDestroy {
console.log('diplomasAssinados', diplomasAssinados) console.log('diplomasAssinados', diplomasAssinados)
this.diplomasAssinadoList = this.sortService.sortArrayISODate(diplomasAssinadoList).reverse(); this.diplomasAssinadoList = this.sortService.sortArrayISODate(diplomasAssinadoList).reverse();
}) })
}
} }
pipeTask(element) { pipeTask(element) {
@@ -14,7 +14,7 @@ import { Location } from '@angular/common';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page'; import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { SqliteService } from '../../../../services/sqlite.service'; 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 { Platform } from '@ionic/angular';
@Component({ @Component({
@@ -33,18 +33,16 @@ export class ApproveEventPage implements OnInit {
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; 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"]; days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
serialNumber:string; serialNumber: string;
caller:string; caller: string;
attachments:any; attachments: any;
@Input() InstanceId:string; @Input() InstanceId: string;
@Output() approveEventDismiss = new EventEmitter<any>(); @Output() approveEventDismiss = new EventEmitter<any>();
@Output() closeEventToApprove = new EventEmitter<any>(); @Output() closeEventToApprove = new EventEmitter<any>();
@Output() AproveEventEditEvent = new EventEmitter<any>(); @Output() AproveEventEditEvent = new EventEmitter<any>();
synch = synchro;
constructor( constructor(
private router: Router, private router: Router,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
@@ -59,7 +57,8 @@ export class ApproveEventPage implements OnInit {
private toastService: ToastService, private toastService: ToastService,
private location: Location, private location: Location,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private platform: Platform private platform: Platform,
private backgroundservice: BackgroundService
) { ) {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
// console.log(params["params"]); // console.log(params["params"]);
@@ -81,7 +80,11 @@ export class ApproveEventPage implements OnInit {
ngOnInit() { ngOnInit() {
console.log(this.serialNumber); console.log(this.serialNumber);
console.log(this.caller); 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) { addProcessToDB(data) {
this.platform.ready().then(() => { this.platform.ready().then(() => {
this.sqliteservice.updateProcess(data); this.sqliteservice.updateProcess(data);
}); });
} }
getProcessFromDB() { getProcessFromDB() {
if (synchro.connected === true) { this.platform.ready().then(() => {
this.getTask();
}
synchro.registerCallback('Offline', () => { this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
this.platform.ready().then(() => { console.log('event aprove serial', process)
this.sqliteservice.getProcessById(this.serialNumber).then((process) => { var doc;
console.log('event aprove serial', process) 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; if (process[0].actions === "null" || process[0].actions === "undefined") {
var action = []; action = []
var origi = []; } else {
var wordafi = {}; action = JSON.parse(process[0].Documents)
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") { if (process[0].originator === "null" || process[0].originator === "undefined") {
action = [] origi = []
} else { } else {
action = JSON.parse(process[0].Documents) 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") { let task = {
origi = [] "Documents": doc,
} else { "actions": action,
origi = JSON.parse(process[0].Documents) "activityInstanceName": process[0].activityInstanceName,
} "formURL": process[0].formURL,
if (process[0].workflowInstanceDataFields === "null" || process[0].workflowInstanceDataFields === "undefined") { "originator": origi,
wordafi = [] "serialNumber": process[0].serialNumber,
} else { "taskStartDate": process[0].taskStartDate,
wordafi = JSON.parse(process[0].workflowInstanceDataFields) "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 this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
console.log('offline event',this.loadedEvent);
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() { async getTask() {
this.loadedEvent = await this.processes.GetTask(this.serialNumber).toPromise(); this.processes.GetTask(this.serialNumber).subscribe(async res => {
console.log(this.loadedEvent);
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) { 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({ const modal = await this.modalController.create({
component: ViewDocumentPage, component: ViewDocumentPage,
@@ -9,7 +9,7 @@ import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.servic
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { SqliteService } from '../../../services/sqlite.service'; 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 { Platform } from '@ionic/angular';
import { SortService } from 'src/app/services/functions/sort.service'; 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 { export class EventListPage implements OnInit {
// [desktop] event list to approve // [desktop] event list to approve
profile:string; profile: string;
segment:string; segment: string;
showLoader: boolean; showLoader: boolean;
eventsPRList: any = [] eventsPRList: any = []
eventsMDGPRList: any = [] eventsMDGPRList: any = []
eventPerson: EventPerson; eventPerson: EventPerson;
eventBody: EventBody; eventBody: EventBody;
categories: string[]; categories: string[];
serialnumber:string; serialnumber: string;
skeletonLoader = true skeletonLoader = true
eventaprovacaostore = EventoAprovacaoStore; eventaprovacaostore = EventoAprovacaoStore;
synch = synchro;
constructor( constructor(
private processes:ProcessesService, private processes: ProcessesService,
private modalController: ModalController, private modalController: ModalController,
private router: Router, private router: Router,
private location: Location, private location: Location,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private platform: Platform, private platform: Platform,
private sortService: SortService, private sortService: SortService,
private backgroundservice: BackgroundService
) { } ) { }
ngOnInit() { ngOnInit() {
this.segment = 'MDGPR'; this.segment = 'MDGPR';
this.getEventToAproveFromDB();
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) => { window.onresize = (event) => {
// if not mobile remove all component // if not mobile remove all component
if( window.innerWidth <= 800){ if (window.innerWidth <= 800) {
this.modalController.dismiss(); this.modalController.dismiss();
} }
}; };
@@ -63,73 +79,58 @@ export class EventListPage implements OnInit {
getEventToAproveFromDB() { getEventToAproveFromDB() {
if( synchro.connected === true) { this.platform.ready().then(() => {
const location = window.location
const pathname = location.pathname + location.search
this.LoadToApproveEvents() this.sqliteservice.getListOfEventAprove('Agenda Oficial MDGPR', 'Agenda Pessoal MDGPR').then((event: any[]) => {
this.eventsMDGPRList = this.sortService.sortArrayByDate(event).reverse()
this.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith(pathname)) { console.log("All evento to aprove from db ", event)
if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { })
this.refreshing()
} else { this.sqliteservice.getListOfEventAprove('Agenda Oficial PR', 'Agenda Pessoal PR').then((event: any[]) => {
this.LoadToApproveEvents() this.eventsPRList = this.sortService.sortArrayByDate(event).reverse()
} console.log("All evento to aprove from db ", event)
}
});
}
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)
})
}) })
console.log('Offlineee')
}) })
console.log('Offlineee')
} }
segmentChanged(ev: any) { segmentChanged(ev: any) {
this.LoadToApproveEvents(); this.LoadToApproveEvents();
} }
async LoadToApproveEvents(){ async LoadToApproveEvents() {
this.showLoader = true; this.processes.GetTasksList('Agenda Oficial MDGPR', false).subscribe(async res => {
this.skeletonLoader = true this.showLoader = true;
this.skeletonLoader = true
console.log(this.segment); console.log(this.segment);
if(this.segment == 'MDGPR'){ if (this.segment == 'MDGPR') {
let mdEventsOficial = await this.processes.GetTasksList('Agenda Oficial MDGPR', false).toPromise(); let mdEventsOficial = await this.processes.GetTasksList('Agenda Oficial MDGPR', false).toPromise();
let mdEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal MDGPR', false).toPromise(); let mdEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal MDGPR', false).toPromise();
this.eventsMDGPRList = mdEventsOficial.concat(mdEventsPessoal); this.eventsMDGPRList = mdEventsOficial.concat(mdEventsPessoal);
this.eventaprovacaostore.resetmd(this.sortService.sortArrayByDate(this.eventsMDGPRList).reverse()); 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(); else if (this.segment == 'PR') {
let prEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal PR', false).toPromise(); let prEventsOficial = await this.processes.GetTasksList('Agenda Oficial PR', false).toPromise();
this.eventsPRList = prEventsOficial.concat(prEventsPessoal); let prEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal PR', false).toPromise();
this.eventaprovacaostore.resetpr(this.sortService.sortArrayByDate(this.eventsPRList).reverse()); this.eventsPRList = prEventsOficial.concat(prEventsPessoal);
} this.eventsPRList = this.sortService.sortArrayByDate(this.eventsPRList).reverse();
this.showLoader = false; this.eventaprovacaostore.resetpr(this.sortService.sortArrayByDate(this.eventsPRList).reverse());
this.skeletonLoader = false }
this.showLoader = false;
this.skeletonLoader = false
}, (error) => {
this.getEventToAproveFromDB();
})
} }
getEventToaproveFromDB() { async openApproveModal(eventSerialNumber, event) {
}
async openApproveModal(eventSerialNumber, event){
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: ApproveEventModalPage, component: ApproveEventModalPage,
componentProps:{ componentProps: {
serialNumber: eventSerialNumber, serialNumber: eventSerialNumber,
}, },
cssClass: 'event-list cal-modal modal modal-desktop', cssClass: 'event-list cal-modal modal modal-desktop',
@@ -138,7 +139,7 @@ export class EventListPage implements OnInit {
await modal.present(); await modal.present();
} }
goToEventToApproveDetail(serialNumber:string){ goToEventToApproveDetail(serialNumber: string) {
console.log(serialNumber); console.log(serialNumber);
/* let navigationExtras: NavigationExtras = { /* let navigationExtras: NavigationExtras = {
@@ -147,11 +148,11 @@ export class EventListPage implements OnInit {
} }
}; */ }; */
if(this.router.url == '/home/agenda/event-list'){ if (this.router.url == '/home/agenda/event-list') {
this.router.navigate(['/home/agenda/event-list/approve-event',serialNumber, 'agenda']) this.router.navigate(['/home/agenda/event-list/approve-event', serialNumber, 'agenda'])
} }
else if(this.router.url == '/home/gabinete-digital/event-list'){ 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', serialNumber, 'gabinete-digital'])
} }
//this.router.navigate(['/home/gabinete-digital/event-list/approve-event'], navigationExtras) //this.router.navigate(['/home/gabinete-digital/event-list/approve-event'], navigationExtras)
@@ -171,7 +172,7 @@ export class EventListPage implements OnInit {
}, 1000); }, 1000);
} }
close(){ close() {
this.modalController.dismiss(null); this.modalController.dismiss(null);
} }
goBack() { goBack() {
@@ -28,7 +28,7 @@ import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.pag
import { SqliteService } from 'src/app/services/sqlite.service'; import { SqliteService } from 'src/app/services/sqlite.service';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { synchro } from 'src/app/services/socket/synchro.service'; import { BackgroundService } from 'src/app/services/background.service';
@Component({ @Component({
selector: 'app-expediente-detail', selector: 'app-expediente-detail',
@@ -56,7 +56,6 @@ export class ExpedienteDetailPage implements OnInit {
hideSendToPendentes = true hideSendToPendentes = true
searchDocumentPipe = new SearchDocumentPipe() searchDocumentPipe = new SearchDocumentPipe()
synch = synchro
onlinecheck: boolean; onlinecheck: boolean;
constructor( constructor(
@@ -76,6 +75,7 @@ export class ExpedienteDetailPage implements OnInit {
private expedienteService: ExpedienteService, private expedienteService: ExpedienteService,
public platform: Platform, public platform: Platform,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) { ) {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
if (params["params"].SerialNumber) { if (params["params"].SerialNumber) {
@@ -88,7 +88,11 @@ export class ExpedienteDetailPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.getFromDB();
this.LoadTaskDetail(this.serialNumber);
this.backgroundservice.registerBackService('Online', () => {
this.LoadTaskDetail(this.serialNumber);
});
} }
@@ -102,44 +106,37 @@ export class ExpedienteDetailPage implements OnInit {
getFromDB() { getFromDB() {
if(synchro.connected === true) { this.platform.ready().then(() => {
this.LoadTaskDetail(this.serialNumber); this.onlinecheck = false;
} this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
console.log("expedient ditail", process)
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
var origina
if (process[0].originator === "undefined") {
origina = ""
} else {
origina = JSON.parse(process[0].originator)
}
synchro.registerCallback('Offline', () => { this.task = {
this.platform.ready().then(() => { "SerialNumber": process[0].serialNumber,
this.onlinecheck = false; "Folio": workflow.Subject,
this.sqliteservice.getProcessById(this.serialNumber).then((process) => { "Senders": origina.email || process[0].originator,
console.log("expedient ditail", process) "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,
"WorkflowName": process[0].workflowDisplayName,
"Status": workflow.Status,
"DispatchNumber": workflow.DispatchNumber,
"AttachmentsProcessLastInstanceID": workflow.AttachmentsProcessLastInstanceID,
"InstanceID": workflow.InstanceID
}
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
var origina
if (process[0].originator === "undefined") {
origina = ""
} else {
origina = JSON.parse(process[0].originator)
}
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,
"WorkflowName": process[0].workflowDisplayName,
"Status": workflow.Status,
"DispatchNumber": workflow.DispatchNumber,
"AttachmentsProcessLastInstanceID": workflow.AttachmentsProcessLastInstanceID,
"InstanceID": workflow.InstanceID
}
})
}) })
}) })
} }
@@ -336,17 +333,17 @@ export class ExpedienteDetailPage implements OnInit {
console.log('this.task.DocumentURL', this.task.DocumentURL) console.log('this.task.DocumentURL', this.task.DocumentURL)
}, (error) => { }, (error) => {
try {
this.toastService.badRequest('Processo não encontrado') if (error.status == 0) {
this.goBack() this.getFromDB();
} catch (e) { } else {
window.history.back(); try {
} 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') this.toastService.badRequest('Processo não encontrado')
this.goBack()
} catch (e) {
window.history.back();
} }
this.toastService.badRequest('Processo não encontrado')
} }
}); });
@@ -358,7 +355,7 @@ export class ExpedienteDetailPage implements OnInit {
} }
async viewDocument(DocId:string, Document) { async viewDocument(DocId: string, Document) {
// this.expedienteService.viewDocument({ApplicationId:'361', DocId}) // this.expedienteService.viewDocument({ApplicationId:'361', DocId})
@@ -6,7 +6,7 @@ import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe'; import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
import { SqliteService } from 'src/app/services/sqlite.service'; import { SqliteService } from 'src/app/services/sqlite.service';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { synchro } from '../../../services/socket/synchro.service'; import { BackgroundService } from '../../../services/background.service';
@Component({ @Component({
selector: 'app-expediente', selector: 'app-expediente',
@@ -28,48 +28,69 @@ export class ExpedientePage implements OnInit {
onlinecheck: boolean; onlinecheck: boolean;
listToPresent; listToPresent;
synch = synchro
constructor( constructor(
private processes: ProcessesService, private processes: ProcessesService,
private router: Router, private router: Router,
private toastService: ToastService, private toastService: ToastService,
public platform: Platform, public platform: Platform,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) { } ) { }
ngOnInit() { ngOnInit() {
this.getEventsFromLocalDb(); const location = window.location
console.log("segrsgre") 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 LoadList() { async LoadList() {
this.skeletonLoader = true
try { this.processes.GetTaskListExpediente(false).subscribe(async res => {
const expediente: object[] = await this.processes.GetTaskListExpediente(false).toPromise() this.skeletonLoader = true
const result = expediente
this.taskslist = new Array(); try {
let res = result.reverse().filter((data: any) => data.workflowInstanceDataFields.Status == "Active"); const expediente: object[] = await this.processes.GetTaskListExpediente(false).toPromise()
const result = expediente
res.forEach((element: any) => { this.taskslist = new Array();
let res = result.reverse().filter((data: any) => data.workflowInstanceDataFields.Status == "Active");
let task = this.expedienteTaskPipe.transform(element) res.forEach((element: any) => {
this.taskslist.push(task);
this.sqliteservice.addProcess(task);
});
this.listToPresent = this.taskslist let task = this.expedienteTaskPipe.transform(element)
console.log('expediente list', this.listToPresent) this.taskslist.push(task);
this.sqliteservice.addProcess(task);
});
} catch (error) { this.listToPresent = this.taskslist
this.toastService.badRequest('Processo não encontrado') console.log('expediente list', this.listToPresent)
this.goBack()
} finally { } catch (error) {
this.skeletonLoader = false; this.toastService.badRequest('Processo não encontrado')
} this.goBack()
} finally {
this.skeletonLoader = false;
}
}, (error) => {
this.getEventsFromLocalDb();
})
} }
@@ -121,49 +142,32 @@ export class ExpedientePage implements OnInit {
getEventsFromLocalDb() { getEventsFromLocalDb() {
if (synchro.connected === true) { this.taskslist = new Array();
const location = window.location this.sqliteservice.getprocessByworkflow("Expediente").then((expediente: any[]) => {
const pathname = location.pathname + location.search console.log("All expedientes from local,", expediente)
this.LoadList() expediente.forEach((element) => {
this.router.events.forEach((event) => { var workflow = JSON.parse(element.workflowInstanceDataFields);
if (event instanceof NavigationStart && event.url.startsWith(pathname)) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { let exped = {
this.refreshing() "CreateDate": element.taskStartDate,
} else { "DocumentsQty": element.totalDocuments,
this.LoadList() "Senders": workflow.Senders,
} "SerialNumber": element.serialNumber,
"Status": workflow.Status,
"Subject": workflow.Subject,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName
} }
this.taskslist.push(exped)
}); });
} else {
this.taskslist = new Array();
this.sqliteservice.getprocessByworkflow("Expediente").then((expediente: any[]) => {
console.log("All expedientes from local,", expediente)
expediente.forEach((element) => { this.listToPresent = this.taskslist
var workflow = JSON.parse(element.workflowInstanceDataFields); })
let exped = {
"CreateDate": element.taskStartDate,
"DocumentsQty": element.totalDocuments,
"Senders": workflow.Senders,
"SerialNumber": element.serialNumber,
"Status": workflow.Status,
"Subject": workflow.Subject,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName
}
this.taskslist.push(exped)
});
this.listToPresent = this.taskslist
})
}
} }
} }
@@ -26,8 +26,8 @@ import { PermissionService } from 'src/app/services/worker/permission.service';
import { SqliteService } from '../../services/sqlite.service'; import { SqliteService } from '../../services/sqlite.service';
import { synchro } from '../../services/socket/synchro.service';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { BackgroundService } from 'src/app/services/background.service';
@Component({ @Component({
selector: 'app-gabinete-digital', selector: 'app-gabinete-digital',
@@ -109,9 +109,6 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
// //
// pipe // pipe
synch = synchro;
customTaskPipe = new CustomTaskPipe() customTaskPipe = new CustomTaskPipe()
@ViewChild(ExpedientsPage) expedientesPage: ExpedientsPage; @ViewChild(ExpedientsPage) expedientesPage: ExpedientsPage;
@@ -130,7 +127,8 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
private despachoRule: DespachoService, private despachoRule: DespachoService,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private platform: Platform, private platform: Platform,
private changeProfileService: ChangeProfileService private changeProfileService: ChangeProfileService,
private backgroundservice: BackgroundService
) { ) {
this.loggeduser = authService.ValidatedUser; this.loggeduser = authService.ValidatedUser;
@@ -178,57 +176,91 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
this.segmentVista = "boxview" this.segmentVista = "boxview"
} }
this.getAllProcessFromDB() const pathname = window.location.pathname
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == pathname) {
this.waitForDomService.selector({
selector: 'app-gabinete-digital ion-content .aside-wrapper',
callback: () => {
this.checkRoutes();
this.LoadCounts();
}
})
}
});
this.hideRefreshButton();
this.waitForDomService.selector({
selector: 'app-gabinete-digital ion-content .aside-wrapper',
callback: () => {
this.loadAllProcesses();
}
})
this.backgroundservice.registerBackService('Online', () => {
this.loadAllProcesses();
});
} }
async loadAllProcesses() { async loadAllProcesses() {
let allProcessesList = await this.processesbackend.GetTasksList("", false).toPromise();
if (!this.p.userRole(['PR'])) { this.processesbackend.GetTasksList("", false).subscribe(async res => {
allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Assinar Diplomas')
} else if (this.p.userRole(['PR'])) {
allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Diploma Assinado')
}
console.log('allProcessesList', allProcessesList); let allProcessesList = await this.processesbackend.GetTasksList("", false).toPromise();
this.addProcessToDB(allProcessesList)
this.skeletonLoader = true;
this.allProcessesList = []; if (!this.p.userRole(['PR'])) {
allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Assinar Diplomas')
allProcessesList.forEach(element => { } else if (this.p.userRole(['PR'])) {
let date = new Date(element.taskStartDate); allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Diploma Assinado')
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,
"CreateDate": new Date(element.taskStartDate),
"DocumentURL": element.workflowInstanceDataFields.ViewerRequest,
"Remetente": element.workflowInstanceDataFields.Remetente,
"DocumentsQty": element.totalDocuments,
"DocId": element.workflowInstanceDataFields.DispatchDocId,
"FolderID": element.workflowInstanceDataFields.FolderID,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName,
"Status": element.workflowInstanceDataFields.Status,
"Agenda": element.workflowInstanceDataFields.Agenda,
"customDate": this.setFormatDate(new Date(element.workflowInstanceDataFields.StartDate), new Date(element.workflowInstanceDataFields.EndDate), element.workflowInstanceDataFields.IsAllDayEvent),
} }
this.allProcessesList.push(task); console.log('allProcessesList', allProcessesList);
this.allProcessesList = removeDuplicate(this.allProcessesList)
this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse();
this.addProcessToDB(allProcessesList)
this.skeletonLoader = true;
}); this.allProcessesList = [];
allProcessesList.forEach(element => {
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,
"CreateDate": new Date(element.taskStartDate),
"DocumentURL": element.workflowInstanceDataFields.ViewerRequest,
"Remetente": element.workflowInstanceDataFields.Remetente,
"DocumentsQty": element.totalDocuments,
"DocId": element.workflowInstanceDataFields.DispatchDocId,
"FolderID": element.workflowInstanceDataFields.FolderID,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName,
"Status": element.workflowInstanceDataFields.Status,
"Agenda": element.workflowInstanceDataFields.Agenda,
"customDate": this.setFormatDate(new Date(element.workflowInstanceDataFields.StartDate), new Date(element.workflowInstanceDataFields.EndDate), element.workflowInstanceDataFields.IsAllDayEvent),
}
this.allProcessesList.push(task);
this.allProcessesList = removeDuplicate(this.allProcessesList)
this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse();
});
}, (error) => {
console.log('gabinete digital offline', error)
this.getAllProcessFromDB();
})
this.skeletonLoader = false; this.skeletonLoader = false;
@@ -254,7 +286,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
"workflowInstanceID": element.workflowInstanceID, "workflowInstanceID": element.workflowInstanceID,
"workflowName": element.workflowName "workflowName": element.workflowName
} }
this.sqliteservice.addProcess(process); this.sqliteservice.addProcess(process);
}); });
}); });
@@ -262,65 +294,40 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
getAllProcessFromDB() { getAllProcessFromDB() {
if (synchro.connected === true ) { this.hideRefreshButton();
const pathname = window.location.pathname
this.router.events.forEach((event) => { this.sqliteservice.getAllProcess().then((allprocess: any[]) => {
if (event instanceof NavigationEnd && event.url == pathname) { allprocess.forEach(element => {
let date = new Date(element.taskStartDate);
this.waitForDomService.selector({ date.setMonth(date.getMonth() + 1);
selector: 'app-gabinete-digital ion-content .aside-wrapper', let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
callback: () => {
this.checkRoutes(); var workflowInstanceDataFields = JSON.parse(element.workflowInstanceDataFields);
this.LoadCounts();
} let task = {
}) "SerialNumber": element.serialNumber,
"Folio": workflowInstanceDataFields.Subject,
"Senders": workflowInstanceDataFields.Sender,
"CreateDate": taskDate,
"DocumentURL": workflowInstanceDataFields.ViewerRequest,
"Remetente": workflowInstanceDataFields.Remetente,
"DocumentsQty": element.totalDocuments,
"DocId": workflowInstanceDataFields.DispatchDocId,
"FolderID": workflowInstanceDataFields.FolderID,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName,
"Status": workflowInstanceDataFields.Status,
"Agenda": workflowInstanceDataFields.Agenda,
"customDate": this.setFormatDate(new Date(workflowInstanceDataFields.StartDate), new Date(workflowInstanceDataFields.EndDate), workflowInstanceDataFields.IsAllDayEvent),
} }
this.allProcessesList.push(task);
this.allProcessesList = removeDuplicate(this.allProcessesList)
this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse();
}); });
console.log("All process from db ", allprocess)
this.hideRefreshButton(); })
this.waitForDomService.selector({
selector: 'app-gabinete-digital ion-content .aside-wrapper',
callback: () => {
this.loadAllProcesses();
}
})
} else {
this.hideRefreshButton();
this.sqliteservice.getAllProcess().then((allprocess: any[]) => {
allprocess.forEach(element => {
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();
var workflowInstanceDataFields = JSON.parse(element.workflowInstanceDataFields);
let task = {
"SerialNumber": element.serialNumber,
"Folio": workflowInstanceDataFields.Subject,
"Senders": workflowInstanceDataFields.Sender,
"CreateDate": taskDate,
"DocumentURL": workflowInstanceDataFields.ViewerRequest,
"Remetente": workflowInstanceDataFields.Remetente,
"DocumentsQty": element.totalDocuments,
"DocId": workflowInstanceDataFields.DispatchDocId,
"FolderID": workflowInstanceDataFields.FolderID,
"WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName,
"Status": workflowInstanceDataFields.Status,
"Agenda": workflowInstanceDataFields.Agenda,
"customDate": this.setFormatDate(new Date(workflowInstanceDataFields.StartDate), new Date(workflowInstanceDataFields.EndDate), workflowInstanceDataFields.IsAllDayEvent),
}
this.allProcessesList.push(task);
this.allProcessesList = removeDuplicate(this.allProcessesList)
this.allProcessesList = this.sortArrayISODate(this.allProcessesList).reverse();
});
console.log("All process from db ", allprocess)
})
}
} }
sortArrayISODate(myArray: any) { sortArrayISODate(myArray: any) {
@@ -376,15 +383,15 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
thedate.getMinutes(); thedate.getMinutes();
} }
goToProcess(serialNumber:string, workflowName:string, activityName:string){ goToProcess(serialNumber: string, workflowName: string, activityName: string) {
if(workflowName == 'Despacho') { if (workflowName == 'Despacho') {
if(activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho'){ if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') {
this.router.navigate(['/home/gabinete-digital/despachos',serialNumber,'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']);
} }
} }
else if(workflowName == 'Despacho do Presidente da República') { else if (workflowName == 'Despacho do Presidente da República') {
if(activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho'){ if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') {
this.router.navigate(['/home/gabinete-digital/despachos-pr',serialNumber,'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/despachos-pr', serialNumber, 'gabinete-digital']);
} }
else if (activityName == 'Revisar Diploma' || activityName == 'Assinar Diploma') { else if (activityName == 'Revisar Diploma' || activityName == 'Assinar Diploma') {
this.router.navigate(['/home/gabinete-digital/diplomas', serialNumber, 'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/diplomas', serialNumber, 'gabinete-digital']);
@@ -538,7 +545,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
let allPreocesses_ = await this.processesbackend.GetTasksList("", false).toPromise(); let allPreocesses_ = await this.processesbackend.GetTasksList("", false).toPromise();
let count_all_processes = Object.keys(allPreocesses_).length; let count_all_processes = Object.keys(allPreocesses_).length;
let expedientes = await this.processesbackend.GetTaskListExpediente(false).toPromise(); let expedientes = await this.processesbackend.GetTaskListExpediente(false).toPromise();
expedientes = expedientes.filter(data => data.workflowInstanceDataFields.Status == "Active") expedientes = expedientes.filter(data => data.workflowInstanceDataFields.Status == "Active")
@@ -21,7 +21,7 @@ import { Location } from '@angular/common';
import { PedidoService } from 'src/app/Rules/pedido.service'; import { PedidoService } from 'src/app/Rules/pedido.service';
import { SqliteService } from 'src/app/services/sqlite.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 { PermissionService } from 'src/app/services/worker/permission.service'; import { PermissionService } from 'src/app/services/worker/permission.service';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page'; import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
@@ -62,6 +62,7 @@ export class PedidoPage implements OnInit {
private location: Location, private location: Location,
private pedidoService: PedidoService, private pedidoService: PedidoService,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private backgroundservices: BackgroundService
) { ) {
this.loggeduser = authService.ValidatedUser; this.loggeduser = authService.ValidatedUser;
@@ -79,7 +80,10 @@ export class PedidoPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.getfromDb() this.LoadTaskDetail(this.serialnumber);
this.backgroundservices.registerBackService('Online', () => {
this.LoadTaskDetail(this.serialnumber);
});
} }
close() { close() {
@@ -155,7 +159,7 @@ export class PedidoPage implements OnInit {
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(res.workflowInstanceDataFields.FolderID).subscribe(users => { this.processes.GetTaskParticipants(res.workflowInstanceDataFields.FolderID).subscribe(users => {
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialnumber), JSON.stringify(users)).then(() =>{ this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialnumber), JSON.stringify(users)).then(() => {
console.log('Pedido ') console.log('Pedido ')
}) })
this.intervenientes = users.filter(user => { this.intervenientes = users.filter(user => {
@@ -167,114 +171,108 @@ export class PedidoPage implements OnInit {
}); });
this.getDocumentDetails(res.workflowInstanceDataFields.FolderID, '361'); this.getDocumentDetails(res.workflowInstanceDataFields.FolderID, '361');
}, (error) => { }, (error) => {
try { if (error.status == 0) {
this.goBack() this.getfromDb();
this.close() } else {
} catch (e) { try {
window.history.back(); this.goBack()
} finally { this.close()
if (error.status == 0) { } catch (e) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline') window.history.back();
} else {
this.toastService.badRequest('Processo não encontrado')
} }
this.toastService.badRequest('Processo não encontrado')
} }
}); });
} }
getfromDb() { getfromDb() {
if (synchro.connected === true) {
this.LoadTaskDetail(this.serialnumber);
}
if (synchro.connected === false) { this.sqliteservice.getProcessById(this.serialnumber).then((process) => {
this.sqliteservice.getProcessById(this.serialnumber).then((process) => {
console.log('PROCESS BY ID', process,this.serialnumber ) console.log('PROCESS BY ID', process, this.serialnumber)
let fulltak = { let fulltak = {
Documents: JSON.parse(process[0].Documents), Documents: JSON.parse(process[0].Documents) || [],
actions: JSON.parse(process[0].actions), actions: JSON.parse(process[0].actions),
activityInstanceName: process[0].activityInstanceName, activityInstanceName: process[0].activityInstanceName,
formURL: process[0].formURL, formURL: process[0].formURL,
originator: JSON.parse(process[0].originator), originator: JSON.parse(process[0].originator),
serialNumber: process[0].serialNumber, serialNumber: process[0].serialNumber,
taskStartDate: process[0].taskStartDate, taskStartDate: process[0].taskStartDate,
totalDocuments: process[0].totalDocuments, totalDocuments: process[0].totalDocuments,
workflowDisplayName: process[0].workflowDisplayName, workflowDisplayName: process[0].workflowDisplayName,
workflowID: process[0].workflowID, workflowID: process[0].workflowID,
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields), workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
workflowInstanceFolio: process[0].workflowInstanceFolio, workflowInstanceFolio: process[0].workflowInstanceFolio,
workflowInstanceID: process[0].workflowInstanceID, workflowInstanceID: process[0].workflowInstanceID,
workflowName: process[0].workflowName workflowName: process[0].workflowName
}
this.fulltask = fulltak;
console.log('FULLTAK OFFLINE', this.fulltask);
if (process[0].workflowDisplayName == 'Pedido de Parecer' || process[0].workflowDisplayName == 'Pedido de Parecer do Presidente') {
let date = new Date(process[0].taskStartDate);
date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
this.task = {
"SerialNumber": process[0].serialNumber,
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
"Senders": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"CreateDate": taskDate,
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage,
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
"FsId": '361',
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DocIdDeferimento,
"WorkflowName": process[0].workflowDisplayName,
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
"ProcessInstanceID": JSON.parse(process[0].workflowInstanceDataFields).InstanceID,
"activityInstanceName": process[0].activityInstanceName,
"Status": JSON.parse(process[0].workflowInstanceDataFields).Status,
} }
this.fulltask = fulltak; this.attachments = JSON.parse(process[0].Documents);
console.log('FULLTAK OFFLINE', this.fulltask); } else if (process[0].workflowDisplayName == 'Pedido de Deferimento') {
if (process[0].workflowDisplayName == 'Pedido de Parecer' || process[0].workflowDisplayName == 'Pedido de Parecer do Presidente') { let date = new Date(process[0].taskStartDate);
let date = new Date(process[0].taskStartDate); date.setMonth(date.getMonth() + 1);
date.setMonth(date.getMonth() + 1); let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); this.task = {
"SerialNumber": process[0].serialNumber,
this.task = { "Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
"SerialNumber": process[0].serialNumber, "Senders": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject, "CreateDate": taskDate,
"Senders": JSON.parse(process[0].workflowInstanceDataFields).Sender, "DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
"CreateDate": taskDate, "Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest, "Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage,
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender, "FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage, "FsId": '361',
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID, "DocId": JSON.parse(process[0].workflowInstanceDataFields).DocIdDeferimento,
"FsId": '361', "WorkflowName": process[0].workflowDisplayName,
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DocIdDeferimento, "DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
"WorkflowName": process[0].workflowDisplayName, "ProcessInstanceID": JSON.parse(process[0].workflowInstanceDataFields).InstanceID,
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType, "activityInstanceName": process[0].activityInstanceName,
"ProcessInstanceID": JSON.parse(process[0].workflowInstanceDataFields).InstanceID, "Status": JSON.parse(process[0].workflowInstanceDataFields).Status,
"activityInstanceName": process[0].activityInstanceName,
"Status": JSON.parse(process[0].workflowInstanceDataFields).Status,
}
this.attachments = JSON.parse(process[0].Documents);
} else if (process[0].workflowDisplayName == 'Pedido de Deferimento') {
let date = new Date(process[0].taskStartDate);
date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
this.task = {
"SerialNumber": process[0].serialNumber,
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
"Senders": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"CreateDate": taskDate,
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage,
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
"FsId": '361',
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DocIdDeferimento,
"WorkflowName": process[0].workflowDisplayName,
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
"ProcessInstanceID": JSON.parse(process[0].workflowInstanceDataFields).InstanceID,
"activityInstanceName": process[0].activityInstanceName,
"Status": JSON.parse(process[0].workflowInstanceDataFields).Status,
}
this.attachments = JSON.parse(process[0].Documents);
} }
this.attachments = JSON.parse(process[0].Documents);
}
let thedate = new Date(process[0].taskStartDate); let thedate = new Date(process[0].taskStartDate);
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.intervenientes = JSON.parse(process[0].interveners).filter(user => { this.intervenientes = JSON.parse(process[0].interveners).filter(user => {
return user.Type == 'I'; 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'; return user.Type == 'CC';
}); });
this.getDocumentDetails(JSON.parse(process[0].workflowInstanceDataFields).FolderID, '361'); this.getDocumentDetails(JSON.parse(process[0].workflowInstanceDataFields).FolderID, '361');
}) })
}
} }
getDocumentDetails(forlderId: string, applicationId: string) { getDocumentDetails(forlderId: string, applicationId: string) {
@@ -284,7 +282,7 @@ export class PedidoPage implements OnInit {
}) })
} }
async viewDocument(DocId:string, Document) { async viewDocument(DocId: string, Document) {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: ViewDocumentPage, component: ViewDocumentPage,
@@ -329,7 +327,7 @@ export class PedidoPage implements OnInit {
popover.onDidDismiss().then((res => { popover.onDidDismiss().then((res => {
if( res['data'] == 'close') { if (res['data'] == 'close') {
this.goBack() this.goBack()
} }
@@ -478,7 +476,7 @@ export class PedidoPage implements OnInit {
// }); // });
// } // }
async distartExpedientModal(){ async distartExpedientModal() {
console.log(this.fulltask); console.log(this.fulltask);
const modal = await this.modalController.create({ const modal = await this.modalController.create({
component: DiscartExpedientModalPage, component: DiscartExpedientModalPage,
@@ -9,7 +9,7 @@ import { PedidosStore } from 'src/app/store/pedidos-store.service';
import { ModalService } from 'src/app/services/modal.service'; import { ModalService } from 'src/app/services/modal.service';
import { SqliteService } from 'src/app/services/sqlite.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'; import { SortService } from 'src/app/services/functions/sort.service';
@Component({ @Component({
@@ -19,41 +19,42 @@ import { SortService } from 'src/app/services/functions/sort.service';
}) })
export class PedidosPage implements OnInit { export class PedidosPage implements OnInit {
@ViewChild(CalendarComponent) myCal: CalendarComponent; @ViewChild(CalendarComponent) myCal: CalendarComponent;
taskslist:DailyWorkTask[] = []; taskslist: DailyWorkTask[] = [];
parecerList:any[] = []; parecerList: any[] = [];
listToPresentparecerList: any[] = []; listToPresentparecerList: any[] = [];
listToPresentdeferimentoList: any[] = []; listToPresentdeferimentoList: any[] = [];
fulltask:any; fulltask: any;
parecerListResult:customTask[] = []; parecerListResult: customTask[] = [];
deferimentoListResult:customTask[] = []; deferimentoListResult: customTask[] = [];
deferimentoList:any[] = []; deferimentoList: any[] = [];
taskType: string; taskType: string;
serialNumber:string; serialNumber: string;
skeletonLoader = true skeletonLoader = true
pedidosstorage = PedidosStore; pedidosstorage = PedidosStore;
segment:string; segment: string;
@Output() openExpedientDetail:EventEmitter<any> = new EventEmitter<any>(); @Output() openExpedientDetail: EventEmitter<any> = new EventEmitter<any>();
constructor( constructor(
private router: Router, private router: Router,
private processes:ProcessesService, private processes: ProcessesService,
private modalController: ModalController, private modalController: ModalController,
private alertService: AlertService, private alertService: AlertService,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private modalService: ModalService, private modalService: ModalService,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private sortService: SortService, private sortService: SortService,
) { private backgroundservice: BackgroundService
//Inicializar segment ) {
//Inicializar segment
this.segment = 'parecer'; this.segment = 'parecer';
this.activatedRoute.queryParams.subscribe(params => { this.activatedRoute.queryParams.subscribe(params => {
if(params['deferimento'] == 'true') { if (params['deferimento'] == 'true') {
this.segment = 'deferimento'; this.segment = 'deferimento';
} else if (params['parecer'] == 'true') { } else if (params['parecer'] == 'true') {
this.segment = 'parecer'; this.segment = 'parecer';
@@ -61,12 +62,30 @@ export class PedidosPage implements OnInit {
}); });
const modal = this.modalService.BookMeetingModalPage({task: ''},{}) const modal = this.modalService.BookMeetingModalPage({ task: '' }, {})
} }
ngOnInit() { ngOnInit() {
this.getFromDb();
this.LoadList()
this.router.events.forEach((event) => {
if (event instanceof NavigationStart && '/home/gabinete-digital/pedidos?parecer=true'.startsWith(event.url) ||
event instanceof NavigationStart && '/home/gabinete-digital/pedidos?deferimento=true'.startsWith(event.url)
) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
this.refreshing()
} else {
this.LoadList()
}
}
});
this.backgroundservice.registerBackService('Online', () => {
this.getFromDb();
});
} }
goBack() { goBack() {
@@ -88,8 +107,8 @@ export class PedidosPage implements OnInit {
// this.LoadList(); // this.LoadList();
} */ } */
goToPedido(serialNumber:any) { goToPedido(serialNumber: any) {
this.router.navigate(['/home/gabinete-digital/pedidos',serialNumber,'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/pedidos', serialNumber, 'gabinete-digital']);
} }
notImplemented() { notImplemented() {
@@ -102,27 +121,30 @@ export class PedidosPage implements OnInit {
} }
async LoadList() { async LoadList() {
this.skeletonLoader = true
if(this.segment == 'parecer') { this.processes.GetTasksList("Pedido de Parecer", false).subscribe(async res => {
this.taskType = "Pedido de Parecer";
let parecer = await this.processes.GetTasksList("Pedido de Parecer", false).toPromise(); this.skeletonLoader = true
let parecerPr = await this.processes.GetTasksList("Pedido de Parecer do Presidente", false).toPromise();
this.skeletonLoader = false if (this.segment == 'parecer') {
this.taskType = "Pedido de Parecer";
let allParecer = parecer.concat(parecerPr).reverse().filter(data => data.workflowInstanceDataFields.Status == "Active") let parecer = await this.processes.GetTasksList("Pedido de Parecer", false).toPromise();
let parecerPr = await this.processes.GetTasksList("Pedido de Parecer do Presidente", false).toPromise();
this.parecerList =[]; this.skeletonLoader = false
allParecer.filter(data => data.workflowInstanceDataFields.Status == "Active").forEach(element => { let allParecer = parecer.concat(parecerPr).reverse().filter(data => data.workflowInstanceDataFields.Status == "Active")
let date = new Date(element.taskStartDate); this.parecerList = [];
date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds();
let task = { allParecer.filter(data => data.workflowInstanceDataFields.Status == "Active").forEach(element => {
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, "SerialNumber": element.serialNumber,
"Folio": element.workflowInstanceDataFields.Subject, "Folio": element.workflowInstanceDataFields.Subject,
"Senders": element.workflowInstanceDataFields.Sender, "Senders": element.workflowInstanceDataFields.Sender,
@@ -133,32 +155,32 @@ export class PedidosPage implements OnInit {
"DocId": element.workflowInstanceDataFields.DocIdDiferimento, "DocId": element.workflowInstanceDataFields.DocIdDiferimento,
"WorkflowName": element.workflowDisplayName, "WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName, "activityInstanceName": element.activityInstanceName,
} }
this.parecerList.push(task); this.parecerList.push(task);
}); });
this.sqliteservice.addProcess(this.parecerList); this.sqliteservice.addProcess(this.parecerList);
this.listToPresentparecerList = this.sortService.sortArrayISODate(this.parecerList); this.listToPresentparecerList = this.sortService.sortArrayISODate(this.parecerList);
} }
else if(this.segment == 'deferimento') { else if (this.segment == 'deferimento') {
this.taskType = "Pedido de Deferimento"; this.taskType = "Pedido de Deferimento";
this.processes.GetTasksList("Pedido de Deferimento", false).subscribe(result => { this.processes.GetTasksList("Pedido de Deferimento", false).subscribe(result => {
this.skeletonLoader = false this.skeletonLoader = false
console.log(result); console.log(result);
this.deferimentoList = []; this.deferimentoList = [];
let res = result.filter(data => data.workflowInstanceDataFields.Status == "Active") let res = result.filter(data => data.workflowInstanceDataFields.Status == "Active")
res = res.reverse() res = res.reverse()
res.forEach(element => { res.forEach(element => {
let date = new Date(element.taskStartDate); let date = new Date(element.taskStartDate);
date.setMonth(date.getMonth() + 1); date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
let task = { let task = {
"SerialNumber": element.serialNumber, "SerialNumber": element.serialNumber,
"Folio": element.workflowInstanceDataFields.Subject, "Folio": element.workflowInstanceDataFields.Subject,
"Senders": element.workflowInstanceDataFields.Sender, "Senders": element.workflowInstanceDataFields.Sender,
@@ -169,98 +191,80 @@ export class PedidosPage implements OnInit {
"DocId": element.workflowInstanceDataFields.DocIdDiferimento, "DocId": element.workflowInstanceDataFields.DocIdDiferimento,
"WorkflowName": element.workflowDisplayName, "WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName, "activityInstanceName": element.activityInstanceName,
} }
if(element.workflowInstanceDataFields.Status == "Active") {
this.deferimentoList.push(task);
}
if (element.workflowInstanceDataFields.Status == "Active") {
this.deferimentoList.push(task);
}
});
}); });
this.sqliteservice.addProcess(this.deferimentoList); this.sqliteservice.addProcess(this.deferimentoList);
this.listToPresentdeferimentoList = this.sortService.sortArrayISODate(this.deferimentoList); this.listToPresentdeferimentoList = this.sortService.sortArrayISODate(this.deferimentoList);
}
}); }, (error) => {
} this.getFromDb()
})
} }
getFromDb() { getFromDb() {
if(synchro.connected === true) {
this.LoadList()
this.router.events.forEach((event) => { let parecerlist = [];
if(event instanceof NavigationStart && '/home/gabinete-digital/pedidos?parecer=true'.startsWith(event.url) || let deferimentolist = []
event instanceof NavigationStart && '/home/gabinete-digital/pedidos?deferimento=true'.startsWith(event.url) this.sqliteservice.getprocessByworkflowpedido("Pedido de Parecer", "Pedido de Parecer do Presidente").then((process: any[]) => {
) {
if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { process.forEach((element) => {
this.refreshing() if (JSON.parse(element.workflowInstanceDataFields).Status == "Active") {
} else { let date = new Date(element.taskStartDate);
this.LoadList()
}
}
});
}
if(synchro.connected === false) {
let parecerlist = [];
let deferimentolist = []
this.sqliteservice.getprocessByworkflowpedido("Pedido de Parecer", "Pedido de Parecer do Presidente").then((process: any[]) => {
process.forEach((element) => {
if(JSON.parse(element.workflowInstanceDataFields).Status == "Active") {
let date = new Date(element.taskStartDate);
date.setMonth(date.getMonth() + 1); date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
let task = { let task = {
"SerialNumber": element.serialNumber, "SerialNumber": element.serialNumber,
"Folio": JSON.parse(element.workflowInstanceDataFields).Subject, "Folio": JSON.parse(element.workflowInstanceDataFields).Subject,
"Senders": JSON.parse(element.workflowInstanceDataFields).Sender, "Senders": JSON.parse(element.workflowInstanceDataFields).Sender,
"CreateDate": taskDate, "CreateDate": taskDate,
"DocumentURL": JSON.parse(element.workflowInstanceDataFields).ViewerRequest, "DocumentURL": JSON.parse(element.workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(element.workflowInstanceDataFields).Remetente, "Remetente": JSON.parse(element.workflowInstanceDataFields).Remetente,
"DocumentsQty": element.totalDocuments, "DocumentsQty": element.totalDocuments,
"DocId": JSON.parse(element.workflowInstanceDataFields).DocIdDiferimento, "DocId": JSON.parse(element.workflowInstanceDataFields).DocIdDiferimento,
"WorkflowName": element.workflowDisplayName, "WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName, "activityInstanceName": element.activityInstanceName,
} }
parecerlist.push(task) parecerlist.push(task)
} }
})
this.listToPresentparecerList = this.sortService.sortArrayISODate(parecerlist);
console.log('parecer',process)
}) })
this.listToPresentparecerList = this.sortService.sortArrayISODate(parecerlist);
console.log('parecer', process)
})
this.sqliteservice.getprocessByworkflow("Pedido de Deferimento").then((process: any[]) => { this.sqliteservice.getprocessByworkflow("Pedido de Deferimento").then((process: any[]) => {
process.forEach((element) => { process.forEach((element) => {
if(JSON.parse(element.workflowInstanceDataFields).Status == "Active") { if (JSON.parse(element.workflowInstanceDataFields).Status == "Active") {
let date = new Date(element.taskStartDate); let date = new Date(element.taskStartDate);
date.setMonth(date.getMonth() + 1); date.setMonth(date.getMonth() + 1);
let taskDate = date.getFullYear()+"-"+ date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
let task = { let task = {
"SerialNumber": element.serialNumber, "SerialNumber": element.serialNumber,
"Folio": JSON.parse(element.workflowInstanceDataFields).Subject, "Folio": JSON.parse(element.workflowInstanceDataFields).Subject,
"Senders": JSON.parse(element.workflowInstanceDataFields).Sender, "Senders": JSON.parse(element.workflowInstanceDataFields).Sender,
"CreateDate": taskDate, "CreateDate": taskDate,
"DocumentURL": JSON.parse(element.workflowInstanceDataFields).ViewerRequest, "DocumentURL": JSON.parse(element.workflowInstanceDataFields).ViewerRequest,
"Remetente": JSON.parse(element.workflowInstanceDataFields).Remetente, "Remetente": JSON.parse(element.workflowInstanceDataFields).Remetente,
"DocumentsQty": element.totalDocuments, "DocumentsQty": element.totalDocuments,
"DocId": JSON.parse(element.workflowInstanceDataFields).DocIdDiferimento, "DocId": JSON.parse(element.workflowInstanceDataFields).DocIdDiferimento,
"WorkflowName": element.workflowDisplayName, "WorkflowName": element.workflowDisplayName,
"activityInstanceName": element.activityInstanceName, "activityInstanceName": element.activityInstanceName,
}
deferimentolist.push(task)
} }
}) deferimentolist.push(task)
this.listToPresentdeferimentoList = this.sortService.sortArrayISODate(deferimentolist); }
console.log('deferimento',process)
}) })
this.listToPresentdeferimentoList = this.sortService.sortArrayISODate(deferimentolist);
} console.log('deferimento', process)
})
} }
segmentChanged(ev: any) { segmentChanged(ev: any) {
@@ -11,7 +11,7 @@ import { AuthService } from 'src/app/services/auth.service';
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe'; import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
import { SqliteService } from 'src/app/services/sqlite.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 { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { SortService } from 'src/app/services/functions/sort.service'; import { SortService } from 'src/app/services/functions/sort.service';
@@ -37,8 +37,6 @@ export class PendentesPage implements OnInit {
customTaskPipe = new CustomTaskPipe() customTaskPipe = new CustomTaskPipe()
listToPresent = []; listToPresent = [];
synch = synchro
constructor( constructor(
private processes: ProcessesService, private processes: ProcessesService,
private alertService: AlertService, private alertService: AlertService,
@@ -47,6 +45,7 @@ export class PendentesPage implements OnInit {
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private platform: Platform, private platform: Platform,
private backgroundservices: BackgroundService,
private sortService: SortService, private sortService: SortService,
) { ) {
this.loggeduser = authService.ValidatedUser; this.loggeduser = authService.ValidatedUser;
@@ -56,7 +55,24 @@ export class PendentesPage implements OnInit {
ngOnInit() { ngOnInit() {
//Inicializar segment //Inicializar segment
this.segment = "despachos"; 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 NavigationEnd && event.url.startsWith(pathname)) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
this.refreshing()
} else {
this.LoadList()
}
}
});
this.backgroundservices.registerBackService('Online', () => {
this.LoadList();
});
} }
@@ -74,69 +90,58 @@ export class PendentesPage implements OnInit {
async LoadList() { async LoadList() {
this.skeletonLoader = true; this.processes.GetPendingTasks(false).subscribe(async res => {
this.skeletonLoader = true;
let pendentes = await this.processes.GetPendingTasks(false).toPromise(); let pendentes = await this.processes.GetPendingTasks(false).toPromise();
let pendentesList = []; let pendentesList = [];
pendentes.forEach(element => { pendentes.forEach(element => {
let task: customTask = this.customTaskPipe.transform(element); let task: customTask = this.customTaskPipe.transform(element);
pendentesList.push(task); pendentesList.push(task);
}); });
pendentesList = removeDuplicate(pendentesList) pendentesList = removeDuplicate(pendentesList)
pendentesList = this.sortService.sortArrayISODate(pendentesList); pendentesList = this.sortService.sortArrayISODate(pendentesList);
this.listToPresent = pendentesList; this.listToPresent = pendentesList;
this.skeletonLoader = false; this.skeletonLoader = false;
}, (error) => {
if(error.status == 0){
this.getFromDb();
}
})
} }
getFromDb() { getFromDb() {
if (synchro.connected === true) { this.platform.ready().then(() => {
const location = window.location this.sqliteservice.getAllProcess().then((process: any[]) => {
const pathname = location.pathname + location.search var pendingList = []
console.log('Pendentes off off',process )
process.forEach(element => {
var workflow = JSON.parse(element.workflowInstanceDataFields);
if (workflow.Status === "Pending") {
let task = {
"CreateDate": new Date(element.taskStartDate),
"DocumentsQty": element.totalDocuments,
"FolderID": workflow.FolderID,
"Folio": workflow.Subject,
"Senders": workflow.Sender,
"SerialNumber": element.serialNumber,
"Status": workflow.Status,
"WorkflowName": element.workflowDisplayName
this.LoadList()
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url.startsWith(pathname)) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
this.refreshing()
} else {
this.LoadList()
}
}
});
}
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => {
this.sqliteservice.getAllProcess().then((process: any[]) => {
var pendingList = []
process.forEach(element => {
var workflow = JSON.parse(element.workflowInstanceDataFields);
if (workflow.Status === "Pending") {
let task = {
"CreateDate": new Date(element.taskStartDate),
"DocumentsQty": element.totalDocuments,
"FolderID": workflow.FolderID,
"Folio": workflow.Subject,
"Senders": workflow.Sender,
"SerialNumber": element.serialNumber,
"Status": workflow.Status,
"WorkflowName": element.workflowDisplayName
}
pendingList.push(task)
} }
}); pendingList.push(task)
}
});
pendingList = pendingList; pendingList = pendingList;
this.listToPresent = pendingList; this.listToPresent = pendingList;
console.log('pendentes', pendingList) console.log('pendentes', pendingList)
})
}) })
}) })
} }
+1
View File
@@ -108,6 +108,7 @@ export class LoginPage implements OnInit {
this.changeProfileService.run() this.changeProfileService.run()
await this.authService.loginChat(this.userattempt); await this.authService.loginChat(this.userattempt);
this.getToken();
this.router.navigate(['/pin']); this.router.navigate(['/pin']);
} }
@@ -7,7 +7,7 @@ import { ImageModalPage } from '../gallery/image-modal/image-modal.page';
import { NewPublicationPage } from '../new-publication/new-publication.page'; import { NewPublicationPage } from '../new-publication/new-publication.page';
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { SqliteService } from 'src/app/services/sqlite.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({ @Component({
@@ -28,7 +28,8 @@ export class PublicationDetailPage implements OnInit {
private animationController: AnimationController, private animationController: AnimationController,
private toastService: ToastService, private toastService: ToastService,
private location: Location, private location: Location,
private sqliteservice: SqliteService ) { private sqliteservice: SqliteService,
private backgroundservice: BackgroundService ) {
this.publicationId = this.navParams.get('publicationId'); this.publicationId = this.navParams.get('publicationId');
/* this.folderId = this.navParams.get('folderIdId'); */ /* this.folderId = this.navParams.get('folderIdId'); */
@@ -81,11 +82,7 @@ export class PublicationDetailPage implements OnInit {
} }
getFromDB() { getFromDB() {
if(synchro.connected === true) {
} else {
}
} }
close() { close() {
+42 -38
View File
@@ -14,7 +14,7 @@ import { ToastService } from 'src/app/services/toast.service';
import { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service'; import { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service';
import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.service'; import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.service';
import { SqliteService } from 'src/app/services/sqlite.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({ @Component({
selector: 'app-publications', selector: 'app-publications',
@@ -64,14 +64,28 @@ export class PublicationsPage implements OnInit {
private animationController: AnimationController, private animationController: AnimationController,
private publications: PublicationsService, private publications: PublicationsService,
private toastService: ToastService, private toastService: ToastService,
private sqliteservice: SqliteService private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) { ) {
this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
} }
ngOnInit() { ngOnInit() {
this.getFromDB();
const pathname = window.location.pathname
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == pathname) {
this.getActions();
}
});
this.hideRefreshButton();
this.backgroundservice.registerBackService('Online', () => {
this.getActions();
})
} }
hideRefreshButton() { hideRefreshButton() {
@@ -153,50 +167,40 @@ export class PublicationsPage implements OnInit {
}); });
}, (error) => {
this.getFromDB();
}); });
} }
getFromDB() { getFromDB() {
if (synchro.connected === true) { this.sqliteservice.getAllActions().then((actions: any[]) => {
const pathname = window.location.pathname
this.router.events.forEach((event) => { console.log('offline publi', actions)
if (event instanceof NavigationEnd && event.url == pathname) {
this.getActions(); this.publicationsEventFolderList = new Array();
this.publicationsTravelFolderList = new Array();
actions.forEach(data => {
let folder: PublicationFolder = {
ProcessId: data.ProcessId,
Description: data.Description,
Detail: data.Detail,
DateBegin: data.DateBegin,
DateEnd: data.DateEnd,
ActionType: data.ActionType,
} }
if (data.ActionType == "Evento") {
this.publicationsEventFolderList.push(folder);
}
else {
this.publicationsTravelFolderList.push(folder);
}
this.showLoader = false;
}); });
this.hideRefreshButton(); })
} else {
this.sqliteservice.getAllActions().then((actions: any[]) => {
console.log('offline publi', actions)
this.publicationsEventFolderList = new Array();
this.publicationsTravelFolderList = new Array();
actions.forEach(data => {
let folder: PublicationFolder = {
ProcessId: data.ProcessId,
Description: data.Description,
Detail: data.Detail,
DateBegin: data.DateBegin,
DateEnd: data.DateEnd,
ActionType: data.ActionType,
}
if (data.ActionType == "Evento") {
this.publicationsEventFolderList.push(folder);
}
else {
this.publicationsTravelFolderList.push(folder);
}
this.showLoader = false;
});
})
}
} }
async editAction(folderId?: string) { async editAction(folderId?: string) {
@@ -11,7 +11,7 @@ import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-f
import { NewPublicationPage } from '../new-publication/new-publication.page'; import { NewPublicationPage } from '../new-publication/new-publication.page';
import { PublicationDetailPage } from './publication-detail/publication-detail.page'; import { PublicationDetailPage } from './publication-detail/publication-detail.page';
import { SqliteService } from 'src/app/services/sqlite.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({ @Component({
selector: 'app-view-publications', selector: 'app-view-publications',
@@ -42,7 +42,8 @@ export class ViewPublicationsPage implements OnInit {
private publications: PublicationsService, private publications: PublicationsService,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private router: Router, private router: Router,
private sqliteservice: SqliteService) { private sqliteservice: SqliteService,
private backgroundservice: BackgroundService) {
this.item = new PublicationFolder(); this.item = new PublicationFolder();
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
@@ -63,7 +64,16 @@ export class ViewPublicationsPage implements OnInit {
this.folderId = this.folderId['ProcessId'] this.folderId = this.folderId['ProcessId']
} }
this.getFromDB(); this.getPublicationDetail();
setTimeout(() => {
this.getPublications();
}, 5000);
this.backgroundservice.registerBackService('Online',() => {
this.getPublicationDetail();
this.getPublications();
})
} }
@@ -129,6 +139,9 @@ export class ViewPublicationsPage implements OnInit {
this.showLoader = false; this.showLoader = false;
}, },
(error) => { (error) => {
if(error.status == '0') {
this.getFromDB();
}
if (error.status == '404') { if (error.status == '404') {
this.error = 'Sem publicações disponíveis!'; this.error = 'Sem publicações disponíveis!';
this.publicationList = []; this.publicationList = [];
@@ -142,47 +155,38 @@ export class ViewPublicationsPage implements OnInit {
} }
getFromDB() { getFromDB() {
if (synchro.connected === true) {
this.getPublicationDetail();
setTimeout(() => {
this.getPublications();
}, 5000);
} else { this.sqliteservice.getActionById(this.folderId).then((publications) => {
console.log('publications', publications)
let item = {
ActionType: publications[0].ActionType,
DateBegin: publications[0].DateBegin,
DateEnd: publications[0].DateEnd,
Description: publications[0].Description,
Detail: publications[0].Detail,
ProcessId: publications[0].ProcessId
}
this.publicationDitails = item;
this.sqliteservice.getActionById(this.folderId).then((publications) => { let publicationArray = [];
console.log('publications', publications) JSON.parse(publications[0].publications).forEach(element => {
let item = { let publicationlis = {
ActionType: publications[0].ActionType, DateIndex: element.DateIndex,
DateBegin: publications[0].DateBegin, DatePublication: element.DatePublication,
DateEnd: publications[0].DateEnd, DocumentId: element.DocumentId,
Description: publications[0].Description, FileBase64: element.FileBase64,
Detail: publications[0].Detail, FileExtension: element.FileExtension,
ProcessId: publications[0].ProcessId Message: element.Message,
OrganicEntityId: element.OrganicEntityId,
OriginalFileName: element.OriginalFileName,
ProcessId: element.ProcessId
} }
this.publicationDitails = item; publicationArray.push(publicationlis);
let publicationArray = []; });
JSON.parse(publications[0].publications).forEach(element => {
let publicationlis = {
DateIndex: element.DateIndex,
DatePublication: element.DatePublication,
DocumentId: element.DocumentId,
FileBase64: element.FileBase64,
FileExtension: element.FileExtension,
Message: element.Message,
OrganicEntityId: element.OrganicEntityId,
OriginalFileName: element.OriginalFileName,
ProcessId: element.ProcessId
}
publicationArray.push(publicationlis);
});
this.getpublication = publicationArray; this.getpublication = publicationArray;
}) })
}
} }
async AddPublication(publicationType: any, folderId: any) { async AddPublication(publicationType: any, folderId: any) {
+24
View File
@@ -5,6 +5,12 @@ import { Injectable } from '@angular/core';
}) })
export class BackgroundService { export class BackgroundService {
callBacks: {
type: 'Offline' | 'Online' | 'Notification',
object?: string
funx: Function
}[] = []
constructor() { } constructor() { }
online() { online() {
@@ -13,6 +19,11 @@ export class BackgroundService {
document.body.style.setProperty(`--color3`, "#0782C9"); document.body.style.setProperty(`--color3`, "#0782C9");
document.body.style.setProperty(`--color4`, "#0782c9f0"); document.body.style.setProperty(`--color4`, "#0782c9f0");
document.body.style.setProperty(`--color5`, "#45BAFF"); document.body.style.setProperty(`--color5`, "#45BAFF");
this.callBacks.forEach((e) => {
if (e.type == 'Online') {
e.funx()
}
})
} }
offline() { offline() {
@@ -21,5 +32,18 @@ export class BackgroundService {
document.body.style.setProperty(`--color3`, "#ffb703"); document.body.style.setProperty(`--color3`, "#ffb703");
document.body.style.setProperty(`--color4`, "#ffb703"); document.body.style.setProperty(`--color4`, "#ffb703");
document.body.style.setProperty(`--color5`, "#ffb703"); document.body.style.setProperty(`--color5`, "#ffb703");
this.callBacks.forEach((e) => {
if (e.type == 'Offline') {
e.funx()
}
})
}
registerBackService(type: 'Offline' | 'Online' | 'Notification', funx: Function, object = '') {
this.callBacks.push({
type,
funx,
object
})
} }
} }
+83 -76
View File
@@ -1,12 +1,16 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Event, EventToApproveEdit } from '../models/event.model'; import { Event, EventToApproveEdit } from '../models/event.model';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs'; import { Observable, from } from 'rxjs';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service'; import { AuthService } from '../services/auth.service';
import { UserSession } from '../models/user.model'; import { UserSession } from '../models/user.model';
import { EventList } from '../models/agenda/AgendaEventList'; import { EventList } from '../models/agenda/AgendaEventList';
import { ChangeProfileService } from './change-profile.service'; import { ChangeProfileService } from './change-profile.service';
import { OfflineManagerService } from 'src/app/services/offline-manager.service';
import { catchError } from "rxjs/operators";
import { Storage } from '@ionic/storage';
import { BackgroundService } from 'src/app/services/background.service';
@Injectable({ @Injectable({
@@ -28,10 +32,12 @@ export class EventsService {
headersSharedPessoal: HttpHeaders; headersSharedPessoal: HttpHeaders;
constructor( constructor(
private http: HttpClient, private http: HttpClient,
public user: AuthService, public user: AuthService,
private changeProfileService: ChangeProfileService) private changeProfileService: ChangeProfileService,
{ private offlinemanager: OfflineManagerService,
private storage: Storage,
private backgroundservice: BackgroundService) {
this.loggeduser = this.user.ValidatedUser; this.loggeduser = this.user.ValidatedUser;
@@ -44,9 +50,9 @@ export class EventsService {
this.headersSharedOficial = new HttpHeaders(); this.headersSharedOficial = new HttpHeaders();
this.headersSharedPessoal = new HttpHeaders(); this.headersSharedPessoal = new HttpHeaders();
this.setHeader() this.setHeader()
this.changeProfileService.registerCallback(()=>{ this.changeProfileService.registerCallback(() => {
this.loggeduser = this.user.ValidatedUser; this.loggeduser = this.user.ValidatedUser;
this.setHeader() this.setHeader()
}) })
@@ -55,16 +61,16 @@ export class EventsService {
setHeader() { setHeader() {
if(this.loggeduser){ if (this.loggeduser) {
if(this.loggeduser.Profile == 'MDGPR') { if (this.loggeduser.Profile == 'MDGPR') {
this.loggeduser.OwnerCalendars.forEach(calendar => { this.loggeduser.OwnerCalendars.forEach(calendar => {
if(calendar.CalendarName == 'Oficial') { if (calendar.CalendarName == 'Oficial') {
this.headersMdOficial = this.headersMdOficial.set('Authorization', this.loggeduser.BasicAuthKey); this.headersMdOficial = this.headersMdOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersMdOficial = this.headersMdOficial.set('CalendarId', calendar.CalendarId); this.headersMdOficial = this.headersMdOficial.set('CalendarId', calendar.CalendarId);
this.headersMdOficial = this.headersMdOficial.set('CalendarRoleId', calendar.CalendarRoleId); this.headersMdOficial = this.headersMdOficial.set('CalendarRoleId', calendar.CalendarRoleId);
} }
else if(calendar.CalendarName == 'Pessoal') { else if (calendar.CalendarName == 'Pessoal') {
this.headersMdPessoal = this.headersMdPessoal.set('Authorization', this.loggeduser.BasicAuthKey); this.headersMdPessoal = this.headersMdPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersMdPessoal = this.headersMdPessoal.set('CalendarId', calendar.CalendarId); this.headersMdPessoal = this.headersMdPessoal.set('CalendarId', calendar.CalendarId);
this.headersMdPessoal = this.headersMdPessoal.set('CalendarRoleId', calendar.CalendarRoleId); this.headersMdPessoal = this.headersMdPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
@@ -73,27 +79,27 @@ export class EventsService {
}); });
this.loggeduser.SharedCalendars.forEach(sharedCalendar => { this.loggeduser.SharedCalendars.forEach(sharedCalendar => {
if(sharedCalendar.CalendarName == 'Oficial') { if (sharedCalendar.CalendarName == 'Oficial') {
this.headersSharedOficial = this.headersSharedOficial.set('Authorization', this.loggeduser.BasicAuthKey); this.headersSharedOficial = this.headersSharedOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', sharedCalendar.CalendarId); this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', sharedCalendar.CalendarId);
this.headersSharedOficial = this.headersSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId); this.headersSharedOficial = this.headersSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
} }
else if(sharedCalendar.CalendarName == 'Pessoal') { else if (sharedCalendar.CalendarName == 'Pessoal') {
this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', this.loggeduser.BasicAuthKey); this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', sharedCalendar.CalendarId); this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', sharedCalendar.CalendarId);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId); this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
} }
}); });
} }
else if(this.loggeduser.Profile == 'PR') { else if (this.loggeduser.Profile == 'PR') {
this.loggeduser.OwnerCalendars.forEach(calendar =>{ this.loggeduser.OwnerCalendars.forEach(calendar => {
if(calendar.CalendarName == 'Oficial'){ if (calendar.CalendarName == 'Oficial') {
this.headersPrOficial = this.headersPrOficial.set('Authorization', this.loggeduser.BasicAuthKey); this.headersPrOficial = this.headersPrOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersPrOficial = this.headersPrOficial.set('CalendarId', calendar.CalendarId); this.headersPrOficial = this.headersPrOficial.set('CalendarId', calendar.CalendarId);
this.headersPrOficial = this.headersPrOficial.set('CalendarRoleId', calendar.CalendarRoleId); this.headersPrOficial = this.headersPrOficial.set('CalendarRoleId', calendar.CalendarRoleId);
} }
else if(calendar.CalendarName == 'Pessoal') { else if (calendar.CalendarName == 'Pessoal') {
this.headersPrPessoal = this.headersPrPessoal.set('Authorization', this.loggeduser.BasicAuthKey); this.headersPrPessoal = this.headersPrPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersPrPessoal = this.headersPrPessoal.set('CalendarId', calendar.CalendarId); this.headersPrPessoal = this.headersPrPessoal.set('CalendarId', calendar.CalendarId);
this.headersPrPessoal = this.headersPrPessoal.set('CalendarRoleId', calendar.CalendarRoleId); this.headersPrPessoal = this.headersPrPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
@@ -122,9 +128,9 @@ export class EventsService {
} */ } */
getAllPrOficialEvents(startdate:string, enddate:string): Observable<EventList[]>{ getAllPrOficialEvents(startdate: string, enddate: string): Observable<EventList[]> {
let geturl = environment.apiURL + 'calendar/pr'; let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/') geturl = geturl.replace('/V4/', '/V5/')
let params = new HttpParams(); let params = new HttpParams();
@@ -138,9 +144,9 @@ export class EventsService {
return this.http.get<EventList[]>(`${geturl}`, options); return this.http.get<EventList[]>(`${geturl}`, options);
} }
getAllPrPessoalEvents(startdate:string, enddate:string): Observable<EventList[]>{ getAllPrPessoalEvents(startdate: string, enddate: string): Observable<EventList[]> {
let geturl = environment.apiURL + 'calendar/pr'; let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/') geturl = geturl.replace('/V4/', '/V5/')
let params = new HttpParams(); let params = new HttpParams();
@@ -154,17 +160,17 @@ export class EventsService {
return this.http.get<EventList[]>(`${geturl}`, options); return this.http.get<EventList[]>(`${geturl}`, options);
} }
async getAllPrEvents(startdate:string, enddate:string): Promise<EventList[]>{ async getAllPrEvents(startdate: string, enddate: string): Promise<EventList[]> {
let prO = await this.getAllPrOficialEvents(startdate, enddate).toPromise(); let prO = await this.getAllPrOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllPrPessoalEvents(startdate, enddate).toPromise(); let prP = await this.getAllPrPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP); const resFinal = prO.concat(prP);
return new Promise(resolve =>{ return new Promise(resolve => {
return resolve(resFinal) return resolve(resFinal)
}) })
} }
getAllMdOficialEvents(startdate:string, enddate:string): Observable<EventList[]>{ getAllMdOficialEvents(startdate: string, enddate: string): Observable<EventList[]> {
let geturl = environment.apiURL + 'calendar/md'; let geturl = environment.apiURL + 'calendar/md';
let params = new HttpParams(); let params = new HttpParams();
@@ -178,7 +184,7 @@ export class EventsService {
return this.http.get<EventList[]>(`${geturl}`, options); return this.http.get<EventList[]>(`${geturl}`, options);
} }
getAllMdPessoalEvents(startdate:string, enddate:string): any{ getAllMdPessoalEvents(startdate: string, enddate: string): any {
let geturl = environment.apiURL + 'calendar/md'; let geturl = environment.apiURL + 'calendar/md';
let params = new HttpParams(); let params = new HttpParams();
@@ -193,30 +199,30 @@ export class EventsService {
return this.http.get<any>(`${geturl}`, options) return this.http.get<any>(`${geturl}`, options)
} }
async getAllMdEvents(startdate:string, enddate:string) { async getAllMdEvents(startdate: string, enddate: string) {
let prO = await this.getAllMdOficialEvents(startdate, enddate).toPromise(); let prO = await this.getAllMdOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllMdPessoalEvents(startdate, enddate).toPromise(); let prP = await this.getAllMdPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP); const resFinal = prO.concat(prP);
return new Promise(resolve =>{ return new Promise(resolve => {
return resolve(resFinal) return resolve(resFinal)
}); });
} }
async getAllSharedEvents(startdate:string, enddate:string) { async getAllSharedEvents(startdate: string, enddate: string) {
let prO = await this.getAllSharedOficialEvents(startdate, enddate).toPromise(); let prO = await this.getAllSharedOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllSharedPessoalEvents(startdate, enddate).toPromise(); let prP = await this.getAllSharedPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP); const resFinal = prO.concat(prP);
return new Promise(resolve =>{ return new Promise(resolve => {
return resolve(resFinal) return resolve(resFinal)
}); });
} }
getAllSharedOficialEvents(startdate:string, enddate:string): Observable<Event[]>{ getAllSharedOficialEvents(startdate: string, enddate: string): Observable<Event[]> {
let geturl = environment.apiURL + 'calendar/pr'; let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/') geturl = geturl.replace('/V4/', '/V5/')
let params = new HttpParams(); let params = new HttpParams();
@@ -232,9 +238,9 @@ export class EventsService {
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<Event[]>(`${geturl}`, options);
} }
getAllSharedPessoalEvents(startdate:string, enddate:string): Observable<Event[]>{ getAllSharedPessoalEvents(startdate: string, enddate: string): Observable<Event[]> {
let geturl = environment.apiURL + 'calendar/pr'; let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/') geturl = geturl.replace('/V4/', '/V5/')
let params = new HttpParams(); let params = new HttpParams();
@@ -249,7 +255,7 @@ export class EventsService {
} }
getRecurrenceTypes(): any{ getRecurrenceTypes(): any {
const geturl = environment.apiURL + 'Calendar/RecurrenceTypes'; const geturl = environment.apiURL + 'Calendar/RecurrenceTypes';
let options = { let options = {
headers: this.headers, headers: this.headers,
@@ -258,7 +264,7 @@ export class EventsService {
} }
getEvents(calendarname:string, startdate:string, enddate:string): Observable<Event[]>{ getEvents(calendarname: string, startdate: string, enddate: string): Observable<Event[]> {
const geturl = environment.apiURL + 'calendar/GetEvents'; const geturl = environment.apiURL + 'calendar/GetEvents';
let params = new HttpParams(); let params = new HttpParams();
@@ -273,7 +279,7 @@ export class EventsService {
return this.http.get<Event[]>(`${geturl}`, options); return this.http.get<Event[]>(`${geturl}`, options);
} }
getEvent(eventid: string): Observable<Event>{ getEvent(eventid: string): Observable<Event> {
let geturl = environment.apiURL + 'calendar/GetEvent'; let geturl = environment.apiURL + 'calendar/GetEvent';
let params = new HttpParams(); let params = new HttpParams();
@@ -287,8 +293,7 @@ export class EventsService {
return this.http.get<Event>(`${geturl}`, options); return this.http.get<Event>(`${geturl}`, options);
} }
putEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number, sharedagenda:string): Observable<Event> putEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number, sharedagenda: string): Observable<Event> {
{
const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PutEvent'); const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PutEvent');
let params = new HttpParams(); let params = new HttpParams();
@@ -304,32 +309,32 @@ export class EventsService {
return this.http.put<Event>(`${puturl}`, event, options) return this.http.put<Event>(`${puturl}`, event, options)
} }
editEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number): Observable<Event> editEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number): Observable<Event> {
{ let arrayReq = [];
arrayReq.push(event);
const puturl = environment.apiURL + 'calendar/PutEvent'; const puturl = environment.apiURL + 'calendar/PutEvent';
let params = new HttpParams(); let params = new HttpParams();
params = params.set("conflictResolutionMode", conflictResolutionMode.toString()); params = params.set("conflictResolutionMode", conflictResolutionMode.toString());
params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString()); params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString());
params.set('CalendarId', event.CalendarId) params.set('CalendarId', event.CalendarId)
params.set('CalendarName', event.CalendarName) params.set('CalendarName', event.CalendarName)
this.headers['CalendarId'] = event.CalendarId this.headers['CalendarId'] = event.CalendarId
this.headers['CalendarName'] = event.CalendarName this.headers['CalendarName'] = event.CalendarName
if(event.CalendarName == 'Oficial'){ if (event.CalendarName == 'Oficial') {
if(this.loggeduser.Profile == 'MDGPR'){ if (this.loggeduser.Profile == 'MDGPR') {
this.headers = this.headersMdOficial; this.headers = this.headersMdOficial;
} }
else if(this.loggeduser.Profile == 'PR'){ else if (this.loggeduser.Profile == 'PR') {
this.headers = this.headersPrOficial; this.headers = this.headersPrOficial;
} }
} }
else{ else {
if(this.loggeduser.Profile == 'MDGPR'){ if (this.loggeduser.Profile == 'MDGPR') {
this.headers = this.headersMdPessoal; this.headers = this.headersMdPessoal;
} }
else if(this.loggeduser.Profile == 'PR'){ else if (this.loggeduser.Profile == 'PR') {
this.headers = this.headersPrPessoal; this.headers = this.headersPrPessoal;
} }
} }
@@ -339,10 +344,15 @@ export class EventsService {
params: params params: params
}; };
return this.http.put<Event>(`${puturl}`, event, options) return this.http.put<Event>(`${puturl}`, event, options).pipe(
catchError(err => {
this.offlinemanager.storeRequest(puturl, 'PUT', arrayReq);
throw new Error(err);
})
)
} }
changeAgenda(body:any){ changeAgenda(body: any) {
const puturl = environment.apiURL + 'Calendar/MoveEvent'; const puturl = environment.apiURL + 'Calendar/MoveEvent';
let options = { let options = {
headers: this.headers, headers: this.headers,
@@ -365,14 +375,13 @@ export class EventsService {
return this.http.post<Event>(`${puturl}`, event, options) return this.http.post<Event>(`${puturl}`, event, options)
} */ } */
postEventMd(event:Event, calendarName:string) postEventMd(event: Event, calendarName: string) {
{
const puturl = environment.apiURL + 'calendar/md'; const puturl = environment.apiURL + 'calendar/md';
let params = new HttpParams(); let params = new HttpParams();
params = params.set("CalendarName", calendarName); params = params.set("CalendarName", calendarName);
let options:any; let options: any;
switch (calendarName) { switch (calendarName) {
case 'Oficial': case 'Oficial':
console.log(calendarName); console.log(calendarName);
@@ -394,14 +403,13 @@ export class EventsService {
return this.http.post<string>(`${puturl}`, event, options) return this.http.post<string>(`${puturl}`, event, options)
} }
postEventPr(event:Event, calendarName:string) postEventPr(event: Event, calendarName: string) {
{
const puturl = environment.apiURL + 'calendar/pr'; const puturl = environment.apiURL + 'calendar/pr';
let params = new HttpParams(); let params = new HttpParams();
params = params.set("CalendarName", calendarName); params = params.set("CalendarName", calendarName);
let options:any; let options: any;
switch (calendarName) { switch (calendarName) {
case 'Oficial': case 'Oficial':
console.log(calendarName); console.log(calendarName);
@@ -423,8 +431,7 @@ export class EventsService {
return this.http.post<string>(`${puturl}`, event, options) return this.http.post<string>(`${puturl}`, event, options)
} }
deleteEvent(eventid:string, eventDeleteType:number, calendarName:string) deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) {
{
const puturl = environment.apiURL + 'calendar/DeleteEvent'; const puturl = environment.apiURL + 'calendar/DeleteEvent';
let params = new HttpParams(); let params = new HttpParams();
@@ -436,13 +443,13 @@ export class EventsService {
switch (this.loggeduser.Profile) { switch (this.loggeduser.Profile) {
case 'MDGPR': case 'MDGPR':
if(calendarName == 'Pessoal'){ if (calendarName == 'Pessoal') {
options = { options = {
headers: this.headersMdPessoal, headers: this.headersMdPessoal,
params: params params: params
}; };
} }
else if(calendarName == 'Oficial'){ else if (calendarName == 'Oficial') {
options = { options = {
headers: this.headersMdOficial, headers: this.headersMdOficial,
params: params params: params
@@ -450,13 +457,13 @@ export class EventsService {
} }
break; break;
case 'PR': case 'PR':
if(calendarName == 'Pessoal'){ if (calendarName == 'Pessoal') {
options = { options = {
headers: this.headersPrPessoal, headers: this.headersPrPessoal,
params: params params: params
}; };
} }
else if(calendarName == 'Oficial'){ else if (calendarName == 'Oficial') {
options = { options = {
headers: this.headersPrOficial, headers: this.headersPrOficial,
params: params params: params
@@ -467,8 +474,8 @@ export class EventsService {
return this.http.delete(`${puturl}`, options) return this.http.delete(`${puturl}`, options)
} }
postExpedientEvent(docId:any, body:any, sharedagenda:string, serialNumber:any, applicationID:any){ postExpedientEvent(docId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) {
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente')+'/event'; const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/event';
let params = new HttpParams(); let params = new HttpParams();
let options; let options;
@@ -478,13 +485,13 @@ export class EventsService {
switch (this.loggeduser.Profile) { switch (this.loggeduser.Profile) {
case 'MDGPR': case 'MDGPR':
if(body.CalendarName == 'Pessoal'){ if (body.CalendarName == 'Pessoal') {
options = { options = {
headers: this.headersMdPessoal, headers: this.headersMdPessoal,
params: params params: params
}; };
} }
else if(body.CalendarName == 'Oficial'){ else if (body.CalendarName == 'Oficial') {
options = { options = {
headers: this.headersMdOficial, headers: this.headersMdOficial,
params: params params: params
@@ -492,13 +499,13 @@ export class EventsService {
} }
break; break;
case 'PR': case 'PR':
if(body.CalendarName == 'Pessoal'){ if (body.CalendarName == 'Pessoal') {
options = { options = {
headers: this.headersPrPessoal, headers: this.headersPrPessoal,
params: params params: params
}; };
} }
else if(body.CalendarName == 'Oficial'){ else if (body.CalendarName == 'Oficial') {
options = { options = {
headers: this.headersPrOficial, headers: this.headersPrOficial,
params: params params: params
@@ -508,8 +515,8 @@ export class EventsService {
} }
return this.http.post<any>(`${geturl}`, body, options) return this.http.post<any>(`${geturl}`, body, options)
} }
createTaskEvent(folderId:any, body:any, sharedagenda:string, serialNumber:any, applicationID:any){ createTaskEvent(folderId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) {
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente')+'/dispatch'; const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/dispatch';
let params = new HttpParams(); let params = new HttpParams();
let options; let options;
@@ -519,13 +526,13 @@ export class EventsService {
switch (this.loggeduser.Profile) { switch (this.loggeduser.Profile) {
case 'MDGPR': case 'MDGPR':
if(body.CalendarName == 'Pessoal'){ if (body.CalendarName == 'Pessoal') {
options = { options = {
headers: this.headersMdPessoal, headers: this.headersMdPessoal,
params: params params: params
}; };
} }
else if(body.CalendarName == 'Oficial'){ else if (body.CalendarName == 'Oficial') {
options = { options = {
headers: this.headersMdOficial, headers: this.headersMdOficial,
params: params params: params
@@ -533,20 +540,20 @@ export class EventsService {
} }
break; break;
case 'PR': case 'PR':
if(body.CalendarName == 'Pessoal'){ if (body.CalendarName == 'Pessoal') {
options = { options = {
headers: this.headersPrPessoal, headers: this.headersPrPessoal,
params: params params: params
}; };
} }
else if(body.CalendarName == 'Oficial'){ else if (body.CalendarName == 'Oficial') {
options = { options = {
headers: this.headersPrOficial, headers: this.headersPrOficial,
params: params params: params
}; };
} }
break; break;
} }
return this.http.post<any>(`${geturl}`, body, options) return this.http.post<any>(`${geturl}`, body, options)
} }
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { NetworkConnectionService } from './network-connection.service';
describe('NetworkConnectionService', () => {
let service: NetworkConnectionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(NetworkConnectionService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs'
import { Platform } from '@ionic/angular'
@Injectable({
providedIn: 'root'
})
export class NetworkConnectionService {
online: boolean = true;
constructor(){}
checkOnline() {
window.addEventListener('online', (on) => {
this.online === true;
console.log('Became online');
});
}
checkOffline() {
window.addEventListener('offline', (off) => {
this.online === false;
console.log('Became offline')
});
}
}
+8 -5
View File
@@ -12,7 +12,7 @@ import { ModalController, AlertController, AnimationController, Platform } from
import { NavigationExtras,Router } from '@angular/router'; import { NavigationExtras,Router } from '@angular/router';
import { ToastService } from '../services/toast.service'; import { ToastService } from '../services/toast.service';
import { JsonStore } from './jsonStore.service'; import { JsonStore } from './jsonStore.service';
import { synchro } from './socket/synchro.service'; import { BackgroundService } from './background.service';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { EventTrigger } from '../services/eventTrigger.service'; import { EventTrigger } from '../services/eventTrigger.service';
import { SessionStore } from '../store/session.service'; import { SessionStore } from '../store/session.service';
@@ -44,7 +44,8 @@ export class NotificationsService {
private zone: NgZone, private zone: NgZone,
private activeroute: ActivatedRoute, private activeroute: ActivatedRoute,
private jsonstore: JsonStore, private jsonstore: JsonStore,
private eventtrigger: EventTrigger) { private eventtrigger: EventTrigger,
private backgroundservice: BackgroundService) {
this.storageService.get("Notifications").then((value) => { this.storageService.get("Notifications").then((value) => {
@@ -60,7 +61,7 @@ export class NotificationsService {
const id = uuidv4() const id = uuidv4()
this.callbacks.push({type, funx, id}) this.callbacks.push({type, funx, id})
if(!object.hasOwnProperty('desktop') && object['desktop'] != false) { if(!object.hasOwnProperty('desktop') && object['desktop'] != false) {
synchro.registerCallback('Notification',funx, type) this.backgroundservice.registerBackService('Notification',funx, type)
} }
return id; return id;
@@ -108,7 +109,9 @@ export class NotificationsService {
window['MFPPush'].registerDevice(null, async (successResponse) => { window['MFPPush'].registerDevice(null, async (successResponse) => {
console.log("Successfully registered: " + JSON.stringify(successResponse)); console.log("Successfully registered: " + JSON.stringify(successResponse));
console.log('token: ', successResponse.deviceId) console.log('token: ', successResponse.deviceId)
await this.storageService.store(username, successResponse.deviceId); await this.storageService.store(username, successResponse.deviceId).then((tokennoti) => {
console.log('token store',tokennoti)
});
await this.storageService.get(username).then(value => { await this.storageService.get(username).then(value => {
console.log('STORAGE TOKEN', value) console.log('STORAGE TOKEN', value)
this.storageService.get(AuthConnstants.USER).then(res => { this.storageService.get(AuthConnstants.USER).then(res => {
@@ -176,7 +179,7 @@ export class NotificationsService {
}) })
var data = JSON.parse(message.payload); var data = JSON.parse(message.payload);
synchro.$send(data) //synchro.$send(data)
console.log('data.Service', data.Service); // module console.log('data.Service', data.Service); // module
console.log('data.IdObject', data.IdObject); // Object id console.log('data.IdObject', data.IdObject); // Object id
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { OfflineManagerService } from './offline-manager.service';
describe('OfflineManagerService', () => {
let service: OfflineManagerService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(OfflineManagerService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,94 @@
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
import { Observable, from, of, forkJoin } from 'rxjs';
import { switchMap, finalize } from 'rxjs/operators';
import { HttpClient } from '@angular/common/http';
import { ToastController } from '@ionic/angular';
const STORAGE_REQ_KEY = 'storedreq';
interface StoredRequest {
url: string,
type: string,
data: any,
time: number,
id: string
}
@Injectable({
providedIn: 'root'
})
export class OfflineManagerService {
constructor(
private storage: Storage,
private http: HttpClient,
private toastController: ToastController) { }
checkForEvents(): Observable<any> {
return from(this.storage.get(STORAGE_REQ_KEY)).pipe(
switchMap(storedOperations => {
let storedObj = JSON.parse(storedOperations);
if (storedObj && storedObj.length > 0) {
return this.sendRequests(storedObj).pipe(
finalize(() => {
let toast = this.toastController.create({
message: `Local data succesfully synced to API!`,
duration: 3000,
position: 'bottom'
});
toast.then(toast => toast.present());
this.storage.remove(STORAGE_REQ_KEY);
})
);
} else {
console.log('no local events to sync');
return of(false);
}
})
)
}
storeRequest(url, type, data) {
let toast = this.toastController.create({
message: `Your data is stored locally because you seem to be offline.`,
duration: 3000,
position: 'bottom'
});
toast.then(toast => toast.present());
let action: StoredRequest = {
url: url,
type: type,
data: data,
time: new Date().getTime(),
id: Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)
};
return this.storage.get(STORAGE_REQ_KEY).then(storedOperations => {
let storedObj = JSON.parse(storedOperations);
if (storedObj) {
storedObj.push(action);
} else {
storedObj = [action];
}
// Save old & new local transactions back to Storage
return this.storage.set(STORAGE_REQ_KEY, JSON.stringify(storedObj));
});
}
sendRequests(operations: StoredRequest[]) {
let obs = [];
for (let op of operations) {
console.log('Make one request: ', op);
let oneObs = this.http.request(op.type, op.url, op.data);
obs.push(oneObs);
}
// Send out all local events and return once they are finished
return forkJoin(obs);
}
}
+6 -6
View File
@@ -21,7 +21,7 @@ export interface wss {
providedIn: 'root' providedIn: 'root'
}) })
class SynchroService { class SynchroService {
[x: string]: any; /* [x: string]: any;
private connection!: WebSocket; private connection!: WebSocket;
private id: string = uuidv4(); private id: string = uuidv4();
@@ -86,7 +86,7 @@ class SynchroService {
//if (this._connected === true) { //if (this._connected === true) {
this.BackgroundService.online() //this.BackgroundService.online()
console.log('Online', this._connected) console.log('Online', this._connected)
this.callBacks.forEach((e) => { this.callBacks.forEach((e) => {
if (e.type == 'Online') { if (e.type == 'Online') {
@@ -183,7 +183,7 @@ class SynchroService {
// if (this._connected === false) { // if (this._connected === false) {
this.BackgroundService.offline(); // this.BackgroundService.offline();
console.log('Offline', this._connected) console.log('Offline', this._connected)
this.callBacks.forEach((e) => { this.callBacks.forEach((e) => {
if (e.type == 'Offline') { if (e.type == 'Offline') {
@@ -204,12 +204,12 @@ class SynchroService {
private onerror = (event: any) => { private onerror = (event: any) => {
console.log(`[error] ${event.message}`); console.log(`[error] ${event.message}`);
} } */
} }
export const synchro = new SynchroService() /* export const synchro = new SynchroService()
synchro.setUrl() synchro.setUrl()
synchro.connect() synchro.connect()
window['synchro'] = synchro window['synchro'] = synchro */
+15
View File
@@ -182,6 +182,20 @@ export class SqliteService {
}); });
} }
//updateevent
public updateEvent(data) {
this.dbInstance.executeSql(`
INSERT OR REPLACE INTO ${this.events} (EventId,Subject,HasAttachments,Location,CalendarId,CalendarName,StartDate,EndDate,EventType,Attendees,IsMeeting,IsRecurring,IsAllDayEvent,AppointmentState,TimeZone,Organizer,Category,EventRecurrence,Attachments,Body,Profile,HumanDate )
VALUES ('${data.EventId}','${data.Subject}','${data.HasAttachments}','${data.Location}','${data.CalendarId}','${data.CalendarName}','${data.StartDate}','${data.EndDate}','${data.EventType}','${data.Attendees}','${data.IsMeeting}','${data.IsRecurring}',
'${data.IsAllDayEvent}','${data.AppointmentState}','${data.TimeZone}','${data.Organizer}','${data.Category}','${data.EventRecurrence}','${data.Attachments}','${data.Body}','${data.Profile}','${data.HumanDate}')`, [])
.then(() => {
console.log("event update with Success");
}, (e) => {
console.log(JSON.stringify(e));
});
}
//updateActions //updateActions
public updateactions(id,data) { public updateactions(id,data) {
console.log("update action data", data ) console.log("update action data", data )
@@ -359,6 +373,7 @@ export class SqliteService {
if (res.rows.length > 0) { if (res.rows.length > 0) {
for (var i = 0; i < res.rows.length; i++) { for (var i = 0; i < res.rows.length; i++) {
this.ALLPROCESS.push(res.rows.item(i)); this.ALLPROCESS.push(res.rows.item(i));
console.log('getEXPEDIENTE DB LOOP')
} }
return this.ALLPROCESS; return this.ALLPROCESS;
} }
@@ -8,7 +8,6 @@ import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popo
import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page'; import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page';
import { ContactsPage } from '../new-group/contacts/contacts.page'; import { ContactsPage } from '../new-group/contacts/contacts.page';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { synchro } from 'src/app/services/socket/synchro.service';
import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/chat-options-features.page'; import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/chat-options-features.page';
import { ChatMessageStore } from 'src/app/store/chat/chat-message.service'; import { ChatMessageStore } from 'src/app/store/chat/chat-message.service';
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service'; import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
@@ -45,7 +44,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
@Output() getDirectMessages:EventEmitter<any> = new EventEmitter<any>(); @Output() getDirectMessages:EventEmitter<any> = new EventEmitter<any>();
synchro = synchro;
chatMessageStore = ChatMessageStore chatMessageStore = ChatMessageStore
chatUserStorage = ChatUserStorage chatUserStorage = ChatUserStorage
@@ -199,7 +197,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
sendMessage() { sendMessage() {
this.synchro.$send({}) //this.synchro.$send({})
let body = { let body = {
"message": "message":
@@ -5,7 +5,6 @@ import { AuthService } from 'src/app/services/auth.service';
import { ProcessesService } from 'src/app/services/processes.service'; import { ProcessesService } from 'src/app/services/processes.service';
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'; import { removeDuplicate } from 'src/plugin/removeDuplicate.js';
import { SqliteService } from '../../../services/sqlite.service'; import { SqliteService } from '../../../services/sqlite.service';
import { synchro } from '../../../services/socket/synchro.service';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { SortService } from 'src/app/services/functions/sort.service'; import { SortService } from 'src/app/services/functions/sort.service';
@@ -20,8 +19,6 @@ export class AllProcessesPage implements OnInit {
allProcessesList: any[] = []; allProcessesList: any[] = [];
loggeduser: LoginUserRespose; loggeduser: LoginUserRespose;
synch = synchro;
constructor( constructor(
private processesService: ProcessesService, private processesService: ProcessesService,
private router: Router, private router: Router,