add seach button

This commit is contained in:
Peter Maquiran
2023-04-20 11:45:46 +01:00
parent 15276dfc1a
commit 47dd1b2bc8
12 changed files with 274 additions and 165 deletions
@@ -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) {