+
+
-
diff --git a/src/app/pages/search/search.page.ts b/src/app/pages/search/search.page.ts
index a01dc100a..e7a892237 100644
--- a/src/app/pages/search/search.page.ts
+++ b/src/app/pages/search/search.page.ts
@@ -11,6 +11,7 @@ import { DocumentDetailPage } from 'src/app/modals/document-detail/document-deta
import { SearchCategory, SearchList } from 'src/app/models/search-document';
import { ThemeService } from 'src/app/services/theme.service'
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
+import { Router } from '@angular/router';
@Component({
selector: 'app-search',
@@ -62,7 +63,8 @@ export class SearchPage implements OnInit {
private search: SearchService,
private modalCtrl: ModalController,
private navParams: NavParams,
- public ThemeService: ThemeService)
+ public ThemeService: ThemeService,
+ private router: Router)
{
this.ordinance = "recent";
this.currentPath= window.location.pathname;
@@ -166,9 +168,7 @@ export class SearchPage implements OnInit {
wordCloud() {
- this.search.mostSeachWord("15").subscribe(res=>{
-
- console.log('LOAD LIST');
+ this.search.mostSeachWord("15").subscribe( res => {
const highest= res[0].Hits;
const lowest = res[res.length-1].Hits;
@@ -191,7 +191,6 @@ export class SearchPage implements OnInit {
});
this.list = list
- console.log('set list')
const elem = document.documentElement.querySelector('.most-searched-word-container');
@@ -213,7 +212,7 @@ export class SearchPage implements OnInit {
loadWordCloud() {
- setTimeout(()=>{
+ setTimeout(() => {
const elem = document.documentElement.querySelector('.most-searched-word-container');
WordCloud(
@@ -386,7 +385,7 @@ export class SearchPage implements OnInit {
let counter = 0;
this.search.basicSearch(this.searchSubject, this.searchDocumentDate, this.searchSender
- ,this.searchOrganicEntiry, this.searchDocTypeId, '8').subscribe(res=>{
+ ,this.searchOrganicEntiry, this.searchDocTypeId, '8').subscribe(res => {
res.Categories.forEach( e => {
e['Active'] = false;
this.searchCategories.push(e)
@@ -544,7 +543,7 @@ export class SearchPage implements OnInit {
counter++;
- if(counter ==2){
+ if(counter ==2) {
this.showLoader = false;
}
@@ -552,7 +551,7 @@ export class SearchPage implements OnInit {
},error => {
counter++;
- if(counter ==2){
+ if(counter ==2) {
this.showLoader = false;
}
this.searchResult = "Registo não encontrado"
@@ -561,9 +560,13 @@ export class SearchPage implements OnInit {
}
}
- else if (this.type == "AccoesPresidenciais"){
+ else if (this.type == "AccoesPresidenciais") {
+
+ let counter = 0;
this.showLoader = true;
+ this.searchCategories = []
+ this.searchDocuments = []
this.search.basicSearch(this.searchSubject, this.searchDocumentDate, this.searchSender
,this.searchOrganicEntiry, this.searchDocTypeId, '386').subscribe(res=>{
@@ -571,12 +574,18 @@ export class SearchPage implements OnInit {
res.Categories.forEach( e => {
e['Active'] = false;
+ e['Name'] = "Publicações"
});
// bind respose
- this.searchCategories = res.Categories;
+ for ( const a of res.Categories) {
+ this.searchCategories.push(a);
+ }
- this.searchDocuments = this.sortArrayISODate(res.Documents);
+ for ( const a of this.sortArrayISODate(res.Documents)) {
+ a.DocTypeDesc = "Publicações"
+ this.searchDocuments.push(a);
+ }
this.reorderList(this.ordinance);
@@ -587,13 +596,71 @@ export class SearchPage implements OnInit {
this.showDocuments = false
}
- this.showLoader = false;
+ counter++;
+
+ if(counter ==2){
+ this.showLoader = false;
+ }
+
this.loadWordCloud();
},error => {
- this.showLoader = false;
+ counter++;
+
+ if(counter ==2){
+ 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;
+ e['Name'] = "Acções"
+ });
+
+ // bind respose
+ for ( const a of res.Categories) {
+ this.searchCategories.push(a);
+ }
+
+
+
+ for ( const a of this.sortArrayISODate(res.Documents)) {
+ a.DocTypeDesc = "Acções"
+ this.searchDocuments.push(a);
+ }
+
+ 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;
+ }
+ this.searchResult = "Registo não encontrado"
+ console.log(error)
+ });
+
}
}
@@ -757,6 +824,7 @@ export class SearchPage implements OnInit {
const ApplicationType = searchDocument.ApplicationType.toString()
const Id = searchDocument.Id
const CalendarId = searchDocument.ApplicationName.split(':')[1]
+ const DocTypeDesc = searchDocument.DocTypeDesc
if(this.select == false) {
if(this.type == "Agenda") {
@@ -776,7 +844,7 @@ export class SearchPage implements OnInit {
} else if(this.type == "AccoesPresidenciais") {
- this.viewPublicationDetail(Id);
+ this.viewPublicationDetail(Id, DocTypeDesc);
}
else if(this.type == "AccoesPresidenciais & ArquivoDespachoElect") {
@@ -790,19 +858,27 @@ export class SearchPage implements OnInit {
}
}
- async viewPublicationDetail(publicationId:string) {
- const modal = await this.modalController.create({
- component: PublicationDetailPage,
- componentProps:{
- publicationId: publicationId,
- isModal: true
- },
- cssClass: 'publication-detail modal modal-desktop ',
- //backdropDismiss: false
- });
+ 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(()=>{});
+ }
+
- await modal.present();
- modal.onDidDismiss().then(()=>{});
}
diff --git a/src/app/services/search.service.ts b/src/app/services/search.service.ts
index 8b6075663..71acc268a 100644
--- a/src/app/services/search.service.ts
+++ b/src/app/services/search.service.ts
@@ -66,6 +66,32 @@ export class SearchService {
return this.http.get
(`${geturl}`, options);
}
+
+ basicSearchPublication(subject:string, date:string = null, sender:string = null, organicEntity:string = null, docTypeId:string = null, applicationType:string): Observable{
+ // Endpoint
+ const geturl = environment.apiURL + 'search';
+ // store params
+ let params = new HttpParams();
+ // set https params
+
+
+ params = params.set("assunto", subject);
+ params = params.set("data", date);
+ params = params.set("remetente", sender);
+ params = params.set("entidadeOrganica", organicEntity);
+ params = params.set("docTypeId", docTypeId);
+ params = params.set("applicationType", applicationType);
+ params = params.set("listOnlyFolders", true)
+
+
+ const options = {
+ headers: this.headers,
+ params: params
+ };
+
+ return this.http.get(`${geturl}`, options);
+ }
+
mostSeachWord(size:string):Observable{
// Endpoint
diff --git a/src/app/shared/header/header.page.html b/src/app/shared/header/header.page.html
index 0187c4f53..429ee8f1f 100644
--- a/src/app/shared/header/header.page.html
+++ b/src/app/shared/header/header.page.html
@@ -127,18 +127,23 @@