mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Merge branch 'developer' of https://bitbucket.org/equilibriumito/gabinete-digital into developer
This commit is contained in:
+12
-28
@@ -23,7 +23,7 @@ import { Network } from '@ionic-native/network/ngx';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
import { OfflineManagerService } from 'src/app/services/offline-manager.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { EventsService} from 'src/app/services/events.service';
|
||||
import { EventsService } from 'src/app/services/events.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -81,11 +81,10 @@ export class HomePage implements OnInit {
|
||||
private inativityService: InativityService,
|
||||
private storageService: StorageService,
|
||||
private webNotificationPopupService: WebNotificationPopupService,
|
||||
private network: Network,
|
||||
private backgroundservice: BackgroundService,
|
||||
private offlinemanager: OfflineManagerService,
|
||||
private storage: Storage,
|
||||
private eventservice: EventsService ) {
|
||||
private eventservice: EventsService) {
|
||||
|
||||
this.webNotificationPopupService.askNotificationPermission()
|
||||
|
||||
@@ -118,37 +117,20 @@ export class HomePage implements OnInit {
|
||||
window.addEventListener('online', () => {
|
||||
console.log('Became online')
|
||||
this.backgroundservice.online()
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
this.webnotification.webconnection();
|
||||
this.webnotification.register();
|
||||
} else {
|
||||
this.mobilefirstConnect();
|
||||
this.notificationsService.onReceviNotification();
|
||||
this.offlinemanager.synchnize()
|
||||
}
|
||||
});
|
||||
window.addEventListener('offline', () => {
|
||||
console.log('Became offline')
|
||||
this.backgroundservice.offline()
|
||||
});
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
this.webnotification.webconnection();
|
||||
this.webnotification.register();
|
||||
} else {
|
||||
window.addEventListener('online', (on) => {
|
||||
console.log('Became online',on)
|
||||
this.storage.get('storedreq').then((req) =>{
|
||||
console.log('STORED REQUEST', req)
|
||||
req.forEach(element => {
|
||||
this.eventservice.editEvent(element,2,3).subscribe((res) =>{
|
||||
console.log('REQUEST RESULT', res)
|
||||
})
|
||||
});
|
||||
|
||||
})
|
||||
this.backgroundservice.online()
|
||||
});
|
||||
window.addEventListener('offline', (off) => {
|
||||
console.log('Became offline',off)
|
||||
this.backgroundservice.offline()
|
||||
});
|
||||
this.mobilefirstConnect();
|
||||
this.notificationsService.onReceviNotification();
|
||||
}
|
||||
|
||||
this.updateList()
|
||||
|
||||
var myWorker = new Worker(new URL('./nice.worker.js', import.meta.url));
|
||||
@@ -197,6 +179,8 @@ export class HomePage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
updateList() {
|
||||
|
||||
this.notificationsService.registerCallback(
|
||||
|
||||
@@ -209,6 +209,7 @@ export class EditEventPage implements OnInit {
|
||||
this.toastService.successMessage();
|
||||
|
||||
}, error => {
|
||||
if(error.status != 0)
|
||||
this.toastService.badRequest()
|
||||
});
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import { DocumentSetUpMeetingPage } from 'src/app/modals/document-set-up-meeting
|
||||
import { ExpedientTaskModalPage } from '../../gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
|
||||
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
import { StorageService } from 'src/app/services/storage.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-event',
|
||||
@@ -66,7 +67,8 @@ export class ViewEventPage implements OnInit {
|
||||
private location: Location,
|
||||
public platform: Platform,
|
||||
private sqliteservice: SqliteService,
|
||||
private backgroundservice: BackgroundService
|
||||
private backgroundservice: BackgroundService,
|
||||
private storage: StorageService
|
||||
) {
|
||||
this.isEventEdited = false;
|
||||
this.loadedEvent = new Event();
|
||||
@@ -100,6 +102,22 @@ export class ViewEventPage implements OnInit {
|
||||
this.loadEvent();
|
||||
|
||||
this.backgroundservice.registerBackService('Online', () => {
|
||||
this.storage.get('eventEdit').then((req) => {
|
||||
JSON.parse(req).forEach(element => {
|
||||
this.eventsService.editEvent(element, 2, 3).subscribe((res) => {
|
||||
this.storage.remove('eventEdit')
|
||||
console.log('eventEdit synchnize', res)
|
||||
})
|
||||
});
|
||||
})
|
||||
this.storage.get('eventDelete').then((req) => {
|
||||
JSON.parse(req).forEach(element => {
|
||||
this.eventsService.editEvent(element, 2, 3).subscribe((res) => {
|
||||
this.storage.remove('eventDelete')
|
||||
console.log('eventEdit synchnize', res)
|
||||
})
|
||||
});
|
||||
})
|
||||
this.loadEvent();
|
||||
});
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { NetworkConnectionService } from 'src/app/services/network-connection.service'
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
import { momentG } from 'src/plugin/momentG';
|
||||
|
||||
@Component({
|
||||
selector: 'app-events',
|
||||
@@ -107,14 +108,10 @@ export class EventsPage implements OnInit {
|
||||
// console.log('Resize event detected');
|
||||
|
||||
});
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
try {
|
||||
this.sqliteservice.databaseConn();
|
||||
} catch (error) {
|
||||
console.log("Error creating local database: ", error)
|
||||
}
|
||||
try {
|
||||
this.sqliteservice.databaseConn();
|
||||
} catch (error) {
|
||||
console.log("Error creating local database: ", error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,18 +205,9 @@ export class EventsPage implements OnInit {
|
||||
|
||||
const list = mdOficialEvents.concat(mdPessoalEvents);
|
||||
console.log("getAllMdOficialPessoalEvents", list)
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
if (list.length > 0) {
|
||||
list.forEach(element => {
|
||||
this.sqliteservice.addEvent(element)
|
||||
});
|
||||
}
|
||||
}
|
||||
this.addEventToDb(list);
|
||||
this.listToPresent = list
|
||||
|
||||
|
||||
|
||||
if (list.length > 0) {
|
||||
this.currentEvent = list[0].Subject;
|
||||
this.currentHoursMinutes = list[0].StartDate;
|
||||
@@ -236,14 +224,7 @@ export class EventsPage implements OnInit {
|
||||
|
||||
const list = prOficialEvents.concat(prPessoalEvents);
|
||||
console.log("getAllPrOficialPessoalEvents", list)
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
if (list.length > 0) {
|
||||
list.forEach(element => {
|
||||
this.sqliteservice.addEvent(element)
|
||||
});
|
||||
}
|
||||
}
|
||||
this.addEventToDb(list);
|
||||
if (list.length > 0) {
|
||||
this.currentEvent = list[0].Subject;
|
||||
this.currentHoursMinutes = list[0].StartDate;
|
||||
@@ -326,38 +307,65 @@ export class EventsPage implements OnInit {
|
||||
} */
|
||||
}
|
||||
|
||||
addEventToDb(list) {
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
if (list.length > 0) {
|
||||
list.forEach(element => {
|
||||
this.sqliteservice.addEvent(element)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getEventsFromLocalDb() {
|
||||
|
||||
/* window.addEventListener('online', (on) => {
|
||||
this.showGreeting();
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationEnd && event.url == '/home/events') {
|
||||
this.RefreshEvents();
|
||||
setTimeout(() => {
|
||||
this.LoadList();
|
||||
|
||||
}, 1500)
|
||||
}
|
||||
});
|
||||
this.hideSearch();
|
||||
}); */
|
||||
|
||||
// window.addEventListener('offline', (off) => {
|
||||
let date = new Date();
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
let dateToday = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate();
|
||||
console.log('dateeeeee', dateToday)
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
|
||||
} else {
|
||||
this.sqliteservice.getAllEvents().then((event: any[]) => {
|
||||
this.listToPresent = event
|
||||
let todayEvents = new Array()
|
||||
event.forEach((element) => {
|
||||
let eventObject = {
|
||||
AppointmentState: element.AppointmentState,
|
||||
Attachments: element.Attachments,
|
||||
Attendees: element.Attendees,
|
||||
CalendarId: element.CalendarId,
|
||||
CalendarName: element.CalendarName,
|
||||
Category: element.Category,
|
||||
EndDate: element.EndDate,
|
||||
EventId: element.EventId,
|
||||
EventRecurrence: element.EventRecurrence,
|
||||
EventType: element.EventType,
|
||||
HasAttachments: element.HasAttachments,
|
||||
HumanDate: element.HumanDate,
|
||||
IsAllDayEvent: element.IsAllDayEvent,
|
||||
IsMeeting: element.IsMeeting,
|
||||
IsRecurring: element.IsRecurring,
|
||||
Location: element.Location,
|
||||
Organizer: element.Organizer,
|
||||
Profile: element.Profile,
|
||||
StartDate: element.StartDate,
|
||||
Subject: element.Subject
|
||||
}
|
||||
let starteDate = momentG(new Date(element.StartDate), 'yyyy-MM-dd');
|
||||
console.log('startTOdayyy', starteDate)
|
||||
if (dateToday == starteDate) {
|
||||
todayEvents.push(eventObject);
|
||||
}
|
||||
})
|
||||
this.listToPresent = todayEvents
|
||||
this.totalEvent = this.listToPresent.length
|
||||
this.currentEvent = this.listToPresent[0].Subject
|
||||
this.currentHoursMinutes = this.listToPresent[0].StartDate
|
||||
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[]) => {
|
||||
|
||||
console.log('OFOFOFOOF', process)
|
||||
|
||||
@@ -19,7 +19,7 @@ import { ToastService } from 'src/app/services/toast.service';
|
||||
import { Location } from '@angular/common'
|
||||
import { DespachoService } from 'src/app/Rules/despacho.service';
|
||||
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
||||
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
|
||||
@@ -57,7 +57,8 @@ export class DespachoPrPage implements OnInit {
|
||||
private location: Location,
|
||||
private despachoService: DespachoService,
|
||||
private sqliteservice: SqliteService,
|
||||
private backgroundservice: BackgroundService
|
||||
private backgroundservice: BackgroundService,
|
||||
private platform: Platform,
|
||||
) {
|
||||
this.activatedRoute.paramMap.subscribe(params => {
|
||||
if (params["params"].SerialNumber) {
|
||||
@@ -123,16 +124,14 @@ export class DespachoPrPage implements OnInit {
|
||||
console.log(this.task);
|
||||
|
||||
console.log('GetTask', res);
|
||||
this.sqliteservice.updateProcess(res)
|
||||
this.updateProcessOnDB(res);
|
||||
|
||||
let thedate = new Date(this.task.CreateDate);
|
||||
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
|
||||
|
||||
|
||||
this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users => {
|
||||
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialNumber), JSON.stringify(users)).then(() => {
|
||||
console.log('internen despacho pr ')
|
||||
})
|
||||
this.updateProcessInterveners(users)
|
||||
this.intervenientes = users.filter(user => {
|
||||
return user.Type == 'I';
|
||||
});
|
||||
@@ -162,6 +161,19 @@ export class DespachoPrPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
updateProcessOnDB(res) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.updateProcess(res);
|
||||
}
|
||||
}
|
||||
updateProcessInterveners(users) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialNumber), JSON.stringify(users))
|
||||
}
|
||||
}
|
||||
|
||||
getFromDB() {
|
||||
|
||||
this.sqliteservice.getProcessById(this.serialNumber).then((process: any[]) => {
|
||||
|
||||
@@ -144,14 +144,14 @@ export class DespachoPage implements OnInit {
|
||||
"Status": res.workflowInstanceDataFields.Status,
|
||||
}
|
||||
|
||||
this.sqliteservice.updateProcess(res);
|
||||
this.updateProcessOnDB(res);
|
||||
this.fulltask = res;
|
||||
|
||||
let thedate = new Date(this.task.CreateDate);
|
||||
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
|
||||
|
||||
this.processes.GetTaskParticipants(this.task.FolderID).subscribe(users => {
|
||||
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialnumber), JSON.stringify(users))
|
||||
this.updateProcessInterveners(users)
|
||||
console.log('interveniers online', users)
|
||||
|
||||
this.intervenientes = users.filter(user => {
|
||||
@@ -177,72 +177,88 @@ export class DespachoPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
updateProcessOnDB(res) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.updateProcess(res);
|
||||
}
|
||||
}
|
||||
updateProcessInterveners(users) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialnumber), JSON.stringify(users))
|
||||
}
|
||||
}
|
||||
|
||||
getFromDb() {
|
||||
|
||||
this.platform.ready().then(() => {
|
||||
this.sqliteservice.getProcessById(this.serialnumber).then((process) => {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.getProcessById(this.serialnumber).then((process) => {
|
||||
|
||||
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
|
||||
var intervine = JSON.parse(process[0].interveners)
|
||||
var origina
|
||||
if (process[0].originator === "undefined") {
|
||||
origina = ""
|
||||
} else {
|
||||
origina = JSON.parse(process[0].originator)
|
||||
}
|
||||
var workflow = JSON.parse(process[0].workflowInstanceDataFields);
|
||||
var intervine = JSON.parse(process[0].interveners)
|
||||
var origina
|
||||
if (process[0].originator === "undefined") {
|
||||
origina = ""
|
||||
} else {
|
||||
origina = JSON.parse(process[0].originator)
|
||||
}
|
||||
|
||||
console.log('sqlite', process)
|
||||
console.log('sqlite', process)
|
||||
|
||||
this.task = {
|
||||
"SerialNumber": process[0].serialNumber,
|
||||
"Folio": workflow.Subject,
|
||||
"Senders": origina.email || process[0].originator,
|
||||
"CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
|
||||
"DocumentURL": workflow.ViewerRequest,
|
||||
"Remetente": workflow.Sender,
|
||||
"Note": workflow.TaskMessage || workflow.Note,
|
||||
"FolderId": workflow.FolderID,
|
||||
"FsId": workflow.FsId,
|
||||
"DocId": workflow.DocID,
|
||||
"DocumentsQty": process[0].DocumentsQty,
|
||||
"WorkflowName": process[0].workflowDisplayName,
|
||||
"DeadlineType": workflow.DeadlineType,
|
||||
"activityInstanceName": process[0].activityInstanceName,
|
||||
"Status": workflow.Status,
|
||||
}
|
||||
this.task = {
|
||||
"SerialNumber": process[0].serialNumber,
|
||||
"Folio": workflow.Subject,
|
||||
"Senders": origina.email || process[0].originator,
|
||||
"CreateDate": momentG(new Date(process[0].taskStartDate), 'yyyy-MM-dd HH:mm:ss'),
|
||||
"DocumentURL": workflow.ViewerRequest,
|
||||
"Remetente": workflow.Sender,
|
||||
"Note": workflow.TaskMessage || workflow.Note,
|
||||
"FolderId": workflow.FolderID,
|
||||
"FsId": workflow.FsId,
|
||||
"DocId": workflow.DocID,
|
||||
"DocumentsQty": process[0].DocumentsQty,
|
||||
"WorkflowName": process[0].workflowDisplayName,
|
||||
"DeadlineType": workflow.DeadlineType,
|
||||
"activityInstanceName": process[0].activityInstanceName,
|
||||
"Status": workflow.Status,
|
||||
}
|
||||
|
||||
let thedate = new Date(this.task.CreateDate);
|
||||
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
|
||||
let thedate = new Date(this.task.CreateDate);
|
||||
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
|
||||
|
||||
let fulltak = {
|
||||
Documents: JSON.parse(process[0].Documents),
|
||||
actions: JSON.parse(process[0].actions),
|
||||
activityInstanceName: process[0].activityInstanceName,
|
||||
formURL: process[0].formURL,
|
||||
originator: JSON.parse(process[0].originator),
|
||||
serialNumber: process[0].serialNumber,
|
||||
taskStartDate: process[0].taskStartDate,
|
||||
totalDocuments: process[0].totalDocuments,
|
||||
workflowDisplayName: process[0].workflowDisplayName,
|
||||
workflowID: process[0].workflowID,
|
||||
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
|
||||
workflowInstanceFolio: process[0].workflowInstanceFolio,
|
||||
workflowInstanceID: process[0].workflowInstanceID,
|
||||
workflowName: process[0].workflowName
|
||||
}
|
||||
this.fulltask = fulltak;
|
||||
let fulltak = {
|
||||
Documents: JSON.parse(process[0].Documents),
|
||||
actions: JSON.parse(process[0].actions),
|
||||
activityInstanceName: process[0].activityInstanceName,
|
||||
formURL: process[0].formURL,
|
||||
originator: JSON.parse(process[0].originator),
|
||||
serialNumber: process[0].serialNumber,
|
||||
taskStartDate: process[0].taskStartDate,
|
||||
totalDocuments: process[0].totalDocuments,
|
||||
workflowDisplayName: process[0].workflowDisplayName,
|
||||
workflowID: process[0].workflowID,
|
||||
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
|
||||
workflowInstanceFolio: process[0].workflowInstanceFolio,
|
||||
workflowInstanceID: process[0].workflowInstanceID,
|
||||
workflowName: process[0].workflowName
|
||||
}
|
||||
this.fulltask = fulltak;
|
||||
|
||||
console.log('interveniers offline', intervine)
|
||||
this.intervenientes = intervine.filter(user => {
|
||||
console.log('interveniers offline 2', user)
|
||||
return user.Type == 'I';
|
||||
});
|
||||
this.cc = intervine.filter(user => {
|
||||
console.log('interveniers offline 3', user)
|
||||
return user.Type == 'CC';
|
||||
});
|
||||
console.log('interveniers offline', intervine)
|
||||
this.intervenientes = intervine.filter(user => {
|
||||
console.log('interveniers offline 2', user)
|
||||
return user.Type == 'I';
|
||||
});
|
||||
this.cc = intervine.filter(user => {
|
||||
console.log('interveniers offline 3', user)
|
||||
return user.Type == 'CC';
|
||||
});
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -76,32 +76,35 @@ export class DespachosPage implements OnInit {
|
||||
getFromDb() {
|
||||
|
||||
this.platform.ready().then(() => {
|
||||
this.sqliteservice.getprocessByworkflow('Despacho').then((process: any[]) => {
|
||||
var listtopresent = [];
|
||||
process.forEach(element => {
|
||||
var workflow = JSON.parse(element.workflowInstanceDataFields);
|
||||
let task = {
|
||||
"CreateDate": element.taskStartDate,
|
||||
"DocId": workflow.DispatchDocID,
|
||||
"DocumentURL": undefined,
|
||||
"DocumentsQty": element.totalDocuments,
|
||||
"FolderID": workflow.FolderID,
|
||||
"Folio": workflow.Subject,
|
||||
"Remetente": undefined,
|
||||
"Senders": workflow.Sender,
|
||||
"SerialNumber": element.serialNumber,
|
||||
"Status": workflow.Status,
|
||||
"WorkflowName": element.workflowDisplayName
|
||||
}
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.getprocessByworkflow('Despacho').then((process: any[]) => {
|
||||
var listtopresent = [];
|
||||
process.forEach(element => {
|
||||
var workflow = JSON.parse(element.workflowInstanceDataFields);
|
||||
let task = {
|
||||
"CreateDate": element.taskStartDate,
|
||||
"DocId": workflow.DispatchDocID,
|
||||
"DocumentURL": undefined,
|
||||
"DocumentsQty": element.totalDocuments,
|
||||
"FolderID": workflow.FolderID,
|
||||
"Folio": workflow.Subject,
|
||||
"Remetente": undefined,
|
||||
"Senders": workflow.Sender,
|
||||
"SerialNumber": element.serialNumber,
|
||||
"Status": workflow.Status,
|
||||
"WorkflowName": element.workflowDisplayName
|
||||
}
|
||||
|
||||
listtopresent.push(task);
|
||||
listtopresent.push(task);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
this.listToPresent = listtopresent;
|
||||
console.log('Tarefas de despach', this.listToPresent)
|
||||
this.listToPresent = listtopresent;
|
||||
console.log('Tarefas de despach', this.listToPresent)
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { DeplomaOptionsPage } from 'src/app/shared/popover/deploma-options/deplo
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { Location } from '@angular/common';
|
||||
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
||||
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
|
||||
@@ -47,7 +47,8 @@ export class DiplomaPage implements OnInit {
|
||||
private toastService: ToastService,
|
||||
private location: Location,
|
||||
private sqliteservice: SqliteService,
|
||||
private backgroundservice: BackgroundService
|
||||
private backgroundservice: BackgroundService,
|
||||
private platform: Platform,
|
||||
) {
|
||||
this.activatedRoute.paramMap.subscribe(params => {
|
||||
// console.log(params["params"]);
|
||||
@@ -134,15 +135,13 @@ export class DiplomaPage implements OnInit {
|
||||
"activityInstanceName": res.activityInstanceName,
|
||||
}
|
||||
this.fulltask = res;
|
||||
this.sqliteservice.updateProcess(res)
|
||||
this.updateProcessOnDB(res)
|
||||
|
||||
let thedate = new Date(this.task.CreateDate);
|
||||
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
|
||||
|
||||
this.processes.GetTaskParticipants(this.task.FolderId).subscribe(users => {
|
||||
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialNumber), JSON.stringify(users)).then(() => {
|
||||
console.log('internen diploma ')
|
||||
})
|
||||
this.updateProcessInterveners(users)
|
||||
this.intervenientes = users.filter(user => {
|
||||
return user.Type == 'I';
|
||||
});
|
||||
@@ -167,6 +166,19 @@ export class DiplomaPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
updateProcessOnDB(res) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.updateProcess(res);
|
||||
}
|
||||
}
|
||||
updateProcessInterveners(users) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialNumber), JSON.stringify(users))
|
||||
}
|
||||
}
|
||||
|
||||
getFromDb() {
|
||||
|
||||
this.sqliteservice.getProcessById(this.serialNumber).then((process) => {
|
||||
|
||||
@@ -268,27 +268,31 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
|
||||
|
||||
addProcessToDB(data) {
|
||||
this.platform.ready().then(() => {
|
||||
data.forEach(element => {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
|
||||
let process = {
|
||||
"serialNumber": element.serialNumber,
|
||||
"workflowInstanceFolio": element.workflowInstanceFolio,
|
||||
"Documents": element.Documents,
|
||||
"actions": element.actions,
|
||||
"activityInstanceName": element.activityInstanceName,
|
||||
"formURL": element.formURL,
|
||||
"originator": element.originator,
|
||||
"taskStartDate": element.taskStartDate,
|
||||
"totalDocuments": element.totalDocuments,
|
||||
"workflowDisplayName": element.workflowDisplayName,
|
||||
"workflowID": element.workflowID,
|
||||
"workflowInstanceDataFields": element.workflowInstanceDataFields,
|
||||
"workflowInstanceID": element.workflowInstanceID,
|
||||
"workflowName": element.workflowName
|
||||
}
|
||||
} else {
|
||||
data.forEach(element => {
|
||||
|
||||
this.sqliteservice.addProcess(process);
|
||||
});
|
||||
let process = {
|
||||
"serialNumber": element.serialNumber,
|
||||
"workflowInstanceFolio": element.workflowInstanceFolio,
|
||||
"Documents": element.Documents,
|
||||
"actions": element.actions,
|
||||
"activityInstanceName": element.activityInstanceName,
|
||||
"formURL": element.formURL,
|
||||
"originator": element.originator,
|
||||
"taskStartDate": element.taskStartDate,
|
||||
"totalDocuments": element.totalDocuments,
|
||||
"workflowDisplayName": element.workflowDisplayName,
|
||||
"workflowID": element.workflowID,
|
||||
"workflowInstanceDataFields": element.workflowInstanceDataFields,
|
||||
"workflowInstanceID": element.workflowInstanceID,
|
||||
"workflowName": element.workflowName
|
||||
}
|
||||
|
||||
this.sqliteservice.addProcess(process);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import { AuthService } from 'src/app/services/auth.service';
|
||||
import { LoginUserRespose } from 'src/app/models/user.model';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { ForwardPage } from 'src/app/modals/forward/forward.page';
|
||||
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { Location } from '@angular/common';
|
||||
import { PedidoService } from 'src/app/Rules/pedido.service';
|
||||
|
||||
@@ -62,7 +62,8 @@ export class PedidoPage implements OnInit {
|
||||
private location: Location,
|
||||
private pedidoService: PedidoService,
|
||||
private sqliteservice: SqliteService,
|
||||
private backgroundservices: BackgroundService
|
||||
private backgroundservices: BackgroundService,
|
||||
private platform: Platform
|
||||
) {
|
||||
this.loggeduser = authService.ValidatedUser;
|
||||
|
||||
@@ -127,7 +128,7 @@ export class PedidoPage implements OnInit {
|
||||
"Status": res.workflowInstanceDataFields.Status,
|
||||
}
|
||||
console.log(this.task);
|
||||
this.sqliteservice.updateProcess(res);
|
||||
this.updateProcess(res);
|
||||
}
|
||||
else if (res.workflowDisplayName == 'Pedido de Deferimento') {
|
||||
|
||||
@@ -152,16 +153,14 @@ export class PedidoPage implements OnInit {
|
||||
"activityInstanceName": res.activityInstanceName,
|
||||
"Status": res.workflowInstanceDataFields.Status,
|
||||
}
|
||||
this.sqliteservice.updateProcess(res);
|
||||
this.updateProcess(res)
|
||||
}
|
||||
|
||||
let thedate = new Date(res.taskStartDate);
|
||||
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
|
||||
|
||||
this.processes.GetTaskParticipants(res.workflowInstanceDataFields.FolderID).subscribe(users => {
|
||||
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialnumber), JSON.stringify(users)).then(() => {
|
||||
console.log('Pedido ')
|
||||
})
|
||||
this.updateProcessInterveners(users)
|
||||
this.intervenientes = users.filter(user => {
|
||||
return user.Type == 'I';
|
||||
});
|
||||
@@ -186,93 +185,109 @@ export class PedidoPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
updateProcess(res) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.updateProcess(res);
|
||||
}
|
||||
}
|
||||
|
||||
updateProcessInterveners(users) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.updateProcessInterveners(JSON.stringify(this.serialnumber), JSON.stringify(users));
|
||||
}
|
||||
}
|
||||
|
||||
getfromDb() {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
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 = {
|
||||
Documents: JSON.parse(process[0].Documents) || [],
|
||||
actions: JSON.parse(process[0].actions),
|
||||
activityInstanceName: process[0].activityInstanceName,
|
||||
formURL: process[0].formURL,
|
||||
originator: JSON.parse(process[0].originator),
|
||||
serialNumber: process[0].serialNumber,
|
||||
taskStartDate: process[0].taskStartDate,
|
||||
totalDocuments: process[0].totalDocuments,
|
||||
workflowDisplayName: process[0].workflowDisplayName,
|
||||
workflowID: process[0].workflowID,
|
||||
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
|
||||
workflowInstanceFolio: process[0].workflowInstanceFolio,
|
||||
workflowInstanceID: process[0].workflowInstanceID,
|
||||
workflowName: process[0].workflowName
|
||||
}
|
||||
|
||||
this.fulltask = fulltak;
|
||||
console.log('FULLTAK OFFLINE', this.fulltask);
|
||||
|
||||
if (process[0].workflowDisplayName == 'Pedido de Parecer' || process[0].workflowDisplayName == 'Pedido de Parecer do Presidente') {
|
||||
let date = new Date(process[0].taskStartDate);
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
||||
|
||||
this.task = {
|
||||
"SerialNumber": process[0].serialNumber,
|
||||
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
|
||||
"Senders": JSON.parse(process[0].workflowInstanceDataFields).Sender,
|
||||
"CreateDate": taskDate,
|
||||
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
|
||||
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
|
||||
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage,
|
||||
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
|
||||
"FsId": '361',
|
||||
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DocIdDeferimento,
|
||||
"WorkflowName": process[0].workflowDisplayName,
|
||||
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
|
||||
"ProcessInstanceID": JSON.parse(process[0].workflowInstanceDataFields).InstanceID,
|
||||
"activityInstanceName": process[0].activityInstanceName,
|
||||
"Status": JSON.parse(process[0].workflowInstanceDataFields).Status,
|
||||
let fulltak = {
|
||||
Documents: JSON.parse(process[0].Documents) || [],
|
||||
actions: JSON.parse(process[0].actions),
|
||||
activityInstanceName: process[0].activityInstanceName,
|
||||
formURL: process[0].formURL,
|
||||
originator: JSON.parse(process[0].originator),
|
||||
serialNumber: process[0].serialNumber,
|
||||
taskStartDate: process[0].taskStartDate,
|
||||
totalDocuments: process[0].totalDocuments,
|
||||
workflowDisplayName: process[0].workflowDisplayName,
|
||||
workflowID: process[0].workflowID,
|
||||
workflowInstanceDataFields: JSON.parse(process[0].workflowInstanceDataFields),
|
||||
workflowInstanceFolio: process[0].workflowInstanceFolio,
|
||||
workflowInstanceID: process[0].workflowInstanceID,
|
||||
workflowName: process[0].workflowName
|
||||
}
|
||||
|
||||
this.attachments = JSON.parse(process[0].Documents);
|
||||
} else if (process[0].workflowDisplayName == 'Pedido de Deferimento') {
|
||||
this.fulltask = fulltak;
|
||||
console.log('FULLTAK OFFLINE', this.fulltask);
|
||||
|
||||
let date = new Date(process[0].taskStartDate);
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
||||
this.task = {
|
||||
"SerialNumber": process[0].serialNumber,
|
||||
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
|
||||
"Senders": JSON.parse(process[0].workflowInstanceDataFields).Sender,
|
||||
"CreateDate": taskDate,
|
||||
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
|
||||
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
|
||||
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage,
|
||||
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
|
||||
"FsId": '361',
|
||||
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DocIdDeferimento,
|
||||
"WorkflowName": process[0].workflowDisplayName,
|
||||
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
|
||||
"ProcessInstanceID": JSON.parse(process[0].workflowInstanceDataFields).InstanceID,
|
||||
"activityInstanceName": process[0].activityInstanceName,
|
||||
"Status": JSON.parse(process[0].workflowInstanceDataFields).Status,
|
||||
if (process[0].workflowDisplayName == 'Pedido de Parecer' || process[0].workflowDisplayName == 'Pedido de Parecer do Presidente') {
|
||||
let date = new Date(process[0].taskStartDate);
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
||||
|
||||
this.task = {
|
||||
"SerialNumber": process[0].serialNumber,
|
||||
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
|
||||
"Senders": JSON.parse(process[0].workflowInstanceDataFields).Sender,
|
||||
"CreateDate": taskDate,
|
||||
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
|
||||
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
|
||||
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage,
|
||||
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
|
||||
"FsId": '361',
|
||||
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DocIdDeferimento,
|
||||
"WorkflowName": process[0].workflowDisplayName,
|
||||
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
|
||||
"ProcessInstanceID": JSON.parse(process[0].workflowInstanceDataFields).InstanceID,
|
||||
"activityInstanceName": process[0].activityInstanceName,
|
||||
"Status": JSON.parse(process[0].workflowInstanceDataFields).Status,
|
||||
}
|
||||
|
||||
this.attachments = JSON.parse(process[0].Documents);
|
||||
} else if (process[0].workflowDisplayName == 'Pedido de Deferimento') {
|
||||
|
||||
let date = new Date(process[0].taskStartDate);
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
let taskDate = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
||||
this.task = {
|
||||
"SerialNumber": process[0].serialNumber,
|
||||
"Folio": JSON.parse(process[0].workflowInstanceDataFields).Subject,
|
||||
"Senders": JSON.parse(process[0].workflowInstanceDataFields).Sender,
|
||||
"CreateDate": taskDate,
|
||||
"DocumentURL": JSON.parse(process[0].workflowInstanceDataFields).ViewerRequest,
|
||||
"Remetente": JSON.parse(process[0].workflowInstanceDataFields).Sender,
|
||||
"Note": JSON.parse(process[0].workflowInstanceDataFields).TaskMessage,
|
||||
"FolderId": JSON.parse(process[0].workflowInstanceDataFields).FolderID,
|
||||
"FsId": '361',
|
||||
"DocId": JSON.parse(process[0].workflowInstanceDataFields).DocIdDeferimento,
|
||||
"WorkflowName": process[0].workflowDisplayName,
|
||||
"DeadlineType": JSON.parse(process[0].workflowInstanceDataFields).DeadlineType,
|
||||
"ProcessInstanceID": JSON.parse(process[0].workflowInstanceDataFields).InstanceID,
|
||||
"activityInstanceName": process[0].activityInstanceName,
|
||||
"Status": JSON.parse(process[0].workflowInstanceDataFields).Status,
|
||||
}
|
||||
this.attachments = JSON.parse(process[0].Documents);
|
||||
}
|
||||
this.attachments = JSON.parse(process[0].Documents);
|
||||
}
|
||||
|
||||
let thedate = new Date(process[0].taskStartDate);
|
||||
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
|
||||
let thedate = new Date(process[0].taskStartDate);
|
||||
this.customDate = this.days[thedate.getDay()] + ", " + thedate.getDate() + " de " + (this.months[thedate.getMonth()]);
|
||||
|
||||
this.intervenientes = JSON.parse(process[0].interveners).filter(user => {
|
||||
return user.Type == 'I';
|
||||
});
|
||||
this.cc = JSON.parse(process[0].interveners).filter(user => {
|
||||
return user.Type == 'CC';
|
||||
});
|
||||
this.getDocumentDetails(JSON.parse(process[0].workflowInstanceDataFields).FolderID, '361');
|
||||
this.intervenientes = JSON.parse(process[0].interveners).filter(user => {
|
||||
return user.Type == 'I';
|
||||
});
|
||||
this.cc = JSON.parse(process[0].interveners).filter(user => {
|
||||
return user.Type == 'CC';
|
||||
});
|
||||
this.getDocumentDetails(JSON.parse(process[0].workflowInstanceDataFields).FolderID, '361');
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
getDocumentDetails(forlderId: string, applicationId: string) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, NavigationEnd } from '@angular/router';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { ModalController, Platform } from '@ionic/angular';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
import { NewActionPage } from './new-action/new-action.page';
|
||||
@@ -65,7 +65,8 @@ export class PublicationsPage implements OnInit {
|
||||
private publications: PublicationsService,
|
||||
private toastService: ToastService,
|
||||
private sqliteservice: SqliteService,
|
||||
private backgroundservice: BackgroundService
|
||||
private backgroundservice: BackgroundService,
|
||||
private platform: Platform
|
||||
) {
|
||||
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"];
|
||||
@@ -150,7 +151,7 @@ export class PublicationsPage implements OnInit {
|
||||
ActionType: data.ActionType,
|
||||
}
|
||||
|
||||
this.sqliteservice.addactions(folder);
|
||||
this.addActionToDB(folder)
|
||||
|
||||
if (data.ActionType == "Evento") {
|
||||
console.log('Evento', folder)
|
||||
@@ -172,35 +173,45 @@ export class PublicationsPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
addActionToDB(folder) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.addactions(folder);
|
||||
}
|
||||
}
|
||||
|
||||
getFromDB() {
|
||||
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.sqliteservice.getAllActions().then((actions: any[]) => {
|
||||
|
||||
this.sqliteservice.getAllActions().then((actions: any[]) => {
|
||||
console.log('offline publi', actions)
|
||||
|
||||
console.log('offline publi', actions)
|
||||
this.publicationsEventFolderList = new Array();
|
||||
this.publicationsTravelFolderList = new Array();
|
||||
|
||||
this.publicationsEventFolderList = new Array();
|
||||
this.publicationsTravelFolderList = new Array();
|
||||
actions.forEach(data => {
|
||||
let folder: PublicationFolder = {
|
||||
ProcessId: data.ProcessId,
|
||||
Description: data.Description,
|
||||
Detail: data.Detail,
|
||||
DateBegin: data.DateBegin,
|
||||
DateEnd: data.DateEnd,
|
||||
ActionType: data.ActionType,
|
||||
}
|
||||
|
||||
actions.forEach(data => {
|
||||
let folder: PublicationFolder = {
|
||||
ProcessId: data.ProcessId,
|
||||
Description: data.Description,
|
||||
Detail: data.Detail,
|
||||
DateBegin: data.DateBegin,
|
||||
DateEnd: data.DateEnd,
|
||||
ActionType: data.ActionType,
|
||||
}
|
||||
if (data.ActionType == "Evento") {
|
||||
this.publicationsEventFolderList.push(folder);
|
||||
}
|
||||
else {
|
||||
this.publicationsTravelFolderList.push(folder);
|
||||
}
|
||||
this.showLoader = false;
|
||||
});
|
||||
|
||||
if (data.ActionType == "Evento") {
|
||||
this.publicationsEventFolderList.push(folder);
|
||||
}
|
||||
else {
|
||||
this.publicationsTravelFolderList.push(folder);
|
||||
}
|
||||
this.showLoader = false;
|
||||
});
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async editAction(folderId?: string) {
|
||||
|
||||
@@ -346,7 +346,7 @@ export class EventsService {
|
||||
|
||||
return this.http.put<Event>(`${puturl}`, event, options).pipe(
|
||||
catchError(err => {
|
||||
this.offlinemanager.storeRequest(puturl, 'PUT', arrayReq);
|
||||
this.offlinemanager.storeRequestData('eventEdit', arrayReq);
|
||||
throw new Error(err);
|
||||
})
|
||||
)
|
||||
@@ -432,6 +432,13 @@ export class EventsService {
|
||||
}
|
||||
|
||||
deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) {
|
||||
let arrayReq = [];
|
||||
let Object = {
|
||||
eventid: eventid,
|
||||
eventDeleteType: eventDeleteType,
|
||||
calendarName: calendarName
|
||||
}
|
||||
arrayReq.push(Object)
|
||||
const puturl = environment.apiURL + 'calendar/DeleteEvent';
|
||||
let params = new HttpParams();
|
||||
|
||||
@@ -472,7 +479,12 @@ export class EventsService {
|
||||
break;
|
||||
}
|
||||
|
||||
return this.http.delete(`${puturl}`, options)
|
||||
return this.http.delete(`${puturl}`, options).pipe(
|
||||
catchError(err => {
|
||||
this.offlinemanager.storeRequestData('eventDelete', arrayReq);
|
||||
throw new Error(err);
|
||||
})
|
||||
)
|
||||
}
|
||||
postExpedientEvent(docId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) {
|
||||
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/event';
|
||||
|
||||
@@ -4,91 +4,40 @@ 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
|
||||
}
|
||||
|
||||
import { BackgroundService } from 'src/app/services/background.service';
|
||||
import { EventsService } from 'src/app/services/events.service';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class OfflineManagerService {
|
||||
|
||||
/* eventservice: EventsService */
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
private storage: Storage,
|
||||
/* private backgroundservice: BackgroundService */) { }
|
||||
|
||||
synchnize() {
|
||||
/* this.backgroundservice.registerBackService('Online', () => {
|
||||
this.storage.get('eventEdit').then((req) => {
|
||||
JSON.parse(req).forEach(element => {
|
||||
this.eventservice.editEvent(element, 2, 3).subscribe((res) => {
|
||||
this.storage.remove('eventEdit')
|
||||
console.log('eventEdit synchnize', res)
|
||||
})
|
||||
});
|
||||
})
|
||||
)
|
||||
}) */
|
||||
}
|
||||
|
||||
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));
|
||||
});
|
||||
|
||||
storeRequestData(key, data) {
|
||||
return this.storage.set(key, JSON.stringify(data));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
sendRequestData(key) {
|
||||
return this.storage.get(key)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,13 +26,15 @@ export class SqliteService {
|
||||
}
|
||||
|
||||
databaseConn() {
|
||||
this.platform.ready().then(async () => {
|
||||
await this.sqlite.create({
|
||||
name: this.db_name,
|
||||
location: 'default'
|
||||
}).then(async (sqLite: SQLiteObject) => {
|
||||
this.dbInstance = sqLite;
|
||||
await sqLite.executeSql(`
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
} else {
|
||||
this.platform.ready().then(async () => {
|
||||
await this.sqlite.create({
|
||||
name: this.db_name,
|
||||
location: 'default'
|
||||
}).then(async (sqLite: SQLiteObject) => {
|
||||
this.dbInstance = sqLite;
|
||||
await sqLite.executeSql(`
|
||||
CREATE TABLE IF NOT EXISTS ${this.events} (
|
||||
EventId varchar(255) PRIMARY KEY,
|
||||
Subject varchar(255),
|
||||
@@ -57,12 +59,12 @@ export class SqliteService {
|
||||
Profile varchar(255),
|
||||
HumanDate varchar(255)
|
||||
)`, [])
|
||||
.then((res) => {
|
||||
console.log("Sucess Events Table created: ", res)
|
||||
})
|
||||
.catch((error) => console.log(JSON.stringify(error)));
|
||||
.then((res) => {
|
||||
console.log("Sucess Events Table created: ", res)
|
||||
})
|
||||
.catch((error) => console.log(JSON.stringify(error)));
|
||||
|
||||
await sqLite.executeSql(`
|
||||
await sqLite.executeSql(`
|
||||
CREATE TABLE IF NOT EXISTS ${this.expedientes} (
|
||||
serialNumber varchar(255) PRIMARY KEY,
|
||||
workflowInstanceFolio varchar(255),
|
||||
@@ -79,12 +81,12 @@ export class SqliteService {
|
||||
workflowInstanceID INTERGER,
|
||||
workflowName varchar(255)
|
||||
)`, [])
|
||||
.then((res) => {
|
||||
console.log("Sucess Espedientes Table created: ", res)
|
||||
})
|
||||
.catch((error) => console.log(JSON.stringify(error)));
|
||||
.then((res) => {
|
||||
console.log("Sucess Espedientes Table created: ", res)
|
||||
})
|
||||
.catch((error) => console.log(JSON.stringify(error)));
|
||||
|
||||
await sqLite.executeSql(`
|
||||
await sqLite.executeSql(`
|
||||
CREATE TABLE IF NOT EXISTS ${this.allprocess} (
|
||||
serialNumber varchar(255) PRIMARY KEY,
|
||||
workflowInstanceFolio varchar(255),
|
||||
@@ -102,12 +104,12 @@ export class SqliteService {
|
||||
workflowName varchar(255),
|
||||
interveners Text
|
||||
)`, [])
|
||||
.then((res) => {
|
||||
console.log("Sucess AllProcess Table created: ", res)
|
||||
})
|
||||
.catch((error) => console.log(JSON.stringify(error)));
|
||||
.then((res) => {
|
||||
console.log("Sucess AllProcess Table created: ", res)
|
||||
})
|
||||
.catch((error) => console.log(JSON.stringify(error)));
|
||||
|
||||
await sqLite.executeSql(`
|
||||
await sqLite.executeSql(`
|
||||
CREATE TABLE IF NOT EXISTS ${this.actions} (
|
||||
ProcessId INTERGER PRIMARY KEY,
|
||||
ActionType varchar(255),
|
||||
@@ -117,13 +119,14 @@ export class SqliteService {
|
||||
Description varchar(255),
|
||||
publications Text
|
||||
)`, [])
|
||||
.then((res) => {
|
||||
console.log("Sucess action Table created: ", res)
|
||||
})
|
||||
.then((res) => {
|
||||
console.log("Sucess action Table created: ", res)
|
||||
})
|
||||
.catch((error) => console.log(JSON.stringify(error)));
|
||||
})
|
||||
.catch((error) => console.log(JSON.stringify(error)));
|
||||
})
|
||||
.catch((error) => console.log(JSON.stringify(error)));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//addactions
|
||||
@@ -182,8 +185,8 @@ export class SqliteService {
|
||||
});
|
||||
}
|
||||
|
||||
//updateevent
|
||||
public updateEvent(data) {
|
||||
//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}',
|
||||
@@ -197,10 +200,10 @@ export class SqliteService {
|
||||
}
|
||||
|
||||
//updateActions
|
||||
public updateactions(id,data) {
|
||||
console.log("update action data", data )
|
||||
public updateactions(id, data) {
|
||||
console.log("update action data", data)
|
||||
this.dbInstance.executeSql(`
|
||||
UPDATE ${this.actions} SET publications = ? WHERE ProcessId = ${id}`,[data])
|
||||
UPDATE ${this.actions} SET publications = ? WHERE ProcessId = ${id}`, [data])
|
||||
.then(() => {
|
||||
console.log("action update with Success");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user