From 47dd1b2bc84906c09e286e745cfc1fef3441133e Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Thu, 20 Apr 2023 11:45:46 +0100 Subject: [PATCH] add seach button --- package-lock.json | 11 ++ package.json | 1 + .../gabinete-digital.page.html | 103 ++++++++++----- .../gabinete-digital.page.scss | 25 +++- .../gabinete-digital/gabinete-digital.page.ts | 24 ++-- src/app/pipes/evento-approve.pipe.ts | 46 +++---- src/app/services/task.service.ts | 23 ++++ .../all-processes/all-processes.page.html | 42 ++++++- .../all-processes/all-processes.page.scss | 27 +++- .../all-processes/all-processes.page.ts | 117 +++++------------- .../store/eventoaprovacao-store.service.ts | 8 +- version/git-version.ts | 12 +- 12 files changed, 274 insertions(+), 165 deletions(-) diff --git a/package-lock.json b/package-lock.json index fcf37b152..7b35965e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -145,6 +145,7 @@ "jest-puppeteer": "^7.0.1", "jetifier": "^1.6.8", "lite-server": "^2.6.1", + "minisearch": "^6.0.1", "moment": "^2.29.3", "ng-lazyload-image": "^9.1.2", "ng2-pdf-viewer": "^3.0.8", @@ -22855,6 +22856,11 @@ "node": ">=8" } }, + "node_modules/minisearch": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/minisearch/-/minisearch-6.0.1.tgz", + "integrity": "sha512-Ly1w0nHKnlhAAh6/BF/+9NgzXfoJxaJ8nhopFhQ3NcvFJrFIL+iCg9gw9e9UMBD+XIsp/RyznJ/o5UIe5Kw+kg==" + }, "node_modules/minizlib": { "version": "2.1.2", "license": "MIT", @@ -55206,6 +55212,11 @@ "minipass": "^3.0.0" } }, + "minisearch": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/minisearch/-/minisearch-6.0.1.tgz", + "integrity": "sha512-Ly1w0nHKnlhAAh6/BF/+9NgzXfoJxaJ8nhopFhQ3NcvFJrFIL+iCg9gw9e9UMBD+XIsp/RyznJ/o5UIe5Kw+kg==" + }, "minizlib": { "version": "2.1.2", "requires": { diff --git a/package.json b/package.json index 9665675e1..54a4e0fed 100644 --- a/package.json +++ b/package.json @@ -155,6 +155,7 @@ "jest-puppeteer": "^7.0.1", "jetifier": "^1.6.8", "lite-server": "^2.6.1", + "minisearch": "^6.0.1", "moment": "^2.29.3", "ng-lazyload-image": "^9.1.2", "ng2-pdf-viewer": "^3.0.8", diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.html b/src/app/pages/gabinete-digital/gabinete-digital.page.html index 3c5ddc073..6be5c86aa 100644 --- a/src/app/pages/gabinete-digital/gabinete-digital.page.html +++ b/src/app/pages/gabinete-digital/gabinete-digital.page.html @@ -27,40 +27,79 @@ -
- - - - - Para hoje - - - - Novos - - - - Lidos - - - - Não lidos - - - - Em atraso - - - - Todos - - - - - -
+ +
+
+
+ + + +
+ + +
+
+ +
+ +
+ + +
+ + + +
+
+
+
+ +
+ + + + + Para hoje + + + + Novos + + + + Lidos + + + + Não lidos + + + + Em atraso + + + + Todos + + + + + +
+ +
diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.scss b/src/app/pages/gabinete-digital/gabinete-digital.page.scss index 4c2d41260..348180670 100644 --- a/src/app/pages/gabinete-digital/gabinete-digital.page.scss +++ b/src/app/pages/gabinete-digital/gabinete-digital.page.scss @@ -693,4 +693,27 @@ ion-content{ .new-task-count{ color: red; font-size: 13px; -} \ No newline at end of file +} + + +.search-input-container{ + background-color: white; + border-radius: 27.5px; + border: solid 1px #ebebeb; + font-size: 14px; + .icon{ + color: #797979; + width: 41px; + height: 41px; + display: flex; + justify-content: center; + font-size: 25px; + align-items: center; + } + .input-text{ + width: 100%; + } + .icon-z{ + width: 20px; + } +} diff --git a/src/app/pages/gabinete-digital/gabinete-digital.page.ts b/src/app/pages/gabinete-digital/gabinete-digital.page.ts index b1a22e222..e9cf7ea5d 100644 --- a/src/app/pages/gabinete-digital/gabinete-digital.page.ts +++ b/src/app/pages/gabinete-digital/gabinete-digital.page.ts @@ -7,17 +7,7 @@ import { LoginUserRespose } from 'src/app/models/user.model'; import { ExpedientsPage } from 'src/app/shared/gabinete-digital/expedients/expedients.page'; import { PendentesPage } from 'src/app/shared/gabinete-digital/pendentes/pendentes.page'; import { EventsToApprovePage } from 'src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page'; -import { DespachoStore } from 'src/app/store/despacho-store.service'; -import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.service'; -import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service'; -import { PendentesStore } from 'src/app/store/pendestes-store.service'; -import { PedidosStore } from 'src/app/store/pedidos-store.service'; -import { DespachosprStore } from 'src/app/store/despachospr-store.service'; - -import { removeDuplicate } from 'src/plugin/removeDuplicate.js' import { WaitForDomService } from 'src/app/services/dom/wait-for-dom.service'; -import { TotalDocumentStore } from 'src/app/store/total-document.service'; -import { DeplomasStore } from 'src/app/store/deplomas.service'; import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe'; import { DespachoService } from 'src/app/Rules/despacho.service'; @@ -106,6 +96,11 @@ export class GabineteDigitalPage implements OnInit { filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos' + hideSearchBtn: boolean = false; + showSearch = false; + searchSubject: string = ''; + + constructor( private processesbackend: ProcessesService, private modalController: ModalController, @@ -153,6 +148,11 @@ export class GabineteDigitalPage implements OnInit { } + openSearch() {} + async closeSearch() {} + async basicSearch() {} + async dynamicSearch() {} + ngOnInit() { if (window.innerWidth < 701) { @@ -173,11 +173,11 @@ export class GabineteDigitalPage implements OnInit { callback: () => { if(this.NotificationsService.active === false) { this.checkRoutes(); - this.LoadCounts(); + // this.LoadCounts(); this.checkFilter() } else { this.checkRoutes(); - this.LoadCounts(); + // this.LoadCounts(); this.checkFilter() } } diff --git a/src/app/pipes/evento-approve.pipe.ts b/src/app/pipes/evento-approve.pipe.ts index e0910ce96..1c6e31593 100644 --- a/src/app/pipes/evento-approve.pipe.ts +++ b/src/app/pipes/evento-approve.pipe.ts @@ -5,33 +5,35 @@ import { Pipe, PipeTransform } from '@angular/core'; }) export class EventoApprovePipe implements PipeTransform { - transform(fullTask): unknown { + transform(fullTask, obj): any { let date = new Date(fullTask.taskStartDate); let month = date.getMonth() + 1; let taskDate = date.getFullYear() + "-" + month +"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+ ":"+date.getSeconds(); - return { - "SerialNumber": fullTask.serialNumber, - "Folio": fullTask.workflowInstanceDataFields.Subject, - "Event": { - StartDate: '', - EndDate: '', - Agenda: '', - Location: '' + return Object.assign({ + "SerialNumber": fullTask.serialNumber, + "Folio": fullTask.workflowInstanceDataFields.Subject, + "Event": { + StartDate: '', + EndDate: '', + Agenda: '', + Location: '' + }, + "CreateDate": taskDate, + "TaskStartDate": fullTask.taskStartDate, + "DocumentURL": fullTask.workflowInstanceDataFields.ViewerRequest, + "Remetente": fullTask.workflowInstanceDataFields.Remetente, + "DocumentsQty": fullTask.totalDocuments, + "DocId": fullTask.workflowInstanceDataFields.DispatchDocId, + "FolderID": fullTask.workflowInstanceDataFields.FolderID, + "WorkflowName": fullTask.workflowDisplayName, + "activityInstanceName": fullTask.activityInstanceName, + "Status": fullTask.workflowInstanceDataFields.Status, + "Deadline": fullTask.deadline, + "TaskStatus": fullTask.taskStatus, }, - "CreateDate": taskDate, - "TaskStartDate": fullTask.taskStartDate, - "DocumentURL": fullTask.workflowInstanceDataFields.ViewerRequest, - "Remetente": fullTask.workflowInstanceDataFields.Remetente, - "DocumentsQty": fullTask.totalDocuments, - "DocId": fullTask.workflowInstanceDataFields.DispatchDocId, - "FolderID": fullTask.workflowInstanceDataFields.FolderID, - "WorkflowName": fullTask.workflowDisplayName, - "activityInstanceName": fullTask.activityInstanceName, - "Status": fullTask.workflowInstanceDataFields.Status, - "Deadline": fullTask.deadline, - "TaskStatus": fullTask.taskStatus - } + obj + ) } } diff --git a/src/app/services/task.service.ts b/src/app/services/task.service.ts index aa23ada53..1512e946a 100644 --- a/src/app/services/task.service.ts +++ b/src/app/services/task.service.ts @@ -47,6 +47,14 @@ export class TaskService { expedienteTaskPipe = new ExpedienteTaskPipe(); customTaskPipe = new CustomTaskPipe() + callbacks: { + [key: string]: { + funx: Function + id: string + } + } = {} + + constructor( private processesbackend: ProcessesService, private despachoRule: DespachoService, @@ -61,6 +69,17 @@ export class TaskService { } + registerCallback({funx, id}) { + this.callbacks[id] = { funx, id} + } + + runCallback() { + for (const [key, value] of Object.entries(this.callbacks)) { + value.funx() + } + } + + deadlineIsToday(isoDateString:string) { if(!isoDateString) { @@ -111,6 +130,8 @@ export class TaskService { this.AllProcess = this.sortArrayISODate(this.despachoprstore.list.concat(this.deplomasStore.diplomasAssinadoList as any).concat(this.deplomasStore.diplomasParaAssinarList as any).concat(this.deplomasStore.DiplomaGerarList as any) .concat(this.eventoaprovacaostore.contactList as any).concat(this.expedientegbstore.list as any).concat(this.despachoStore.list as any).concat(this.pedidosstore.listparecer as any).concat(this.pedidosstore.listdeferimento as any) .concat(this.pendentesstore.list as any)).reverse() + + this.runCallback(); } sortArrayISODate(myArray: any): any[] { @@ -208,6 +229,8 @@ export class TaskService { } + this.runCallback(); + let diplomasValidar = depachoAPI.filter(data => data.activityInstanceName == "Revisar Diploma"); diplomasValidar = diplomasValidar.filter(data => data.activityInstanceName != "Tarefa de Despacho"); diff --git a/src/app/shared/gabinete-digital/all-processes/all-processes.page.html b/src/app/shared/gabinete-digital/all-processes/all-processes.page.html index 989f7c81b..f3befe870 100644 --- a/src/app/shared/gabinete-digital/all-processes/all-processes.page.html +++ b/src/app/shared/gabinete-digital/all-processes/all-processes.page.html @@ -3,7 +3,43 @@
Todas as tarefas
-
+
+
+
+
+ + + +
+ + +
+
+ +
+ +
+ + +
+ + + +
+
+
+
+
@@ -42,7 +78,7 @@
- +
diff --git a/src/app/shared/gabinete-digital/all-processes/all-processes.page.scss b/src/app/shared/gabinete-digital/all-processes/all-processes.page.scss index 362d4a2aa..0bf3e7659 100644 --- a/src/app/shared/gabinete-digital/all-processes/all-processes.page.scss +++ b/src/app/shared/gabinete-digital/all-processes/all-processes.page.scss @@ -167,4 +167,29 @@ ion-list{ .new-task { height: 23px; -} \ No newline at end of file +} + + + + +.search-input-container{ + background-color: white; + border-radius: 27.5px; + border: solid 1px #ebebeb; + font-size: 14px; + .icon{ + color: #797979; + width: 41px; + height: 41px; + display: flex; + justify-content: center; + font-size: 25px; + align-items: center; + } + .input-text{ + width: 100%; + } + .icon-z{ + width: 20px; + } +} diff --git a/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts b/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts index 0012d26fc..701a4af2b 100644 --- a/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts +++ b/src/app/shared/gabinete-digital/all-processes/all-processes.page.ts @@ -1,17 +1,10 @@ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute, NavigationEnd, NavigationStart, Router } from '@angular/router'; +import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; import { LoginUserRespose } from 'src/app/models/user.model'; import { ThemeService } from 'src/app/services/theme.service' -import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service'; -import { DeplomasStore } from 'src/app/store/deplomas.service'; -import { PendentesStore } from 'src/app/store/pendestes-store.service'; -import { DespachoStore } from 'src/app/store/despacho-store.service'; -import { TotalDocumentStore } from 'src/app/store/total-document.service'; -import { DespachosprStore } from 'src/app/store/despachospr-store.service'; -import { EventoAprovacaoStore } from 'src/app/store/eventoaprovacao-store.service'; -import { PedidosStore } from 'src/app/store/pedidos-store.service'; import { SessionStore } from 'src/app/store/session.service'; import { TaskService } from 'src/app/services/task.service' +import MiniSearch from 'minisearch' @Component({ selector: 'app-all-processes', @@ -21,29 +14,24 @@ import { TaskService } from 'src/app/services/task.service' export class AllProcessesPage implements OnInit { skeletonLoader = false; - allProcessesList: any[] = []; loggeduser: LoginUserRespose; - - - expedientegbstore = ExpedienteGdStore; - pendentesstore = PendentesStore; - despachoStore = DespachoStore; - eventoaprovacaostore = EventoAprovacaoStore; - pedidosstore = PedidosStore; - despachoprstore = DespachosprStore; - totalDocumentStore = TotalDocumentStore - deplomasStore = DeplomasStore + hideSearchBtn: boolean = false; + showSearch = false; + searchSubject: string = ''; filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos' + + miniSearch = new MiniSearch({ + fields: ['Folio', 'Senders'], // fields to index for full-text search + idField: 'DocId' + }) constructor( private router: Router, public ThemeService: ThemeService, public TaskService: TaskService, private route: ActivatedRoute - ) { - this.loggeduser = SessionStore.user; - } + ) {} ngOnInit() { // this.updateAllProcess() @@ -51,14 +39,32 @@ export class AllProcessesPage implements OnInit { this.router.events.forEach((event) => { if (event instanceof NavigationEnd && event.url.includes('/home/gabinete-digital')) { - this.refreshing(); + // this.refreshing(); this.checkFilter(); } }); + setTimeout(() => { + console.log('this.TaskService.AllProcess', this.TaskService.AllProcess) + this.miniSearch.addAll(this.TaskService.AllProcess) + window['miniSearch'] = this.miniSearch + }, 5000) + + + this.TaskService.registerCallback({ + id: import.meta.url, + funx:() => { + + } + }) } + openSearch() {} + async closeSearch() {} + async basicSearch() {} + async dynamicSearch() {} + checkFilter() { if(this.router.url.includes('ForToDay')) { @@ -72,69 +78,6 @@ export class AllProcessesPage implements OnInit { } } - doRefresh(event) { - if (event) { - setTimeout(() => { - try { - event?.target?.complete(); - } catch(error) {} - }, 2000); - } - setTimeout(() => { - // this.updateAllProcess(); - }, 1000); - } - - refreshing() { - - setTimeout(() => { - // this.updateAllProcess(); - }, 1000); - } - - - - setFormatDate(start: any, end: any, allday: boolean) { - let customDate; - - const totalSeconds = Math.floor((end - (start)) / 1000);; - const totalMinutes = Math.floor(totalSeconds / 60); - const totalHours = Math.floor(totalMinutes / 60); - const totalDays = Math.floor(totalHours / 24); - - const hours = totalHours - (totalDays * 24); - const minutes = totalMinutes - (totalDays * 24 * 60) - (hours * 60); - const seconds = totalSeconds - (totalDays * 24 * 60 * 60) - (hours * 60 * 60) - (minutes * 60); - - - if (totalDays == 0) { - if (allday) { - customDate = this.getCustomDate(start) + ", " + this.getCustomHours(start) + " (todo dia)"; - - return customDate; - } - else { - //customDate = this.getCustomDate(start)+","+this.getCustomHours(start)+" ("+minutes+" mins)"; - customDate = this.getCustomDate(start) + ", " + this.getCustomHours(start) + " | " + this.getCustomHours(end); - return customDate; - } - } - else { - customDate = this.getCustomDate(start) + "," + this.getCustomHours(start) + - " (termina:" + this.getCustomDate(end) + "," + this.getCustomHours(end) + ")"; - return customDate; - } - } - - getCustomDate(thedate: Date) { - return (thedate.getDay() + 1) + "/" + - (thedate.getMonth() + 1) + "/" + - thedate.getFullYear(); - } - getCustomHours(thedate: Date) { - return thedate.getHours() + ":" + - thedate.getMinutes(); - } goToProcess(serialNumber: string, workflowName: string, activityName: string) { diff --git a/src/app/store/eventoaprovacao-store.service.ts b/src/app/store/eventoaprovacao-store.service.ts index 4d734819a..a422e8b70 100644 --- a/src/app/store/eventoaprovacao-store.service.ts +++ b/src/app/store/eventoaprovacao-store.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { localstoreService } from './localstore.service' import { AES, enc, SHA1 } from 'crypto-js' import { isArray } from 'ionic-angular/umd/util/util'; +import { EventoApprovePipe } from 'src/app/pipes/evento-approve.pipe' @Injectable({ providedIn: 'root' @@ -19,6 +20,8 @@ export class EventoaprovacaoStoreService { private _countsAll = 0 + EventoApprovePipe = new EventoApprovePipe() + callbacks: { [key: string]: { funx: Function @@ -64,7 +67,7 @@ export class EventoaprovacaoStoreService { } - save(segment: string, value: []) { + save(segment: string, value: any[]) { if(typeof segment == 'object') { throw("segment most be userId") @@ -75,6 +78,9 @@ export class EventoaprovacaoStoreService { this._counts[segment] = 0 } + + value = value.map( e => this.EventoApprovePipe.transform(e, e)) + this._list[segment] = value this._counts[segment] = value.length diff --git a/version/git-version.ts b/version/git-version.ts index 721e07384..594e60bc4 100644 --- a/version/git-version.ts +++ b/version/git-version.ts @@ -1,12 +1,12 @@ export let versionData = { - "shortSHA": "9c304e23d", - "SHA": "9c304e23d7f19029c7bb11093b1aea253abf4af3", + "shortSHA": "15276dfc1", + "SHA": "15276dfc1a04fd46c5acb95f0c4df5c80cd97e35", "branch": "feature/gabineteLabels", "lastCommitAuthor": "'Peter Maquiran'", - "lastCommitTime": "'Wed Apr 19 09:35:47 2023 +0100'", - "lastCommitMessage": "another one", - "lastCommitNumber": "4922", + "lastCommitTime": "'Wed Apr 19 12:34:28 2023 +0100'", + "lastCommitMessage": "add search", + "lastCommitNumber": "4923", "change": "", - "changeStatus": "On branch feature/gabineteLabels\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despachos-pr.module.ts\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.html\n\tmodified: src/app/pages/gabinete-digital/despachos-pr/despachos-pr.page.ts\n\tmodified: src/app/pages/gabinete-digital/despachos/despachos.module.ts\n\tmodified: src/app/pages/gabinete-digital/despachos/despachos.page.html\n\tmodified: src/app/pages/gabinete-digital/despachos/despachos.page.ts\n\tmodified: src/app/shared/gabinete-digital/despachos/despachos.page.html\n\tmodified: src/app/shared/gabinete-digital/despachos/despachos.page.ts\n\tmodified: src/app/store/deplomas.service.ts\n\tmodified: src/app/store/despacho-store.service.ts\n\tmodified: src/app/store/despachospr-store.service.ts\n\tmodified: src/app/store/eventoaprovacao-store.service.ts\n\tmodified: src/app/store/expedientegd-store.service.ts\n\tmodified: src/app/store/pedidos-store.service.ts\n\tmodified: src/app/store/pendestes-store.service.ts", + "changeStatus": "On branch feature/gabineteLabels\nChanges to be committed:\n (use \"git restore --staged ...\" to unstage)\n\tmodified: package-lock.json\n\tmodified: package.json\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.html\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.scss\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.ts\n\tmodified: src/app/pipes/evento-approve.pipe.ts\n\tmodified: src/app/services/task.service.ts\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.html\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.scss\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.ts\n\tmodified: src/app/store/eventoaprovacao-store.service.ts", "changeAuthor": "peter.maquiran" } \ No newline at end of file