mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
add either pattern
This commit is contained in:
@@ -19,7 +19,6 @@ import { EventToApproveDataOutputDTOSchema } from './model/eventToApproveListOut
|
||||
import { EventOutputDTOSchema } from './model/eventDTOOutput';
|
||||
import { SharedCalendarListDetectChanges } from './async/change/shareCalendarChangeDetector';
|
||||
import { SharedCalendarListItemOutputDTO } from './model/sharedCalendarOutputDTO';
|
||||
import { EventInputDTOSchema } from './agendaDataModels';
|
||||
import { EventUpdateInputDTOSchema } from './model/eventUpdateInputDtO';
|
||||
import { AttachInputDTOSchema } from './model/addAttachmentDTOInput';
|
||||
import { EventListDataOutputDTOSchema } from './model/eventListDTOOutput';
|
||||
@@ -29,6 +28,8 @@ import { CalendarState, pushEvent, removeRangeForCalendar, selectEventsInRange }
|
||||
import { NativeNotificationService } from 'src/app/services/native-notification.service';
|
||||
import { ListBoxService } from 'src/app/services/agenda/list-box.service';
|
||||
import { EventListStore } from 'src/app/models/agenda/AgendaEventList';
|
||||
import { AttendeeInputDTOSchema } from './model/attendeeInputDTO';
|
||||
import { EventInputDTOSchema } from './model/eventInputDTO';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -59,61 +60,31 @@ export class AgendaDataRepositoryService {
|
||||
}
|
||||
|
||||
async getEventById(id: string, tracing?: TracingType) {
|
||||
try {
|
||||
const result = await this.agendaDataService.getEvent(id).pipe(
|
||||
map((response) => {
|
||||
APINODReturn(EventOutputDTOSchema, response, `get/Events/${id}`, tracing)
|
||||
return EventMapper.toDomain(response)
|
||||
})
|
||||
).toPromise()
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
tracing.setAttribute('eventId', id)
|
||||
if(isHttpError(e)) {
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
if (e.status == 400) {
|
||||
tracing?.bugFlag()
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
}
|
||||
} else {
|
||||
tracing?.bugFlag()
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
|
||||
const result = await this.agendaDataService.getEvent(id, tracing)
|
||||
|
||||
if(result.isOk()) {
|
||||
APINODReturn(EventOutputDTOSchema, result.value, `get/Events/${id}`, tracing)
|
||||
|
||||
return result.map(e => EventMapper.toDomain(e))
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
}
|
||||
|
||||
async getEventToApproveById(id: string, tracing?: TracingType) {
|
||||
|
||||
try {
|
||||
const result = await this.agendaDataService.getEvent(id).pipe(
|
||||
map((response) => {
|
||||
APINODReturn(EventOutputDTOSchema, response, `get/Events/${id}`, tracing)
|
||||
console.log('response',response)
|
||||
console.log('ToDomain',EventToApproveDetailsMapper.toDomain(response))
|
||||
return EventToApproveDetailsMapper.toDomain(response)
|
||||
})
|
||||
).toPromise()
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
tracing.setAttribute('eventId', id)
|
||||
if(isHttpError(e)) {
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
if (e.status == 400) {
|
||||
tracing?.bugFlag()
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
}
|
||||
} else {
|
||||
tracing?.bugFlag()
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
const result = await this.agendaDataService.getEvent(id)
|
||||
|
||||
if(result.isOk()) {
|
||||
APINODReturn(EventOutputDTOSchema, result.value, `get/Events/${id}`, tracing)
|
||||
|
||||
return result.map(e => EventToApproveDetailsMapper.toDomain(e))
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
}
|
||||
|
||||
async searchEvent(queryParameters: {value, status}, tracing?: TracingType) {
|
||||
@@ -126,94 +97,69 @@ export class AgendaDataRepositoryService {
|
||||
|
||||
async EventList({ userId, startDate, endDate, status = EEventFilterStatus.Approved, category = null, type = null, calendarOwnerName = '' }, tracing?: TracingType) {
|
||||
|
||||
try {
|
||||
const result = await this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
|
||||
map((response) => {
|
||||
APINODReturn(EventListDataOutputDTOSchema, response, 'get/Events', tracing)
|
||||
const result = await this.agendaDataService.getEvents({userId, startDate, endDate, status, category, type})
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
return result.map(response => {
|
||||
APINODReturn(EventListDataOutputDTOSchema, response, 'get/Events', tracing)
|
||||
|
||||
|
||||
let profile;
|
||||
let profile;
|
||||
|
||||
if (SessionStore.user.Profile == 'PR') {
|
||||
profile = "pr"
|
||||
} else if (userId == SessionStore.user.UserId as any) {
|
||||
profile = 'md'
|
||||
} else {
|
||||
profile = "pr"
|
||||
if (SessionStore.user.Profile == 'PR') {
|
||||
profile = "pr"
|
||||
} else if (userId == SessionStore.user.UserId as any) {
|
||||
profile = 'md'
|
||||
} else {
|
||||
profile = "pr"
|
||||
}
|
||||
const listToPresent = ListEventMapper.toDomain(response, calendarOwnerName, userId)
|
||||
|
||||
const map : EventListStore[] = listToPresent.map( element => {
|
||||
return {
|
||||
startTime: new Date(element.StartDate),
|
||||
endTime: new Date(element.EndDate),
|
||||
allDay: false,
|
||||
event: element,
|
||||
calendarName: element.CalendarName,
|
||||
profile: profile,
|
||||
id: element.EventId,
|
||||
CalendarId: userId
|
||||
}
|
||||
const listToPresent = ListEventMapper.toDomain(response, calendarOwnerName, userId)
|
||||
|
||||
const map : EventListStore[] = listToPresent.map( element => {
|
||||
return {
|
||||
startTime: new Date(element.StartDate),
|
||||
endTime: new Date(element.EndDate),
|
||||
allDay: false,
|
||||
event: element,
|
||||
calendarName: element.CalendarName,
|
||||
profile: profile,
|
||||
id: element.EventId,
|
||||
CalendarId: userId
|
||||
}
|
||||
}) as any
|
||||
}) as any
|
||||
|
||||
|
||||
const year = this.listBoxService.list(map, 'md', startDate, endDate, { selectedDate: new Date() })
|
||||
const events = this.utils.getAllEvents(year)
|
||||
this.NativeNotificationService.scheduleNotifications(events)
|
||||
const year = this.listBoxService.list(map, 'md', startDate, endDate, { selectedDate: new Date() })
|
||||
const events = this.utils.getAllEvents(year)
|
||||
this.NativeNotificationService.scheduleNotifications(events)
|
||||
|
||||
this.memoryStore.pipe(
|
||||
select(selectEventsInRange(startDate, endDate, userId))
|
||||
).subscribe((localList)=> {
|
||||
// console.log({localList})
|
||||
});
|
||||
this.memoryStore.pipe(
|
||||
select(selectEventsInRange(startDate, endDate, userId))
|
||||
).subscribe((localList)=> {
|
||||
// console.log({localList})
|
||||
});
|
||||
|
||||
// this.memoryStore.dispatch(removeRangeForCalendar({ startDate, endDate, userId }));
|
||||
// this.memoryStore.dispatch(pushEvent({ eventsList:eventsList as any, userId, profile }));
|
||||
this.memoryStore.dispatch(removeRangeForCalendar({ startDate, endDate, userId }));
|
||||
this.memoryStore.dispatch(pushEvent({ eventsList:listToPresent as any, userId, profile }));
|
||||
|
||||
return listToPresent
|
||||
}
|
||||
)).toPromise()
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
if(isHttpError(e)) {
|
||||
console.log(e.status)
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
if (e.status == 400) {
|
||||
tracing?.bugFlag()
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
}
|
||||
} else {
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
return listToPresent
|
||||
})
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
}
|
||||
|
||||
async eventToApproveList({ userId, startDate = null, endDate = null, status = EEventFilterStatus.Pending, category = null, type = null, calendarOwnerName = '' }, tracing?: TracingType) {
|
||||
|
||||
try {
|
||||
const result = await this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category = null, type = null, tracing).pipe(
|
||||
map((response) => {
|
||||
APINODReturn(EventToApproveDataOutputDTOSchema, response, 'get/ApproveList', tracing)
|
||||
return EventListToApproveMapper.toDomain(response, calendarOwnerName, userId)
|
||||
}
|
||||
)).toPromise()
|
||||
const result = await this.agendaDataService.getEvents({userId, startDate : null, endDate: null, status, category: null, type: null}, tracing)
|
||||
|
||||
return result.map(response => {
|
||||
APINODReturn(EventToApproveDataOutputDTOSchema, response, 'get/ApproveList', tracing)
|
||||
return EventListToApproveMapper.toDomain(response, calendarOwnerName, userId)
|
||||
})
|
||||
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
if(isHttpError(e)) {
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
if (e.status == 400) {
|
||||
tracing?.bugFlag()
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
}
|
||||
} else {
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
}
|
||||
|
||||
createEvent(eventData: Event, documents, calendar: TableSharedCalendar, tracing: TracingType) {
|
||||
@@ -278,14 +224,17 @@ export class AgendaDataRepositoryService {
|
||||
return this.agendaDataService.updateEvent(eventId, eventInput)
|
||||
}
|
||||
|
||||
addEventAttendee(id, attendeeData) {
|
||||
addEventAttendee(id, attendeeData, tracing?: TracingType) {
|
||||
console.log(attendeeData)
|
||||
console.log(this.utils.attendeesEdit(attendeeData))
|
||||
|
||||
|
||||
const data = { attendees: this.utils.attendeesAdded(attendeeData) }
|
||||
APINODReturn(AttendeeInputDTOSchema, data, `PUT/Events/${id}/Attendee`, tracing)
|
||||
return this.agendaDataService.addEventAttendee(id, { attendees: this.utils.attendeesAdded(attendeeData) });
|
||||
}
|
||||
|
||||
|
||||
removeEventAttendee(id, attendeeData: {Id : string}[]) {
|
||||
|
||||
return this.agendaDataService.removeEventAttendee(id, { attendees: attendeeData.map(e => e.Id || e['id']) } );
|
||||
@@ -309,12 +258,7 @@ export class AgendaDataRepositoryService {
|
||||
|
||||
async deleteEvent1(eventId) {
|
||||
|
||||
try {
|
||||
const result = await this.agendaDataService.deleteEvent(eventId, false).toPromise()
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
return await this.agendaDataService.deleteEvent(eventId, false)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,8 @@ import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { EventInputDTO } from './model/eventInputDTO';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { SharedCalendarListOutputDTO, SharedCalendarListOutputDTOSchema } from './model/sharedCalendarOutputDTO';
|
||||
import { SharedCalendarListOutputDTO } from './model/sharedCalendarOutputDTO';
|
||||
import { HttpService } from '../../http.service';
|
||||
import { APIReturn } from '../../decorator/api-validate-schema.decorator';
|
||||
import { TracingType } from '../../monitoring/opentelemetry/tracer';
|
||||
import { EventOutputDTO } from './model/eventDTOOutput';
|
||||
import { AttendeesRemoveInputDTO } from './model/attendeeRemoveInputDTO';
|
||||
@@ -23,36 +22,34 @@ export class AgendaDataService {
|
||||
private httpService: HttpService
|
||||
) { }
|
||||
|
||||
getContacts(value: string): Observable<any> {
|
||||
const params = new HttpParams().set('value', value);
|
||||
return this.http.get<any>(`${this.baseUrl}/Contacts`, { params });
|
||||
}
|
||||
|
||||
// Documents Endpoints
|
||||
getAttachments(subject: string, applicationType: number): Observable<any> {
|
||||
const params = new HttpParams()
|
||||
.set('Subject', subject)
|
||||
.set('ApplicationType', applicationType.toString());
|
||||
return this.http.get<any>(`${this.baseUrl}/Documents/Attachments`, { params });
|
||||
getAttachments(subject: string, applicationType: number) {
|
||||
const params = {
|
||||
Subject: subject,
|
||||
ApplicationType: applicationType.toString()
|
||||
}
|
||||
|
||||
return this.httpService.get<any>(`${this.baseUrl}/Documents/Attachments`, { params });
|
||||
}
|
||||
|
||||
viewDocument(userId: number, docId: number, applicationId: number): Observable<any> {
|
||||
viewDocument(userId: number, docId: number, applicationId: number) {
|
||||
const params = new HttpParams()
|
||||
.set('userId', userId.toString())
|
||||
.set('docId', docId.toString())
|
||||
.set('applicationId', applicationId.toString());
|
||||
return this.http.get<any>(`${this.baseUrl}/Documents/view`, { params });
|
||||
return this.httpService.get<any>(`${this.baseUrl}/Documents/view`, params);
|
||||
}
|
||||
|
||||
// Events Endpoints
|
||||
createEvent(eventData: EventInputDTO) {
|
||||
return this.http.post<any>(`${this.baseUrl}/Events`, eventData);
|
||||
return this.httpService.post<any>(`${this.baseUrl}/Events`, eventData);
|
||||
}
|
||||
|
||||
// @APIReturn(EventListOutputDTOSchema, 'get/Events')
|
||||
getEvents(userId: number, startDate: string, endDate: string, status: number, category: string, type: string, tracing?: TracingType): Observable<EventListOutputDTO> {
|
||||
let params = new HttpParams()
|
||||
.set('UserId', userId)
|
||||
getEvents({userId, startDate, endDate, status, category, type }, tracing?: TracingType) {
|
||||
let params: any = {
|
||||
UserId: userId
|
||||
}
|
||||
|
||||
if(userId == null || userId == undefined) {
|
||||
throw('userId '+ userId)
|
||||
@@ -60,43 +57,45 @@ export class AgendaDataService {
|
||||
|
||||
|
||||
if(status != null || status != undefined) {
|
||||
params = params.set('status', status);
|
||||
params.status = status;
|
||||
}
|
||||
|
||||
if (startDate !== null && startDate !== undefined) {
|
||||
params = params.set('startDate', startDate);
|
||||
params.startDate = startDate;
|
||||
}
|
||||
|
||||
if (endDate !== null && endDate !== undefined) {
|
||||
params = params.set('endDate', endDate);
|
||||
params.endDate = endDate;
|
||||
}
|
||||
|
||||
return this.http.get<any>(`${this.baseUrl}/Events`, { params });
|
||||
return this.httpService.get<EventListOutputDTO>(`${this.baseUrl}/Events`, params, tracing);
|
||||
}
|
||||
|
||||
searchEvent(queryParameter: {value, status}) {
|
||||
return this.httpService.get<EventListOutputDTO>(`${this.baseUrl}/Events`, queryParameter);
|
||||
}
|
||||
|
||||
getEvent(id: string): Observable<EventOutputDTO> {
|
||||
return this.http.get<any>(`${this.baseUrl}/Events/${id}`);
|
||||
getEvent(id: string, tracing?: TracingType) {
|
||||
return this.httpService.get<EventOutputDTO>(`${this.baseUrl}/Events/${id}`, {}, tracing);
|
||||
}
|
||||
|
||||
updateEvent(id: string, eventData: any): Observable<any> {
|
||||
return this.http.put<any>(`${this.baseUrl}/Events/${id}`, eventData);
|
||||
updateEvent(id: string, eventData: any) {
|
||||
return this.httpService.put<any>(`${this.baseUrl}/Events/${id}`, eventData);
|
||||
}
|
||||
|
||||
approveEvent(id: string): Observable<any> {
|
||||
return this.http.patch<any>(`${this.baseUrl}/Events/${id}/Approval`, {});
|
||||
approveEvent(id: string) {
|
||||
return this.httpService.patch<any>(`${this.baseUrl}/Events/${id}/Approval`, {});
|
||||
}
|
||||
|
||||
deleteEvent(id: string, deleteAllEvents: boolean): Observable<any> {
|
||||
const params = new HttpParams().set('DeleteAllEvents', deleteAllEvents.toString());
|
||||
return this.http.delete<any>(`${this.baseUrl}/Events/${id}`, { params });
|
||||
async deleteEvent(id: string, deleteAllEvents: boolean) {
|
||||
const params = {
|
||||
'DeleteAllEvents': deleteAllEvents.toString()
|
||||
};
|
||||
return this.httpService.delete<any>(`${this.baseUrl}/Events/${id}`, params);
|
||||
}
|
||||
|
||||
updateEventStatus(id: string, statusData: any): Observable<any> {
|
||||
return this.http.patch<any>(`${this.baseUrl}/Events/${id}/Status`, statusData);
|
||||
updateEventStatus(id: string, statusData: Object) {
|
||||
return this.httpService.patch<any>(`${this.baseUrl}/Events/${id}/Status`, statusData);
|
||||
}
|
||||
|
||||
addEventAttendee(id: string, attendeeData: any): Observable<any> {
|
||||
@@ -116,20 +115,6 @@ export class AgendaDataService {
|
||||
return this.http.delete<any>(`${this.baseUrl}/Events/${id}/Attachment`, { body: attachmentData });
|
||||
}
|
||||
|
||||
communicateEvent(id: string, communicationData: any): Observable<any> {
|
||||
return this.http.post<any>(`${this.baseUrl}/Events/${id}/Communicate`, communicationData);
|
||||
}
|
||||
|
||||
// Users Endpoints
|
||||
getUsers(value: string): Observable<any> {
|
||||
const params = new HttpParams().set('value', value);
|
||||
return this.http.get<any>(`${this.baseUrl}/Users`, { params });
|
||||
}
|
||||
|
||||
|
||||
getToken(): Observable<any> {
|
||||
return this.http.get<any>(`${this.baseUrl}/Users/token`);
|
||||
}
|
||||
|
||||
getDocumentAttachment(aplicationId,userId,value,PageNumber,PageSize): Observable<any> {
|
||||
const params = new HttpParams()
|
||||
|
||||
@@ -1,151 +1,151 @@
|
||||
import { z } from 'zod';
|
||||
// import { z } from 'zod';
|
||||
|
||||
export const AttachCommunicationInputDTOSchema = z.object({
|
||||
attachmentId: z.string().uuid(),
|
||||
description: z.string().nullable().optional(),
|
||||
typeSharing: z.number().int(),
|
||||
dateViewExpire: z.string().datetime().nullable().optional(),
|
||||
}).strict();
|
||||
// export const AttachCommunicationInputDTOSchema = z.object({
|
||||
// attachmentId: z.string().uuid(),
|
||||
// description: z.string().nullable().optional(),
|
||||
// typeSharing: z.number().int(),
|
||||
// dateViewExpire: z.string().datetime().nullable().optional(),
|
||||
// }).strict();
|
||||
|
||||
|
||||
export const AttachmentInputDTOSchema = z.object({
|
||||
sourceId: z.string().nullable().optional(),
|
||||
sourceName: z.string().nullable().optional(),
|
||||
description: z.string().nullable().optional(),
|
||||
applicationId: z.number().int(),
|
||||
}).strict();
|
||||
// export const AttachmentInputDTOSchema = z.object({
|
||||
// sourceId: z.string().nullable().optional(),
|
||||
// sourceName: z.string().nullable().optional(),
|
||||
// description: z.string().nullable().optional(),
|
||||
// applicationId: z.number().int(),
|
||||
// }).strict();
|
||||
|
||||
|
||||
export const AttendeeCommunicationInputDTOSchema = z.object({
|
||||
attendeeId: z.string().uuid(),
|
||||
message: z.string().nullable().optional(),
|
||||
}).strict();
|
||||
// export const AttendeeCommunicationInputDTOSchema = z.object({
|
||||
// attendeeId: z.string().uuid(),
|
||||
// message: z.string().nullable().optional(),
|
||||
// }).strict();
|
||||
|
||||
export const AttendeeExternalInputDTOSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
emailAddress: z.string().email().nullable().optional(),
|
||||
message: z.string().nullable().optional(),
|
||||
}).strict();
|
||||
// export const AttendeeExternalInputDTOSchema = z.object({
|
||||
// name: z.string().min(1),
|
||||
// emailAddress: z.string().email().nullable().optional(),
|
||||
// message: z.string().nullable().optional(),
|
||||
// }).strict();
|
||||
|
||||
export const AttendeeInputDTOSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
emailAddress: z.string().nullable().optional(),
|
||||
attendeeType: z.number(),
|
||||
wxUserId: z.number().int(),
|
||||
}).strict();
|
||||
// export const AttendeeInputDTOSchema = z.object({
|
||||
// name: z.string().min(1),
|
||||
// emailAddress: z.string().nullable().optional(),
|
||||
// attendeeType: z.number(),
|
||||
// wxUserId: z.number().int(),
|
||||
// }).strict();
|
||||
|
||||
const EAttendeeTypeDTO = z.number();
|
||||
// const EAttendeeTypeDTO = z.number();
|
||||
|
||||
const EEventCategoryDTO = z.number();
|
||||
// const EEventCategoryDTO = z.number();
|
||||
|
||||
const EEventFilterCategoryDTO = z.number();
|
||||
// const EEventFilterCategoryDTO = z.number();
|
||||
|
||||
const EEventFilterStatusDTO = z.number();
|
||||
// const EEventFilterStatusDTO = z.number();
|
||||
|
||||
const EEventFilterTypeDTO = z.number();
|
||||
// const EEventFilterTypeDTO = z.number();
|
||||
|
||||
const EEventOwnerTypeDTO = z.number();
|
||||
// const EEventOwnerTypeDTO = z.number();
|
||||
|
||||
const EEventStatusDTO = z.number();
|
||||
// const EEventStatusDTO = z.number();
|
||||
|
||||
const EEventTypeDTO = z.number();
|
||||
// const EEventTypeDTO = z.number();
|
||||
|
||||
const ERecurringTypeDTO = z.number();
|
||||
// const ERecurringTypeDTO = z.number();
|
||||
|
||||
const EventAddAttachmentDTOSchema = z.object({
|
||||
attachments: z.array(AttachmentInputDTOSchema),
|
||||
}).strict();
|
||||
// const EventAddAttachmentDTOSchema = z.object({
|
||||
// attachments: z.array(AttachmentInputDTOSchema),
|
||||
// }).strict();
|
||||
|
||||
const EventAddAttendeeDTOSchema = z.object({
|
||||
attendees: z.array(AttendeeInputDTOSchema),
|
||||
}).strict();
|
||||
// const EventAddAttendeeDTOSchema = z.object({
|
||||
// attendees: z.array(AttendeeInputDTOSchema),
|
||||
// }).strict();
|
||||
|
||||
export const EventCommunicationInputDTOSchema = z.object({
|
||||
attachs: z.array(AttachCommunicationInputDTOSchema).nullable().optional(),
|
||||
attendees: z.array(AttendeeCommunicationInputDTOSchema).nullable().optional(),
|
||||
externalAttendees: z.array(AttendeeExternalInputDTOSchema).nullable().optional(),
|
||||
}).strict();
|
||||
// export const EventCommunicationInputDTOSchema = z.object({
|
||||
// attachs: z.array(AttachCommunicationInputDTOSchema).nullable().optional(),
|
||||
// attendees: z.array(AttendeeCommunicationInputDTOSchema).nullable().optional(),
|
||||
// externalAttendees: z.array(AttendeeExternalInputDTOSchema).nullable().optional(),
|
||||
// }).strict();
|
||||
|
||||
export const EventInputDTOSchema = z.object({
|
||||
userId: z.number().int(),
|
||||
ownerType: EEventOwnerTypeDTO,
|
||||
subject: z.string().min(1),
|
||||
body: z.string().min(1),
|
||||
location: z.string().nullable().optional(),
|
||||
startDate: z.string(),
|
||||
endDate: z.string(),
|
||||
type: EEventTypeDTO,
|
||||
category: EEventCategoryDTO,
|
||||
attendees: z.array(AttendeeInputDTOSchema).nullable().optional(),
|
||||
attachments: z.array(AttachmentInputDTOSchema).nullable().optional(),
|
||||
recurrence: z.object({
|
||||
frequency: z.number().int(),
|
||||
until: z.string(),
|
||||
}),
|
||||
organizerId: z.number().int(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
}).strict();
|
||||
// // export const EventInputDTOSchema = z.object({
|
||||
// // userId: z.number().int(),
|
||||
// // ownerType: EEventOwnerTypeDTO,
|
||||
// // subject: z.string().min(1),
|
||||
// // body: z.string().min(1),
|
||||
// // location: z.string().nullable().optional(),
|
||||
// // startDate: z.string(),
|
||||
// // endDate: z.string(),
|
||||
// // type: EEventTypeDTO,
|
||||
// // category: EEventCategoryDTO,
|
||||
// // attendees: z.array(AttendeeInputDTOSchema).nullable().optional(),
|
||||
// // attachments: z.array(AttachmentInputDTOSchema).nullable().optional(),
|
||||
// // recurrence: z.object({
|
||||
// // frequency: z.number().int(),
|
||||
// // until: z.string(),
|
||||
// // }),
|
||||
// // organizerId: z.number().int(),
|
||||
// // isAllDayEvent: z.boolean(),
|
||||
// // }).strict();
|
||||
|
||||
export const EventRecurrenceInputDTOSchema = z.object({
|
||||
frequency: z.number().int(),
|
||||
occurrences: z.number().int(),
|
||||
}).strict();
|
||||
// export const EventRecurrenceInputDTOSchema = z.object({
|
||||
// frequency: z.number().int(),
|
||||
// occurrences: z.number().int(),
|
||||
// }).strict();
|
||||
|
||||
export const EventRemoveAttachmentDTOSchema = z.object({
|
||||
attachments: z.array(z.string().uuid()),
|
||||
}).strict();
|
||||
// export const EventRemoveAttachmentDTOSchema = z.object({
|
||||
// attachments: z.array(z.string().uuid()),
|
||||
// }).strict();
|
||||
|
||||
export const EventRemoveAttendeeDTOSchema = z.object({
|
||||
attendees: z.array(z.string().uuid()),
|
||||
}).strict();
|
||||
// export const EventRemoveAttendeeDTOSchema = z.object({
|
||||
// attendees: z.array(z.string().uuid()),
|
||||
// }).strict();
|
||||
|
||||
export const EventUpdateDTOSchema = z.object({
|
||||
subject: z.string().min(1),
|
||||
body: z.string().min(1),
|
||||
location: z.string().min(1),
|
||||
startDate: z.string().datetime(),
|
||||
endDate: z.string().datetime(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
updateAllEvents: z.boolean(),
|
||||
recurrence: z.object({
|
||||
frequency: z.number().int(),
|
||||
occurrences: z.number().int(),
|
||||
}),
|
||||
}).strict();
|
||||
// export const EventUpdateDTOSchema = z.object({
|
||||
// subject: z.string().min(1),
|
||||
// body: z.string().min(1),
|
||||
// location: z.string().min(1),
|
||||
// startDate: z.string().datetime(),
|
||||
// endDate: z.string().datetime(),
|
||||
// isAllDayEvent: z.boolean(),
|
||||
// updateAllEvents: z.boolean(),
|
||||
// recurrence: z.object({
|
||||
// frequency: z.number().int(),
|
||||
// occurrences: z.number().int(),
|
||||
// }),
|
||||
// }).strict();
|
||||
|
||||
export const EventUpdateStatusDTOSchema = z.object({
|
||||
status: EEventStatusDTO,
|
||||
comment: z.string().nullable().optional(),
|
||||
}).strict();
|
||||
// export const EventUpdateStatusDTOSchema = z.object({
|
||||
// status: EEventStatusDTO,
|
||||
// comment: z.string().nullable().optional(),
|
||||
// }).strict();
|
||||
|
||||
export const ProblemDetailsDTOSchema = z.object({
|
||||
type: z.string().nullable().optional(),
|
||||
title: z.string().nullable().optional(),
|
||||
status: z.number().int().nullable().optional(),
|
||||
detail: z.string().nullable().optional(),
|
||||
instance: z.string().nullable().optional(),
|
||||
}).strict();
|
||||
// export const ProblemDetailsDTOSchema = z.object({
|
||||
// type: z.string().nullable().optional(),
|
||||
// title: z.string().nullable().optional(),
|
||||
// status: z.number().int().nullable().optional(),
|
||||
// detail: z.string().nullable().optional(),
|
||||
// instance: z.string().nullable().optional(),
|
||||
// }).strict();
|
||||
|
||||
export const ResponseSimpleDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string().nullable().optional(),
|
||||
data: z.any().nullable().optional(),
|
||||
})
|
||||
// export const ResponseSimpleDTOSchema = z.object({
|
||||
// success: z.boolean(),
|
||||
// message: z.string().nullable().optional(),
|
||||
// data: z.any().nullable().optional(),
|
||||
// })
|
||||
|
||||
|
||||
export type AttachCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type AttachmentInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type AttendeeCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type AttendeeExternalInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type AttendeeInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventAddAttachmentDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventAddAttendeeDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventInputDTO = z.infer<typeof EventInputDTOSchema>;
|
||||
export type EventRecurrenceInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventRemoveAttachmentDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventRemoveAttendeeDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventUpdateDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type EventUpdateStatusDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type ProblemDetailsDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
export type ResponseSimpleDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type AttachCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type AttachmentInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type AttendeeCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type AttendeeExternalInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type AttendeeInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type EventAddAttachmentDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type EventAddAttendeeDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type EventCommunicationInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// // export type EventInputDTO = z.infer<typeof EventInputDTOSchema>;
|
||||
// export type EventRecurrenceInputDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type EventRemoveAttachmentDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type EventRemoveAttendeeDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type EventUpdateDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type EventUpdateStatusDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type ProblemDetailsDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
// export type ResponseSimpleDTO = z.infer<typeof AttachCommunicationInputDTOSchema>;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
|
||||
export const AttendeeInputDTOSchema = z.array(z.object({
|
||||
name: z.string(),
|
||||
emailAddress: z.string(),
|
||||
attendeeType: z.number(),
|
||||
wxUserId: z.number(),
|
||||
userType: z.enum(['GD','External', 'Internal']),
|
||||
entity: z.string()
|
||||
}))
|
||||
|
||||
|
||||
export type AttendeeInputDTO = z.infer<typeof AttendeeInputDTOSchema>
|
||||
@@ -5,7 +5,9 @@ const attendeeSchema = z.object({
|
||||
name: z.string(),
|
||||
emailAddress: z.string(),
|
||||
attendeeType: z.number(),
|
||||
wxUserId: z.number()
|
||||
wxUserId: z.number(),
|
||||
userType: z.enum(['GD','External', 'Internal']),
|
||||
entity: z.string()
|
||||
});
|
||||
|
||||
const attachmentSchema = z.object({
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
import { z } from 'zod';
|
||||
import { EEventCategory, EEventOwnerType, EEventType } from './enums';
|
||||
|
||||
const attendeeSchema = z.object({
|
||||
name: z.string(),
|
||||
emailAddress: z.string(),
|
||||
attendeeType: z.number(),
|
||||
wxUserId: z.number()
|
||||
});
|
||||
|
||||
const attachmentSchema = z.object({
|
||||
docId: z.number(),
|
||||
sourceName: z.string(),
|
||||
description: z.string(),
|
||||
applicationId: z.number()
|
||||
});
|
||||
|
||||
const recurrenceSchema = z.object({
|
||||
frequency: z.number(),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AgendaDataService } from './agenda-data.service';
|
||||
import { EventsService } from '../../events.service';
|
||||
import { RoleIdService } from 'src/app/services/role-id.service'
|
||||
import { TableSharedCalendar } from './agenda-local-data-source.service';
|
||||
@@ -131,12 +130,17 @@ export class Utils {
|
||||
|
||||
|
||||
attendeesAdded(taskParticipants: any[]) {
|
||||
|
||||
console.log({taskParticipants});
|
||||
|
||||
return taskParticipants.map((e) => {
|
||||
return {
|
||||
name: e.Name,
|
||||
emailAddress: e.EmailAddress,
|
||||
attendeeType: this.atendeesSeletedType(JSON.stringify(e.IsRequired)),
|
||||
wxUserId: e.Id,
|
||||
userType: e.UserType,
|
||||
entity: e.Entity,
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -159,6 +163,8 @@ export class Utils {
|
||||
emailAddress: e.EmailAddress,
|
||||
attendeeType: this.atendeesSeletedType(JSON.stringify(e.IsRequired)),
|
||||
wxUserId: e.wxUserId || e.Id,
|
||||
userType: e.UserType,
|
||||
entity: e.Entity,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const EventListOutputDTOSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
fullName: z.string(),
|
||||
email: z.string(),
|
||||
role: z.any(),
|
||||
roleId: z.number(),
|
||||
entity: z.string(),
|
||||
userType: z.string(),
|
||||
})
|
||||
|
||||
export const EventListDataOutputDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.array(EventListOutputDTOSchema),
|
||||
}).nullable();
|
||||
|
||||
export type ContactCombinedOutputDTO = z.infer<typeof EventListDataOutputDTOSchema>;
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
export interface UserContacts {
|
||||
wxUserId: number;
|
||||
wxFullName: string;
|
||||
wxeMail: string | null;
|
||||
userPhoto: string | null;
|
||||
}
|
||||
|
||||
export interface UserListResult {
|
||||
total: number,
|
||||
result: UserContacts[]
|
||||
}
|
||||
|
||||
export interface UserListOutOutDTO {
|
||||
success: boolean;
|
||||
message: string;
|
||||
data: UserListResult;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpService } from 'src/app/services/http.service';
|
||||
import { UserListOutOutDTO } from '../DTO/userListOutput';
|
||||
import { ContactCombinedOutputDTO, EventListDataOutputDTOSchema } from '../DTO/contactsCombined';
|
||||
import { APIReturn } from 'src/app/services/decorator/api-validate-schema.decorator';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ContactsDataSourceService {
|
||||
|
||||
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2'; // Your base URL
|
||||
|
||||
constructor(private httpService: HttpService) {}
|
||||
|
||||
|
||||
|
||||
@APIReturn(EventListDataOutputDTOSchema, '/Contacts/Combined')
|
||||
async getCombinedList() {
|
||||
return await this.httpService.get<ContactCombinedOutputDTO>(`${this.baseUrl}/Contacts/Combined`);
|
||||
}
|
||||
|
||||
async getUsers() {
|
||||
return await this.httpService.get<UserListOutOutDTO>(`${this.baseUrl}/Users`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { RoleIdService } from "src/app/services/role-id.service";
|
||||
import { ContactCombinedOutputDTO } from "../DTO/contactsCombined";
|
||||
import { UserList } from "src/app/models/entiry/agenda/contact";
|
||||
|
||||
|
||||
const roles = new RoleIdService()
|
||||
|
||||
export class ListEventMapper {
|
||||
// @XTracer({name:'ListEventMapper/toDomain', log: false, bugPrint: false})
|
||||
static toDomain(dto: ContactCombinedOutputDTO): UserList {
|
||||
|
||||
return dto.data.map((e) => {
|
||||
|
||||
return {
|
||||
Id: e.wxUserId,
|
||||
EmailAddress: e.email,
|
||||
Name: e.fullName,
|
||||
UserType: e.userType,
|
||||
Entity: e.entity,
|
||||
IsPR: e.roleId == roles.PRES,
|
||||
RoleId: e.roleId,
|
||||
IsRequired: false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
static toDTO() {}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ContactsDataSourceService } from '../data-source/contacts-data-source.service';
|
||||
import { ListEventMapper } from '../mapper/contactCombinedMapper';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ContactRepositoryService {
|
||||
|
||||
constructor(
|
||||
private constactsDataSourceService: ContactsDataSourceService,
|
||||
) {}
|
||||
|
||||
async getUsersMap() {
|
||||
const result = await this.constactsDataSourceService.getCombinedList();
|
||||
return result.map((result) => {
|
||||
return ListEventMapper.toDomain(result).filter(e => e.EmailAddress != null)
|
||||
});
|
||||
}
|
||||
|
||||
async getUsers() {
|
||||
const result = await this.constactsDataSourceService.getUsers();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import { NativeNotificationService } from 'src/app/services/native-notification.
|
||||
import { SortService } from '../functions/sort.service';
|
||||
import { chatUser } from 'src/app/models/chatMethod';
|
||||
import { NfService } from 'src/app/services/chat/nf.service'
|
||||
import { ChangeProfileService } from '../change-profile.service';
|
||||
import { ChatMethodsService } from './chat-methods.service';
|
||||
import { AESEncrypt } from '../aesencrypt.service'
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
|
||||
@@ -11,6 +11,8 @@ export function APIReturn(schema: z.ZodTypeAny, path: string) {
|
||||
descriptor.value = async function (...args: any[]) {
|
||||
const result: Result<any, HttpErrorResponse> = await originalMethod.apply(this, args);
|
||||
|
||||
const tracing: TracingType = args[args.length - 1];
|
||||
|
||||
if(result.isOk()) {
|
||||
try {
|
||||
// Validate the result using the provided schema
|
||||
@@ -23,6 +25,14 @@ export function APIReturn(schema: z.ZodTypeAny, path: string) {
|
||||
// Capture the Zod validation error with additional context
|
||||
console.error('Validation failed:', error.errors);
|
||||
console.log(result.value)
|
||||
|
||||
tracing?.setAttribute?.('APIReturn.error', 'true')
|
||||
|
||||
let i = 0;
|
||||
for(const schema of error.errors) {
|
||||
tracing?.setAttribute?.('map.error.schema-'+i, JSON.stringify(schema))
|
||||
}
|
||||
|
||||
} else {
|
||||
// Throw any other unexpected errors
|
||||
// throw error;
|
||||
@@ -57,6 +67,7 @@ export function APINODReturn(schema: z.ZodTypeAny, data , path: string, tracing?
|
||||
console.log(data)
|
||||
|
||||
tracing?.setAttribute('APIReturn.error', 'true')
|
||||
tracing?.setAttribute('path', path)
|
||||
|
||||
let i = 0;
|
||||
for(const schema of error.errors) {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { HttpClient, HttpErrorResponse, HttpResponse } from '@angular/common/htt
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ok, err, Result } from 'neverthrow';
|
||||
import { HttpParams } from '@angular/common/http';
|
||||
import { TracingType } from './monitoring/opentelemetry/tracer';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -9,7 +10,7 @@ export class HttpService {
|
||||
|
||||
constructor(private http:HttpClient) { }
|
||||
|
||||
async post<T>(url: string, body: any): Promise<Result<T, HttpErrorResponse>> {
|
||||
async post<T>(url: string, body: any, tracing?: TracingType): Promise<Result<T, HttpErrorResponse>> {
|
||||
|
||||
try {
|
||||
const result = await this.http.post(url, body).toPromise()
|
||||
@@ -19,7 +20,7 @@ export class HttpService {
|
||||
}
|
||||
}
|
||||
|
||||
async get<T>(url: string, httpParamsObj = {} ): Promise<Result<T, HttpErrorResponse>> {
|
||||
async get<T>(url: string, httpParamsObj = {}, tracing?: TracingType): Promise<Result<T, HttpErrorResponse>> {
|
||||
try {
|
||||
|
||||
let httpParams = new HttpParams();
|
||||
@@ -38,6 +39,18 @@ export class HttpService {
|
||||
|
||||
return ok (result as T)
|
||||
} catch (e) {
|
||||
if(isHttpError(e)) {
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
if (e.status == 400) {
|
||||
tracing?.bugFlag()
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
}
|
||||
} else {
|
||||
tracing?.bugFlag()
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
}
|
||||
@@ -53,10 +66,23 @@ export class HttpService {
|
||||
|
||||
}
|
||||
|
||||
async delete<T>(url: string): Promise<Result<T, HttpErrorResponse>> {
|
||||
async delete<T>(url: string, httpParamsObj = {}): Promise<Result<T, HttpErrorResponse>> {
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await this.http.delete<T>(url).toPromise()
|
||||
const result = await this.http.delete<T>(url, opts).toPromise()
|
||||
return ok (result as T)
|
||||
} catch (e) {
|
||||
return err(e as HttpErrorResponse)
|
||||
|
||||
@@ -60,15 +60,13 @@ export class NotificationsService {
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private storageService: StorageService,
|
||||
public modalCtrl: AlertController,
|
||||
private platform: Platform,
|
||||
private router: Router,
|
||||
private zone: NgZone,
|
||||
private eventtrigger: EventTrigger,
|
||||
private afMessaging: AngularFireMessaging,
|
||||
public NotificationHolderService: NotificationHolderService,
|
||||
private NotificationRepositoryService: NotificationRepositoryService) {
|
||||
public NotificationHolderService: NotificationHolderService) {
|
||||
|
||||
// this.onReciveForeground();
|
||||
this.onReciveBackground();
|
||||
|
||||
Reference in New Issue
Block a user