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 f81eb7b19..2e5a38217 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.ts +++ b/src/app/pages/publications/view-publications/view-publications.page.ts @@ -68,15 +68,16 @@ export class ViewPublicationsPage implements OnInit { if (typeof (this.folderId) == 'object') { this.folderId = this.folderId['ProcessId'] } - this.testForkJoin() + //this.testForkJoin() this.getPublicationDetail(); - setTimeout(() => { + this.getPublicationsIds(); + /* setTimeout(() => { this.getPublicationsIds(); - }, 1000); + }, 1000); */ this.backgroundservice.registerBackService('Online', () => { this.getPublicationDetail(); - this.testForkJoin() + //this.testForkJoin() }) @@ -91,16 +92,16 @@ export class ViewPublicationsPage implements OnInit { // if (typeof (this.id == 'object') { // this.id = this.id['ProcessId'] // } - this.testForkJoin() - this.getPublicationDetail(); + //this.testForkJoin() + //this.getPublicationDetail(); // this.getPublicationsIds(); } doRefresh = (event) => { setTimeout(() => { - this.testForkJoin() + //this.testForkJoin() this.getPublicationDetail(); - // this.getPublicationsIds(); + this.getPublicationsIds(); event.target.complete(); }, 3000); @@ -116,13 +117,14 @@ export class ViewPublicationsPage implements OnInit { } getPublicationDetail() { - this.publications.GetPresidentialAction(this.folderId).subscribe(res=>{ + this.publications.GetPresidentialAction(this.folderId).subscribe(res => { console.log(res); this.item = res; + this.sqliteservice.updatePublicationsDetails(this.folderId, JSON.stringify(res)); }); } -// goes to fork + // goes to fork // getPublicationsIds() { // this.showLoader = true; @@ -138,22 +140,22 @@ export class ViewPublicationsPage implements OnInit { this.showLoader = true; const folderId = this.folderId - + this.getFromDB() this.publications.GetPublicationsImages(this.folderId).subscribe(res => { console.log('publications ids', res) this.publicationList = new Array(); - /* for(let i of res) { - this.publications.GetPublicationById(i).subscribe(ress => { - console.log('publications by ids', ress) - let item: Publication = this.publicationPipe.itemList(ress) - console.log('publications by ids 2', item) - this.publicationList.push(item); - }) - } */ + for(let i = 0; i < res.length; i++) { + this.publications.GetPublicationById(res[i]).subscribe(ress => { + console.log('publications by ids', ress) + let item: Publication = this.publicationPipe.itemList(ress) + console.log('publications by ids 2', item) + this.publicationList.push(item); + }) + } - res.forEach(element => { + /* res.forEach(element => { console.log('publications elements', element) this.publications.GetPublicationById(element).subscribe(ress => { console.log('publications by ids', ress) @@ -162,13 +164,13 @@ export class ViewPublicationsPage implements OnInit { this.publicationList.push(ress); }) - }); - + }); */ + console.log('PUBLICATIONS IMAGEs',this.publicationList) this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList)); + console.log('PUBLICATIONS IMAGEs',this.publicationList) this.publicationListStorage.add(folderId, this.publicationList) this.getpublication = this.publicationList; - this.showLoader = false; /* this.publicationList = new Array(); @@ -189,7 +191,7 @@ export class ViewPublicationsPage implements OnInit { this.showLoader = true; const folderId = this.folderId - + this.getFromDB(); this.publications.GetPublications(this.folderId).subscribe(res => { console.log(this.folderId) @@ -223,13 +225,13 @@ export class ViewPublicationsPage implements OnInit { }); } - testForkJoin(){ + testForkJoin() { forkJoin([ this.getPublicationsIds(), this.getPublications(), - ]).subscribe(allResults =>{ + ]).subscribe(allResults => { this.publicationList = allResults[2] }) } @@ -238,7 +240,7 @@ export class ViewPublicationsPage implements OnInit { this.sqliteservice.getActionById(this.folderId).then((publications) => { console.log('publications', publications) - let item = { + /* let item = { ActionType: publications[0].ActionType, DateBegin: publications[0].DateBegin, DateEnd: publications[0].DateEnd, @@ -246,7 +248,8 @@ export class ViewPublicationsPage implements OnInit { Detail: publications[0].Detail, ProcessId: publications[0].ProcessId } - this.publicationDitails = item; + this.publicationDitails = item; */ + this.item = JSON.parse(publications[0].publicationsDetails); let publicationArray = []; JSON.parse(publications[0].publications).forEach(element => { @@ -264,7 +267,7 @@ export class ViewPublicationsPage implements OnInit { publicationArray.push(publicationlis); }); - + this.getpublication = publicationArray; }) } diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts index 4208e6ca7..2158e8be8 100644 --- a/src/app/services/chat/ws-chat-methods.service.ts +++ b/src/app/services/chat/ws-chat-methods.service.ts @@ -68,6 +68,13 @@ export class WsChatMethodsService { } + getRoomFromDb() { + this.storage.get('Rooms').then((rooms) => { + rooms.result.update.forEach((roomData: room) => { + this.prepareRoom(roomData); + }); + }) + }; openRoom(roomId) { if(this.currentRoom) { @@ -92,9 +99,12 @@ export class WsChatMethodsService { async getAllRooms () { this.loadingWholeList = true - + this.getRoomFromDb(); const rooms = await this.WsChatService.getRooms(); + this.storage.set('Rooms', rooms); + + // console.log("ROOMS" + JSON.stringify(rooms)) this.WsChatService.registerCallback({ type:'Onmessage', funx:(message)=>{ diff --git a/src/app/services/sqlite.service.ts b/src/app/services/sqlite.service.ts index 37638c4c0..1cf19d6e6 100644 --- a/src/app/services/sqlite.service.ts +++ b/src/app/services/sqlite.service.ts @@ -127,7 +127,8 @@ export class SqliteService { DateEnd varchar(255), Detail varchar(255), Description varchar(255), - publications Text + publications Text, + publicationsDetails Text )`, []) .then((res) => { console.log("Sucess action Table created: ", res) @@ -195,8 +196,8 @@ export class SqliteService { public addactions(data) { console.log('Action insert', data) this.dbInstance.executeSql(` - INSERT OR IGNORE INTO ${this.actions} (ActionType,DateBegin,DateEnd,Description,Detail,ProcessId,publications) - VALUES ('${data.ActionType}','${data.DateBegin}', '${data.DateEnd}','${data.Description}','${data.Detail}','${data.ProcessId}','${data.publications}')`, []) + INSERT OR IGNORE INTO ${this.actions} (ActionType,DateBegin,DateEnd,Description,Detail,ProcessId,publications,publicationsDetails) + VALUES ('${data.ActionType}','${data.DateBegin}', '${data.DateEnd}','${data.Description}','${data.Detail}','${data.ProcessId}','${data.publications}','${data.publicationsDetails}')`, []) .then(() => { console.log("action add with Success"); @@ -319,6 +320,22 @@ export class SqliteService { } + //updatePublicationsDetails + public updatePublicationsDetails(id, data) { + try { + console.log("update action data", data) + this.dbInstance.executeSql(` + UPDATE ${this.actions} SET publicationsDetails = ? WHERE ProcessId = ${id}`, [data]) + .then(() => { + console.log("action update with Success"); + + }, (e) => { + console.log(JSON.stringify(e.err)); + }); + } catch(error) {} + + } + //updateChatMsg public updateChatMsg(id, data) { let jsonId = JSON.stringify(id) diff --git a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html index eff4cab69..7a244f1de 100644 --- a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html +++ b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html @@ -28,12 +28,12 @@
-
+
@@ -52,7 +52,7 @@
-
+
@@ -62,12 +62,12 @@
-
+
-
+
@@ -87,10 +87,10 @@
-
+
+ *ngIf="eventsPRList.length < 1"> Lista vazia
diff --git a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts index 93a20876d..34a6c3042 100644 --- a/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts +++ b/src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts @@ -8,6 +8,7 @@ import { LoginUserRespose } from 'src/app/models/user.model'; import { AuthService } from 'src/app/services/auth.service'; import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.service'; import { SortService } from 'src/app/services/functions/sort.service'; +import { Storage } from '@ionic/storage'; @Component({ selector: 'app-events-to-approve', @@ -33,6 +34,7 @@ export class EventsToApprovePage implements OnInit { private router: Router, private userAuth: AuthService, private sortService: SortService, + private storage: Storage ) { this.loggeduser = userAuth.ValidatedUser; @@ -63,25 +65,46 @@ export class EventsToApprovePage implements OnInit { async LoadToApproveEvents() { this.showLoader = true; console.log(this.segment); + this.getFromDB(); if(this.segment == 'MDGPR'){ let mdEventsOficial = await this.processes.GetTasksList('Agenda Oficial MDGPR', false).toPromise(); let mdEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal MDGPR', false).toPromise(); this.eventsMDGPRList = mdEventsOficial.concat(mdEventsPessoal); + this.eventsMDGPRList = this.sortService.sortArrayByDate(this.eventsMDGPRList) console.log(this.sortService.sortArrayByDate(this.eventsMDGPRList)); - this.eventaprovacaostore.resetmd(this.sortService.sortDate(this.eventsMDGPRList, 'CreateDate')); + this.storage.set('event-to-aproveMD',this.eventsMDGPRList).then(() => { + console.log(' EVENTMD TO APROVE SAVED') + }) + + //this.eventaprovacaostore.resetmd(this.sortService.sortDate(this.eventsMDGPRList, 'CreateDate')); } else if(this.segment == 'PR'){ let prEventsOficial = await this.processes.GetTasksList('Agenda Oficial PR', false).toPromise(); let prEventsPessoal = await this.processes.GetTasksList('Agenda Pessoal PR', false).toPromise(); this.eventsPRList = prEventsOficial.concat(prEventsPessoal); + this.eventsPRList = this.sortService.sortArrayByDate(this.eventsPRList) - this.eventaprovacaostore.resetpr(this.sortService.sortDate(this.eventsPRList, 'CreateDate')); + this.storage.set('event-to-aprovePR',this.eventsPRList).then(() => { + console.log(' EVENTPR TO APROVE SAVED') + }) + //this.eventaprovacaostore.resetpr(this.sortService.sortDate(this.eventsPRList, 'CreateDate')); } this.showLoader = false; } + getFromDB() { + this.storage.get('event-to-aproveMD').then((events) => { + this.eventsMDGPRList = events + }) + + this.storage.get('event-to-aprovePR').then((events) => { + this.eventsPRList = events + }) + } + + toDateString(e) { return new Date(e).toDateString() } diff --git a/src/app/shared/gabinete-digital/expedients/expedients.page.html b/src/app/shared/gabinete-digital/expedients/expedients.page.html index 505783c38..b2cb23a60 100644 --- a/src/app/shared/gabinete-digital/expedients/expedients.page.html +++ b/src/app/shared/gabinete-digital/expedients/expedients.page.html @@ -22,10 +22,10 @@
- +
@@ -58,13 +58,13 @@
Lista vazia
-
+
diff --git a/src/app/shared/gabinete-digital/expedients/expedients.page.ts b/src/app/shared/gabinete-digital/expedients/expedients.page.ts index 84d2baad5..8c5696320 100644 --- a/src/app/shared/gabinete-digital/expedients/expedients.page.ts +++ b/src/app/shared/gabinete-digital/expedients/expedients.page.ts @@ -6,6 +6,7 @@ import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service'; import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe'; import { ThemeService } from 'src/app/services/theme.service' import { SortService } from 'src/app/services/functions/sort.service'; +import { Storage } from '@ionic/storage'; @Component({ selector: 'app-expedients', @@ -13,27 +14,28 @@ import { SortService } from 'src/app/services/functions/sort.service'; styleUrls: ['./expedients.page.scss'], }) export class ExpedientsPage implements OnInit { - segment:string; + segment: string; taskslist = []; - serialNumber:string; + serialNumber: string; - @Input() profile:string; + @Input() profile: string; skeletonLoader = true expedientegbstore = ExpedienteGdStore expedienteTaskPipe = new ExpedienteTaskPipe() constructor( - private processes:ProcessesService, + private processes: ProcessesService, private alertService: AlertService, private router: Router, public ThemeService: ThemeService, private sortService: SortService, - ) { - this.profile = 'mdgpr'; + private storage: Storage + ) { + this.profile = 'mdgpr'; - } + } ngOnInit() { //Inicializar segment @@ -43,11 +45,11 @@ export class ExpedientsPage implements OnInit { this.router.events.forEach((event) => { if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital?expedientes=true')) { - if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { - this.doRefresh() - } else { - this.LoadList() - } + if (window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) { + this.doRefresh() + } else { + this.LoadList() + } } }); @@ -75,21 +77,35 @@ export class ExpedientsPage implements OnInit { this.taskslist.push(task); }); - this.taskslist = this.sortService.sortDate(this.taskslist, 'CreateDate') + this.addProcessTODb(this.taskslist); this.expedientegbstore.reset(this.taskslist); + }, (error) => { + this.getEventsFromLocalDb(); }); } - doRefresh() { - setTimeout(()=>{ - this.LoadList(); - }, 1000) - + addProcessTODb(task) { + this.storage.set('gabinete-expediente', task).then(() => { + console.log('GABINETE EXPEDIENTE SAVED') + }) } - goToExpediente(serialNumber:any){ - this.router.navigate(['/home/gabinete-digital/expediente',serialNumber,'gabinete-digital']); + getEventsFromLocalDb() { + this.storage.get('gabinete-expediente').then((expediente) => { + this.taskslist = expediente + }) } -} + doRefresh() { + setTimeout(() => { + this.LoadList(); + }, 1000) + + } + + goToExpediente(serialNumber: any) { + this.router.navigate(['/home/gabinete-digital/expediente', serialNumber, 'gabinete-digital']); + } + + } diff --git a/src/app/shared/gabinete-digital/pendentes/pendentes.page.html b/src/app/shared/gabinete-digital/pendentes/pendentes.page.html index f91d503c5..d3a69b760 100644 --- a/src/app/shared/gabinete-digital/pendentes/pendentes.page.html +++ b/src/app/shared/gabinete-digital/pendentes/pendentes.page.html @@ -20,7 +20,7 @@ diff --git a/src/app/shared/gabinete-digital/pendentes/pendentes.page.ts b/src/app/shared/gabinete-digital/pendentes/pendentes.page.ts index 6ee44b91a..4ee229244 100644 --- a/src/app/shared/gabinete-digital/pendentes/pendentes.page.ts +++ b/src/app/shared/gabinete-digital/pendentes/pendentes.page.ts @@ -8,6 +8,7 @@ import { PendentesStore } from 'src/app/store/pendestes-store.service'; import { LoginUserRespose } from 'src/app/models/user.model'; import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe'; import { SortService } from 'src/app/services/functions/sort.service'; +import { Storage } from '@ionic/storage'; @Component({ selector: 'app-pendentes', @@ -20,6 +21,7 @@ export class PendentesPage implements OnInit { pendentesstore = PendentesStore; customTaskPipe = new CustomTaskPipe() loggeduser: LoginUserRespose; + listToPresent = []; @Input() profile:string; segment:string; @@ -30,6 +32,7 @@ export class PendentesPage implements OnInit { private authService: AuthService, private router: Router, private sortService: SortService, + private storage: Storage ) { this.loggeduser = authService.ValidatedUser; } @@ -52,7 +55,7 @@ export class PendentesPage implements OnInit { async LoadList(){ this.skeletonLoader = true; - + this.processes.GetPendingTasks(false).subscribe(async res => { let pendentes = await this.processes.GetPendingTasks(false).toPromise(); let pendentesList = []; @@ -64,9 +67,24 @@ export class PendentesPage implements OnInit { pendentesList = removeDuplicate( pendentesList) pendentesList = this.sortService.sortDate(pendentesList, 'CreateDate') + this.listToPresent = pendentesList this.pendentesstore.reset(pendentesList); + this.storage.set('pendente-list',pendentesList).then(() => { + console.log('Pendente list SAVED') + }) this.skeletonLoader = false; - } + }, (error) => { + if(error.status == 0){ + this.getFromDb(); + } + }) +} + +getFromDb() { + this.storage.get('pendente-list').then((pendentes) => { + this.listToPresent =pendentes + }) +} doRefresh() { setTimeout(()=>{ diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 42f4c4c87..ce95737f1 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { IonicModule } from '@ionic/angular'; +import { IonicImageLoaderModule } from 'ionic-image-loader-v5'; // import { HeaderPage } from './header/header.page'; // import { HeaderPrPage } from './header-pr/header-pr.page'; // import { BtnSeguintePage } from './btn-seguinte/btn-seguinte.page'; @@ -17,7 +18,8 @@ import { IonicModule } from '@ionic/angular'; imports: [ CommonModule, FormsModule, - IonicModule + IonicModule, + IonicImageLoaderModule ], exports: [ // HeaderPage,