2020-08-05 15:39:16 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2021-01-07 10:57:42 +01:00
|
|
|
import { ModalController } from '@ionic/angular';
|
2021-01-08 11:04:36 +01:00
|
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
2021-02-08 12:27:45 +01:00
|
|
|
import { SearchService, } from "../../services/search.service";
|
2021-01-08 11:04:36 +01:00
|
|
|
import { SearchCategory } from "src/app/models/search-category";
|
|
|
|
|
import { SearchDocument } from "src/app/models/search-document";
|
|
|
|
|
import { formatDate } from '@angular/common';
|
2021-01-15 08:16:36 +01:00
|
|
|
import { CloudData, CloudOptions } from 'angular-tag-cloud-module';
|
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-08 12:27:45 +01:00
|
|
|
import WordCloud from 'src/plugin/wordcloud2.js'
|
|
|
|
|
|
2021-01-19 16:44:39 +01:00
|
|
|
|
|
|
|
|
import { NgModel } from '@angular/forms';
|
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
|
|
|
|
|
|
|
|
searchCategories: SearchCategory[];
|
2021-01-18 14:59:09 +01:00
|
|
|
showSearchDocuments: SearchDocument[];
|
|
|
|
|
showCategory: string;
|
2021-01-08 11:04:36 +01:00
|
|
|
searchDocuments: SearchDocument[];
|
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-01-27 13:57:55 +01:00
|
|
|
height: number = 411;
|
|
|
|
|
width: number = 411;
|
|
|
|
|
|
2021-01-15 08:16:36 +01:00
|
|
|
data: CloudData[] = [
|
2021-01-27 13:57:55 +01:00
|
|
|
{text: 'Docents', weight: 0.1, color: '#ffaaee'},
|
|
|
|
|
{text: '1232', weight: 0.2, tooltip: 'display a tooltip'},
|
|
|
|
|
{text: 'Dcuments', weight: 0.1, color: '#ffaaee'},
|
|
|
|
|
{text: 'Cat', weight: 0.3, color: '#ffaaee'},
|
|
|
|
|
{text: 'Dogs', weight: 0.1, tooltip: 'display a tooltip'},
|
|
|
|
|
{text: 'cars', weight: 0.2, color: '#ffaaee'},
|
2021-01-15 08:16:36 +01:00
|
|
|
];
|
2021-01-27 13:57:55 +01:00
|
|
|
|
2021-01-16 17:45:09 +01:00
|
|
|
// See http://idangero.us/swiper/api/ for valid options.
|
|
|
|
|
slideOpts = {
|
|
|
|
|
slidesPerView: 3,
|
|
|
|
|
initialSlide: 0,
|
|
|
|
|
speed: 400,
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-08 12:27:45 +01:00
|
|
|
|
|
|
|
|
list = []
|
|
|
|
|
|
2021-01-08 11:04:36 +01:00
|
|
|
constructor(private modalController: ModalController,
|
|
|
|
|
private search: SearchService) {
|
2021-01-19 16:44:39 +01:00
|
|
|
this.ordinance = "recent";
|
2021-01-08 11:04:36 +01:00
|
|
|
}
|
2020-08-05 15:39:16 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-02-08 12:27:45 +01:00
|
|
|
|
|
|
|
|
this.search.mostSeachWord("10").subscribe(res=>{
|
|
|
|
|
|
|
|
|
|
let list = []
|
|
|
|
|
|
|
|
|
|
res.forEach(element => {
|
|
|
|
|
list.push(Object.values(element))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.list = list
|
|
|
|
|
|
|
|
|
|
const elem = document.documentElement.querySelector('.most-searched-word-container');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WordCloud(
|
|
|
|
|
elem,
|
|
|
|
|
{
|
|
|
|
|
list: this.list,
|
|
|
|
|
Family: 'Times, serif',
|
|
|
|
|
gridSize: 15
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2020-08-05 15:39:16 +01:00
|
|
|
}
|
2021-01-20 10:41:38 +01:00
|
|
|
|
2021-01-07 10:57:42 +01:00
|
|
|
close(){
|
|
|
|
|
this.modalController.dismiss();
|
|
|
|
|
}
|
2020-08-05 15:39:16 +01:00
|
|
|
|
2021-01-18 09:52:33 +01:00
|
|
|
|
2021-01-20 10:41:38 +01:00
|
|
|
reorderList(orderBy: string){
|
|
|
|
|
|
|
|
|
|
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-01-18 14:59:09 +01:00
|
|
|
sortArrayISODate(myArray: any){
|
|
|
|
|
return myArray.sort(function(a, b) {
|
|
|
|
|
return (a.Data < b.Data) ? -1 : ((a.Data > b.Data) ? 1 : 0);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-19 08:52:43 +01:00
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
basicSearch(){
|
2021-01-15 08:16:36 +01:00
|
|
|
|
2021-01-29 16:25:03 +01:00
|
|
|
function getCookie(cname) {
|
|
|
|
|
var name = cname + "=";
|
|
|
|
|
var decodedCookie = decodeURIComponent(document.cookie);
|
|
|
|
|
var ca = decodedCookie.split(';');
|
|
|
|
|
for(var i = 0; i <ca.length; i++) {
|
|
|
|
|
var c = ca[i];
|
|
|
|
|
while (c.charAt(0) == ' ') {
|
|
|
|
|
c = c.substring(1);
|
|
|
|
|
}
|
|
|
|
|
if (c.indexOf(name) == 0) {
|
|
|
|
|
return c.substring(name.length, c.length);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const APPType = getCookie('searchModalAPPType');
|
|
|
|
|
|
|
|
|
|
if(APPType == '0'){
|
|
|
|
|
|
|
|
|
|
console.log('aplication type 0');
|
|
|
|
|
|
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=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
2021-01-29 17:13:15 +01:00
|
|
|
|
|
|
|
|
this.showLoader = false;
|
2021-01-29 16:25:03 +01:00
|
|
|
});
|
|
|
|
|
} else if (APPType == '8,361'){
|
|
|
|
|
|
|
|
|
|
console.log('aplication type 8,361');
|
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, '8').subscribe(res=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
|
|
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.search.basicSearch(this.searchSubject, this.searchDocumentDate, this.searchSender
|
|
|
|
|
,this.searchOrganicEntiry, this.searchDocTypeId, '361').subscribe(res=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
2021-01-29 17:13:15 +01:00
|
|
|
|
|
|
|
|
this.showLoader = false;
|
2021-01-29 16:25:03 +01:00
|
|
|
});
|
|
|
|
|
} else if (APPType == '386'){
|
|
|
|
|
|
2021-01-29 17:13:15 +01:00
|
|
|
this.showLoader = true;
|
|
|
|
|
|
2021-01-29 16:25:03 +01:00
|
|
|
console.log('aplication type 386');
|
|
|
|
|
|
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=>{
|
|
|
|
|
console.log(res);
|
2021-01-08 11:43:47 +01:00
|
|
|
|
2021-01-20 10:41:38 +01:00
|
|
|
res.Categories.forEach( e => {
|
|
|
|
|
e['Active'] = false;
|
|
|
|
|
});
|
|
|
|
|
|
2021-01-08 12:29:59 +01:00
|
|
|
// bind respose
|
2021-01-08 11:43:47 +01:00
|
|
|
this.searchCategories = res.Categories;
|
2021-01-20 10:41:38 +01:00
|
|
|
|
2021-01-18 14:59:09 +01:00
|
|
|
this.searchDocuments = this.sortArrayISODate(res.Documents);
|
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){
|
|
|
|
|
this.showDocuments = true;
|
|
|
|
|
} else {
|
|
|
|
|
this.showDocuments = false
|
|
|
|
|
}
|
2021-01-29 17:13:15 +01:00
|
|
|
|
|
|
|
|
this.showLoader = false;
|
2021-01-08 11:43:47 +01:00
|
|
|
});
|
2021-01-29 16:25:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-01-08 11:43:47 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-08 12:29:59 +01:00
|
|
|
/**
|
|
|
|
|
* @description set empty value to searchSubject
|
|
|
|
|
*/
|
|
|
|
|
clearSearchInput(){
|
|
|
|
|
this.searchSubject = ""
|
|
|
|
|
}
|
|
|
|
|
|
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-18 14:59:09 +01:00
|
|
|
|
2021-01-20 13:52:25 +01:00
|
|
|
activeCategoty(i){
|
|
|
|
|
|
|
|
|
|
this.searchCategories.forEach((e) => {
|
|
|
|
|
e['Active'] = false;
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.searchCategories[i]['Active'] = true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-18 14:59:09 +01:00
|
|
|
clearInputRemetente(){
|
|
|
|
|
this.searchSender = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearInputDocumentDate(){
|
|
|
|
|
this.searchDocumentDate = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearInputOrganicEntity(){
|
|
|
|
|
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() {
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: SenderPage,
|
|
|
|
|
cssClass: 'sender',
|
|
|
|
|
componentProps: {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2021-01-19 16:44:39 +01:00
|
|
|
await modal.present();
|
|
|
|
|
|
|
|
|
|
modal.onDidDismiss().then((data) => {
|
|
|
|
|
this.searchSender = data.data;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async openOrganicEntitySelection(){
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: OrganicEntityPage,
|
|
|
|
|
cssClass: 'organicEnity',
|
|
|
|
|
componentProps: {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await modal.present();
|
|
|
|
|
|
|
|
|
|
modal.onDidDismiss().then((data) => {
|
|
|
|
|
this.searchOrganicEntiry = data.data;
|
|
|
|
|
});
|
2021-01-16 17:45:09 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-18 14:59:09 +01:00
|
|
|
async filterDocList(categoryName:string){
|
|
|
|
|
|
|
|
|
|
// show all category
|
|
|
|
|
if(this. showCategory == categoryName ){
|
|
|
|
|
|
|
|
|
|
this.showSearchDocuments = this.searchDocuments;
|
|
|
|
|
|
|
|
|
|
} else { // filter category
|
|
|
|
|
this.showSearchDocuments = this.searchDocuments.filter((e) => e.DocTypeDesc == categoryName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.showCategory = categoryName;
|
|
|
|
|
}
|
|
|
|
|
}
|