From d289f377b5f325c93aabed6f5a816583b565a4ae Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Mon, 27 Feb 2023 19:52:30 +0100 Subject: [PATCH 1/5] fix publication --- src/app/home/home.page.ts | 3 ++ .../view-document/view-document.page.scss | 8 ++++ src/app/pages/agenda/agenda.page.ts | 2 +- .../event-list/event-list.page.ts | 2 +- .../pages/publications/publications.page.ts | 42 +++++++++---------- .../agenda/event-list/event-list.page.ts | 2 +- .../agenda/view-event/view-event.page.scss | 4 +- .../events-to-approve.page.ts | 2 +- .../chat-popover/chat-popover.page.html | 2 +- src/environments/environment.ts | 2 +- src/global.scss | 4 +- version/git-version.ts | 12 +++--- 12 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index a6674b05e..52dac3fa0 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -193,6 +193,9 @@ export class HomePage implements OnInit { if (this.p.userPermission([this.p.permissionList.Gabinete.pr_tasks]) && SessionStore.user.RoleID != this.RoleIdService.PRES) { throw ('User has PRES permission but not roleId'); } + if (!this.p.userPermission([this.p.permissionList.Gabinete.pr_tasks]) && SessionStore.user.RoleID == this.RoleIdService.PRES) { + throw ('User has PRES permission but not roleId'); + } }, 1000) } diff --git a/src/app/modals/view-document/view-document.page.scss b/src/app/modals/view-document/view-document.page.scss index 52b553151..8043d493d 100644 --- a/src/app/modals/view-document/view-document.page.scss +++ b/src/app/modals/view-document/view-document.page.scss @@ -16,4 +16,12 @@ background-repeat: no-repeat; background-position-x: center; background-position-y: center; +} + + +@media only screen and (max-width: 650px) { + + .container-img { + background-size: 25%; + } } \ No newline at end of file diff --git a/src/app/pages/agenda/agenda.page.ts b/src/app/pages/agenda/agenda.page.ts index fb12449ee..c2dc4137c 100644 --- a/src/app/pages/agenda/agenda.page.ts +++ b/src/app/pages/agenda/agenda.page.ts @@ -1333,7 +1333,7 @@ export class AgendaPage implements OnInit { async viewEventsToApprove() { await this.cloneAllmobileComponent(); - if (window.innerWidth <= 801) { + if (window.innerWidth <= 1023) { this.router.navigate(['/home/agenda/event-list']); } else { // hide all components diff --git a/src/app/pages/gabinete-digital/event-list/event-list.page.ts b/src/app/pages/gabinete-digital/event-list/event-list.page.ts index 3e392b61f..8dc258889 100644 --- a/src/app/pages/gabinete-digital/event-list/event-list.page.ts +++ b/src/app/pages/gabinete-digital/event-list/event-list.page.ts @@ -171,7 +171,7 @@ export class EventListPage implements OnInit { this.color = 'mdgpr' } - let genericEvents = await this.processes.GetTasksList('Agendar Evento', false).toPromise(); + let genericEvents = await this.processes.eventsToApprove(SessionStore.user.UserId,'mobile agenda').toPromise() try { this.eventsList = this.sortService.sortArrayByDate(genericEvents).reverse(); } catch (error) { diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index b689691b9..74511f859 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -83,10 +83,9 @@ export class PublicationsPage implements OnInit { this.router.events.forEach((event) => { if (event instanceof NavigationEnd && event.url == pathname) { this.getActions(); - - } }); + this.hideRefreshButton(); this.getFromDB() @@ -141,32 +140,29 @@ export class PublicationsPage implements OnInit { getActions() { - if(this.showLoader == false) { + this.showLoader = false + + this.publications.GetPublicationFolderList().subscribe(async res => { this.showLoader = true; - this.publications.GetPublicationFolderList().subscribe(async res => { + const folders: PublicationFolder[] = this.getPublicationFolderMap(res) - const folders: PublicationFolder[] = this.getPublicationFolderMap(res) + this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento') + this.publicationsTravelFolderList = folders.filter((e)=>e.ActionType != 'Evento') - this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento') - this.publicationsTravelFolderList = folders.filter((e)=>e.ActionType != 'Evento') - - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - await this.storage.set('actionsEvents', this.publicationsEventFolderList); - await this.storage.set('actionsViagens', this.publicationsTravelFolderList); - } else { - folders.forEach((folder)=> { - this.addActionToDB(folder); - }) - } - - this.showLoader = false; - - }, (error) => { - this.showLoader = false; - }); - } + if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + await this.storage.set('actionsEvents', this.publicationsEventFolderList); + await this.storage.set('actionsViagens', this.publicationsTravelFolderList); + } else { + folders.forEach((folder)=> { + this.addActionToDB(folder); + }) + } + this.showLoader = false; + }, (error) => { + this.showLoader = false; + }); } diff --git a/src/app/shared/agenda/event-list/event-list.page.ts b/src/app/shared/agenda/event-list/event-list.page.ts index bf31b560b..859448698 100644 --- a/src/app/shared/agenda/event-list/event-list.page.ts +++ b/src/app/shared/agenda/event-list/event-list.page.ts @@ -91,7 +91,7 @@ export class EventListPage implements OnInit { this.color = 'mdgpr' } - let genericEvents = await this.processes.GetTasksList('Agendar Evento', false).toPromise(); + let genericEvents = await this.processes.eventsToApprove(SessionStore.user.UserId,'mobile agenda').toPromise() try { this.eventsList = this.sortService.sortArrayByDate(genericEvents).reverse(); } catch (error) { diff --git a/src/app/shared/agenda/view-event/view-event.page.scss b/src/app/shared/agenda/view-event/view-event.page.scss index 122bc44b3..b23520654 100644 --- a/src/app/shared/agenda/view-event/view-event.page.scss +++ b/src/app/shared/agenda/view-event/view-event.page.scss @@ -197,9 +197,7 @@ ion-content{ left: 0 !important; bottom: 0 !important; right: 0 !important; - top: calc(100% - 160px) !important; - max-height: 160px; - min-height: 160px; + bottom: 0px !important; } 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 689a63134..377f490bf 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 @@ -86,7 +86,7 @@ export class EventsToApprovePage implements OnInit { this.color = 'mdgpr' } - let genericEvents = await this.processes.GetTasksList('Agendar Evento', false).toPromise(); + let genericEvents = await this.processes.eventsToApprove(SessionStore.user.UserId,'mobile agenda').toPromise() try { this.eventsList = this.sortService.sortArrayByDate(genericEvents).reverse(); } catch (error) { diff --git a/src/app/shared/popover/chat-popover/chat-popover.page.html b/src/app/shared/popover/chat-popover/chat-popover.page.html index c2f47a60b..3ae9c4475 100644 --- a/src/app/shared/popover/chat-popover/chat-popover.page.html +++ b/src/app/shared/popover/chat-popover/chat-popover.page.html @@ -8,7 +8,7 @@
- +
diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 10909d23b..aaefbfe6d 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,4 +3,4 @@ import { oaprDev } from './suport/oapr' import { doneITDev } from './suport/doneIt' -export const environment: Environment = oaprDev; \ No newline at end of file +export const environment: Environment = doneITDev; \ No newline at end of file diff --git a/src/global.scss b/src/global.scss index 10ccde75f..c14b1dd69 100644 --- a/src/global.scss +++ b/src/global.scss @@ -843,9 +843,7 @@ ion-content { left: 0 !important; bottom: 0 !important; right: 0 !important; - top: calc(100% - 160px) !important; - max-height: 160px; - min-height: 160px; + bottom: 0px !important; } diff --git a/version/git-version.ts b/version/git-version.ts index 2b2fa4498..8a48690a1 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "79213a543", - "SHA": "79213a543b0b219f83c92199296d94304dde8c74", + "shortSHA": "75e6a6269", + "SHA": "75e6a62695abe44be50786e4cde227eec3b2a93c", "branch": "no_bug_movemente", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Mon Feb 27 18:34:42 2023 +0100'", - "lastCommitMessage": "remove console log", - "lastCommitNumber": "4839", + "lastCommitTime": "'Mon Feb 27 18:38:55 2023 +0100'", + "lastCommitMessage": "remove", + "lastCommitNumber": "4840", "change": "", - "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/services/auth.service.ts\n\tmodified: src/app/services/events.service.ts\n\tmodified: src/environments/environment.ts\n\tmodified: version/git-version.ts", + "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/home/home.page.ts\n\tmodified: src/app/modals/view-document/view-document.page.scss\n\tmodified: src/app/pages/agenda/agenda.page.ts\n\tmodified: src/app/pages/gabinete-digital/event-list/event-list.page.ts\n\tmodified: src/app/pages/publications/publications.page.ts\n\tmodified: src/app/shared/agenda/event-list/event-list.page.ts\n\tmodified: src/app/shared/agenda/view-event/view-event.page.scss\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts\n\tmodified: src/app/shared/popover/chat-popover/chat-popover.page.html\n\tmodified: src/environments/environment.ts\n\tmodified: src/global.scss", "changeAuthor": "peter.maquiran" } \ No newline at end of file From 368607e81cd152a15ecd7aa047c5e33c3de38378 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Mon, 27 Feb 2023 20:04:22 +0100 Subject: [PATCH 2/5] improve publications --- .../view-publications.page.ts | 1 + .../view-publications.page.ts | 24 +++++++------------ version/git-version.ts | 12 +++++----- 3 files changed, 16 insertions(+), 21 deletions(-) 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 ea2a2a2dd..9ea07b9cf 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.ts +++ b/src/app/pages/publications/view-publications/view-publications.page.ts @@ -165,6 +165,7 @@ export class ViewPublicationsPage implements OnInit { this.showLoader = false; }, (error) => { + this.showLoader = false; if(error.status == 0) { this.getFromDB() } else { diff --git a/src/app/shared/publication/view-publications/view-publications.page.ts b/src/app/shared/publication/view-publications/view-publications.page.ts index 758ca8335..641d350ca 100644 --- a/src/app/shared/publication/view-publications/view-publications.page.ts +++ b/src/app/shared/publication/view-publications/view-publications.page.ts @@ -78,11 +78,10 @@ export class ViewPublicationsPage implements OnInit { } doRefresh =(event) => { - this.getPublicationsIds(); - setTimeout(() => { - this.getPublicationDetail(); - }, 3000); + this.getPublicationDetail(); + + this.getPublicationsIds(); } close() { @@ -90,9 +89,13 @@ export class ViewPublicationsPage implements OnInit { } getPublicationDetail() { + this.showLoader = true; this.publications.GetPresidentialAction(this.folderId).subscribe(res=>{ - + this.showLoader = false; this.item = res; + }, (error) => { + this.showLoader = false; + // this.httpErroHandle.httpStatusHandle(error) }); } @@ -100,21 +103,11 @@ export class ViewPublicationsPage implements OnInit { this.showLoader = true; const folderId = this.folderId - //this.getFromDB() this.publications.GetPublicationsImages(this.folderId).subscribe(res => { this.publicationList = new Array(); - /* for(let i = 0; i < res.length; i++) { - this.publications.GetPublicationById(res[i]).subscribe(ress => { - - let item: Publication = this.publicationPipe.itemList(ress) - - this.publicationList.push(item); - }) - } */ - res.forEach(element => { this.publications.GetPublicationById(element).subscribe(ress => { @@ -133,6 +126,7 @@ export class ViewPublicationsPage implements OnInit { this.getpublication = this.publicationList; this.showLoader = false; },() => { + this.showLoader = false; this.getFromDB(); }); } diff --git a/version/git-version.ts b/version/git-version.ts index 8a48690a1..6547ee763 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "75e6a6269", - "SHA": "75e6a62695abe44be50786e4cde227eec3b2a93c", + "shortSHA": "d289f377b", + "SHA": "d289f377b5f325c93aabed6f5a816583b565a4ae", "branch": "no_bug_movemente", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Mon Feb 27 18:38:55 2023 +0100'", - "lastCommitMessage": "remove", - "lastCommitNumber": "4840", + "lastCommitTime": "'Mon Feb 27 19:52:30 2023 +0100'", + "lastCommitMessage": "fix publication", + "lastCommitNumber": "4841", "change": "", - "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/home/home.page.ts\n\tmodified: src/app/modals/view-document/view-document.page.scss\n\tmodified: src/app/pages/agenda/agenda.page.ts\n\tmodified: src/app/pages/gabinete-digital/event-list/event-list.page.ts\n\tmodified: src/app/pages/publications/publications.page.ts\n\tmodified: src/app/shared/agenda/event-list/event-list.page.ts\n\tmodified: src/app/shared/agenda/view-event/view-event.page.scss\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.ts\n\tmodified: src/app/shared/popover/chat-popover/chat-popover.page.html\n\tmodified: src/environments/environment.ts\n\tmodified: src/global.scss", + "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/pages/publications/view-publications/view-publications.page.ts\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file From f218b1a666a0f8cbeae975bc375279c14d5d8464 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Mon, 27 Feb 2023 20:17:03 +0100 Subject: [PATCH 3/5] improve publication --- .../view-publications.page.ts | 56 ++++++++++--------- version/git-version.ts | 12 ++-- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/app/shared/publication/view-publications/view-publications.page.ts b/src/app/shared/publication/view-publications/view-publications.page.ts index 641d350ca..4ecd8b2c4 100644 --- a/src/app/shared/publication/view-publications/view-publications.page.ts +++ b/src/app/shared/publication/view-publications/view-publications.page.ts @@ -59,6 +59,8 @@ export class ViewPublicationsPage implements OnInit { window['app-view-publications-page-doRefresh'] = this.doRefresh this.getPublicationDetail(); + + this.getFromDB(); } ngOnChanges(changes: any): void { @@ -67,7 +69,7 @@ export class ViewPublicationsPage implements OnInit { this.folderId = this.folderId['ProcessId'] } - + this.getFromDB(); //setTimeout(()=>{ this.getPublicationDetail(); this.getPublicationsIds(); @@ -119,8 +121,8 @@ export class ViewPublicationsPage implements OnInit { }); - this.storage.remove('view_publications'); - this.storage.set('view_publications', this.publicationList); + this.storage.remove(folderId); + this.storage.set(this.folderId, this.publicationList); this.getpublication = this.publicationList; @@ -132,39 +134,39 @@ export class ViewPublicationsPage implements OnInit { } getFromDB() { - this.storage.get('view_publications').then((viewPublications) => { + this.storage.get(this.folderId).then((viewPublications) => { this.publicationList = viewPublications; }) } - getPublications() { - this.showLoader = true; - const folderId = this.folderId - this.publicationList = new Array(); - //this.getFromDB(); - this.publications.GetPublications(folderId).subscribe(async res=> { + // getPublications() { + // this.showLoader = true; + // const folderId = this.folderId + // this.publicationList = new Array(); + // this.publications.GetPublications(folderId).subscribe(async res=> { - res.forEach(element => { - let item: Publication = this.publicationPipe.itemList(element) - this.publicationList.push(item); - }); + // res.forEach(element => { + // let item: Publication = this.publicationPipe.itemList(element) + // this.publicationList.push(item); + // }); - await this.storage.remove('view_publications'); - await this.storage.set('view_publications', this.publicationList); - //this.getFromDB(); - this.showLoader = false; - }, - (error)=>{ - if(error.status == '404') { - this.error = 'Sem publicações disponíveis!'; - this.publicationList= []; - } + // this.showLoader = false; + // await this.storage.remove(folderId); + // await this.storage.set(folderId, this.publicationList); + // //this.getFromDB(); + + // }, + // (error)=>{ + // if(error.status == '404') { + // this.error = 'Sem publicações disponíveis!'; + // this.publicationList= []; + // } - this.showLoader = false; + // this.showLoader = false; - }) + // }) - } + // } async AddPublication(publicationType:any, folderId:any) { diff --git a/version/git-version.ts b/version/git-version.ts index 6547ee763..185ed25bf 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "d289f377b", - "SHA": "d289f377b5f325c93aabed6f5a816583b565a4ae", + "shortSHA": "368607e81", + "SHA": "368607e81cd152a15ecd7aa047c5e33c3de38378", "branch": "no_bug_movemente", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Mon Feb 27 19:52:30 2023 +0100'", - "lastCommitMessage": "fix publication", - "lastCommitNumber": "4841", + "lastCommitTime": "'Mon Feb 27 20:04:22 2023 +0100'", + "lastCommitMessage": "improve publications", + "lastCommitNumber": "4842", "change": "", - "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/pages/publications/view-publications/view-publications.page.ts\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts", + "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file From 9a1976f54373e5ed0686998c46bcc00e427d1b88 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Mon, 27 Feb 2023 20:17:47 +0100 Subject: [PATCH 4/5] fix --- src/environments/environment.ts | 2 +- version/git-version.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/environments/environment.ts b/src/environments/environment.ts index aaefbfe6d..10909d23b 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,4 +3,4 @@ import { oaprDev } from './suport/oapr' import { doneITDev } from './suport/doneIt' -export const environment: Environment = doneITDev; \ No newline at end of file +export const environment: Environment = oaprDev; \ No newline at end of file diff --git a/version/git-version.ts b/version/git-version.ts index 185ed25bf..485993f89 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "368607e81", - "SHA": "368607e81cd152a15ecd7aa047c5e33c3de38378", + "shortSHA": "f218b1a66", + "SHA": "f218b1a666a0f8cbeae975bc375279c14d5d8464", "branch": "no_bug_movemente", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Mon Feb 27 20:04:22 2023 +0100'", - "lastCommitMessage": "improve publications", - "lastCommitNumber": "4842", + "lastCommitTime": "'Mon Feb 27 20:17:03 2023 +0100'", + "lastCommitMessage": "improve publication", + "lastCommitNumber": "4843", "change": "", - "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts", + "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/environments/environment.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file From 7e5039b4fac3a44e5a039acd69dcba79b2a984b0 Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Mon, 27 Feb 2023 21:24:34 +0100 Subject: [PATCH 5/5] fix slow publication --- .../pages/publications/publications.page.ts | 17 +- .../view-publications.page.html | 18 +- .../view-publications.page.ts | 208 ++++++------------ .../view-publications.page.html | 20 +- .../view-publications.page.ts | 88 ++++---- version/git-version.ts | 12 +- 6 files changed, 147 insertions(+), 216 deletions(-) diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index 74511f859..19405fbf5 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -79,6 +79,7 @@ export class PublicationsPage implements OnInit { ngOnInit() { const pathname = window.location.pathname + this.getActions(); this.router.events.forEach((event) => { if (event instanceof NavigationEnd && event.url == pathname) { @@ -140,10 +141,10 @@ export class PublicationsPage implements OnInit { getActions() { - this.showLoader = false + this.showLoader = true this.publications.GetPublicationFolderList().subscribe(async res => { - this.showLoader = true; + this.showLoader = false; const folders: PublicationFolder[] = this.getPublicationFolderMap(res) this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento') @@ -166,13 +167,13 @@ export class PublicationsPage implements OnInit { } - addActionToStorage(events, viagens) { + // addActionToStorage(events, viagens) { - if (this.platform.is('desktop') || this.platform.is('mobileweb')) { - this.storage.set('actionsEvents', events); - this.storage.set('actionsViagens', viagens); - } - } + // if (this.platform.is('desktop') || this.platform.is('mobileweb')) { + // this.storage.set('actionsEvents', events); + // this.storage.set('actionsViagens', viagens); + // } + // } addActionToDB(folder) { diff --git a/src/app/pages/publications/view-publications/view-publications.page.html b/src/app/pages/publications/view-publications/view-publications.page.html index 033a353ec..5e41c9ca6 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.html +++ b/src/app/pages/publications/view-publications/view-publications.page.html @@ -11,12 +11,12 @@
-
- {{item.Description}} -

{{item.Detail}}

- +
+ {{publicationItem[folderId].Description}} +

{{publicationItem[folderId].Detail}}

+
-
+
@@ -27,14 +27,14 @@ - +
- - + 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 9ea07b9cf..bf8915d50 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.ts +++ b/src/app/pages/publications/view-publications/view-publications.page.ts @@ -14,6 +14,7 @@ import { forkJoin } from 'rxjs'; import { ToastService } from 'src/app/services/toast.service'; import { PermissionService } from 'src/app/services/permission.service'; import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'; +import { Storage } from '@ionic/storage'; @Component({ selector: 'app-view-publications', @@ -24,8 +25,9 @@ export class ViewPublicationsPage implements OnInit { showLoader = true; loading: any; - publicationList: Publication[] = new Array(); - item: PublicationFolder; + publicationList: {[key: string]: Publication[] } = {}; + publicationItem: {[key: string]: PublicationFolder } = {}; + defaultImage = "/assets/icon/icon-no-image.svg"; folderId: string; id: string; @@ -46,9 +48,16 @@ export class ViewPublicationsPage implements OnInit { public ThemeService: ThemeService, private toastService: ToastService, public p: PermissionService, - private httpErroHandle: HttpErrorHandle) { + private httpErroHandle: HttpErrorHandle, + private storage: Storage,) { + + if(!this.publicationList[this.folderId]) { + this.publicationList[this.folderId] = [] + this.publicationItem[this.folderId] = new PublicationFolder(); + } + + this.getFromDB(); - this.item = new PublicationFolder(); this.activatedRoute.paramMap.subscribe(params => { @@ -66,6 +75,14 @@ export class ViewPublicationsPage implements OnInit { if (typeof (this.folderId) == 'object') { this.folderId = this.folderId['ProcessId'] } + + + if(!this.publicationList[this.folderId]) { + this.publicationList[this.folderId] = [] + this.publicationItem[this.folderId] = new PublicationFolder(); + } + + this.getFromDB(); //this.testForkJoin() this.getPublicationDetail(); this.getPublicationsIds(); @@ -87,22 +104,22 @@ export class ViewPublicationsPage implements OnInit { this.folderId = this.folderId['ProcessId'] } - // if (typeof (this.id == 'object') { - // this.id = this.id['ProcessId'] - // } - //this.testForkJoin() - //this.getPublicationDetail(); - // this.getPublications(); + if(!this.publicationList[this.folderId]) { + this.publicationList[this.folderId] = [] + this.publicationItem[this.folderId] = new PublicationFolder(); + } + + this.getFromDB(); } doRefresh = (event) => { //setTimeout(() => { - //this.testForkJoin() - this.getPublicationDetail(); - this.getPublicationsIds(); - try { - event?.target?.complete(); -} catch(error) {} + //this.testForkJoin() + this.getPublicationDetail(); + this.getPublicationsIds(); + try { + event?.target?.complete(); + } catch(error) {} //}, 3000); } @@ -117,147 +134,52 @@ export class ViewPublicationsPage implements OnInit { } getPublicationDetail() { - this.publications.GetPresidentialAction(this.folderId).subscribe(res => { - - this.item = res; - this.sqliteservice.updatePublicationsDetails(this.folderId, JSON.stringify(res)); - }, (error) => { - this.httpErroHandle.httpStatusHandle(error) - }); - } - - // goes to fork - // getPublicationsIds() { - - // this.showLoader = true; - // const folderId = this.folderId - - // this.publications.GetIdsPublicationsImages(this.id).subscribe(res => { - - // - - // this.publicationList = new Array(); - - getPublicationsIds() { - this.showLoader = true; const folderId = this.folderId - this.publications.GetPublicationsImages(this.folderId).subscribe(res => { - - - this.publicationList = new Array(); - - res.forEach(element => { - - this.publications.GetPublicationById(element).subscribe(ress => { - - let item: Publication = this.publicationPipe.itemList(ress) - - this.publicationList.push(item); - }) - - }); - - this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList)); - - - this.getpublication = this.publicationList; + this.publications.GetPresidentialAction(folderId).subscribe(res=>{ this.showLoader = false; - + this.publicationItem[folderId] = res + this.storage.set(folderId+"name", res) }, (error) => { this.showLoader = false; - if(error.status == 0) { - this.getFromDB() - } else { - this.httpErroHandle.httpStatusHandle(error) - } - + // this.httpErroHandle.httpStatusHandle(error) }); } - getPublications() { - - this.showLoader = true; - const folderId = this.folderId - this.getFromDB(); - this.publications.GetPublications(this.folderId).subscribe(res => { - - - - this.publicationList = new Array(); - - res.forEach(element => { - - let item: Publication = this.publicationPipe.itemList(element) - this.publicationList.push(item); - - - }); - this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList)); - - this.getpublication = this.publicationList; - - this.showLoader = false; - }, (error) => { - - if (error.status == '0') { - this.getFromDB(); - } - if (error.status == '404') { - this.error = 'Sem publicações disponíveis!'; - this.publicationList = []; - } else { - this.httpErroHandle.httpStatusHandle(error) - } - this.showLoader = false; - }); - } - - testForkJoin() { - forkJoin([ - this.getPublicationsIds(), - this.getPublications(), - - - ]).subscribe(allResults => { - this.publicationList = allResults[2] - }) - } - getFromDB() { - - this.sqliteservice.getActionById(this.folderId).then((publications) => { - - this.item = this.isJson(publications[0].publicationsDetails); - - let publicationArray = []; - this.isJson(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.publicationList = publicationArray; + const folderId = this.folderId + this.storage.get(folderId).then((viewPublications) => { + this.publicationList[folderId] = viewPublications + }) + this.storage.get(folderId+"name").then((viewPublications) => { + this.publicationItem[folderId] = viewPublications }) } - isJson(str) { + async getPublicationsIds() { + + this.showLoader = true; + const folderId = this.folderId + try { - JSON.parse(str); - } catch (e) { - return str; + const res = await this.publications.GetPublicationsImages(folderId).toPromise(); + let publicationList = [] + + for (let element of res) { + let ress = await this.publications.GetPublicationById(element).toPromise(); + let item: Publication = this.publicationPipe.itemList(ress) + publicationList.push(item); + } + + this.showLoader = false; + + this.publicationList[folderId] = publicationList + this.storage.set(folderId, publicationList); + this.getpublication = publicationList; + } catch(error) { + this.showLoader = false; } - return JSON.parse(str); + } async AddPublication(publicationType: any, folderId: any) { diff --git a/src/app/shared/publication/view-publications/view-publications.page.html b/src/app/shared/publication/view-publications/view-publications.page.html index 6dd065cc9..79986c91e 100644 --- a/src/app/shared/publication/view-publications/view-publications.page.html +++ b/src/app/shared/publication/view-publications/view-publications.page.html @@ -1,18 +1,18 @@
-
+
- {{item.Description}} + {{publicationItem[folderId].Description}}
- -
-

{{item.Detail}}

- +

{{publicationItem[folderId].Detail}}

+
@@ -35,8 +35,8 @@ -
- +
@@ -84,8 +84,8 @@ -->
- - + + diff --git a/src/app/shared/publication/view-publications/view-publications.page.ts b/src/app/shared/publication/view-publications/view-publications.page.ts index 4ecd8b2c4..db777e3df 100644 --- a/src/app/shared/publication/view-publications/view-publications.page.ts +++ b/src/app/shared/publication/view-publications/view-publications.page.ts @@ -22,8 +22,8 @@ export class ViewPublicationsPage implements OnInit { showLoader: boolean; loading: any; - publicationList: Publication[]; - item: PublicationFolder; + publicationList: {[key: string]: Publication[] } = {}; + publicationItem: {[key: string]: PublicationFolder } = {}; getpublication = []; error: any; @@ -47,7 +47,10 @@ export class ViewPublicationsPage implements OnInit { public p:PermissionService, private httpErrorHandle: HttpErrorHandle ) { - this.item = new PublicationFolder(); + if(!this.publicationList[this.folderId]) { + this.publicationList[this.folderId] = [] + this.publicationItem[this.folderId] = new PublicationFolder(); + } } ngOnInit() { @@ -55,10 +58,12 @@ export class ViewPublicationsPage implements OnInit { this.folderId = this.folderId['ProcessId'] } - //this.getPublicationsIds(); + if(!this.publicationList[this.folderId]) { + this.publicationList[this.folderId] = [] + this.publicationItem[this.folderId] = new PublicationFolder(); + } window['app-view-publications-page-doRefresh'] = this.doRefresh - this.getPublicationDetail(); this.getFromDB(); } @@ -68,13 +73,16 @@ export class ViewPublicationsPage implements OnInit { if(typeof(this.folderId) == 'object') { this.folderId = this.folderId['ProcessId'] } - - this.getFromDB(); - //setTimeout(()=>{ - this.getPublicationDetail(); - this.getPublicationsIds(); - //}, 100) + if(!this.publicationList[this.folderId]) { + this.publicationList[this.folderId] = [] + this.publicationItem[this.folderId] = new PublicationFolder(); + } + + this.getFromDB(); + + this.getPublicationDetail(); + this.getPublicationsIds(); } @@ -82,7 +90,6 @@ export class ViewPublicationsPage implements OnInit { doRefresh =(event) => { this.getPublicationDetail(); - this.getPublicationsIds(); } @@ -92,50 +99,51 @@ export class ViewPublicationsPage implements OnInit { getPublicationDetail() { this.showLoader = true; - this.publications.GetPresidentialAction(this.folderId).subscribe(res=>{ + const folderId = this.folderId + this.publications.GetPresidentialAction(folderId).subscribe(res=>{ this.showLoader = false; - this.item = res; + this.publicationItem[folderId] = res + this.storage.set(folderId+"name", res) }, (error) => { this.showLoader = false; // this.httpErroHandle.httpStatusHandle(error) }); } - getPublicationsIds() { + async getPublicationsIds() { this.showLoader = true; const folderId = this.folderId - this.publications.GetPublicationsImages(this.folderId).subscribe(res => { - - this.publicationList = new Array(); - - res.forEach(element => { - - this.publications.GetPublicationById(element).subscribe(ress => { - - let item: Publication = this.publicationPipe.itemList(ress) - - this.publicationList.push(item); - }) - - }); - - this.storage.remove(folderId); - this.storage.set(this.folderId, this.publicationList); - - - this.getpublication = this.publicationList; + try { + const res = await this.publications.GetPublicationsImages(folderId).toPromise(); + let publicationList = [] + + for (let element of res) { + let ress = await this.publications.GetPublicationById(element).toPromise(); + let item: Publication = this.publicationPipe.itemList(ress) + publicationList.push(item); + } + this.showLoader = false; - },() => { + + this.publicationList[folderId] = publicationList + this.storage.set(folderId, publicationList); + this.getpublication = publicationList; + } catch(error) { this.showLoader = false; - this.getFromDB(); - }); + } + + } getFromDB() { - this.storage.get(this.folderId).then((viewPublications) => { - this.publicationList = viewPublications; + const folderId = this.folderId + this.storage.get(folderId).then((viewPublications) => { + this.publicationList[folderId] = viewPublications + }) + this.storage.get(folderId+"name").then((viewPublications) => { + this.publicationItem[folderId] = viewPublications }) } diff --git a/version/git-version.ts b/version/git-version.ts index 485993f89..c47ca6e10 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "f218b1a66", - "SHA": "f218b1a666a0f8cbeae975bc375279c14d5d8464", + "shortSHA": "9a1976f54", + "SHA": "9a1976f54373e5ed0686998c46bcc00e427d1b88", "branch": "no_bug_movemente", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Mon Feb 27 20:17:03 2023 +0100'", - "lastCommitMessage": "improve publication", - "lastCommitNumber": "4843", + "lastCommitTime": "'Mon Feb 27 20:17:47 2023 +0100'", + "lastCommitMessage": "fix", + "lastCommitNumber": "4844", "change": "", - "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/environments/environment.ts", + "changeStatus": "On branch no_bug_movemente\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/pages/publications/publications.page.ts\n\tmodified: src/app/pages/publications/view-publications/view-publications.page.html\n\tmodified: src/app/pages/publications/view-publications/view-publications.page.ts\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.html\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file