This commit is contained in:
tiago.kayaya
2021-10-19 14:34:51 +01:00
34 changed files with 1795 additions and 1505 deletions
+26 -36
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,7 +115,6 @@ export class HomePage implements OnInit {
ngOnInit() { ngOnInit() {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
window.addEventListener('online', () => { window.addEventListener('online', () => {
console.log('Became online') console.log('Became online')
this.backgroundservice.online() this.backgroundservice.online()
@@ -121,9 +123,28 @@ export class HomePage implements OnInit {
console.log('Became offline') console.log('Became offline')
this.backgroundservice.offline() this.backgroundservice.offline()
}); });
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
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');
}); });
+41 -28
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
@@ -517,7 +534,10 @@ 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;
}) })
@@ -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;
}) })
} }
@@ -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 })
@@ -729,26 +752,9 @@ export class AgendaPage implements OnInit {
} }
getFromDB() { getFromDB() {
if (synchro.connected === true) {
const pathname = window.location.pathname
let realoadCounter = 0
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == pathname) {
if (this.segment == null) {
this.segment = "Combinado";
}
if (realoadCounter != 0) {
this.loadRangeEvents(this.rangeStartDate, this.rangeEndDate);
}
realoadCounter++;
}
});
console.log('LISTTOPRESENT', this.listToPresent)
} else {
console.log('ALL EVENTS FROM DB AGENDA OFFLINE') console.log('ALL EVENTS FROM DB AGENDA OFFLINE')
this.sqliteservice.getAllEvents().then((events: any[]) => { this.sqliteservice.getAllEvents().then((events: any[]) => {
console.log('ALL EVENTS FROM DB', events)
let eventArray = []; let eventArray = [];
events.forEach(element => { events.forEach(element => {
let event = { let event = {
@@ -757,17 +763,24 @@ export class AgendaPage implements OnInit {
allDay: false, allDay: false,
event: element, event: element,
calendarName: element.CalendarName, calendarName: element.CalendarName,
profile: element.profile, profile: element.Profile,
id: element.EventId, id: element.EventId,
} }
eventArray.push(event); eventArray.push(event);
}); });
console.log('ALL EVENTS FROM DB', events)
this.listToPresent = eventArray this.listToPresent = eventArray
this.updateEventListBox()
this.myCal.update();
this.myCal.loadEvents();
this.showLoader = false;
this.showTimeline = true;
}) })
} }
}
updateEventListBox() { updateEventListBox() {
@@ -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',
@@ -48,7 +48,6 @@ 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;
@@ -66,11 +65,9 @@ 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: "" };
@@ -100,23 +97,11 @@ 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.loadedEvent = event[0];
console.log("Event ditails local,", event[0])
})
this.loadEvent(); */
this.backgroundservice.registerBackService('Online', () => {
this.loadEvent();
});
window.onresize = (event) => { window.onresize = (event) => {
// if not mobile remove all component // if not mobile remove all component
@@ -158,22 +143,24 @@ 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) => {
console.log('errorstatus',error.status)
if (error.status == 0) { if (error.status == 0) {
this.toastService.badRequest('Não é possível vizualizar este evento no modo offline') 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() loader.remove()
this.modalController.dismiss('Eevent not Foud'); this.modalController.dismiss('Eevent not Foud');
this.location.back(); this.location.back();
}
loader.remove()
}); });
} }
@@ -181,8 +168,7 @@ export class ViewEventPage implements OnInit {
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',
@@ -381,24 +367,63 @@ export class ViewEventPage implements OnInit {
} }
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', () => { getFromDb() {
this.platform.ready().then(() => { const loader = this.toastService.loading();
this.sqliteservice.getEventById(this.eventId).then((event) => { this.sqliteservice.getEventById(this.eventId).then((event) => {
this.loadedEvent = event[0]; let arrayevent = [];
console.log("Event ditails local,", event[0]) let elemet = {
}) Attendees: JSON.parse(event[0].Attendees) || "",
console.log('Offlineee') 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
+50 -25
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',
@@ -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,7 +123,6 @@ 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.showGreeting();
this.router.events.forEach((event) => { this.router.events.forEach((event) => {
@@ -136,9 +134,15 @@ export class EventsPage implements OnInit {
} }
}); });
this.hideSearch(); this.hideSearch();
}
this.getEventsFromLocalDb(); this.backgroundservice.registerBackService('Online', () => {
this.showGreeting();
this.RefreshEvents();
this.LoadList();
this.hideSearch();
});
//this.getEventsFromLocalDb();
//this.checkScreenOrientation(); //this.checkScreenOrientation();
@@ -324,7 +328,7 @@ export class EventsPage implements OnInit {
getEventsFromLocalDb() { getEventsFromLocalDb() {
if (synchro.connected === true) { /* window.addEventListener('online', (on) => {
this.showGreeting(); this.showGreeting();
this.router.events.forEach((event) => { this.router.events.forEach((event) => {
@@ -332,12 +336,17 @@ export class EventsPage implements OnInit {
this.RefreshEvents(); this.RefreshEvents();
setTimeout(() => { setTimeout(() => {
this.LoadList(); this.LoadList();
}, 1500) }, 1500)
} }
}); });
this.hideSearch(); this.hideSearch();
}); */
// window.addEventListener('offline', (off) => {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else { } else {
this.platform.ready().then(async () => {
this.sqliteservice.getAllEvents().then((event: any[]) => { this.sqliteservice.getAllEvents().then((event: any[]) => {
this.listToPresent = event this.listToPresent = event
this.totalEvent = this.listToPresent.length this.totalEvent = this.listToPresent.length
@@ -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.getAllProcess().then((res) => {
console.log('INICION ALL EVENTs', res)
})
this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[]) => { this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[]) => {
var expedientlist = [];
console.log('OFOFOFOOF', process)
if (process.length > 0 || process != undefined) {
var expedientlist: any = new Array();
process.forEach((element) => { process.forEach((element) => {
let task = { let task = {
CreateDate: element.taskStartDate,
DocumentsQty: element.totalDocuments,
Senders: JSON.parse(element.workflowInstanceDataFields).Sender,
SerialNumber: element.serialNumber,
Status: JSON.parse(element.workflowInstanceDataFields).Status,
Subject: JSON.parse(element.workflowInstanceDataFields).Subject,
WorkflowName: element.workflowDisplayName,
activityInstanceName: element.activityInstanceName, activityInstanceName: element.activityInstanceName,
deadline: null,
serialNumber: element.serialNumber,
taskStartDate: element.taskStartDate, taskStartDate: element.taskStartDate,
totalDocuments: element.totalDocuments,
workflowDisplayName: element.workflowDisplayName,
workflowInstanceDataFields: JSON.parse(element.workflowInstanceDataFields)
} }
expedientlist.push(task); expedientlist.push(task);
}) })
console.log('OFOFOFOOF22222', expedientlist)
const ExpedienteTask = expedientlist.map(e => this.expedienteTaskPipe.transform(e)) const ExpedienteTask = expedientlist.map(e => this.expedienteTaskPipe.transform(e))
this.listToPresentexpediente = ExpedienteTask; 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() {
@@ -130,34 +145,23 @@ export class DespachoPrPage implements OnInit {
}); });
}, (error) => { }, (error) => {
if (error.status == 0) {
this.getFromDB()
} else {
try { try {
this.goBack() this.goBack()
} catch (e) { } catch (e) {
window.history.back(); window.history.back();
} finally {
if (error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
} else {
this.toastService.badRequest('Processo não encontrado')
} }
this.toastService.badRequest('Processo não encontrado')
} }
}); });
} }
getFromDB() { getFromDB() {
if (synchro.connected === true) {
this.activateRoute.paramMap.subscribe(paramMap => {
if (!paramMap.has('SerialNumber')) {
return;
}
/* this.serialNumber = paramMap.get('SerialNumber'); */
this.LoadTaskDetail(this.serialNumber);
// this.LoadRelatedEvents(this.serialNumber);
});
this.LoadTaskDetail(this.serialNumber);
// this.LoadRelatedEvents(this.serialNumber);
} else {
this.sqliteservice.getProcessById(this.serialNumber).then((process: any[]) => { this.sqliteservice.getProcessById(this.serialNumber).then((process: any[]) => {
console.log('OFFLINE', process) console.log('OFFLINE', process)
this.task = { this.task = {
@@ -207,7 +211,6 @@ export class DespachoPrPage implements OnInit {
}) })
} }
}
async viewDocument(DocId: string, Document) { async viewDocument(DocId: string, Document) {
@@ -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,6 +113,7 @@ export class DespachosPrPage implements OnInit {
async LoadList() { async LoadList() {
this.processes.GetTasksList("Despacho do Presidente da República", false).subscribe(async res => {
this.skeletonLoader = true 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();
@@ -139,25 +159,14 @@ export class DespachosPrPage implements OnInit {
}); });
this.listToPresent = 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.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()
}
}
});
} else {
this.sqliteservice.getAllProcess().then((all) => { this.sqliteservice.getAllProcess().then((all) => {
console.log('DESPACHO PR ALL', all) console.log('DESPACHO PR ALL', all)
}) })
@@ -203,7 +212,6 @@ export class DespachosPrPage implements OnInit {
}) })
} }
}
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,26 +164,21 @@ export class DespachoPage implements OnInit {
}); });
}); });
}, (error) => { }, (error) => {
if (error.status == 0) {
this.getFromDb();
} else {
try { try {
this.goBack() this.goBack()
} catch (e) { } catch (e) {
this.location.back(); this.location.back();
} finally {
if (error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
} else {
this.toastService.badRequest('Processo não encontrado')
} }
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) => {
@@ -248,7 +245,6 @@ export class DespachoPage implements OnInit {
}) })
}) })
} }
}
async viewDocument(docId: string, Document) { async viewDocument(docId: string, Document) {
@@ -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,31 +67,16 @@ 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.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()
}
}
});
}
if (synchro.connected === false) {
this.platform.ready().then(() => { this.platform.ready().then(() => {
this.sqliteservice.getDespachosProcess('Tarefa de Despacho').then((process: any[]) => { this.sqliteservice.getprocessByworkflow('Despacho').then((process: any[]) => {
var listtopresent = []; var listtopresent = [];
process.forEach(element => { process.forEach(element => {
var workflow = JSON.parse(element.workflowInstanceDataFields); var workflow = JSON.parse(element.workflowInstanceDataFields);
@@ -96,11 +99,11 @@ export class DespachosPage implements OnInit {
}); });
this.listToPresent = listtopresent; this.listToPresent = listtopresent;
console.log('Tarefas de despach', this.listToPresent)
}) })
}) })
} }
}
get skeletonLoader(): boolean { get skeletonLoader(): boolean {
return this.despachoRule.LoaderService.loading return this.despachoRule.LoaderService.loading
@@ -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',
@@ -46,7 +46,8 @@ 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"]);
@@ -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() {
@@ -149,25 +153,22 @@ export class DiplomaPage implements OnInit {
this.getDocumentDetails(this.task.FolderId, '361'); this.getDocumentDetails(this.task.FolderId, '361');
}, (error) => { }, (error) => {
if (error.status == 0) {
this.getFromDb();
} else {
try { try {
this.goBack() this.goBack()
} catch (e) { } catch (e) {
window.history.back(); window.history.back();
} finally {
if(error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
} else {
this.toastService.badRequest('Processo não encontrado')
} }
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.sqliteservice.getProcessById(this.serialNumber).then((process) => {
this.task = { this.task = {
@@ -218,7 +219,6 @@ export class DiplomaPage implements OnInit {
}) })
} }
}
async viewDocument(DocId: string, Document) { async viewDocument(DocId: string, Document) {
@@ -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,6 +170,8 @@ export class DiplomasPage implements OnInit, OnDestroy {
async LoadList() { async LoadList() {
this.processes.GetTasksList("Despacho do Presidente da República", false).subscribe(async res => {
this.skeletonLoader = true this.skeletonLoader = true
let diplomas = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise(); let diplomas = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
@@ -170,7 +188,7 @@ export class DiplomasPage implements OnInit, OnDestroy {
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");
@@ -181,27 +199,16 @@ export class DiplomasPage implements OnInit, OnDestroy {
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.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith(pathname)) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
this.refreshing()
} else {
this.LoadList()
}
}
});
} else {
this.sqliteservice.getprocessByworkflow("Despacho do Presidente da República").then((process: any[]) => { this.sqliteservice.getprocessByworkflow("Despacho do Presidente da República").then((process: any[]) => {
let diplomasValidar = process.filter(data => data.activityInstanceName == "Revisar Diploma"); let diplomasValidar = process.filter(data => data.activityInstanceName == "Revisar Diploma");
@@ -226,7 +233,6 @@ export class DiplomasPage implements OnInit, OnDestroy {
}) })
} }
}
pipeTask(element) { pipeTask(element) {
let date = new Date(element.taskStartDate); let date = new Date(element.taskStartDate);
@@ -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({
@@ -43,8 +43,6 @@ export class ApproveEventPage implements OnInit {
@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();
});
} }
@@ -108,11 +111,6 @@ export class ApproveEventPage implements OnInit {
getProcessFromDB() { getProcessFromDB() {
if (synchro.connected === true) {
this.getTask();
}
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => { this.platform.ready().then(() => {
this.sqliteservice.getProcessById(this.serialNumber).then((process) => { this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
@@ -177,16 +175,21 @@ export class ApproveEventPage implements OnInit {
}) })
}) })
console.log('Offlineee') console.log('Offlineee')
})
} }
async getTask() { async getTask() {
this.processes.GetTask(this.serialNumber).subscribe(async res => {
this.loadedEvent = await this.processes.GetTask(this.serialNumber).toPromise(); this.loadedEvent = await this.processes.GetTask(this.serialNumber).toPromise();
console.log(this.loadedEvent); console.log(this.loadedEvent);
this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate); this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]); this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
}, (error) => {
this.getProcessFromDB();
})
} }
async approveTask(serialNumber: string) { async approveTask(serialNumber: string) {
@@ -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';
@@ -34,9 +34,6 @@ export class EventListPage implements OnInit {
skeletonLoader = true skeletonLoader = true
eventaprovacaostore = EventoAprovacaoStore; eventaprovacaostore = EventoAprovacaoStore;
synch = synchro;
constructor( constructor(
private processes: ProcessesService, private processes: ProcessesService,
private modalController: ModalController, private modalController: ModalController,
@@ -45,25 +42,13 @@ export class EventListPage implements OnInit {
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();
window.onresize = (event) => {
// if not mobile remove all component
if( window.innerWidth <= 800){
this.modalController.dismiss();
}
};
}
getEventToAproveFromDB() {
if( synchro.connected === true) {
const location = window.location const location = window.location
const pathname = location.pathname + location.search const pathname = location.pathname + location.search
@@ -78,23 +63,36 @@ export class EventListPage implements OnInit {
} }
} }
}); });
this.backgroundservice.registerBackService('Online', () => {
this.LoadToApproveEvents();
});
window.onresize = (event) => {
// if not mobile remove all component
if (window.innerWidth <= 800) {
this.modalController.dismiss();
}
};
} }
synchro.registerCallback('Offline', () => { getEventToAproveFromDB() {
this.platform.ready().then(() => { this.platform.ready().then(() => {
this.sqliteservice.getListOfEventAprove('Agenda Oficial MDGPR', 'Agenda Pessoal MDGPR').then((event: any[]) => { this.sqliteservice.getListOfEventAprove('Agenda Oficial MDGPR', 'Agenda Pessoal MDGPR').then((event: any[]) => {
this.eventsMDGPRList = event this.eventsMDGPRList = this.sortService.sortArrayByDate(event).reverse()
console.log("All evento to aprove from db ", event) console.log("All evento to aprove from db ", event)
}) })
this.sqliteservice.getListOfEventAprove('Agenda Oficial PR', 'Agenda Pessoal PR').then((event: any[]) => { this.sqliteservice.getListOfEventAprove('Agenda Oficial PR', 'Agenda Pessoal PR').then((event: any[]) => {
this.eventsPRList = event this.eventsPRList = this.sortService.sortArrayByDate(event).reverse()
console.log("All evento to aprove from db ", event) console.log("All evento to aprove from db ", event)
}) })
}) })
console.log('Offlineee') console.log('Offlineee')
})
} }
segmentChanged(ev: any) { segmentChanged(ev: any) {
@@ -102,6 +100,7 @@ export class EventListPage implements OnInit {
} }
async LoadToApproveEvents() { async LoadToApproveEvents() {
this.processes.GetTasksList('Agenda Oficial MDGPR', false).subscribe(async res => {
this.showLoader = true; this.showLoader = true;
this.skeletonLoader = true this.skeletonLoader = true
@@ -110,20 +109,22 @@ export class EventListPage implements OnInit {
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.eventsMDGPRList = this.sortService.sortArrayByDate(this.eventsMDGPRList).reverse()
this.eventaprovacaostore.resetmd(this.sortService.sortArrayByDate(this.eventsMDGPRList).reverse()); this.eventaprovacaostore.resetmd(this.sortService.sortArrayByDate(this.eventsMDGPRList).reverse());
} }
else if (this.segment == 'PR') { else if (this.segment == 'PR') {
let prEventsOficial = await this.processes.GetTasksList('Agenda Oficial PR', false).toPromise(); let prEventsOficial = await this.processes.GetTasksList('Agenda Oficial PR', false).toPromise();
let prEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal PR', false).toPromise(); let prEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal PR', false).toPromise();
this.eventsPRList = prEventsOficial.concat(prEventsPessoal); this.eventsPRList = prEventsOficial.concat(prEventsPessoal);
this.eventsPRList = this.sortService.sortArrayByDate(this.eventsPRList).reverse();
this.eventaprovacaostore.resetpr(this.sortService.sortArrayByDate(this.eventsPRList).reverse()); this.eventaprovacaostore.resetpr(this.sortService.sortArrayByDate(this.eventsPRList).reverse());
} }
this.showLoader = false; this.showLoader = false;
this.skeletonLoader = false this.skeletonLoader = false
}
getEventToaproveFromDB() {
}, (error) => {
this.getEventToAproveFromDB();
})
} }
async openApproveModal(eventSerialNumber, event) { async openApproveModal(eventSerialNumber, event) {
@@ -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,12 +106,6 @@ export class ExpedienteDetailPage implements OnInit {
getFromDB() { getFromDB() {
if(synchro.connected === true) {
this.LoadTaskDetail(this.serialNumber);
}
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => { this.platform.ready().then(() => {
this.onlinecheck = false; this.onlinecheck = false;
this.sqliteservice.getProcessById(this.serialNumber).then((process) => { this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
@@ -141,7 +139,6 @@ export class ExpedienteDetailPage implements OnInit {
}) })
}) })
})
} }
@@ -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) => {
if (error.status == 0) {
this.getFromDB();
} else {
try { try {
this.toastService.badRequest('Processo não encontrado') this.toastService.badRequest('Processo não encontrado')
this.goBack() this.goBack()
} catch (e) { } catch (e) {
window.history.back(); window.history.back();
} finally {
if (error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
} else {
this.toastService.badRequest('Processo não encontrado')
} }
this.toastService.badRequest('Processo não encontrado')
} }
}); });
@@ -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,23 +28,41 @@ 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.processes.GetTaskListExpediente(false).subscribe(async res => {
this.skeletonLoader = true this.skeletonLoader = true
try { try {
@@ -70,6 +88,9 @@ export class ExpedientePage implements OnInit {
} finally { } finally {
this.skeletonLoader = false; this.skeletonLoader = false;
} }
}, (error) => {
this.getEventsFromLocalDb();
})
} }
@@ -121,22 +142,6 @@ export class ExpedientePage implements OnInit {
getEventsFromLocalDb() { getEventsFromLocalDb() {
if (synchro.connected === true) {
const location = window.location
const pathname = location.pathname + location.search
this.LoadList()
this.router.events.forEach((event) => {
if (event instanceof NavigationStart && event.url.startsWith(pathname)) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
this.refreshing()
} else {
this.LoadList()
}
}
});
} else {
this.taskslist = new Array(); this.taskslist = new Array();
this.sqliteservice.getprocessByworkflow("Expediente").then((expediente: any[]) => { this.sqliteservice.getprocessByworkflow("Expediente").then((expediente: any[]) => {
console.log("All expedientes from local,", expediente) console.log("All expedientes from local,", expediente)
@@ -164,6 +169,5 @@ export class ExpedientePage implements OnInit {
}) })
} }
}
} }
@@ -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,14 +176,43 @@ 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() {
this.processesbackend.GetTasksList("", false).subscribe(async res => {
let allProcessesList = await this.processesbackend.GetTasksList("", false).toPromise(); let allProcessesList = await this.processesbackend.GetTasksList("", false).toPromise();
if (!this.p.userRole(['PR'])) { if (!this.p.userRole(['PR'])) {
allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Assinar Diplomas') allProcessesList = allProcessesList.filter(element => element.activityInstanceName != 'Assinar Diplomas')
} else if (this.p.userRole(['PR'])) { } else if (this.p.userRole(['PR'])) {
@@ -230,6 +257,11 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
}); });
}, (error) => {
console.log('gabinete digital offline', error)
this.getAllProcessFromDB();
})
this.skeletonLoader = false; this.skeletonLoader = false;
} }
@@ -262,30 +294,6 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
getAllProcessFromDB() { getAllProcessFromDB() {
if (synchro.connected === true ) {
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();
}
})
} else {
this.hideRefreshButton(); this.hideRefreshButton();
this.sqliteservice.getAllProcess().then((allprocess: any[]) => { this.sqliteservice.getAllProcess().then((allprocess: any[]) => {
@@ -321,7 +329,6 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
console.log("All process from db ", allprocess) console.log("All process from db ", allprocess)
}) })
} }
}
sortArrayISODate(myArray: any) { sortArrayISODate(myArray: any) {
return myArray.sort(function (a, b) { return myArray.sort(function (a, b) {
@@ -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() {
@@ -167,34 +171,29 @@ export class PedidoPage implements OnInit {
}); });
this.getDocumentDetails(res.workflowInstanceDataFields.FolderID, '361'); this.getDocumentDetails(res.workflowInstanceDataFields.FolderID, '361');
}, (error) => { }, (error) => {
if (error.status == 0) {
this.getfromDb();
} else {
try { try {
this.goBack() this.goBack()
this.close() this.close()
} catch (e) { } catch (e) {
window.history.back(); window.history.back();
} finally {
if (error.status == 0) {
this.toastService.badRequest('Não é possível visualizar este processo no modo offline')
} else {
this.toastService.badRequest('Processo não encontrado')
} }
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,
@@ -275,7 +274,6 @@ export class PedidoPage 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 => {
@@ -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({
@@ -48,6 +48,7 @@ export class PedidosPage implements OnInit {
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';
@@ -66,7 +67,25 @@ export class PedidosPage implements OnInit {
} }
ngOnInit() { ngOnInit() {
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(); this.getFromDb();
});
} }
goBack() { goBack() {
@@ -102,6 +121,9 @@ export class PedidosPage implements OnInit {
} }
async LoadList() { async LoadList() {
this.processes.GetTasksList("Pedido de Parecer", false).subscribe(async res => {
this.skeletonLoader = true this.skeletonLoader = true
if (this.segment == 'parecer') { if (this.segment == 'parecer') {
@@ -174,37 +196,21 @@ export class PedidosPage implements OnInit {
if (element.workflowInstanceDataFields.Status == "Active") { if (element.workflowInstanceDataFields.Status == "Active") {
this.deferimentoList.push(task); 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) => {
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()
}
}
});
}
if(synchro.connected === false) {
let parecerlist = []; let parecerlist = [];
let deferimentolist = [] let deferimentolist = []
this.sqliteservice.getprocessByworkflowpedido("Pedido de Parecer", "Pedido de Parecer do Presidente").then((process: any[]) => { this.sqliteservice.getprocessByworkflowpedido("Pedido de Parecer", "Pedido de Parecer do Presidente").then((process: any[]) => {
@@ -259,8 +265,6 @@ export class PedidosPage implements OnInit {
this.listToPresentdeferimentoList = this.sortService.sortArrayISODate(deferimentolist); this.listToPresentdeferimentoList = this.sortService.sortArrayISODate(deferimentolist);
console.log('deferimento', process) 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,6 +90,7 @@ export class PendentesPage implements OnInit {
async LoadList() { async LoadList() {
this.processes.GetPendingTasks(false).subscribe(async res => {
this.skeletonLoader = true; this.skeletonLoader = true;
let pendentes = await this.processes.GetPendingTasks(false).toPromise(); let pendentes = await this.processes.GetPendingTasks(false).toPromise();
@@ -89,31 +106,20 @@ export class PendentesPage implements OnInit {
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) {
const location = window.location
const pathname = location.pathname + location.search
this.LoadList()
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url.startsWith(pathname)) {
if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
this.refreshing()
} else {
this.LoadList()
}
}
});
}
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => { this.platform.ready().then(() => {
this.sqliteservice.getAllProcess().then((process: any[]) => { this.sqliteservice.getAllProcess().then((process: any[]) => {
var pendingList = [] var pendingList = []
console.log('Pendentes off off',process )
process.forEach(element => { process.forEach(element => {
var workflow = JSON.parse(element.workflowInstanceDataFields); var workflow = JSON.parse(element.workflowInstanceDataFields);
if (workflow.Status === "Pending") { if (workflow.Status === "Pending") {
@@ -138,7 +144,6 @@ export class PendentesPage implements OnInit {
}) })
}) })
})
} }
async refreshing() { async refreshing() {
+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() {
+19 -15
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,22 +167,13 @@ export class PublicationsPage implements OnInit {
}); });
}, (error) => {
this.getFromDB();
}); });
} }
getFromDB() { getFromDB() {
if (synchro.connected === true) {
const pathname = window.location.pathname
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == pathname) {
this.getActions();
}
});
this.hideRefreshButton();
} else {
this.sqliteservice.getAllActions().then((actions: any[]) => { this.sqliteservice.getAllActions().then((actions: any[]) => {
console.log('offline publi', actions) console.log('offline publi', actions)
@@ -197,7 +202,6 @@ export class PublicationsPage implements OnInit {
}) })
} }
}
async editAction(folderId?: string) { async editAction(folderId?: string) {
const modal = await this.modalController.create({ const modal = await this.modalController.create({
@@ -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,13 +155,6 @@ 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) => { this.sqliteservice.getActionById(this.folderId).then((publications) => {
console.log('publications', publications) console.log('publications', publications)
@@ -181,8 +187,6 @@ export class ViewPublicationsPage implements OnInit {
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
})
} }
} }
+22 -15
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({
@@ -30,8 +34,10 @@ export class EventsService {
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;
@@ -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,10 +309,10 @@ 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());
@@ -339,7 +344,12 @@ 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) {
@@ -365,8 +375,7 @@ 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();
@@ -394,8 +403,7 @@ 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();
@@ -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();
@@ -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,