Files
doneit-web/src/app/pages/search/search.page.ts
T

957 lines
23 KiB
TypeScript
Raw Normal View History

2020-08-05 15:39:16 +01:00
import { Component, OnInit } from '@angular/core';
2021-04-19 11:35:48 +01:00
import { ModalController, NavParams } from '@ionic/angular';
2021-02-08 16:55:55 +01:00
import { SearchService } from "../../services/search.service";
2021-01-08 11:04:36 +01:00
import { formatDate } from '@angular/common';
2021-01-16 17:45:09 +01:00
import { SenderPage } from 'src/app/pages/search/sender/sender.page';
2021-01-19 16:44:39 +01:00
import { OrganicEntityPage } from 'src/app/pages/search/organic-entity/organic-entity.page';
2021-02-18 12:44:35 +01:00
import WordCloud from 'src/plugin/wordcloud2.js';
2021-02-11 14:42:10 +01:00
import { ViewEventPage } from 'src/app/pages/agenda/view-event/view-event.page';
2021-02-11 15:18:27 +01:00
import { PublicationDetailPage } from '../publications/view-publications/publication-detail/publication-detail.page';
2021-04-09 04:34:21 +01:00
import { DocumentDetailPage } from 'src/app/modals/document-detail/document-detail.page';
2021-08-20 17:14:25 +01:00
import { SearchCategory, SearchList } from 'src/app/models/search-document';
2021-10-25 13:54:34 +01:00
import { ThemeService } from 'src/app/services/theme.service'
2022-05-23 14:54:40 +01:00
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
2023-01-24 15:56:47 +01:00
import { Router } from '@angular/router';
2023-01-25 15:49:16 +01:00
import { environment } from 'src/environments/environment';
2021-04-19 11:35:48 +01:00
2020-08-05 15:39:16 +01:00
@Component({
selector: 'app-search',
templateUrl: './search.page.html',
styleUrls: ['./search.page.scss'],
})
export class SearchPage implements OnInit {
2021-01-08 11:04:36 +01:00
// https params
2021-01-24 23:40:03 +01:00
searchSubject: string;
searchDocumentDate: string;
searchSender: string;
searchOrganicEntiry: string;
searchDocTypeId: string;
ordinance: string;
2021-01-08 11:04:36 +01:00
2021-04-09 05:46:01 +01:00
searchCategories: SearchCategory[] = [];
2021-08-20 12:02:27 +01:00
showSearchDocuments: SearchList[] = [];
2021-01-18 14:59:09 +01:00
showCategory: string;
2021-08-20 12:02:27 +01:00
searchDocuments: SearchList[] =[];
2021-01-18 14:59:09 +01:00
2021-01-15 08:16:36 +01:00
showDocuments = false;
showAdvanceSearch = false;
2021-01-29 17:13:15 +01:00
showLoader: boolean;
2021-04-14 11:04:28 +01:00
currentPath: string
2022-05-10 11:12:56 +01:00
searchResult = "Assuntos mais recebidos";
2021-04-14 11:04:28 +01:00
2021-01-16 17:45:09 +01:00
// See http://idangero.us/swiper/api/ for valid options.
slideOpts = {
2021-02-26 10:05:00 +01:00
slidesPerView: parseInt(`${window.innerWidth/147}`, 10),
2021-01-16 17:45:09 +01:00
initialSlide: 0,
speed: 400,
}
2021-02-11 14:31:43 +01:00
loadedAttachments:any;
2021-02-08 12:27:45 +01:00
list = []
2021-02-26 10:05:00 +01:00
windowWidth: number;
2021-04-19 11:35:48 +01:00
type : "Agenda" | "Correspondencia" | "AccoesPresidenciais" | "ArquivoDespachoElect" | "AccoesPresidenciais & ArquivoDespachoElect" = "Agenda";
2021-04-19 11:38:34 +01:00
select: boolean = false;
2021-04-19 11:35:48 +01:00
2021-04-29 15:25:14 +01:00
showSearchInput = false
2021-01-08 11:04:36 +01:00
constructor(private modalController: ModalController,
2021-02-11 14:42:10 +01:00
private search: SearchService,
2021-04-19 11:35:48 +01:00
private modalCtrl: ModalController,
2021-10-25 13:54:34 +01:00
private navParams: NavParams,
2023-01-24 15:56:47 +01:00
public ThemeService: ThemeService,
private router: Router)
2021-10-25 13:54:34 +01:00
{
2021-01-19 16:44:39 +01:00
this.ordinance = "recent";
2021-04-14 11:04:28 +01:00
this.currentPath= window.location.pathname;
2021-04-19 11:35:48 +01:00
this.type = this.navParams.get('type');
2021-04-29 15:25:14 +01:00
this.type = this.navParams.get('type');
2021-04-30 14:12:45 +01:00
this.select = this.navParams.get('select');
2021-04-29 15:25:14 +01:00
this.showSearchInput = this.navParams.get('showSearchInput');
2021-09-15 13:38:14 +01:00
2021-04-19 11:35:48 +01:00
if(this.type == null || this.type == undefined) {
2021-09-15 13:38:14 +01:00
2021-04-19 11:35:48 +01:00
if(this.currentPath == '/home/agenda') {
this.type = "Agenda"
} else if (this.currentPath =='/home/gabinete-digital') {
this.type = "AccoesPresidenciais & ArquivoDespachoElect"
} else if (this.currentPath == '/home/publications') {
this.type = "AccoesPresidenciais"
} else {
2022-04-28 09:32:27 +01:00
2021-04-19 11:35:48 +01:00
}
}
}
2021-08-20 12:02:27 +01:00
selectItem(item: SearchList) {
2021-04-19 11:35:48 +01:00
if(this.select){
this.modalController.dismiss({
selected: item
});
2021-01-08 11:04:36 +01:00
}
2022-05-23 14:54:40 +01:00
}
async view(item: SearchList) {
const ApplicationType = item.ApplicationType.toString()
const Id = item.Id
2021-04-30 14:12:45 +01:00
2022-05-23 14:54:40 +01:00
if(ApplicationType == '8' ) {
2022-06-30 16:57:31 +01:00
// this.viewDocumentDetail(Id, ApplicationType);
2022-05-23 14:54:40 +01:00
2022-06-30 16:47:45 +01:00
const modal = await this.modalController.create({
component: ViewDocumentPage,
componentProps: {
trustedUrl: '',
file: {
title: item.Assunto,
url: '',
title_link: '',
},
applicationId: ApplicationType,
docId: item.Id,
},
cssClass: 'modal modal-desktop'
});
await modal.present();
2022-05-23 14:54:40 +01:00
} else if (ApplicationType == '361') {
const modal = await this.modalController.create({
component: ViewDocumentPage,
componentProps: {
trustedUrl: '',
file: {
title: item.Assunto,
url: '',
title_link: '',
},
applicationId: ApplicationType,
docId: item.Id,
},
cssClass: 'modal modal-desktop'
});
await modal.present();
}
2021-04-19 11:35:48 +01:00
}
2020-08-05 15:39:16 +01:00
ngOnInit() {
2021-02-08 12:27:45 +01:00
2021-02-26 10:05:00 +01:00
this.wordCloud();
window.onresize = (event) => {
this.windowWidth = window.innerWidth
this.loadWordCloud()
};
this.windowWidth = window.innerWidth
2023-01-04 11:11:30 +01:00
window['dynamicSearch'] = (search:string) => {
2021-03-05 14:54:10 +01:00
this.searchSubject = search;
}
2021-03-05 16:04:15 +01:00
2022-10-13 14:37:03 +01:00
window['searchTriger'] = () => {
2021-03-05 14:54:10 +01:00
this.basicSearch();
}
2021-02-11 11:06:56 +01:00
}
2021-07-29 10:13:39 +01:00
wordCloud() {
2021-02-11 14:31:43 +01:00
2023-01-24 15:56:47 +01:00
this.search.mostSeachWord("15").subscribe( res => {
2021-02-11 14:31:43 +01:00
2021-02-12 10:16:27 +01:00
const highest= res[0].Hits;
const lowest = res[res.length-1].Hits;
const range = highest - lowest;
const perPercent = range / 100;
let list = [];
// minimum font sixe
// Editable -----------------------------------
const minimumSize = 9;
// Editable ------------------------------------
2021-03-05 16:04:15 +01:00
// 64
2021-02-12 16:56:26 +01:00
const maximum = 64;
2021-02-12 10:16:27 +01:00
res.forEach(e => {
const array: any = Object.values(e);
2021-09-15 13:38:14 +01:00
2021-02-12 16:56:26 +01:00
array[1] = (((array[1] - lowest) / perPercent) * (maximum - minimumSize)/ 100 ) + minimumSize;
2021-02-12 10:16:27 +01:00
list.push(array)
2021-02-08 12:27:45 +01:00
});
this.list = list
2021-03-05 16:04:15 +01:00
2021-02-08 12:27:45 +01:00
const elem = document.documentElement.querySelector('.most-searched-word-container');
2023-01-04 11:11:30 +01:00
setTimeout(() => {
2021-02-26 10:05:00 +01:00
WordCloud(
elem,
2021-09-15 13:38:14 +01:00
{
2021-02-26 10:05:00 +01:00
list: this.list,
Family: 'Times, serif',
gridSize: 15
},
);
2023-01-04 11:11:30 +01:00
console.log('set visualy')
}, 300)
2021-02-26 10:05:00 +01:00
});
}
2021-07-29 10:13:39 +01:00
loadWordCloud() {
2021-02-26 10:05:00 +01:00
2023-01-24 15:56:47 +01:00
setTimeout(() => {
2021-02-26 10:05:00 +01:00
const elem = document.documentElement.querySelector('.most-searched-word-container');
2021-02-08 12:27:45 +01:00
WordCloud(
elem,
2021-09-15 13:38:14 +01:00
{
2021-02-08 12:27:45 +01:00
list: this.list,
Family: 'Times, serif',
gridSize: 15
},
);
2021-08-13 16:07:17 +01:00
}, 100);
2021-02-26 10:05:00 +01:00
2020-08-05 15:39:16 +01:00
}
2021-01-20 10:41:38 +01:00
2021-07-29 10:13:39 +01:00
close() {
2021-01-07 10:57:42 +01:00
this.modalController.dismiss();
}
2020-08-05 15:39:16 +01:00
2021-01-18 09:52:33 +01:00
2021-07-29 10:13:39 +01:00
reorderList(orderBy: string) {
2021-09-15 13:38:14 +01:00
2021-01-20 10:41:38 +01:00
this.ordinance = orderBy;
if(this.ordinance == 'recent'){
this.showSearchDocuments = this.sortArrayISODate(this.searchDocuments).reverse();
2021-01-20 13:52:25 +01:00
} else {
this.showSearchDocuments = this.sortArrayISODate(this.searchDocuments)
2021-01-20 10:41:38 +01:00
}
2021-01-19 16:44:39 +01:00
}
2021-07-29 10:13:39 +01:00
sortArrayISODate(myArray: any) {
2021-01-18 14:59:09 +01:00
return myArray.sort(function(a, b) {
return (a.Data < b.Data) ? -1 : ((a.Data > b.Data) ? 1 : 0);
});
}
2021-01-08 11:43:47 +01:00
/**
2021-01-15 08:16:36 +01:00
* @description Basic search
2021-01-08 11:43:47 +01:00
*/
2021-07-29 10:13:39 +01:00
basicSearch() {
2021-01-15 08:16:36 +01:00
2021-04-19 11:35:48 +01:00
if(this.type == "Agenda" ){
2021-09-15 13:38:14 +01:00
2021-01-29 17:13:15 +01:00
this.showLoader = true;
2021-01-29 16:25:03 +01:00
this.search.basicSearch(this.searchSubject, this.searchDocumentDate, this.searchSender
,this.searchOrganicEntiry, this.searchDocTypeId, '0').subscribe(res=>{
2022-05-10 11:12:56 +01:00
res.Categories.forEach( e => {
e['Active'] = false;
});
// bind respose
this.searchCategories = res.Categories;
this.searchDocuments = this.sortArrayISODate(res.Documents);
this.reorderList(this.ordinance);
// hide show document
if(this.searchDocuments.length >= 1){
this.showDocuments = true;
} else {
this.showDocuments = false
}
this.showLoader = false;
this.loadWordCloud();
2021-02-26 10:05:00 +01:00
2022-05-10 11:12:56 +01:00
},error => {
2022-12-17 16:19:23 +01:00
this.showLoader = false;
// this.searchResult = "Registo não encontrado"
2022-05-10 11:12:56 +01:00
console.log(error)
2021-01-29 16:25:03 +01:00
});
2021-12-13 12:49:47 +01:00
}
2022-10-13 14:37:03 +01:00
else if ( this.type == "AccoesPresidenciais & ArquivoDespachoElect") {
2021-01-29 16:25:03 +01:00
2021-01-29 17:13:15 +01:00
this.showLoader = true;
2021-01-29 16:25:03 +01:00
2021-04-13 10:35:43 +01:00
this.searchCategories = [];
this.searchDocuments = [];
this.showSearchDocuments = [];
2021-05-07 13:19:50 +01:00
if(this.select) {
let counter = 0;
this.search.searchForDoc(this.searchSubject, this.searchDocumentDate, this.searchSender
,this.searchOrganicEntiry, this.searchDocTypeId, '8').subscribe(res=>{
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
res.Categories.forEach( e => {
e['Active'] = false;
this.searchCategories.push(e)
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
// bind respose
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.sortArrayISODate(res.Documents).forEach(e => {
e['appName'] = 'Correspondencia'
this.searchDocuments.push(e)
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.reorderList(this.ordinance);
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
// hide show document
if(this.searchDocuments.length >= 1){
2021-09-15 13:38:14 +01:00
this.showDocuments = true;
2021-05-07 13:19:50 +01:00
} else {
this.showDocuments = false
}
counter++;
if(counter ==2){
this.showLoader = false;
}
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.loadWordCloud();
2022-05-10 11:12:56 +01:00
},error => {
this.searchResult = "Registo não encontrado"
2022-10-13 14:37:03 +01:00
counter++;
console.log('application 8 failed', error)
if(counter ==2) {
this.showLoader = false;
}
2021-01-29 16:25:03 +01:00
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.search.searchForDoc(this.searchSubject, this.searchDocumentDate, this.searchSender
,this.searchOrganicEntiry, this.searchDocTypeId, '361').subscribe(res=>{
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
res.Categories.forEach( e => {
e['Active'] = false;
this.searchCategories.push(e)
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.sortArrayISODate(res.Documents).forEach(e => {
e['appName'] = 'ArquivoDespachoElect'
this.searchDocuments.push(e)
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.reorderList(this.ordinance);
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
// hide show document
if(this.searchDocuments.length >= 1){
2021-09-15 13:38:14 +01:00
this.showDocuments = true;
2021-05-07 13:19:50 +01:00
} else {
this.showDocuments = false
}
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.loadWordCloud();
counter++;
if(counter ==2){
this.showLoader = false;
}
2022-05-10 11:12:56 +01:00
},error => {
2022-10-13 14:37:03 +01:00
counter++;
if(counter ==2) {
this.showLoader = false;
}
2022-05-10 11:12:56 +01:00
this.searchResult = "Registo não encontrado"
2022-10-13 14:37:03 +01:00
console.log('application 361 failed', error);
2021-04-08 22:53:31 +01:00
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
} else {
2021-12-13 12:49:47 +01:00
let counter = 0;
2021-05-07 13:19:50 +01:00
this.search.basicSearch(this.searchSubject, this.searchDocumentDate, this.searchSender
2023-01-24 15:56:47 +01:00
,this.searchOrganicEntiry, this.searchDocTypeId, '8').subscribe(res => {
2021-05-07 13:19:50 +01:00
res.Categories.forEach( e => {
e['Active'] = false;
this.searchCategories.push(e)
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
// bind respose
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.sortArrayISODate(res.Documents).forEach(e => {
e['appName'] = 'Correspondencia'
this.searchDocuments.push(e)
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.reorderList(this.ordinance);
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
// hide show document
if(this.searchDocuments.length >= 1){
2021-09-15 13:38:14 +01:00
this.showDocuments = true;
2021-05-07 13:19:50 +01:00
} else {
this.showDocuments = false
}
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
counter++;
if(counter ==2){
this.showLoader = false;
}
this.loadWordCloud();
2022-05-10 11:12:56 +01:00
},error => {
2022-10-13 14:37:03 +01:00
console.log('application 8 failed', error)
2022-05-10 11:12:56 +01:00
this.searchResult = "Registo não encontrado"
2022-10-13 14:37:03 +01:00
counter++;
if(counter ==2){
this.showLoader = false;
}
2021-01-29 16:25:03 +01:00
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.search.basicSearch(this.searchSubject, this.searchDocumentDate, this.searchSender
2023-01-24 15:56:47 +01:00
,this.searchOrganicEntiry, this.searchDocTypeId, '361').subscribe(res => {
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
res.Categories.forEach( e => {
e['Active'] = false;
this.searchCategories.push(e)
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.sortArrayISODate(res.Documents).forEach(e => {
e['appName'] = 'ArquivoDespachoElect'
this.searchDocuments.push(e)
});
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
this.reorderList(this.ordinance);
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
// hide show document
2023-01-24 15:56:47 +01:00
if(this.searchDocuments.length >= 1) {
2021-09-15 13:38:14 +01:00
this.showDocuments = true;
2021-05-07 13:19:50 +01:00
} else {
this.showDocuments = false
}
2021-09-15 13:38:14 +01:00
2021-05-07 13:19:50 +01:00
counter++;
if(counter ==2){
this.showLoader = false;
}
this.loadWordCloud();
2022-05-10 11:12:56 +01:00
},error => {
this.searchResult = "Registo não encontrado"
2022-10-13 14:37:03 +01:00
counter++;
console.log('application 361 faield', error);
if(counter ==2){
this.showLoader = false;
}
2021-04-08 22:53:31 +01:00
});
2021-05-07 13:19:50 +01:00
}
2021-12-13 12:49:47 +01:00
}
else if ( this.type == "Correspondencia"){
this.showLoader = true;
this.searchCategories = [];
this.searchDocuments = [];
this.showSearchDocuments = [];
if(this.select) {
let counter = 0;
this.search.searchForDoc(this.searchSubject, this.searchDocumentDate, this.searchSender
,this.searchOrganicEntiry, this.searchDocTypeId, '8').subscribe(res=>{
res.Categories.forEach( e => {
e['Active'] = false;
this.searchCategories.push(e)
});
2021-01-29 16:25:03 +01:00
2021-12-13 12:49:47 +01:00
// bind respose
this.sortArrayISODate(res.Documents).forEach(e => {
e['appName'] = 'Correspondencia'
this.searchDocuments.push(e)
});
this.reorderList(this.ordinance);
// hide show document
if(this.searchDocuments.length >= 1){
this.showDocuments = true;
} else {
this.showDocuments = false
}
counter++;
if(counter ==2){
this.showLoader = false;
}
this.showLoader = false;
this.loadWordCloud();
2022-05-10 11:12:56 +01:00
},error => {
this.searchResult = "Registo não encontrado"
console.log(error)
});
2021-12-13 12:49:47 +01:00
} else {
let counter = 0;
this.search.basicSearch(this.searchSubject, this.searchDocumentDate, this.searchSender
,this.searchOrganicEntiry, this.searchDocTypeId, '8').subscribe(res=>{
res.Categories.forEach( e => {
e['Active'] = false;
this.searchCategories.push(e)
});
// bind respose
this.sortArrayISODate(res.Documents).forEach(e => {
e['appName'] = 'Correspondencia'
this.searchDocuments.push(e)
});
this.reorderList(this.ordinance);
// hide show document
if(this.searchDocuments.length >= 1){
this.showDocuments = true;
} else {
this.showDocuments = false
}
counter++;
2023-01-24 15:56:47 +01:00
if(counter ==2) {
2021-12-13 12:49:47 +01:00
this.showLoader = false;
}
this.loadWordCloud();
2022-05-10 11:12:56 +01:00
},error => {
2022-12-17 16:19:23 +01:00
counter++;
2023-01-24 15:56:47 +01:00
if(counter ==2) {
2022-12-17 16:19:23 +01:00
this.showLoader = false;
}
2022-05-10 11:12:56 +01:00
this.searchResult = "Registo não encontrado"
console.log(error)
2021-12-13 12:49:47 +01:00
});
}
}
2021-04-13 10:35:43 +01:00
2023-01-24 15:56:47 +01:00
else if (this.type == "AccoesPresidenciais") {
let counter = 0;
2021-09-15 13:38:14 +01:00
2021-01-29 17:13:15 +01:00
this.showLoader = true;
2023-01-24 15:56:47 +01:00
this.searchCategories = []
this.searchDocuments = []
2021-01-29 17:13:15 +01:00
2021-01-18 09:52:33 +01:00
this.search.basicSearch(this.searchSubject, this.searchDocumentDate, this.searchSender
2021-01-29 14:13:31 +01:00
,this.searchOrganicEntiry, this.searchDocTypeId, '386').subscribe(res=>{
2022-04-28 09:32:27 +01:00
2021-09-15 13:38:14 +01:00
2021-01-20 10:41:38 +01:00
res.Categories.forEach( e => {
e['Active'] = false;
2023-01-25 15:49:16 +01:00
if(!environment.presidencial) {
e['Name'] = "Publicações"
}
2021-01-20 10:41:38 +01:00
});
2021-09-15 13:38:14 +01:00
2021-01-08 12:29:59 +01:00
// bind respose
2023-01-24 15:56:47 +01:00
for ( const a of res.Categories) {
this.searchCategories.push(a);
}
2021-01-20 10:41:38 +01:00
2023-01-24 15:56:47 +01:00
for ( const a of this.sortArrayISODate(res.Documents)) {
2023-01-25 15:49:16 +01:00
if(!environment.presidencial) {
a.DocTypeDesc = "Publicações"
}
2023-01-24 15:56:47 +01:00
this.searchDocuments.push(a);
}
2021-01-08 11:43:47 +01:00
2021-01-20 13:52:25 +01:00
this.reorderList(this.ordinance);
2021-01-08 12:29:59 +01:00
// hide show document
if(this.searchDocuments.length >= 1){
2021-09-15 13:38:14 +01:00
this.showDocuments = true;
2021-01-08 12:29:59 +01:00
} else {
this.showDocuments = false
}
2021-09-15 13:38:14 +01:00
2023-01-24 15:56:47 +01:00
counter++;
if(counter ==2){
this.showLoader = false;
}
2021-02-26 10:05:00 +01:00
this.loadWordCloud();
2023-01-30 14:04:57 +01:00
}, error => {
2023-01-24 15:56:47 +01:00
counter++;
2023-01-30 14:04:57 +01:00
if(counter == 2) {
2023-01-24 15:56:47 +01:00
this.showLoader = false;
}
this.searchResult = "Registo não encontrado"
console.log(error)
});
this.search.basicSearchPublication(this.searchSubject, this.searchDocumentDate, this.searchSender
,this.searchOrganicEntiry, this.searchDocTypeId, '386').subscribe(res => {
res.Categories.forEach( e => {
e['Active'] = false;
2023-01-25 15:49:16 +01:00
if(!environment.presidencial) {
e['Name'] = "Acções"
}
2023-01-24 15:56:47 +01:00
});
2023-01-25 15:49:16 +01:00
if(!environment.presidencial) {
// bind respose
for ( const a of res.Categories) {
this.searchCategories.push(a);
}
2023-01-24 15:56:47 +01:00
}
for ( const a of this.sortArrayISODate(res.Documents)) {
2023-01-25 15:49:16 +01:00
if(!environment.presidencial) {
a.DocTypeDesc = "Acções"
this.searchDocuments.push(a);
}
2023-01-24 15:56:47 +01:00
}
this.reorderList(this.ordinance);
// hide show document
if(this.searchDocuments.length >= 1) {
this.showDocuments = true;
} else {
this.showDocuments = false
}
counter++;
if(counter ==2) {
this.showLoader = false;
}
this.loadWordCloud();
}, error => {
counter++;
if(counter ==2) {
this.showLoader = false;
}
2022-05-10 11:12:56 +01:00
this.searchResult = "Registo não encontrado"
console.log(error)
2021-01-08 11:43:47 +01:00
});
2023-01-24 15:56:47 +01:00
2021-01-29 16:25:03 +01:00
}
2021-04-19 11:35:48 +01:00
2021-01-08 11:43:47 +01:00
}
2021-01-08 12:29:59 +01:00
/**
* @description set empty value to searchSubject
*/
2021-07-22 16:06:52 +01:00
clearSearchInput() {
2021-01-08 12:29:59 +01:00
this.searchSubject = ""
2021-02-11 11:06:56 +01:00
this.searchCategories = [];
this.searchDocuments = [];
this.showDocuments = false;
this.wordCloud();
2021-07-22 16:06:52 +01:00
}
2021-01-08 12:29:59 +01:00
2021-01-08 11:04:36 +01:00
/**
* @param isoDate String Iso date
2021-01-08 13:00:34 +01:00
* @returns date in format dd/MM/yyyy
2021-01-08 12:29:59 +01:00
* @description convert Iso date to dd/MM/yyyy
2021-01-08 11:04:36 +01:00
*/
formateIsoDate(isoDate:string): string{
const date = new Date(isoDate);
return formatDate(date, 'dd/MM/yyyy', 'pt');
}
2021-01-20 13:52:25 +01:00
activeCategoty(i){
2021-02-10 16:55:27 +01:00
this.searchCategories.forEach((e, j) => {
if(i != j){
e['Active'] = false;
2021-09-15 13:38:14 +01:00
}
2021-01-20 13:52:25 +01:00
})
2021-02-10 16:55:27 +01:00
if (this.searchCategories[i]['Active']){
this.searchCategories[i]['Active'] = false;
} else {
this.searchCategories[i]['Active'] = true
}
2021-01-20 13:52:25 +01:00
}
2023-01-24 15:56:47 +01:00
clearInputRemetente() {
2021-01-18 14:59:09 +01:00
this.searchSender = "";
}
2021-07-09 12:35:11 +01:00
clearInputDocumentDate(){
2021-01-18 14:59:09 +01:00
this.searchDocumentDate = "";
}
2021-07-09 12:35:11 +01:00
clearInputOrganicEntity(){
2021-01-18 14:59:09 +01:00
this.searchOrganicEntiry = "";
}
2021-01-15 08:16:36 +01:00
/**
* @description Clean inputs
*/
showHideAdvanceSearch(show:boolean) {
this.showAdvanceSearch = show;
}
2021-01-16 17:45:09 +01:00
async openAdvanceSearchSelection() {
2021-03-11 10:31:46 +01:00
let classs;
if( window.innerWidth <= 1024){
classs = 'modal modal-desktop'
} else {
classs = 'search-desktop-modal search-submodal'
}
2021-01-16 17:45:09 +01:00
const modal = await this.modalController.create({
component: SenderPage,
2021-03-11 10:31:46 +01:00
cssClass: classs,
2021-01-16 17:45:09 +01:00
componentProps: {
}
});
2021-01-19 16:44:39 +01:00
await modal.present();
modal.onDidDismiss().then((data) => {
this.searchSender = data.data;
});
}
2022-06-22 16:37:51 +01:00
async openOrganicEntitySelection() {
2021-01-19 16:44:39 +01:00
2021-03-11 10:31:46 +01:00
let classs;
if( window.innerWidth <= 1024){
classs = 'modal modal-desktop'
} else {
classs = 'search-desktop-modal search-submodal'
}
2021-01-19 16:44:39 +01:00
const modal = await this.modalController.create({
component: OrganicEntityPage,
2021-03-11 10:31:46 +01:00
cssClass: classs,
2021-01-19 16:44:39 +01:00
componentProps: {
}
});
await modal.present();
modal.onDidDismiss().then((data) => {
this.searchOrganicEntiry = data.data;
});
2021-01-16 17:45:09 +01:00
}
2023-01-24 15:56:47 +01:00
TodosCategory = true
2021-12-13 11:13:21 +01:00
async filterDocList(categoryName:string){
2021-09-15 13:38:14 +01:00
2021-01-18 14:59:09 +01:00
// show all category
2021-12-13 11:13:21 +01:00
if(this. showCategory == categoryName ){
2021-09-15 13:38:14 +01:00
2021-01-18 14:59:09 +01:00
this.showSearchDocuments = this.searchDocuments;
} else { // filter category
this.showSearchDocuments = this.searchDocuments.filter((e) => e.DocTypeDesc == categoryName);
}
this.showCategory = categoryName;
2023-01-24 15:56:47 +01:00
for(let category of this.searchCategories) {
if(category['Active']) {
this.TodosCategory = false
return false
}
}
this.TodosCategory = true
}
noFilter() {
this.TodosCategory = true
let n = 0
for(let category of this.searchCategories) {
this.searchCategories[n]['Active'] = false
n++
}
this.showSearchDocuments = this.searchDocuments;
2021-01-18 14:59:09 +01:00
}
2021-02-11 14:31:43 +01:00
itemIcons(): string{
2021-04-19 11:35:48 +01:00
return this.type
2021-02-11 14:31:43 +01:00
}
viewDocument(){
const url: string = this.loadedAttachments.DocumentURL.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
// const browser = this.iab.create(url,"_blank");
// browser.show();
}
2021-08-20 12:02:27 +01:00
async viewDetail(searchDocument: SearchList) {
2021-04-30 14:12:45 +01:00
const ApplicationType = searchDocument.ApplicationType.toString()
const Id = searchDocument.Id
2022-06-13 16:49:36 +01:00
const CalendarId = searchDocument.ApplicationName.split(':')[1]
2023-01-24 15:56:47 +01:00
const DocTypeDesc = searchDocument.DocTypeDesc
2022-06-13 16:49:36 +01:00
2022-05-23 14:54:40 +01:00
if(this.select == false) {
2021-04-30 14:12:45 +01:00
if(this.type == "Agenda") {
2021-02-11 15:18:27 +01:00
2021-04-19 11:35:48 +01:00
const modal = await this.modalCtrl.create({
component: ViewEventPage,
2022-06-14 14:34:54 +01:00
componentProps: {
2021-07-26 11:34:46 +01:00
eventId: Id,
2022-06-13 16:49:36 +01:00
CalendarId: CalendarId,
2021-08-25 12:34:02 +01:00
isModal: true,
header: false
2021-04-19 11:35:48 +01:00
},
cssClass: 'modal modal-desktop',
});
await modal.present();
modal.onDidDismiss().then((res)=>{});
2021-09-15 13:38:14 +01:00
2022-05-23 14:54:40 +01:00
} else if(this.type == "AccoesPresidenciais") {
2021-09-15 13:38:14 +01:00
2023-01-24 15:56:47 +01:00
this.viewPublicationDetail(Id, DocTypeDesc);
2021-04-19 11:35:48 +01:00
}
2022-05-23 14:54:40 +01:00
else if(this.type == "AccoesPresidenciais & ArquivoDespachoElect") {
2021-09-15 13:38:14 +01:00
2023-01-24 15:56:47 +01:00
// 361
if(ApplicationType == '8') {
2021-07-23 15:57:01 +01:00
this.viewDocumentDetail(Id, ApplicationType);
2023-01-24 15:56:47 +01:00
} else if (ApplicationType == '361') {
this.viewDocumentModal(searchDocument)
2021-07-23 15:57:01 +01:00
}
2021-04-19 11:35:48 +01:00
}
2021-04-07 09:32:17 +01:00
}
2021-02-11 14:46:34 +01:00
}
2021-02-11 14:42:10 +01:00
2023-01-24 15:56:47 +01:00
async viewPublicationDetail(publicationId:string, DocTypeDesc) {
// validation my friend
if(DocTypeDesc == 'Acções') {
this.router.navigate(['/home/publications', publicationId]);
} else if( DocTypeDesc == 'Publicações') {
const modal = await this.modalController.create({
component: PublicationDetailPage,
componentProps:{
publicationId: publicationId,
isModal: true
},
cssClass: 'publication-detail modal modal-desktop ',
//backdropDismiss: false
});
await modal.present();
modal.onDidDismiss().then(()=>{});
}
2021-09-15 13:38:14 +01:00
2021-02-11 15:18:27 +01:00
}
2021-04-07 09:32:17 +01:00
2021-04-09 04:34:21 +01:00
async viewDocumentDetail(docId:string, applicationId:string) {
2021-04-07 09:32:17 +01:00
let classs;
2021-07-23 15:57:01 +01:00
2021-09-15 13:38:14 +01:00
if( window.innerWidth < 701) {
2021-04-19 11:35:48 +01:00
classs = 'modal modal-desktop'
2021-04-07 09:32:17 +01:00
} else {
2021-04-09 04:34:21 +01:00
classs = 'modal modal-desktop showAsideOptions'
2021-04-07 09:32:17 +01:00
}
2021-09-15 13:38:14 +01:00
2021-04-07 09:32:17 +01:00
const modal = await this.modalController.create({
2021-04-09 04:34:21 +01:00
component: DocumentDetailPage,
2021-04-07 09:32:17 +01:00
componentProps:{
2021-04-09 04:34:21 +01:00
docId: docId,
applicationId: applicationId,
2021-04-07 09:32:17 +01:00
},
cssClass: classs,
});
await modal.present();
2021-07-23 15:57:01 +01:00
modal.onDidDismiss().then((res)=>{});
}
2021-09-15 13:38:14 +01:00
2023-01-24 15:56:47 +01:00
async viewDocumentModal(LoadedDocument) {
let task = {
serialNumber: '',
taskStartDate: '',
isEvent: true,
workflowInstanceDataFields: {
FolderID: '',
Subject: LoadedDocument.SourceName || LoadedDocument.Assunto,
SourceSecFsID: LoadedDocument.ApplicationId || LoadedDocument.ApplicationType,
SourceType: 'DOC',
SourceID: LoadedDocument.Id || LoadedDocument.Id,
DispatchNumber: ''
}
}
const modal = await this.modalController.create({
component: ViewDocumentPage,
componentProps: {
trustedUrl: '',
file: {
title: task.workflowInstanceDataFields.Subject,
url: '',
title_link: '',
},
Document: LoadedDocument,
applicationId: task.workflowInstanceDataFields.SourceSecFsID,
docId: task.workflowInstanceDataFields.SourceID ,
folderId: '',
task: task
},
cssClass: 'modal modal-desktop'
});
await modal.present();
}
2021-02-11 15:18:27 +01:00
}