mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix slow publication
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
<ion-header class="ion-no-border">
|
||||
<div class="main-header">
|
||||
<div class="title-content">
|
||||
<div *ngIf="item" class="div-title width-100 flex-grow-1">
|
||||
<div *ngIf="publicationItem[folderId]" class="div-title width-100 flex-grow-1">
|
||||
<div class="title">
|
||||
<ion-label>{{item.Description}}</ion-label>
|
||||
<ion-label>{{publicationItem[folderId].Description}}</ion-label>
|
||||
</div>
|
||||
|
||||
<div class="actions-icon">
|
||||
<!-- <ion-icon (click)="AddPublication('1',item.ProcessId)" slot="end" src='assets/images/icons-add-photo.svg'></ion-icon> -->
|
||||
<button *ngIf="p.userPermission([p.permissionList.Actions.editPost])" class="btn-no-color" (click)="openEditPublication(item.ProcessId)">
|
||||
<button *ngIf="p.userPermission([p.permissionList.Actions.editPost])" class="btn-no-color" (click)="openEditPublication(publicationItem[folderId].ProcessId)">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="edit" slot="end" src="assets/images/icons-edit.svg" ></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="edit" slot="end" src="assets/images/theme/gov/icons-edit.svg" ></ion-icon>
|
||||
</button>
|
||||
<button *ngIf="p.userPermission([p.permissionList.Actions.deletePost])" class="btn-no-color" (click)="deletePublication(item.ProcessId)">
|
||||
<button *ngIf="p.userPermission([p.permissionList.Actions.deletePost])" class="btn-no-color" (click)="deletePublication(publicationItem[folderId].ProcessId)">
|
||||
<ion-icon class="delete" src='assets/images/theme/gov/icons-delete.svg'></ion-icon>
|
||||
</button>
|
||||
<button class="btn-no-color cursor-pointer" (click)="doRefresh($event)">
|
||||
@@ -21,8 +21,8 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="div-body width-100">
|
||||
<p class="item-content-detail">{{item.Detail}}</p>
|
||||
<p class="item-content-date">{{ item.DateBegin | date: 'dd-MM-yy HH:mm'}}</p>
|
||||
<p class="item-content-detail">{{publicationItem[folderId].Detail}}</p>
|
||||
<p class="item-content-date">{{ publicationItem[folderId].DateBegin | date: 'dd-MM-yy HH:mm'}}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -35,8 +35,8 @@
|
||||
<ion-refresher-content>
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<div class="main-container px-20">
|
||||
<ion-card *ngFor="let publication of publicationList let i = index"
|
||||
<div class="main-container px-20" *ngIf="publicationItem[folderId]">
|
||||
<ion-card *ngFor="let publication of publicationList[folderId] let i = index"
|
||||
(click)="viewPublicationDetail(publication.DocumentId)">
|
||||
<ion-card-content>
|
||||
<div class="post-img">
|
||||
@@ -84,8 +84,8 @@
|
||||
</ion-list> -->
|
||||
</div>
|
||||
<!-- fab placed to the bottom end -->
|
||||
<ion-fab *ngIf="p.userPermission([p.permissionList.Actions.create])" vertical="bottom" horizontal="end">
|
||||
<ion-fab-button title="Nova Publicação" (click)="AddPublication('2',item.ProcessId)">
|
||||
<ion-fab *ngIf="p.userPermission([p.permissionList.Actions.create]) && publicationItem[folderId]" vertical="bottom" horizontal="end">
|
||||
<ion-fab-button title="Nova Publicação" (click)="AddPublication('2',publicationItem[folderId].ProcessId)">
|
||||
<ion-icon name="add"></ion-icon>
|
||||
</ion-fab-button>
|
||||
</ion-fab>
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user