ITOTEAM-609 search event>

This commit is contained in:
Peter Maquiran
2024-06-26 13:45:25 +01:00
parent 02891dbb9a
commit 78c13d1bfb
13 changed files with 174 additions and 78 deletions
+3 -2
View File
@@ -4,7 +4,7 @@ import { z } from 'zod';
const eventListSchema = z.array(z.object({
HasAttachments: z.boolean(),
IsAllDayEvent: z.boolean(),
EventId: z.string(),
EventId: z.any(),
Subject: z.string(),
Location: z.string().nullable(),
CalendarId: z.string(),
@@ -16,7 +16,8 @@ const eventListSchema = z.array(z.object({
OptionalAttendees: z.string().nullable(),
HumanDate: z.string(),
TimeZone: z.string(),
IsPrivate: z.boolean()
IsPrivate: z.boolean(),
createdAt: z.string()
}));
export type EventList = z.infer<typeof eventListSchema>
+1 -3
View File
@@ -2,9 +2,7 @@ export class SearchList {
ApplicationType: number | string;
Assunto: string;
Data: string;
DocTypeDesc: string;
EntidadeOrganicaId: number;
EntidadeOrganicaNome: string;
DocTypeDesc?: 'Acções' | 'Publicações';
Id: string;
appName?: string;
ApplicationName: string;
+10 -6
View File
@@ -303,18 +303,22 @@
<span class="app-name"
*ngIf="itemIcons() == 'AccoesPresidenciais & ArquivoDespachoElect' || itemIcons() == 'Correspondencia' ">
<span class="app-name" *ngIf="searchDocument.applicationId == '8' || searchDocument.applicationId == 8"> Correspondencia </span>
<span class="app-name" *ngIf="searchDocument.applicationId == '386' || searchDocument.applicationId == 386"> AccoesPresidenciais </span>
<span class="app-name" *ngIf="searchDocument.applicationId == '361' || searchDocument.applicationId == 361 "> ArquivoDespachoElect </span>
<span class="app-name" *ngIf="searchDocument.applicationId == '8' || searchDocument.applicationId == 8 || searchDocument.ApplicationType == 8"> Correspondencia </span>
<span class="app-name" *ngIf="searchDocument.applicationId == '386' || searchDocument.applicationId == 386 || searchDocument.ApplicationType == 386"> AccoesPresidenciais </span>
<span class="app-name" *ngIf="searchDocument.applicationId == '361' || searchDocument.applicationId == 361 || searchDocument.ApplicationType == 361 "> ArquivoDespachoElect </span>
</span>
</div>
<div class="d-flex ion-justify-content-between ">
<span class="organic-entity">{{ searchDocument.entity }}</span>
<span class="organic-entity">{{ searchDocument.entity || searchDocument.EntidadeOrganicaNome }}</span>
<span class="documente-date">{{ formateIsoDate(searchDocument.dateEntry || searchDocument.Data) }}</span>
</div>
<div *ngIf="select" (click)="view(searchDocument)"> Ver</div>
<div *ngIf="select" (click)="view(searchDocument)" style="color: gray;">
<button mat-icon-button aria-label="Example icon-button with a menu">
<ion-icon src="assets/icon/iconmonstr-eye-9.svg" class=" font-25-em "></ion-icon>
</button>
</div>
</div>
</li>
@@ -323,7 +327,7 @@
<!-- <a href="#" class="previous">&laquo; Previous</a>
<a href="#" class="next">Next &raquo;</a> -->
<div class="nextAndPreviewDiv" >
<div class="nextAndPreviewDiv" *ngIf="type != 'Agenda' && select == true ">
<a href="#" class="previous round" (click)="previeweButton($event)">&#8249;</a>
<div>{{pageNumber + "/" + totalPage}}</div>
<a href="#" class="next round" (click)="nextButton($event)" >&#8250;</a>
+66 -49
View File
@@ -20,6 +20,9 @@ import { momentG } from 'src/plugin/momentG';
import { Cy } from 'cypress/enum'
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { SessionStore } from 'src/app/store/session.service';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { isHttpError } from 'src/app/services/http.service';
import { ToastService } from 'src/app/services/toast.service';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -114,7 +117,9 @@ export class SearchPage implements OnInit {
public ThemeService: ThemeService,
private router: Router,
private httpErrorhandle: HttpErrorHandle,
private agendaDataRepository: AgendaDataRepositoryService) {
private agendaDataRepository: AgendaDataRepositoryService,
private toastService: ToastService,
) {
this.ordinance = "recent";
this.currentPath = window.location.pathname;
@@ -168,7 +173,7 @@ export class SearchPage implements OnInit {
console.log('doc item',item)
const ApplicationType = item.applicationId.toString()
const Id = item.docId
const Id = item.docId
if (ApplicationType == '8') {
@@ -363,7 +368,8 @@ export class SearchPage implements OnInit {
/**
* @description Basic search
*/
basicSearch() {
@XTracerAsync({name:'search/basicSearch', bugPrint: true})
async basicSearch(tracing?: TracingType) {
let searchDocumentDate
let searchDocumentDateEnd;
@@ -386,70 +392,81 @@ export class SearchPage implements OnInit {
if (this.searchSubject.trim() == "" && searchDocumentDate == null && searchDocumentDateEnd == null && this.searchSenderId == null && this.searchOrganicEntiryCode == null && this.searchDocTypeId == null) {
this.searchResult = "Campo de pesquisa esta vazio, entre com assunto que deseja pesquisa";
this.searchResult = "Campo de pesquisa está vazio, entre com assunto que deseja pesquisa";
console.log('enter text');
} else {
/* this.showLoader = true;
this.agendaDataRepository.getDocumentAttachments(361, SessionStore.user.UserId, this.searchSubject, this.pageNumber, this.pageSize).subscribe((values) => {
this.totalPage = values.data.total / this.pageSize;
this.totalPage = Math.round(this.totalPage)
console.log(values.data.result)
this.searchDocuments = this.sortArrayISODate(values.data.result);
const searchEvents = await this.agendaDataRepository.searchEvent({value: this.searchSubject.trim() }, tracing)
if(searchEvents.isOk()) {
this.showDocuments = true;
this.searchDocuments = searchEvents.value
this.searchDocuments = this.sortArrayISODate(this.searchDocuments);
this.reorderList(this.ordinance);
// hide show document
if (this.searchDocuments.length >= 1) {
this.showDocuments = true;
} else {
this.searchResult = "Registo não encontrado"
this.showDocuments = false
}
this.showLoader = false;
this.loadWordCloud();
}, error => {
this.showLoader = false;
// this.searchResult = "Registo não encontrado"
this.httpErrorhandle.httpStatusHandle(error)
// console.log(error)
})
return */
this.showLoader = true;
this.search.basicSearch(this.searchSubject, searchDocumentDate, searchDocumentDateEnd, this.searchSenderId
, this.searchOrganicEntiryCode, this.searchDocTypeId, '0').subscribe(res => {
console.log(res)
tracing.setAttribute('outcome', 'success');
} else {
if (!res.Categories.length) {
this.searchResult = "Não encontramos o que procura";
}
this.loadWordCloud();
this.showDocuments = true;
res.Categories.forEach(e => {
e['Active'] = false;
});
if(!isHttpError(searchEvents.error)) {
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico.')
// bind respose
this.searchCategories = res.Categories;
} else if (isHttpError(searchEvents.error)) {
this.httpErrorhandle.httpStatusHandle(searchEvents.error)
}
this.searchDocuments = this.sortArrayISODate(res.Documents);
tracing.setAttribute('outcome', 'failed');
console.log('create event error: ', searchEvents.error)
}
this.reorderList(this.ordinance);
// this.showLoader = true;
// this.search.basicSearch(this.searchSubject, searchDocumentDate, searchDocumentDateEnd, this.searchSenderId
// , this.searchOrganicEntiryCode, this.searchDocTypeId, '0').subscribe(res => {
// console.log(res)
// hide show document
if (this.searchDocuments.length >= 1) {
this.showDocuments = true;
} else {
this.showDocuments = false
}
// if (!res.Categories.length) {
// this.searchResult = "Não encontramos o que procura";
// }
this.showLoader = false;
this.loadWordCloud();
// res.Categories.forEach(e => {
// e['Active'] = false;
// });
}, error => {
this.showLoader = false;
// this.searchResult = "Registo não encontrado"
this.httpErrorhandle.httpStatusHandle(error)
// console.log(error)
});
// // 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();
// }, error => {
// this.showLoader = false;
// // this.searchResult = "Registo não encontrado"
// this.httpErrorhandle.httpStatusHandle(error)
// // console.log(error)
// });
}
}
else if (this.type == "AccoesPresidenciais & ArquivoDespachoElect" && this.eventAgenda == true) {
@@ -1073,9 +1090,9 @@ export class SearchPage implements OnInit {
async viewDetail(searchDocument: SearchList) {
const ApplicationType = searchDocument.ApplicationType.toString()
const ApplicationType = searchDocument?.ApplicationType?.toString()
const Id = searchDocument.Id
const CalendarId = searchDocument.ApplicationName.split(':')[1]
const CalendarId = searchDocument?.ApplicationName?.split(':')[1]
const DocTypeDesc = searchDocument.DocTypeDesc
if (this.select == false) {
@@ -15,7 +15,6 @@ import { EEventFilterStatus } from './model/enums';
import { isHttpError } from '../../http.service';
import { TracingType } from '../../monitoring/opentelemetry/tracer';
import { APINODReturn } from '../../decorator/api-validate-schema.decorator';
import { EventListDataOutputDTOSchema } from './model/eventListDTOOutput';
import { EventToApproveDataOutputDTOSchema } from './model/eventToApproveListOutputDTO';
import { EventOutputDTOSchema } from './model/eventDTOOutput';
import { SharedCalendarListDetectChanges } from './async/change/shareCalendarChangeDetector';
@@ -23,6 +22,8 @@ import { SharedCalendarListItemOutputDTO } from './model/sharedCalendarOutputDTO
import { EventInputDTOSchema } from './agendaDataModels';
import { EventUpdateInputDTOSchema } from './model/eventUpdateInputDtO';
import { AttachInputDTOSchema } from './model/addAttachmentDTOInput';
import { EventListDataOutputDTOSchema } from './model/eventListDTOOutput';
import { EventSearchMapper } from './mapper/EventSearchMapper';
@Injectable({
providedIn: 'root'
@@ -107,6 +108,14 @@ export class AgendaDataRepositoryService {
}
async searchEvent(queryParameters: {value}, tracing?: TracingType) {
const result = await this.agendaDataService.searchEvent(queryParameters)
return result.map( response => {
APINODReturn(EventListDataOutputDTOSchema, response, 'get/Events', tracing)
return EventSearchMapper.toDomain(response, "calendarOwnerName", "userId")
})
}
async EventList({ userId, startDate, endDate, status = EEventFilterStatus.Approved, category = null, type = null, calendarOwnerName = '' }, tracing?: TracingType) {
try {
@@ -7,9 +7,9 @@ import { SharedCalendarListOutputDTO, SharedCalendarListOutputDTOSchema } from '
import { HttpService } from '../../http.service';
import { APIReturn } from '../../decorator/api-validate-schema.decorator';
import { TracingType } from '../../monitoring/opentelemetry/tracer';
import { EventListOutputDTO, EventListOutputDTOSchema } from './model/eventListDTOOutput';
import { EventOutputDTO } from './model/eventDTOOutput';
import { AttendeesRemoveInputDTO } from './model/attendeeRemoveInputDTO';
import { EventListOutputDTO } from './model/eventListDTOOutput';
@Injectable({
providedIn: 'root'
@@ -74,6 +74,10 @@ export class AgendaDataService {
return this.http.get<any>(`${this.baseUrl}/Events`, { params });
}
searchEvent(queryParameter: {value}) {
return this.httpService.get<EventListOutputDTO>(`${this.baseUrl}/Events`, queryParameter);
}
getEvent(id: string): Observable<EventOutputDTO> {
return this.http.get<any>(`${this.baseUrl}/Events/${id}`);
}
@@ -1,7 +1,7 @@
import { EventList } from "src/app/models/entiry/agenda/eventList"
import { EventListOutputDTO } from "../model/eventListDTOOutput"
import { EEventCategory, EEventOwnerType, EEventStatus, EEventType } from "../model/enums";
import { XTracer } from "src/app/services/monitoring/opentelemetry/tracer";
import { EventListOutputDTO } from "../model/eventListDTOOutput";
function getTextInsideParentheses(inputString): string {
var startIndex = inputString.indexOf('(');
@@ -60,16 +60,17 @@ export class ListEventMapper {
"EventId": e.id,
"Subject": e.subject,
"Location": e.location,
"CalendarId": userId,
"CalendarId": (e.owner.wxUserId) as any,
"CalendarName": category,
"StartDate": new Date(e.startDate) + '',
"EndDate": new Date(e.endDate)+ '',
"Schedule": calendarOwnerName,
"Schedule": (e.owner.wxFullName) as any,
"RequiredAttendees": null as any,
"OptionalAttendees": null as any,
"HumanDate": "2 semanas atrás" as any,
"TimeZone": getTextInsideParentheses(new Date(e.startDate)+ ''),
"IsPrivate": false as any
"IsPrivate": false as any,
"createdAt": e.createdAt
}
})
}
@@ -0,0 +1,37 @@
import { SearchList } from "src/app/models/search-document";
import { EventListOutputDTO } from "../model/eventListDTOOutput";
function getTextInsideParentheses(inputString): string {
var startIndex = inputString.indexOf('(');
var endIndex = inputString.indexOf(')');
if (startIndex !== -1 && endIndex !== -1) {
return inputString.substring(startIndex + 1, endIndex);
} else {
return null;
}
}
export class EventSearchMapper {
// @XTracer({name:'ListEventMapper/toDomain', log: false, bugPrint: false})
static toDomain(dto: EventListOutputDTO, calendarOwnerName: string, userId: string): SearchList[] {
return dto.data.map((e) => {
return {
Id: e.id as any,
subject: e.subject,
dateEntry: e.createdAt as any,
Data: e.createdAt as any,
entity: (e.owner.wxFullName),
ApplicationType: 0 as any,
Assunto: e.subject,
appName: "string",
ApplicationName: "",
docId: e.id as any,
applicationId: 0 as any
}
})
}
static toDTO() {}
}
@@ -1,5 +1,3 @@
import { EventList } from "src/app/models/entiry/agenda/eventList"
import { EventListOutputDTO } from "../model/eventListDTOOutput"
import { EventToApproveListOutputDTO } from "../model/eventToApproveListOutputDTO";
import { EventToApproveList } from "src/app/models/entiry/agenda/eventToApproveList";
import { EEventCategory, EEventOwnerType, EEventStatus } from "../model/enums";
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { EEventCategory, EEventOwnerType, EEventStatus, EEventType } from './enums';
import { EEventCategory, EEventOwnerType, EEventStatus, EEventType } from '../model/enums';
const OwnerSchema = z.object({
@@ -29,6 +29,7 @@ export const EventListOutputDTOSchema = z.object({
isAllDayEvent: z.boolean(),
// status: z.enum(['Approved']), // Assuming "Approved" is the only valid option based on provided data
status: z.nativeEnum(EEventStatus), // Assuming "Approved" is the only valid option based on provided data
createdAt: z.string().datetime({ offset: true }),
})
export const EventListDataOutputDTOSchema = z.object({
@@ -0,0 +1,12 @@
import { z } from 'zod';
import { EEventOwnerType } from './enums';
export const EventSearchOutputDTOSchema = z.object({
Id: z.string(),
subject: z.string(),
dateEntry: z.string(),
Data: z.string(),
entity: z.string().optional()
}).nullable();
export type EventSearchOutput = z.infer<typeof EventSearchOutputDTOSchema>;
+17 -3
View File
@@ -1,7 +1,7 @@
import { HttpClient, HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ok, err, Result } from 'neverthrow';
import { HttpParams } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
@@ -19,9 +19,23 @@ export class HttpService {
}
}
async get<T>(url: string): Promise<Result<T, HttpErrorResponse>> {
async get<T>(url: string, httpParamsObj = {} ): Promise<Result<T, HttpErrorResponse>> {
try {
const result = await this.http.get<T>(url).toPromise()
let httpParams = new HttpParams();
// Convert params object to HttpParams
if (httpParamsObj) {
Object.keys(httpParamsObj).forEach(key => {
httpParams = httpParams.set(key, httpParamsObj[key]);
})
}
let opts = {
params : httpParams
}
const result = await this.http.get<T>(url, opts).toPromise()
return ok (result as T)
} catch (e) {
return err(e as HttpErrorResponse)
+6 -6
View File
@@ -1,11 +1,11 @@
export let versionData = {
"shortSHA": "fbaf0afcf",
"SHA": "fbaf0afcf137adaf815d2013e6c1d6f87561cf95",
"shortSHA": "02891dbb9",
"SHA": "02891dbb9a9d1123f7cd0ca2414fd6014599aec1",
"branch": "feature/agenda-api-peter",
"lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Tue Jun 25 12:11:44 2024 +0100'",
"lastCommitMessage": "ITOTEAM-523 A app não redireciona as notificações",
"lastCommitNumber": "5842",
"changeStatus": "On branch feature/agenda-api-peter\nYour branch is ahead of 'origin/feature/agenda-api-peter' by 5 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: gabinete-digital-fo.code-workspace\n\tmodified: package-lock.json\n\tmodified: package.json\n\tmodified: src/app/home/home.page.ts\n\tmodified: src/app/pages/agenda/agenda.page.html\n\tmodified: src/app/pages/search/search.page.html\n\tmodified: src/app/pages/search/search.page.scss\n\tmodified: src/app/services/agenda/list-box.service.ts\n\tnew file: src/app/services/logger/log4js/logging.service.ts\n\tmodified: src/app/services/monitoring/capture-log/capture-log.service.ts\n\tmodified: src/app/services/monitoring/capture-log/worker.worker.ts\n\tmodified: src/app/services/monitoring/opentelemetry/matrix.ts\n\tmodified: src/app/services/monitoring/opentelemetry/tracer.ts\n\tmodified: src/app/shared/agenda/edit-event/edit-event.page.ts\n\tmodified: src/app/shared/agenda/view-event/view-event.page.html\n\tmodified: src/app/shared/agenda/view-event/view-event.page.ts\n\tmodified: src/app/store/calendar.service.ts",
"lastCommitTime": "'Wed Jun 26 10:11:02 2024 +0100'",
"lastCommitMessage": "ITOTEAM-530 Inform the user how many days are left until the end of the wind for each selected day",
"lastCommitNumber": "5843",
"changeStatus": "On branch feature/agenda-api-peter\nYour branch is ahead of 'origin/feature/agenda-api-peter' by 6 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/models/entiry/agenda/eventList.ts\n\tmodified: src/app/models/search-document.ts\n\tmodified: src/app/pages/search/search.page.html\n\tmodified: src/app/pages/search/search.page.ts\n\tmodified: src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts\n\tmodified: src/app/services/Repositorys/Agenda/agenda-data.service.ts\n\tmodified: src/app/services/Repositorys/Agenda/mapper/EventListMapper.ts\n\tnew file: src/app/services/Repositorys/Agenda/mapper/EventSearchMapper.ts\n\tmodified: src/app/services/Repositorys/Agenda/mapper/eventToApproveListMapper.ts\n\tmodified: src/app/services/Repositorys/Agenda/model/eventListDTOOutput.ts\n\tnew file: src/app/services/Repositorys/Agenda/model/eventSearchOutputDTO.ts\n\tmodified: src/app/services/http.service.ts\n\tmodified: version/git-version.ts",
"changeAuthor": "peter.maquiran"
}