pr eftu<r despachp

This commit is contained in:
Eudes Inácio
2023-02-27 22:52:33 +01:00
16 changed files with 527 additions and 541 deletions
+1 -1
View File
@@ -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
@@ -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) {
+27 -30
View File
@@ -79,14 +79,14 @@ 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) {
this.getActions();
}
});
this.hideRefreshButton();
this.getFromDB()
@@ -141,42 +141,39 @@ export class PublicationsPage implements OnInit {
getActions() {
if(this.showLoader == false) {
this.showLoader = true;
this.publications.GetPublicationFolderList().subscribe(async res => {
this.showLoader = true
const folders: PublicationFolder[] = this.getPublicationFolderMap(res)
this.publications.GetPublicationFolderList().subscribe(async res => {
this.showLoader = false;
const folders: PublicationFolder[] = this.getPublicationFolderMap(res)
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;
});
}
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;
});
}
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) {
@@ -11,12 +11,12 @@
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " src="assets/images/theme/doneIt/icons-calendar-arrow-left.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src='assets/images/theme/gov/icons-calendar-arrow-left.svg'></ion-icon>
</div>
<div class="div-title flex-grow-1">
<ion-label class="title">{{item.Description}}</ion-label>
<p class="item-content-detail">{{item.Detail}}</p>
<p class="item-content-date">{{item.DateBegin | date: 'dd-MM-yy HH:mm'}}</p>
<div *ngIf="publicationItem[folderId]" class="div-title flex-grow-1">
<ion-label class="title">{{publicationItem[folderId].Description}}</ion-label>
<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 *ngIf="p.userPermission([p.permissionList.Actions.createPost])" class="actions-icon cursor-pointer" (click)="AddPublication('2',item.ProcessId)">
<div *ngIf="p.userPermission([p.permissionList.Actions.createPost]) && publicationItem[folderId]" class="actions-icon cursor-pointer" (click)="AddPublication('2',publicationItem[folderId].ProcessId)">
<!-- <ion-icon (click)="AddPublication('1',item.ProcessId)" slot="end" src='assets/images/icons-add-photo.svg'></ion-icon> -->
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="end" src='assets/images/icons-add.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src='assets/images/theme/gov/icons-add.svg'></ion-icon>
@@ -27,14 +27,14 @@
</ion-header>
<ion-content class="background-white">
<!-- <ion-refresher name="refresher" slot="fixed" (ionRefresh)="doRefresh($event)">
<ion-refresher name="refresher" slot="fixed" (ionRefresh)="doRefresh($event)">
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
<ion-refresher-content>
</ion-refresher-content>
</ion-refresher> -->
</ion-refresher>
<div class="main-container background-white height-100 overflow-y-auto">
<ion-content>
<ion-card *ngFor="let publication of getpublication let i = index"
<ion-content *ngIf="publicationItem[folderId]">
<ion-card *ngFor="let publication of publicationList[folderId] let i = index"
(click)="goToPublicationDetail(publication.DocumentId)"
>
<ion-card-content>
@@ -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,146 +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) => {
if(error.status == 0) {
this.getFromDB()
} else {
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;
// this.httpErroHandle.httpStatusHandle(error)
});
}
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) {