diff --git a/config.xml b/config.xml index 2e850bb20..7cb062033 100644 --- a/config.xml +++ b/config.xml @@ -3,7 +3,7 @@ gabinete digital An awesome Ionic/Cordova app. Ionic Framework Team - + diff --git a/src/app/pages/chat/messages/messages.page.ts b/src/app/pages/chat/messages/messages.page.ts index 2b4c147e7..0c01a9ea7 100644 --- a/src/app/pages/chat/messages/messages.page.ts +++ b/src/app/pages/chat/messages/messages.page.ts @@ -12,7 +12,6 @@ import { AuthService } from 'src/app/services/auth.service'; import { ChatService } from 'src/app/services/chat.service'; import { FileService } from 'src/app/services/functions/file.service'; import { ProcessesService } from 'src/app/services/processes.service'; -import { synchro } from 'src/app/services/socket/synchro.service'; import { ToastService } from 'src/app/services/toast.service'; import { NewEventPage } from 'src/app/shared/agenda/new-event/new-event.page'; import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popover/chat-options-popover.page'; @@ -45,7 +44,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy { members:any; scrollingOnce:boolean = true; - synchro = synchro; chatMessageStore = ChatMessageStore chatUserStorage = ChatUserStorage diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts index a9b88b3b2..360f71d8c 100644 --- a/src/app/pages/events/events.page.ts +++ b/src/app/pages/events/events.page.ts @@ -17,7 +17,6 @@ import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx'; import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe'; import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service'; import { SqliteService } from 'src/app/services/sqlite.service'; -import { synchro } from '../../services/socket/synchro.service'; import { NetworkConnectionService } from 'src/app/services/network-connection.service' import { BackgroundService } from 'src/app/services/background.service'; @@ -79,7 +78,6 @@ export class EventsPage implements OnInit { loggeduser: LoginUserRespose; existingScreenOrientation: string; - synch = synchro constructor( private eventService: EventsService, diff --git a/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts b/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts index 156d921b9..96bd68c43 100644 --- a/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts +++ b/src/app/pages/gabinete-digital/despachos-pr/despacho-pr/despacho-pr.page.ts @@ -21,7 +21,6 @@ import { DespachoService } from 'src/app/Rules/despacho.service'; import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page'; import { SqliteService } from 'src/app/services/sqlite.service'; -import { synchro } from 'src/app/services/socket/synchro.service'; import { BackgroundService } from 'src/app/services/background.service'; @Component({ diff --git a/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts b/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts index ccbf7579e..2043460b5 100644 --- a/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts +++ b/src/app/pages/gabinete-digital/despachos/despacho/despacho.page.ts @@ -19,7 +19,6 @@ import { AttachmentList } from 'src/app/models/Excludetask'; import { PermissionService } from 'src/app/services/worker/permission.service'; import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page'; -import { synchro } from 'src/app/services/socket/synchro.service'; import { SqliteService } from 'src/app/services/sqlite.service'; import { Platform } from '@ionic/angular'; import { BackgroundService } from 'src/app/services/background.service'; @@ -47,8 +46,6 @@ export class DespachoPage implements OnInit { intervenientes: any; cc: any = []; - synch = synchro; - constructor(private activateRoute: ActivatedRoute, private processes: ProcessesService, private iab: InAppBrowser, diff --git a/src/app/pages/gabinete-digital/despachos/despachos.page.ts b/src/app/pages/gabinete-digital/despachos/despachos.page.ts index 37823aa68..cf1beeaa0 100644 --- a/src/app/pages/gabinete-digital/despachos/despachos.page.ts +++ b/src/app/pages/gabinete-digital/despachos/despachos.page.ts @@ -4,7 +4,6 @@ import { DespachoService } from 'src/app/Rules/despacho.service'; import { DespachoStore } from 'src/app/store/despacho-store.service'; import { SqliteService } from 'src/app/services/sqlite.service'; -import { synchro } from 'src/app/services/socket/synchro.service'; import { Platform } from '@ionic/angular'; import { isThisHour } from 'date-fns'; import { BackgroundService } from 'src/app/services/background.service'; @@ -18,7 +17,6 @@ import { BackgroundService } from 'src/app/services/background.service'; export class DespachosPage implements OnInit { despachoStore = DespachoStore; - synch = synchro; listToPresent = []; constructor( diff --git a/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts b/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts index 566d1b16d..ae310da3d 100644 --- a/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts +++ b/src/app/pages/gabinete-digital/diplomas/diploma/diploma.page.ts @@ -14,7 +14,6 @@ import { Location } from '@angular/common'; import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page'; import { SqliteService } from 'src/app/services/sqlite.service'; -import { synchro } from 'src/app/services/socket/synchro.service'; import { BackgroundService } from 'src/app/services/background.service'; @Component({ diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.ts b/src/app/pages/gabinete-digital/gabinete-digital.page.ts index adb7b3693..346fe3e06 100644 --- a/src/app/pages/gabinete-digital/gabinete-digital.page.ts +++ b/src/app/pages/gabinete-digital/gabinete-digital.page.ts @@ -26,7 +26,6 @@ import { PermissionService } from 'src/app/services/worker/permission.service'; import { SqliteService } from '../../services/sqlite.service'; -import { synchro } from '../../services/socket/synchro.service'; import { Platform } from '@ionic/angular'; import { BackgroundService } from 'src/app/services/background.service'; @@ -110,9 +109,6 @@ export class GabineteDigitalPage implements OnInit, DoCheck { // // pipe - synch = synchro; - - customTaskPipe = new CustomTaskPipe() @ViewChild(ExpedientsPage) expedientesPage: ExpedientsPage; diff --git a/src/app/pages/publications/publication-detail/publication-detail.page.ts b/src/app/pages/publications/publication-detail/publication-detail.page.ts index 90d2efc93..8160c658b 100644 --- a/src/app/pages/publications/publication-detail/publication-detail.page.ts +++ b/src/app/pages/publications/publication-detail/publication-detail.page.ts @@ -7,7 +7,7 @@ import { ImageModalPage } from '../gallery/image-modal/image-modal.page'; import { NewPublicationPage } from '../new-publication/new-publication.page'; import { Location } from '@angular/common'; 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({ @@ -28,7 +28,8 @@ export class PublicationDetailPage implements OnInit { private animationController: AnimationController, private toastService: ToastService, private location: Location, - private sqliteservice: SqliteService ) { + private sqliteservice: SqliteService, + private backgroundservice: BackgroundService ) { this.publicationId = this.navParams.get('publicationId'); /* this.folderId = this.navParams.get('folderIdId'); */ @@ -81,11 +82,7 @@ export class PublicationDetailPage implements OnInit { } getFromDB() { - if(synchro.connected === true) { - } else { - - } } close() { diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index 70b5f7da8..f98774851 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -14,7 +14,7 @@ import { ToastService } from 'src/app/services/toast.service'; import { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service'; import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.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({ selector: 'app-publications', @@ -64,14 +64,28 @@ export class PublicationsPage implements OnInit { private animationController: AnimationController, private publications: PublicationsService, 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.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"]; } 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() { @@ -153,50 +167,40 @@ export class PublicationsPage implements OnInit { }); + }, (error) => { + this.getFromDB(); }); } getFromDB() { - if (synchro.connected === true) { - const pathname = window.location.pathname + this.sqliteservice.getAllActions().then((actions: any[]) => { - this.router.events.forEach((event) => { - if (event instanceof NavigationEnd && event.url == pathname) { - this.getActions(); + console.log('offline publi', actions) + + this.publicationsEventFolderList = new Array(); + this.publicationsTravelFolderList = new Array(); + + actions.forEach(data => { + let folder: PublicationFolder = { + ProcessId: data.ProcessId, + Description: data.Description, + Detail: data.Detail, + DateBegin: data.DateBegin, + DateEnd: data.DateEnd, + ActionType: data.ActionType, } + + if (data.ActionType == "Evento") { + this.publicationsEventFolderList.push(folder); + } + else { + this.publicationsTravelFolderList.push(folder); + } + this.showLoader = false; }); - this.hideRefreshButton(); - } else { - this.sqliteservice.getAllActions().then((actions: any[]) => { - - console.log('offline publi', actions) - - this.publicationsEventFolderList = new Array(); - this.publicationsTravelFolderList = new Array(); - - actions.forEach(data => { - let folder: PublicationFolder = { - ProcessId: data.ProcessId, - Description: data.Description, - Detail: data.Detail, - DateBegin: data.DateBegin, - DateEnd: data.DateEnd, - ActionType: data.ActionType, - } - - if (data.ActionType == "Evento") { - this.publicationsEventFolderList.push(folder); - } - else { - this.publicationsTravelFolderList.push(folder); - } - this.showLoader = false; - }); - - }) - } + }) } async editAction(folderId?: string) { diff --git a/src/app/pages/publications/view-publications/view-publications.page.ts b/src/app/pages/publications/view-publications/view-publications.page.ts index 3fb9a9676..a41378420 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.ts +++ b/src/app/pages/publications/view-publications/view-publications.page.ts @@ -11,7 +11,7 @@ import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-f import { NewPublicationPage } from '../new-publication/new-publication.page'; import { PublicationDetailPage } from './publication-detail/publication-detail.page'; import { SqliteService } from 'src/app/services/sqlite.service'; -import { synchro } from 'src/app/services/socket/synchro.service'; +import { BackgroundService } from 'src/app/services/background.service'; @Component({ selector: 'app-view-publications', @@ -42,7 +42,8 @@ export class ViewPublicationsPage implements OnInit { private publications: PublicationsService, private activatedRoute: ActivatedRoute, private router: Router, - private sqliteservice: SqliteService) { + private sqliteservice: SqliteService, + private backgroundservice: BackgroundService) { this.item = new PublicationFolder(); this.activatedRoute.paramMap.subscribe(params => { @@ -63,7 +64,16 @@ export class ViewPublicationsPage implements OnInit { 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; }, (error) => { + if(error.status == '0') { + this.getFromDB(); + } if (error.status == '404') { this.error = 'Sem publicações disponíveis!'; this.publicationList = []; @@ -142,47 +155,38 @@ export class ViewPublicationsPage implements OnInit { } getFromDB() { - if (synchro.connected === true) { - this.getPublicationDetail(); - setTimeout(() => { - this.getPublications(); - }, 5000); - } else { + this.sqliteservice.getActionById(this.folderId).then((publications) => { + console.log('publications', publications) + let item = { + ActionType: publications[0].ActionType, + DateBegin: publications[0].DateBegin, + DateEnd: publications[0].DateEnd, + Description: publications[0].Description, + Detail: publications[0].Detail, + ProcessId: publications[0].ProcessId + } + this.publicationDitails = item; - this.sqliteservice.getActionById(this.folderId).then((publications) => { - console.log('publications', publications) - let item = { - ActionType: publications[0].ActionType, - DateBegin: publications[0].DateBegin, - DateEnd: publications[0].DateEnd, - Description: publications[0].Description, - Detail: publications[0].Detail, - ProcessId: publications[0].ProcessId + let publicationArray = []; + JSON.parse(publications[0].publications).forEach(element => { + let publicationlis = { + DateIndex: element.DateIndex, + DatePublication: element.DatePublication, + DocumentId: element.DocumentId, + FileBase64: element.FileBase64, + FileExtension: element.FileExtension, + Message: element.Message, + OrganicEntityId: element.OrganicEntityId, + OriginalFileName: element.OriginalFileName, + ProcessId: element.ProcessId } - this.publicationDitails = item; + publicationArray.push(publicationlis); - let publicationArray = []; - JSON.parse(publications[0].publications).forEach(element => { - let publicationlis = { - DateIndex: element.DateIndex, - DatePublication: element.DatePublication, - DocumentId: element.DocumentId, - FileBase64: element.FileBase64, - FileExtension: element.FileExtension, - Message: element.Message, - OrganicEntityId: element.OrganicEntityId, - OriginalFileName: element.OriginalFileName, - ProcessId: element.ProcessId - } - publicationArray.push(publicationlis); - - }); + }); - this.getpublication = publicationArray; - }) - - } + this.getpublication = publicationArray; + }) } async AddPublication(publicationType: any, folderId: any) { diff --git a/src/app/services/background.service.ts b/src/app/services/background.service.ts index 9e303344f..84ed29d7c 100644 --- a/src/app/services/background.service.ts +++ b/src/app/services/background.service.ts @@ -6,7 +6,7 @@ import { Injectable } from '@angular/core'; export class BackgroundService { callBacks: { - type: 'Offline' | 'Online', + type: 'Offline' | 'Online' | 'Notification', object?: string funx: Function }[] = [] @@ -39,7 +39,7 @@ export class BackgroundService { }) } - registerBackService(type: 'Offline' | 'Online', funx: Function, object = '') { + registerBackService(type: 'Offline' | 'Online' | 'Notification', funx: Function, object = '') { this.callBacks.push({ type, funx, diff --git a/src/app/services/events.service.ts b/src/app/services/events.service.ts index f2d3221e3..2c7b591f1 100644 --- a/src/app/services/events.service.ts +++ b/src/app/services/events.service.ts @@ -1,16 +1,16 @@ import { Injectable } from '@angular/core'; import { Event, EventToApproveEdit } from '../models/event.model'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; -import { Observable, from} from 'rxjs'; +import { Observable, from } from 'rxjs'; import { environment } from 'src/environments/environment'; import { AuthService } from '../services/auth.service'; import { UserSession } from '../models/user.model'; import { EventList } from '../models/agenda/AgendaEventList'; import { ChangeProfileService } from './change-profile.service'; import { OfflineManagerService } from 'src/app/services/offline-manager.service'; -import { synchro } from 'src/app/services/socket/synchro.service'; import { catchError } from "rxjs/operators"; import { Storage } from '@ionic/storage'; +import { BackgroundService } from 'src/app/services/background.service'; @Injectable({ @@ -32,12 +32,12 @@ export class EventsService { headersSharedPessoal: HttpHeaders; constructor( - private http: HttpClient, + private http: HttpClient, public user: AuthService, private changeProfileService: ChangeProfileService, private offlinemanager: OfflineManagerService, - private storage: Storage) - { + private storage: Storage, + private backgroundservice: BackgroundService) { this.loggeduser = this.user.ValidatedUser; @@ -50,9 +50,9 @@ export class EventsService { this.headersSharedOficial = new HttpHeaders(); this.headersSharedPessoal = new HttpHeaders(); - + this.setHeader() - this.changeProfileService.registerCallback(()=>{ + this.changeProfileService.registerCallback(() => { this.loggeduser = this.user.ValidatedUser; this.setHeader() }) @@ -61,16 +61,16 @@ export class EventsService { setHeader() { - if(this.loggeduser){ - if(this.loggeduser.Profile == 'MDGPR') { + if (this.loggeduser) { + if (this.loggeduser.Profile == 'MDGPR') { this.loggeduser.OwnerCalendars.forEach(calendar => { - if(calendar.CalendarName == 'Oficial') { + if (calendar.CalendarName == 'Oficial') { this.headersMdOficial = this.headersMdOficial.set('Authorization', this.loggeduser.BasicAuthKey); this.headersMdOficial = this.headersMdOficial.set('CalendarId', calendar.CalendarId); this.headersMdOficial = this.headersMdOficial.set('CalendarRoleId', calendar.CalendarRoleId); } - else if(calendar.CalendarName == 'Pessoal') { + else if (calendar.CalendarName == 'Pessoal') { this.headersMdPessoal = this.headersMdPessoal.set('Authorization', this.loggeduser.BasicAuthKey); this.headersMdPessoal = this.headersMdPessoal.set('CalendarId', calendar.CalendarId); this.headersMdPessoal = this.headersMdPessoal.set('CalendarRoleId', calendar.CalendarRoleId); @@ -79,27 +79,27 @@ export class EventsService { }); this.loggeduser.SharedCalendars.forEach(sharedCalendar => { - if(sharedCalendar.CalendarName == 'Oficial') { + if (sharedCalendar.CalendarName == 'Oficial') { this.headersSharedOficial = this.headersSharedOficial.set('Authorization', this.loggeduser.BasicAuthKey); this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', sharedCalendar.CalendarId); this.headersSharedOficial = this.headersSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId); } - else if(sharedCalendar.CalendarName == 'Pessoal') { + else if (sharedCalendar.CalendarName == 'Pessoal') { this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', this.loggeduser.BasicAuthKey); this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', sharedCalendar.CalendarId); this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId); } }); } - else if(this.loggeduser.Profile == 'PR') { + else if (this.loggeduser.Profile == 'PR') { - this.loggeduser.OwnerCalendars.forEach(calendar =>{ - if(calendar.CalendarName == 'Oficial'){ + this.loggeduser.OwnerCalendars.forEach(calendar => { + if (calendar.CalendarName == 'Oficial') { this.headersPrOficial = this.headersPrOficial.set('Authorization', this.loggeduser.BasicAuthKey); this.headersPrOficial = this.headersPrOficial.set('CalendarId', calendar.CalendarId); this.headersPrOficial = this.headersPrOficial.set('CalendarRoleId', calendar.CalendarRoleId); } - else if(calendar.CalendarName == 'Pessoal') { + else if (calendar.CalendarName == 'Pessoal') { this.headersPrPessoal = this.headersPrPessoal.set('Authorization', this.loggeduser.BasicAuthKey); this.headersPrPessoal = this.headersPrPessoal.set('CalendarId', calendar.CalendarId); this.headersPrPessoal = this.headersPrPessoal.set('CalendarRoleId', calendar.CalendarRoleId); @@ -128,9 +128,9 @@ export class EventsService { } */ - getAllPrOficialEvents(startdate:string, enddate:string): Observable{ + getAllPrOficialEvents(startdate: string, enddate: string): Observable { let geturl = environment.apiURL + 'calendar/pr'; - geturl = geturl.replace('/V4/','/V5/') + geturl = geturl.replace('/V4/', '/V5/') let params = new HttpParams(); @@ -144,9 +144,9 @@ export class EventsService { return this.http.get(`${geturl}`, options); } - getAllPrPessoalEvents(startdate:string, enddate:string): Observable{ + getAllPrPessoalEvents(startdate: string, enddate: string): Observable { let geturl = environment.apiURL + 'calendar/pr'; - geturl = geturl.replace('/V4/','/V5/') + geturl = geturl.replace('/V4/', '/V5/') let params = new HttpParams(); @@ -160,17 +160,17 @@ export class EventsService { return this.http.get(`${geturl}`, options); } - async getAllPrEvents(startdate:string, enddate:string): Promise{ + async getAllPrEvents(startdate: string, enddate: string): Promise { let prO = await this.getAllPrOficialEvents(startdate, enddate).toPromise(); let prP = await this.getAllPrPessoalEvents(startdate, enddate).toPromise(); const resFinal = prO.concat(prP); - return new Promise(resolve =>{ + return new Promise(resolve => { return resolve(resFinal) }) } - getAllMdOficialEvents(startdate:string, enddate:string): Observable{ - let geturl = environment.apiURL + 'calendar/md'; + getAllMdOficialEvents(startdate: string, enddate: string): Observable { + let geturl = environment.apiURL + 'calendar/md'; let params = new HttpParams(); @@ -184,7 +184,7 @@ export class EventsService { return this.http.get(`${geturl}`, options); } - getAllMdPessoalEvents(startdate:string, enddate:string): any{ + getAllMdPessoalEvents(startdate: string, enddate: string): any { let geturl = environment.apiURL + 'calendar/md'; let params = new HttpParams(); @@ -199,30 +199,30 @@ export class EventsService { return this.http.get(`${geturl}`, options) } - async getAllMdEvents(startdate:string, enddate:string) { + async getAllMdEvents(startdate: string, enddate: string) { let prO = await this.getAllMdOficialEvents(startdate, enddate).toPromise(); let prP = await this.getAllMdPessoalEvents(startdate, enddate).toPromise(); const resFinal = prO.concat(prP); - return new Promise(resolve =>{ + return new Promise(resolve => { return resolve(resFinal) }); } - async getAllSharedEvents(startdate:string, enddate:string) { + async getAllSharedEvents(startdate: string, enddate: string) { let prO = await this.getAllSharedOficialEvents(startdate, enddate).toPromise(); let prP = await this.getAllSharedPessoalEvents(startdate, enddate).toPromise(); const resFinal = prO.concat(prP); - return new Promise(resolve =>{ + return new Promise(resolve => { return resolve(resFinal) }); } - getAllSharedOficialEvents(startdate:string, enddate:string): Observable{ + getAllSharedOficialEvents(startdate: string, enddate: string): Observable { let geturl = environment.apiURL + 'calendar/pr'; - geturl = geturl.replace('/V4/','/V5/') + geturl = geturl.replace('/V4/', '/V5/') let params = new HttpParams(); @@ -238,9 +238,9 @@ export class EventsService { return this.http.get(`${geturl}`, options); } - getAllSharedPessoalEvents(startdate:string, enddate:string): Observable{ + getAllSharedPessoalEvents(startdate: string, enddate: string): Observable { let geturl = environment.apiURL + 'calendar/pr'; - geturl = geturl.replace('/V4/','/V5/') + geturl = geturl.replace('/V4/', '/V5/') let params = new HttpParams(); @@ -255,7 +255,7 @@ export class EventsService { } - getRecurrenceTypes(): any{ + getRecurrenceTypes(): any { const geturl = environment.apiURL + 'Calendar/RecurrenceTypes'; let options = { headers: this.headers, @@ -264,7 +264,7 @@ export class EventsService { } - getEvents(calendarname:string, startdate:string, enddate:string): Observable{ + getEvents(calendarname: string, startdate: string, enddate: string): Observable { const geturl = environment.apiURL + 'calendar/GetEvents'; let params = new HttpParams(); @@ -279,7 +279,7 @@ export class EventsService { return this.http.get(`${geturl}`, options); } - getEvent(eventid: string): Observable{ + getEvent(eventid: string): Observable { let geturl = environment.apiURL + 'calendar/GetEvent'; let params = new HttpParams(); @@ -293,8 +293,7 @@ export class EventsService { return this.http.get(`${geturl}`, options); } - putEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number, sharedagenda:string): Observable - { + putEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number, sharedagenda: string): Observable { const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PutEvent'); let params = new HttpParams(); @@ -310,55 +309,50 @@ export class EventsService { return this.http.put(`${puturl}`, event, options) } - editEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number): Observable - { + editEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number): Observable { let arrayReq = []; + arrayReq.push(event); const puturl = environment.apiURL + 'calendar/PutEvent'; - if(synchro.connected === false) { - arrayReq.push(event) - return from(this.storage.set('storedreq', arrayReq)) - } else { - let params = new HttpParams(); + let params = new HttpParams(); - params = params.set("conflictResolutionMode", conflictResolutionMode.toString()); - params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString()); - params.set('CalendarId', event.CalendarId) - params.set('CalendarName', event.CalendarName) - this.headers['CalendarId'] = event.CalendarId - this.headers['CalendarName'] = event.CalendarName - - if(event.CalendarName == 'Oficial'){ - if(this.loggeduser.Profile == 'MDGPR'){ - this.headers = this.headersMdOficial; - } - else if(this.loggeduser.Profile == 'PR'){ - this.headers = this.headersPrOficial; - } + params = params.set("conflictResolutionMode", conflictResolutionMode.toString()); + params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString()); + params.set('CalendarId', event.CalendarId) + params.set('CalendarName', event.CalendarName) + this.headers['CalendarId'] = event.CalendarId + this.headers['CalendarName'] = event.CalendarName + + if (event.CalendarName == 'Oficial') { + if (this.loggeduser.Profile == 'MDGPR') { + this.headers = this.headersMdOficial; } - else{ - if(this.loggeduser.Profile == 'MDGPR'){ - this.headers = this.headersMdPessoal; - } - else if(this.loggeduser.Profile == 'PR'){ - this.headers = this.headersPrPessoal; - } + else if (this.loggeduser.Profile == 'PR') { + this.headers = this.headersPrOficial; } - - let options = { - headers: this.headers, - params: params - }; - - return this.http.put(`${puturl}`, event, options).pipe( - catchError(err => { - this.offlinemanager.storeRequest(puturl, 'PUT', event); - throw new Error(err); - }) - ) } + else { + if (this.loggeduser.Profile == 'MDGPR') { + this.headers = this.headersMdPessoal; + } + else if (this.loggeduser.Profile == 'PR') { + this.headers = this.headersPrPessoal; + } + } + + let options = { + headers: this.headers, + params: params + }; + + return this.http.put(`${puturl}`, event, options).pipe( + catchError(err => { + this.offlinemanager.storeRequest(puturl, 'PUT', arrayReq); + throw new Error(err); + }) + ) } - changeAgenda(body:any){ + changeAgenda(body: any) { const puturl = environment.apiURL + 'Calendar/MoveEvent'; let options = { headers: this.headers, @@ -381,14 +375,13 @@ export class EventsService { return this.http.post(`${puturl}`, event, options) } */ - postEventMd(event:Event, calendarName:string) - { + postEventMd(event: Event, calendarName: string) { const puturl = environment.apiURL + 'calendar/md'; let params = new HttpParams(); params = params.set("CalendarName", calendarName); - let options:any; + let options: any; switch (calendarName) { case 'Oficial': console.log(calendarName); @@ -410,14 +403,13 @@ export class EventsService { return this.http.post(`${puturl}`, event, options) } - postEventPr(event:Event, calendarName:string) - { + postEventPr(event: Event, calendarName: string) { const puturl = environment.apiURL + 'calendar/pr'; let params = new HttpParams(); params = params.set("CalendarName", calendarName); - let options:any; + let options: any; switch (calendarName) { case 'Oficial': console.log(calendarName); @@ -439,8 +431,7 @@ export class EventsService { return this.http.post(`${puturl}`, event, options) } - deleteEvent(eventid:string, eventDeleteType:number, calendarName:string) - { + deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) { const puturl = environment.apiURL + 'calendar/DeleteEvent'; let params = new HttpParams(); @@ -452,13 +443,13 @@ export class EventsService { switch (this.loggeduser.Profile) { case 'MDGPR': - if(calendarName == 'Pessoal'){ + if (calendarName == 'Pessoal') { options = { headers: this.headersMdPessoal, params: params }; } - else if(calendarName == 'Oficial'){ + else if (calendarName == 'Oficial') { options = { headers: this.headersMdOficial, params: params @@ -466,13 +457,13 @@ export class EventsService { } break; case 'PR': - if(calendarName == 'Pessoal'){ + if (calendarName == 'Pessoal') { options = { headers: this.headersPrPessoal, params: params }; } - else if(calendarName == 'Oficial'){ + else if (calendarName == 'Oficial') { options = { headers: this.headersPrOficial, params: params @@ -483,8 +474,8 @@ export class EventsService { return this.http.delete(`${puturl}`, options) } - postExpedientEvent(docId:any, body:any, sharedagenda:string, serialNumber:any, applicationID:any){ - const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente')+'/event'; + postExpedientEvent(docId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) { + const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/event'; let params = new HttpParams(); let options; @@ -494,13 +485,13 @@ export class EventsService { switch (this.loggeduser.Profile) { case 'MDGPR': - if(body.CalendarName == 'Pessoal'){ + if (body.CalendarName == 'Pessoal') { options = { headers: this.headersMdPessoal, params: params }; } - else if(body.CalendarName == 'Oficial'){ + else if (body.CalendarName == 'Oficial') { options = { headers: this.headersMdOficial, params: params @@ -508,13 +499,13 @@ export class EventsService { } break; case 'PR': - if(body.CalendarName == 'Pessoal'){ + if (body.CalendarName == 'Pessoal') { options = { headers: this.headersPrPessoal, params: params }; } - else if(body.CalendarName == 'Oficial'){ + else if (body.CalendarName == 'Oficial') { options = { headers: this.headersPrOficial, params: params @@ -524,8 +515,8 @@ export class EventsService { } return this.http.post(`${geturl}`, body, options) } - createTaskEvent(folderId:any, body:any, sharedagenda:string, serialNumber:any, applicationID:any){ - const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente')+'/dispatch'; + createTaskEvent(folderId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) { + const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/dispatch'; let params = new HttpParams(); let options; @@ -535,13 +526,13 @@ export class EventsService { switch (this.loggeduser.Profile) { case 'MDGPR': - if(body.CalendarName == 'Pessoal'){ + if (body.CalendarName == 'Pessoal') { options = { headers: this.headersMdPessoal, params: params }; } - else if(body.CalendarName == 'Oficial'){ + else if (body.CalendarName == 'Oficial') { options = { headers: this.headersMdOficial, params: params @@ -549,20 +540,20 @@ export class EventsService { } break; case 'PR': - if(body.CalendarName == 'Pessoal'){ + if (body.CalendarName == 'Pessoal') { options = { headers: this.headersPrPessoal, params: params }; } - else if(body.CalendarName == 'Oficial'){ + else if (body.CalendarName == 'Oficial') { options = { headers: this.headersPrOficial, params: params }; } break; - } + } return this.http.post(`${geturl}`, body, options) } diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts index 6ef45c88c..6f7fec31e 100644 --- a/src/app/services/notifications.service.ts +++ b/src/app/services/notifications.service.ts @@ -12,7 +12,7 @@ import { ModalController, AlertController, AnimationController, Platform } from import { NavigationExtras,Router } from '@angular/router'; import { ToastService } from '../services/toast.service'; import { JsonStore } from './jsonStore.service'; -import { synchro } from './socket/synchro.service'; +import { BackgroundService } from './background.service'; import { v4 as uuidv4 } from 'uuid'; import { EventTrigger } from '../services/eventTrigger.service'; import { SessionStore } from '../store/session.service'; @@ -44,7 +44,8 @@ export class NotificationsService { private zone: NgZone, private activeroute: ActivatedRoute, private jsonstore: JsonStore, - private eventtrigger: EventTrigger) { + private eventtrigger: EventTrigger, + private backgroundservice: BackgroundService) { this.storageService.get("Notifications").then((value) => { @@ -60,7 +61,7 @@ export class NotificationsService { const id = uuidv4() this.callbacks.push({type, funx, id}) if(!object.hasOwnProperty('desktop') && object['desktop'] != false) { - synchro.registerCallback('Notification',funx, type) + this.backgroundservice.registerBackService('Notification',funx, type) } return id; @@ -178,7 +179,7 @@ export class NotificationsService { }) var data = JSON.parse(message.payload); - synchro.$send(data) + //synchro.$send(data) console.log('data.Service', data.Service); // module console.log('data.IdObject', data.IdObject); // Object id diff --git a/src/app/services/socket/synchro.service.ts b/src/app/services/socket/synchro.service.ts index a5bc6b5fa..7f5cd2994 100644 --- a/src/app/services/socket/synchro.service.ts +++ b/src/app/services/socket/synchro.service.ts @@ -21,7 +21,7 @@ export interface wss { providedIn: 'root' }) class SynchroService { - [x: string]: any; + /* [x: string]: any; private connection!: WebSocket; private id: string = uuidv4(); @@ -204,12 +204,12 @@ class SynchroService { private onerror = (event: any) => { console.log(`[error] ${event.message}`); - } + } */ } -export const synchro = new SynchroService() +/* export const synchro = new SynchroService() synchro.setUrl() synchro.connect() -window['synchro'] = synchro \ No newline at end of file +window['synchro'] = synchro */ \ No newline at end of file diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index ed9dac9be..6c75ef5c0 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -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 { ContactsPage } from '../new-group/contacts/contacts.page'; 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 { ChatMessageStore } from 'src/app/store/chat/chat-message.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 = new EventEmitter(); - synchro = synchro; chatMessageStore = ChatMessageStore chatUserStorage = ChatUserStorage @@ -198,7 +196,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy sendMessage() { - this.synchro.$send({}) + //this.synchro.$send({}) let body = { "message": diff --git a/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts b/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts index 9c0b58953..065465439 100644 --- a/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts +++ b/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts @@ -5,7 +5,6 @@ import { AuthService } from 'src/app/services/auth.service'; import { ProcessesService } from 'src/app/services/processes.service'; import { removeDuplicate } from 'src/plugin/removeDuplicate.js'; import { SqliteService } from '../../../services/sqlite.service'; -import { synchro } from '../../../services/socket/synchro.service'; import { Platform } from '@ionic/angular'; import { SortService } from 'src/app/services/functions/sort.service'; @@ -20,8 +19,6 @@ export class AllProcessesPage implements OnInit { allProcessesList: any[] = []; loggeduser: LoginUserRespose; - synch = synchro; - constructor( private processesService: ProcessesService, private router: Router,