2020-12-01 14:03:15 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2021-06-18 11:01:02 +01:00
|
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
|
|
|
|
import { ModalController } from '@ionic/angular';
|
2020-12-09 12:10:19 +01:00
|
|
|
import { Publication } from 'src/app/models/publication';
|
|
|
|
|
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
2020-12-15 19:37:42 +01:00
|
|
|
import { LoadingService } from 'src/app/services/loading.service';
|
2020-12-09 12:10:19 +01:00
|
|
|
import { PublicationsService } from 'src/app/services/publications.service';
|
2020-12-01 17:22:45 +01:00
|
|
|
import { NewPublicationPage } from '../new-publication/new-publication.page';
|
2020-12-09 12:10:19 +01:00
|
|
|
import { PublicationDetailPage } from './publication-detail/publication-detail.page';
|
2020-12-01 14:03:15 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-view-publications',
|
|
|
|
|
templateUrl: './view-publications.page.html',
|
|
|
|
|
styleUrls: ['./view-publications.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class ViewPublicationsPage implements OnInit {
|
2021-07-15 16:07:55 +01:00
|
|
|
showLoader = true;
|
2020-12-15 19:37:42 +01:00
|
|
|
loading: any;
|
2020-12-11 15:09:53 +01:00
|
|
|
|
2020-12-09 12:10:19 +01:00
|
|
|
publicationList: Publication[];
|
|
|
|
|
item: PublicationFolder;
|
2021-02-03 15:13:23 +01:00
|
|
|
folderId:string;
|
2021-07-15 11:53:16 +01:00
|
|
|
error: any;
|
2020-12-01 14:03:15 +01:00
|
|
|
|
2021-07-15 16:07:55 +01:00
|
|
|
constructor( private loadingController: LoadingService,
|
2020-12-09 12:10:19 +01:00
|
|
|
private modalController: ModalController,
|
|
|
|
|
private publications: PublicationsService,
|
2021-06-18 11:01:02 +01:00
|
|
|
private activatedRoute: ActivatedRoute,
|
2021-07-15 16:07:55 +01:00
|
|
|
private router: Router )
|
2021-06-21 08:27:57 +01:00
|
|
|
{
|
2021-02-03 15:13:23 +01:00
|
|
|
this.item = new PublicationFolder();
|
2021-06-18 11:01:02 +01:00
|
|
|
this.activatedRoute.paramMap.subscribe(params => {
|
|
|
|
|
console.log(params);
|
|
|
|
|
|
|
|
|
|
if(params["params"]) {
|
|
|
|
|
this.folderId = params["params"].folderId;
|
|
|
|
|
console.log(params["params"]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-12-01 14:03:15 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-02-03 15:13:23 +01:00
|
|
|
console.log(this.folderId);
|
|
|
|
|
|
|
|
|
|
this.getPublications();
|
|
|
|
|
this.getPublicationDetail();
|
2020-12-09 12:10:19 +01:00
|
|
|
}
|
2021-06-21 08:27:57 +01:00
|
|
|
|
2020-12-11 15:09:53 +01:00
|
|
|
doRefresh(event) {
|
2020-12-15 19:37:42 +01:00
|
|
|
this.getPublications();
|
2020-12-11 15:09:53 +01:00
|
|
|
|
|
|
|
|
setTimeout(() => {
|
2020-12-17 10:59:11 +01:00
|
|
|
this.getPublications();
|
2021-02-03 15:13:23 +01:00
|
|
|
this.getPublicationDetail();
|
2020-12-17 10:59:11 +01:00
|
|
|
event.target.complete();
|
|
|
|
|
}, 3000);
|
2021-07-15 16:07:55 +01:00
|
|
|
|
2020-12-11 15:09:53 +01:00
|
|
|
}
|
2021-06-21 08:27:57 +01:00
|
|
|
|
|
|
|
|
close() {
|
2020-12-09 12:10:19 +01:00
|
|
|
this.modalController.dismiss();
|
|
|
|
|
}
|
2021-06-21 08:27:57 +01:00
|
|
|
|
|
|
|
|
goBack() {
|
2021-07-15 16:07:55 +01:00
|
|
|
this.modalController.dismiss();
|
2021-06-18 11:01:02 +01:00
|
|
|
this.router.navigate(['/home/publications']);
|
|
|
|
|
}
|
2021-06-21 08:27:57 +01:00
|
|
|
|
2021-07-15 16:07:55 +01:00
|
|
|
getPublicationDetail() {
|
2021-07-01 09:36:17 +01:00
|
|
|
this.publications.GetPresidentialAction(this.folderId).subscribe(res=>{
|
2021-02-03 15:13:23 +01:00
|
|
|
console.log(res);
|
|
|
|
|
this.item = res;
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-06-21 08:27:57 +01:00
|
|
|
|
2021-07-15 16:07:55 +01:00
|
|
|
getPublications() {
|
2020-12-15 19:37:42 +01:00
|
|
|
this.showLoader = true;
|
2020-12-09 12:10:19 +01:00
|
|
|
|
2021-02-03 15:13:23 +01:00
|
|
|
this.publications.GetPublications(this.folderId).subscribe(res=>{
|
2020-12-09 12:10:19 +01:00
|
|
|
this.publicationList = new Array();
|
|
|
|
|
console.log(res);
|
|
|
|
|
res.forEach(element => {
|
2020-12-10 11:22:06 +01:00
|
|
|
let itemImage = {
|
|
|
|
|
title: 'Title',
|
|
|
|
|
url: "data:image/jpg;base64," + element.FileBase64,
|
|
|
|
|
format: 'png'
|
|
|
|
|
}
|
2020-12-09 12:10:19 +01:00
|
|
|
let item: Publication = {
|
2020-12-17 10:59:11 +01:00
|
|
|
"DateIndex": element.DateIndex,
|
2020-12-11 15:09:53 +01:00
|
|
|
"DocumentId":element.DocumentId,
|
|
|
|
|
"ProcessId":element.ProcessId,
|
|
|
|
|
"Title":element.Title,
|
|
|
|
|
"Message": element.Message,
|
|
|
|
|
"DatePublication": element.DatePublication,
|
2020-12-10 11:22:06 +01:00
|
|
|
/* image:itemImage, */
|
2020-12-11 15:09:53 +01:00
|
|
|
"FileBase64": "data:image/jpg;base64," + element.FileBase64,
|
|
|
|
|
"OriginalFileName": '',
|
|
|
|
|
"FileExtension": '',
|
2020-12-09 12:10:19 +01:00
|
|
|
}
|
|
|
|
|
this.publicationList.push(item);
|
|
|
|
|
});
|
|
|
|
|
console.log(this.publicationList);
|
2020-12-15 19:37:42 +01:00
|
|
|
this.showLoader = false;
|
2021-07-15 11:53:16 +01:00
|
|
|
},
|
|
|
|
|
(error)=>{
|
|
|
|
|
if(error.status == '404'){
|
|
|
|
|
this.error = 'Sem publicações disponíveis!';
|
|
|
|
|
this.publicationList=null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.showLoader = false;
|
|
|
|
|
|
2020-12-09 12:10:19 +01:00
|
|
|
});
|
2020-12-15 19:37:42 +01:00
|
|
|
|
2020-12-01 14:03:15 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-03 15:50:12 +01:00
|
|
|
async AddPublication(publicationType:any, folderId:any) {
|
2020-12-01 17:22:45 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: NewPublicationPage,
|
|
|
|
|
componentProps:{
|
|
|
|
|
publicationType: publicationType,
|
2020-12-10 11:22:06 +01:00
|
|
|
folderId: folderId,
|
2020-12-01 17:22:45 +01:00
|
|
|
},
|
2021-04-14 15:27:50 +01:00
|
|
|
cssClass: 'new-publication modal modal-desktop',
|
2020-12-01 17:22:45 +01:00
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
2020-12-15 19:37:42 +01:00
|
|
|
modal.onDidDismiss().then(()=>{
|
|
|
|
|
this.doRefresh(event);
|
|
|
|
|
});
|
2020-12-01 17:22:45 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-18 11:59:06 +01:00
|
|
|
goToPublicationDetail(publicationId:string){
|
|
|
|
|
this.router.navigate(['/home/publications/view-publications', this.folderId, publicationId]);
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 15:20:47 +01:00
|
|
|
async viewPublicationDetail(publicationId:string) {
|
2020-12-09 12:10:19 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: PublicationDetailPage,
|
|
|
|
|
componentProps:{
|
|
|
|
|
publicationId: publicationId,
|
2021-04-07 10:20:01 +01:00
|
|
|
folderId: this.folderId,
|
2020-12-09 12:10:19 +01:00
|
|
|
},
|
2021-04-14 15:27:50 +01:00
|
|
|
cssClass: 'publication-detail modal modal-desktop',
|
2021-04-29 19:46:40 +01:00
|
|
|
// backdropDismiss: false
|
2020-12-09 12:10:19 +01:00
|
|
|
});
|
|
|
|
|
await modal.present();
|
2020-12-15 19:37:42 +01:00
|
|
|
modal.onDidDismiss().then(()=>{
|
2021-04-07 10:20:01 +01:00
|
|
|
this.getPublications();
|
2020-12-15 19:37:42 +01:00
|
|
|
});
|
2020-12-09 12:10:19 +01:00
|
|
|
}
|
|
|
|
|
|
2020-12-01 14:03:15 +01:00
|
|
|
}
|