ITOTEAM-525 send the rigth category and ownertype

This commit is contained in:
Peter Maquiran
2024-06-22 13:28:14 +01:00
parent 0c14b9be97
commit 536548af0c
17 changed files with 157 additions and 499 deletions
+2 -2
View File
@@ -54,7 +54,7 @@
"vendorChunk": true,
"extractLicenses": false,
"buildOptimizer": false,
"sourceMap": true,
"sourceMap": false,
"optimization": false,
"namedChunks": true
},
@@ -68,7 +68,7 @@
],
"optimization": true,
"outputHashing": "all",
"sourceMap": true,
"sourceMap": false,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
+14 -12
View File
@@ -10,17 +10,19 @@ import { MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk
const meterProvider = new MeterProvider();
metrics.setGlobalMeterProvider(meterProvider);
const metricReader = new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter({
url: 'http://5-180-182-151.cloud-xip.com:4318/v1/metrics',
// headers: {
// 'Authorization': 'Basic ' + btoa('tabteste@006:tabteste@006'),
// }
}),
exportIntervalMillis: 1000,
});
if (window.location.protocol !== 'https:') {
const metricReader = new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter({
url: 'http://5-180-182-151.cloud-xip.com:4318/v1/metrics',
// headers: {
// 'Authorization': 'Basic ' + btoa('tabteste@006:tabteste@006'),
// }
}),
exportIntervalMillis: 3000,
});
meterProvider.addMetricReader(metricReader);
meterProvider.addMetricReader(metricReader);
}
const meter = meterProvider.getMeter('example-exporter-collector');
const requestCounter = meter.createCounter('post_requests', {
@@ -37,7 +39,7 @@ export class MetricsInterceptor implements HttpInterceptor {
if (req.method !== 'GET' && !req.urlWithParams.includes('metrics')) {
const path = req.urlWithParams;
const url = new URL(path);
if (!window.location.origin.includes('https:')) {
if (window.location.protocol !== 'https:') {
let attributes = { path: url.pathname, method: req.method };
const statusCode = event.status;
const extendedAttributes = { ...attributes, status: statusCode };
@@ -54,4 +56,4 @@ export const metricsInterceptor = {
provide: HTTP_INTERCEPTORS,
useClass: MetricsInterceptor,
multi: true
};
};
@@ -350,28 +350,6 @@
</div>
</div>
<!-- <div class="container-div d-flex width-100">
<div class="ion-item-class-2 width-100 d-flex">
<div class="ion-icon-class">
<ion-icon slot="start" src="assets/images/icons-refresh.svg"></ion-icon>
</div>
<div class="ion-input-class flex-grow-1">
<mat-form-field appearance="none" floatLabel="never" class="width-100" value="false" interface="action-sheet" required>
<mat-select
placeholder="Selecione repetição*"
[(ngModel)]="selectedRecurringType"
(ngModelChange)="onSelectedRecurringChanged($event)">
<mat-option
*ngFor="let recurring of recurringTypes"
value="{{recurring.Code}}">
{{recurring.Description}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</div> -->
<div *ngIf="selectedRecurringType != '-1'" class="container-div width-100">
<div class="ion-item-class-2 d-flex">
@@ -7,7 +7,6 @@ import { EventBody } from 'src/app/models/eventbody.model';
import { EventPerson } from 'src/app/models/eventperson.model';
import { AttachmentsService } from 'src/app/services/attachments.service';
import { EventsService } from 'src/app/services/events.service';
import { ToastService } from 'src/app/services/toast.service';
import { Event } from '../../../models/event.model';
import { AttendeesPageModal } from '../../events/attendees/attendees.page';
import { SearchPage } from '../../search/search.page';
@@ -18,12 +17,12 @@ import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'
import { environment } from 'src/environments/environment';
import { ContactsService } from 'src/app/services/contacts.service';
import { DomSanitizerService } from 'src/app/services/DomSanitizer.service';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { Utils } from 'src/app/services/Repositorys/Agenda/utils';
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { Observable } from 'rxjs';
import { RoleIdService } from 'src/app/services/role-id.service'
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -61,7 +60,6 @@ export class EditEventPage implements OnInit {
selectedDate: Date;
initCalendarName: string;
caller: string;
recurringTypes: any;
selectedRecurringType: any;
CalendarNameOwnerName = ''
@@ -108,12 +106,10 @@ export class EditEventPage implements OnInit {
public eventsService: EventsService,
public alertController: AlertController,
private attachmentsService: AttachmentsService,
private toastService: ToastService,
private router: Router,
public ThemeService: ThemeService,
private httpErrorHandle: HttpErrorHandle,
private contactsService: ContactsService,
private domSanitazerService: DomSanitizerService,
private agendaDataRepository: AgendaDataRepositoryService,
private utils: Utils,
public RoleIdService: RoleIdService,
@@ -193,7 +189,6 @@ export class EditEventPage implements OnInit {
}
ngOnInit() {
console.log('this.postEvent', this.postEvent)
this.selectedUserCalendar = this.postEvent.owner.wxUserId
if (!this.postEvent.IsRecurring) {
@@ -202,8 +197,7 @@ export class EditEventPage implements OnInit {
this.postEvent.EventRecurrence.frequency = this.utils.recurenceTypeSeleted(this.postEvent.EventRecurrence.frequency)
}
this.postEvent.Category = this.setEventType(this.postEvent.Category)
console.log(this.postEvent?.Attachments)
console.log(this.loadedEventAttachments)
window.onresize = (event) => {
// if not mobile remove all component
if (window.innerWidth >= 1024) {
@@ -214,7 +208,6 @@ export class EditEventPage implements OnInit {
this.showAttendees = true;
}
this.getRecurrenceTypes();
setTimeout(() => {
this.selectedRecurringType = this.postEvent.EventRecurrence.Type.toString();
}, 500);
@@ -250,13 +243,6 @@ export class EditEventPage implements OnInit {
this.router.navigate(['/home', this.caller]);
}
getRecurrenceTypes() {
this.eventsService.getRecurrenceTypes().subscribe(res => {
this.recurringTypes = res;
});
}
roundTimeQuarterHour(timeToReturn = new Date()) {
let date = timeToReturn || new Date();
const minutes = date.getMinutes();
@@ -438,7 +424,9 @@ export class EditEventPage implements OnInit {
this.save_v2(false)
}
}
async save_v2(editAllEvent) {
@XTracerAsync({name:'desktop/create-event', bugPrint: true, daley: 4000})
async save_v2(editAllEvent, tracing?: TracingType) {
this.injectValidation()
this.runValidation()
@@ -448,15 +436,16 @@ export class EditEventPage implements OnInit {
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
try {
const events = []
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent, editAllEvent, calendar.value).subscribe((value) => {
this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent, editAllEvent, calendar.value, tracing).subscribe((value) => {
console.log(value)
this.goBack();
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
tracing.setAttribute('outcome', 'success')
}, ((error) => {
tracing.setAttribute('outcome', 'failed')
console.log('edit event error: ', error)
}));
@@ -482,6 +471,7 @@ export class EditEventPage implements OnInit {
console.log(value)
}, ((error) => {
console.log('remove attachment error: ', error)
tracing.setAttribute('failed.remove.attachment', 'true')
}));
}
@@ -501,89 +491,6 @@ export class EditEventPage implements OnInit {
}
// async save() {
// this.injectValidation()
// this.runValidation()
// if (this.Form.invalid) return false;
// if (this.selectedRecurringType != '-1') {
// this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
// }
// this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc)
// this.postEvent.Subject = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Subject/* ) */;
// this.postEvent.Location = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Location/* ) */;
// this.postEvent.Body.Text = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Body.Text/* ) */;
// this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
// if (this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
// this.eventsService.editEvent(this.postEvent, 2, 3, null).subscribe(async () => {
// if (window['reloadCalendar']) {
// window['reloadCalendar']()
// }
// if (this.initCalendarName != this.postEvent.CalendarName) {
// let body = {
// "EventId": this.postEvent.EventId,
// "CalendarDestinationName": this.postEvent.CalendarName,
// }
// try {
// await this.eventsService.changeAgenda(body).toPromise();
// } catch (error) { }
// finally {
// }
// }
// this.httpErrorHandle.httpsSucessMessagge('Editar evento')
// }, error => {
// this.httpErrorHandle.httpStatusHandle(error)
// });
// } else {
// console.log('edid calendar id', this.postEvent.CalendarId);
// this.eventsService.editEvent(this.postEvent, 2, 3, this.postEvent.CalendarId).subscribe(async () => {
// if (window['reloadCalendar']) {
// window['reloadCalendar']()
// }
// if (this.initCalendarName != this.postEvent.CalendarName) {
// let body = {
// "EventId": this.postEvent.EventId,
// "CalendarDestinationName": this.postEvent.CalendarName,
// }
// try {
// await this.eventsService.changeAgenda(body).toPromise();
// } catch (error) { }
// finally {
// }
// }
// this.httpErrorHandle.httpsSucessMessagge('Editar evento')
// }, error => {
// this.httpErrorHandle.httpStatusHandle(error)
// });
// }
// this.isEventEdited = true;
// await this.saveDocument()
// this.goBack();
// }
async saveDocument() {
try {
+13 -300
View File
@@ -26,6 +26,7 @@ import { Observable } from 'rxjs';
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { map } from 'rxjs/operators';
import { RoleIdService } from 'src/app/services/role-id.service'
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -84,7 +85,6 @@ export class NewEventPage implements OnInit {
selectedSegment: string;
selectedDate: Date;
CalendarDate: Date;
recurringTypes: any;
selectedRecurringType: any;
adding: "intervenient" | "CC";
@@ -212,8 +212,6 @@ export class NewEventPage implements OnInit {
this.selectedRecurringType = "-1";
this.getRecurrenceTypes();
if (this.selectedSegment != "Combinada") {
this.postEvent = {
EventId: '',
@@ -342,14 +340,6 @@ export class NewEventPage implements OnInit {
}
}
getRecurrenceTypes() {
this.eventService.getRecurrenceTypes().subscribe(res => {
this.recurringTypes = res;
});
}
onSelectedRecurringChanged(ev: any) {
this.calculetedLastOccurrence(ev);
@@ -472,7 +462,8 @@ export class NewEventPage implements OnInit {
}
async save_v2() {
@XTracerAsync({name:'Mobile/create-event', bugPrint: true})
async save_v2(tracing?: TracingType) {
this.injectValidation()
this.runValidation()
@@ -493,132 +484,27 @@ export class NewEventPage implements OnInit {
const loader = this.toastService.loading()
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this.postEvent.IsAllDayEvent = this.allDayCheck;
this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value).subscribe((value) => {
try {
const value = await this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value, tracing).toPromise()
console.log(value)
loader.remove()
this.hhtpErrorHandle.httpsSucessMessagge('new event')
let data = Object.assign(this.postEvent)
this.modalController.dismiss(data);
}, ((error) => {
tracing.setAttribute('outcome', 'success');
} catch(error) {
tracing.setAttribute('outcome', 'failed');
console.log('create event error: ', error)
loader.remove()
}));
}
} else {
}
}
// async save() {
// this.injectValidation()
// this.runValidation()
// if (this.Form.invalid) {
// return false
// }
// if (this.documents.length >= 0) {
// this.postEvent.HasAttachments = true;
// }
// if (this.selectedRecurringType != '-1') {
// this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
// }
// this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
// this.postEvent.Subject = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Subject/* ); */
// this.postEvent.Location = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Location/* ); */
// this.postEvent.Body.Text = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Body.Text/* ); */
// let eventId: any;
// const loader = this.toastService.loading()
// try {
// const CalendarId = this.selectedCalendarId()
// this.postEvent.CalendarId = CalendarId
// if (this.loggeduser.Profile == 'MDGPR') {
// eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
// this.hhtpErrorHandle.httpsSucessMessagge('new event')
// }
// else if (this.loggeduser.Profile == 'PR') {
// const CalendarId = this.selectedCalendarId()
// this.postEvent.CalendarId = CalendarId
// eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
// this.hhtpErrorHandle.httpsSucessMessagge('new event')
// } else if (this.loggeduser.Profile == 'SGGPR') {
// this.saveAproveEvent();
// } else {
// const CalendarId = this.selectedCalendarId()
// this.postEvent.CalendarId = CalendarId
// eventId = await this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).toPromise();
// this.hhtpErrorHandle.httpsSucessMessagge('new event')
// }
// //foi adicionado este if para não ter de fazer muitas alterações sobre a criação dos eventos. Deve ser refatorado
// if (this.loggeduser.Profile != 'SGGPR') {
// const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
// return {
// SourceTitle: e.Assunto,
// ParentId: eventId,
// Source: '1',
// SourceId: e.Id,
// ApplicationId: e.ApplicationType.toString(),
// Id: '',
// Link: '',
// SerialNumber: ''
// };
// });
// await DocumentToSave.forEach(async (attachments, i) => {
// try {
// await this.attachmentsService.setEventAttachmentById(attachments).toPromise();
// } catch (error) {
// }
// });
// let data1 = {
// "subject": this.postEvent.Subject,
// "start": this.postEvent.StartDate,
// "end": this.postEvent.EndDate,
// "venue": this.postEvent.Location,
// "id": eventId,
// "calendarId": CalendarId
// }
// if (this.roomId) {
// this.chatMethodService.sendMessage(this.roomId, data1);
// }
// this.hhtpErrorHandle.httpsSucessMessagge('new event');
// let data = Object.assign(this.postEvent, { id: eventId })
// this.modalController.dismiss(data);
// }
// } catch (error) {
// this.hhtpErrorHandle.httpStatusHandle(error)
// } finally {
// loader.remove()
// }
// }
//This method return calendar id
@@ -772,179 +658,6 @@ export class NewEventPage implements OnInit {
}
}
//Deve ser removido posteriormente
// async saveAproveEvent() {
// // console.log(this.postEvent)
// // console.log(this.postEvent.CalendarName)
// // console.log(this.CalendarName)
// // console.log(this.eventService.calendarNamesAry)
// const CalendarId = this.selectedCalendarId()
// let selectedCalendar
// try {
// selectedCalendar = this.eventService.calendarNamesAry.find(calendar => calendar.Fullname === this.CalendarName)
// } catch (error) {
// }
// // console.log('selectedCalendar', selectedCalendar)
// if (selectedCalendar) {
// if (selectedCalendar.Role = 'Presidente da República') {
// let loader = this.toastService.loading();
// const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
// return {
// SourceTitle: e.Assunto,
// ParentId: "AGD_" + this.loggeduser.UserName + "_" + this.processeService.generateInstaceFormatDate(),
// Source: '1',
// SourceId: e.Id,
// ApplicationId: e.ApplicationType.toString(),
// Id: '',
// Link: '',
// SerialNumber: ''
// };
// });
// let body = this.eventToaproveBody(this.postEvent, CalendarId, this.loggeduser.RoleID, this.loggeduser.UserId, DocumentToSave);
// await this.processeService.createEventToAprove(this.postEvent.CalendarName, 'pr', body).subscribe((id) => {
// loader.remove()
// this.modalController.dismiss();
// this.hhtpErrorHandle.httpsSucessMessagge('new event to aprove')
// /* DocumentToSave.forEach((attachments, i) => {
// this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => {
// if (DocumentToSave.length == (i + 1)) {
// this.afterSave();
// }
// });
// });
// if (DocumentToSave.length == 0) {
// this.afterSave();
// } */
// }, (error) => {
// loader.remove()
// this.hhtpErrorHandle.httpStatusHandle(error)
// });
// } else if (selectedCalendar.Role = 'Ministro e Director do Gabinete do PR') {
// let loader = this.toastService.loading();
// const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
// return {
// SourceTitle: e.Assunto,
// ParentId: "AGD_" + this.loggeduser.UserName + "_" + this.processeService.generateInstaceFormatDate(),
// Source: '1',
// SourceId: e.Id,
// ApplicationId: e.ApplicationType.toString(),
// Id: '',
// Link: '',
// SerialNumber: ''
// };
// });
// let body = this.eventToaproveBody(this.postEvent, CalendarId, this.loggeduser.RoleID, this.loggeduser.UserId, DocumentToSave);
// await this.processeService.createEventToAprove(this.postEvent.CalendarName, 'md', body).subscribe((id) => {
// loader.remove()
// this.modalController.dismiss();
// this.hhtpErrorHandle.httpsSucessMessagge('new event to aprove')
// /* DocumentToSave.forEach((attachments, i) => {
// this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => {
// if (DocumentToSave.length == (i + 1)) {
// this.afterSave();
// }
// });
// });
// if (DocumentToSave.length == 0) {
// this.afterSave();
// } */
// }, (error) => {
// loader.remove()
// this.hhtpErrorHandle.httpStatusHandle(error)
// });
// }
// }
// if (!selectedCalendar && this.CalendarName == "Meu calendario") {
// console.log('SG generic')
// this.postEvent.CalendarName
// const CalendarId = this.selectedCalendarId()
// let loader = this.toastService.loading();
// this.postEvent.CalendarId = CalendarId
// this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe(
// (id) => {
// loader.remove();
// const eventId: any = id;
// const DocumentToSave: EventAttachment[] = this.documents.map((e) => {
// return {
// SourceTitle: e.Assunto,
// ParentId: eventId,
// Source: '1',
// SourceId: e.Id,
// ApplicationId: e.ApplicationType.toString(),
// Id: '',
// Link: '',
// SerialNumber: ''
// };
// });
// DocumentToSave.forEach((attachments, i) => {
// this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => {
// if (DocumentToSave.length == (i + 1)) {
// }
// });
// });
// if (DocumentToSave.length == 0) {
// }
// this.hhtpErrorHandle.httpsSucessMessagge('new event')
// let data = {
// "subject": this.postEvent.Subject,
// "start": this.postEvent.StartDate,
// "end": this.postEvent.EndDate,
// "venue": this.postEvent.Location,
// "id": id,
// "calendarId": CalendarId
// }
// if (this.roomId) {
// this.chatMethodService.sendMessage(this.roomId, data);
// }
// let dataa = Object.assign(this.postEvent, { id: eventId })
// this.modalController.dismiss(dataa);
// }, (error) => {
// loader.remove()
// this.hhtpErrorHandle.httpStatusHandle(error)
// });
// }
// }
// Deve ser removido posteriormente
eventToaproveBody(event, calendarId, role, userId, attachments) {
let toAproveObject = {
@@ -20,6 +20,8 @@ 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';
@Injectable({
providedIn: 'root'
@@ -156,7 +158,7 @@ export class AgendaDataRepositoryService {
}
}
createEvent(eventData: Event, documents, calendar: TableSharedCalendar) {
createEvent(eventData: Event, documents, calendar: TableSharedCalendar, tracing: TracingType) {
console.log('create repository 1',eventData, calendar)
let eventInput = {
@@ -181,10 +183,11 @@ export class AgendaDataRepositoryService {
console.log('create repository 2',eventInput)
APINODReturn(EventInputDTOSchema, eventInput, 'post/Events', tracing)
return this.agendaDataService.createEvent(eventInput)
}
updateEvent(eventId, eventData, editAllEvent, calendar: TableSharedCalendar) {
updateEvent(eventId, eventData, editAllEvent, calendar: TableSharedCalendar, tracing: TracingType) {
let body;
if(typeof eventData?.Body == 'object') {
@@ -212,7 +215,9 @@ export class AgendaDataRepositoryService {
}
console.log({eventData})
console.log({eventInput})
APINODReturn(EventUpdateInputDTOSchema, eventInput, 'PUT/Events', tracing)
return this.agendaDataService.updateEvent(eventId, eventInput)
}
@@ -1,34 +1,35 @@
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()
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()
docId: z.number(),
sourceName: z.string(),
description: z.string(),
applicationId: z.number()
});
const recurrenceSchema = z.object({
frequency: z.number(),
occurrences: z.number()
frequency: z.number(),
until: z.string().nullable().optional()
});
const EventInputDTOSchema = z.object({
export const EventInputDTOSchema = z.object({
userId: z.number(),
ownerType: z.number(),
ownerType: z.nativeEnum(EEventOwnerType),
subject: z.string(),
body: z.string(),
location: z.string(),
startDate: z.string().datetime(),
endDate: z.string().datetime(),
type: z.number(),
category: z.number(),
startDate: z.string(),
endDate: z.string(),
type: z.nativeEnum(EEventType),
category: z.nativeEnum(EEventCategory),
attendees: z.array(attendeeSchema),
attachments: z.array(attachmentSchema),
recurrence: recurrenceSchema,
@@ -36,7 +37,4 @@ const EventInputDTOSchema = z.object({
isAllDayEvent: z.boolean()
});
export type EventInputDTO = z.infer<typeof EventInputDTOSchema>
@@ -15,7 +15,7 @@ export const EventListOutputDTOSchema = z.object({
owner: OwnerSchema,
ownerType: z.nativeEnum(EEventOwnerType),// ['MD','PR', 'Other'] // Assuming "MD" is the only valid option based on provided data
subject: z.string(),
body: z.string(),
body: z.string().optional(),
location: z.string().nullable(),
startDate: z.string().datetime({ offset: true }),
endDate: z.string().datetime({ offset: true }),
@@ -15,7 +15,7 @@ const EventToApproveList = z.array(z.object({
owner: OwnerSchema,
ownerType: z.nativeEnum(EEventOwnerType),
subject: z.string(),
body: z.string(),
body: z.string().nullable().optional(),
location: z.string().nullable(),
startDate: z.string().datetime({ offset: true }),
endDate: z.string().datetime({ offset: true }),
@@ -0,0 +1,38 @@
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(),
until: z.string().nullable().optional()
});
export const EventUpdateInputDTOSchema = z.object({
userId: z.number(),
ownerType: z.nativeEnum(EEventOwnerType),
subject: z.string(),
body: z.string().optional(),
location: z.string(),
startDate: z.string(),
endDate: z.string(),
type: z.nativeEnum(EEventType),
category: z.nativeEnum(EEventCategory),
recurrence: recurrenceSchema,
isAllDayEvent: z.boolean(),
updateAllEvents: z.boolean()
});
export type EventUpdateInputDTO = z.infer<typeof EventUpdateInputDTOSchema>
@@ -74,7 +74,7 @@ const createTracingInstance = ({bugPrint, name, module, autoFinish}): TracingTyp
}
}
export function XTracerAsync({ name, bugPrint, module = null, autoFinish = true }) {
export function XTracerAsync({ name, bugPrint, module = null, autoFinish = true, daley =0 }) {
return (
target: unknown,
propertyKey: string,
@@ -98,7 +98,7 @@ export function XTracerAsync({ name, bugPrint, module = null, autoFinish = true
const result = await originalMethod.apply(this, args);
if(autoFinish) {
tracing.finish()
setTimeout(tracing.finish , daley)
}
return result
@@ -106,7 +106,7 @@ export function XTracerAsync({ name, bugPrint, module = null, autoFinish = true
tracing.setAttribute('catch', 'true')
if(autoFinish) {
tracing.finish()
setTimeout(tracing.finish , daley)
}
console.error(e);
return false
@@ -116,7 +116,7 @@ export function XTracerAsync({ name, bugPrint, module = null, autoFinish = true
}
export function XTracer({ name, bugPrint, module, autoFinish = true }) {
export function XTracer({ name, bugPrint, module, autoFinish = true, daley =0 }) {
return (
target: unknown,
propertyKey: string,
@@ -140,7 +140,7 @@ export function XTracer({ name, bugPrint, module, autoFinish = true }) {
if(autoFinish) {
tracing.finish()
setTimeout(tracing.finish , daley)
}
return result
} catch (e) {
@@ -148,7 +148,7 @@ export function XTracer({ name, bugPrint, module, autoFinish = true }) {
tracing.setAttribute('catch', 'true')
if(autoFinish) {
tracing.finish()
setTimeout(tracing.finish , daley)
}
console.error(e);
return false
@@ -15,9 +15,8 @@ import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { EventToApproveEdit } from 'src/app/models/event.model';
import { ThemeService } from 'src/app/services/theme.service'
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { DomSanitizerService } from 'src/app/services/DomSanitizer.service';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -137,7 +136,6 @@ export class EditEventToApprovePage implements OnInit {
private toastService: ToastService,
public ThemeService: ThemeService,
public httpErrorHandler: HttpErrorHandle,
private domSanitizeService: DomSanitizerService,
private agendaDataRepository: AgendaDataRepositoryService
) {
this.isEventEdited = false;
@@ -316,7 +314,8 @@ export class EditEventToApprovePage implements OnInit {
})
}
async save() {
@XTracerAsync({name:'desktop/edit-event', bugPrint: true, daley: 4000})
async save(tracing?: TracingType) {
this.injectValidation()
this.runValidation()
@@ -375,18 +374,21 @@ export class EditEventToApprovePage implements OnInit {
const calendar = await this.agendaDataRepository.getCalendarByUserId((this.eventProcess as any).owner.wxUserId)
if(calendar.isOk()) {
this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event, false, calendar.value).subscribe((value) => {
this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event, false, calendar.value, tracing).subscribe((value) => {
console.log(value)
this.close()
tracing.setAttribute('outcome', 'success')
}, ((error) => {
console.log('edit event error: ', error)
tracing.setAttribute('outcome', 'failed')
}));
this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, this.eventProcess.workflowInstanceDataFields.ParticipantsList).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add Attendee error: ', error)
tracing.setAttribute('failed.attendees', 'true')
}));
if (this.addedAttachmentsList.length > 0) {
@@ -395,6 +397,7 @@ export class EditEventToApprovePage implements OnInit {
}, ((error) => {
this.showLoader = false
console.log('add attachment error: ', error)
tracing.setAttribute('failed.add.attachment', 'true')
}));
}
@@ -404,6 +407,7 @@ export class EditEventToApprovePage implements OnInit {
}, ((error) => {
this.showLoader = false
console.log('remove attachment error: ', error)
tracing.setAttribute('failed.remove.attachment', 'true')
}));
}
@@ -19,6 +19,7 @@ import { Utils } from 'src/app/services/Repositorys/Agenda/utils';
import { Observable } from 'rxjs';
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { RoleIdService } from 'src/app/services/role-id.service'
import { XTracerAsync, TracingType } from 'src/app/services/monitoring/opentelemetry/tracer';
@Component({
selector: 'app-edit-event',
templateUrl: './edit-event.page.html',
@@ -413,7 +414,8 @@ export class EditEventPage implements OnInit {
}
}
async save_v2(editAllEvent) {
@XTracerAsync({name:'desktop/edit-event', bugPrint: true, daley: 4000})
async save_v2(editAllEvent, tracing?: TracingType) {
this.injectValidation()
this.runValidation()
@@ -431,7 +433,7 @@ export class EditEventPage implements OnInit {
if(calendar.isOk()) {
this.showLoader = true;
this.agendaDataRepository.updateEvent(this._postEvent.EventId, this._postEvent, editAllEvent, calendar.value).subscribe((value) => {
this.agendaDataRepository.updateEvent(this._postEvent.EventId, this._postEvent, editAllEvent, calendar.value, tracing).subscribe((value) => {
console.log(value)
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
@@ -439,14 +441,17 @@ export class EditEventPage implements OnInit {
this.deleteTemporaryData();
this.showLoader = false;
this.close();
tracing.setAttribute('outcome', 'success')
}, ((error) => {
console.log('edit event error: ', error)
tracing.setAttribute('outcome', 'failed')
}));
this.agendaDataRepository.addEventAttendee(this._postEvent.EventId, this._postEvent.Attendees).subscribe((value) => {
console.log(value)
}, ((error) => {
tracing.setAttribute('failed.attendees', 'true')
console.log('add Attendee error: ', error)
}));
@@ -456,6 +461,7 @@ export class EditEventPage implements OnInit {
console.log(value)
}, ((error) => {
this.showLoader = false
tracing.setAttribute('failed.add.attachment', 'true')
console.log('add attachment error: ', error)
}));
}
@@ -32,6 +32,7 @@ import { ChangeProfileService } from 'src/app/services/change-profile.service';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { RoleIdService } from 'src/app/services/role-id.service'
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
@@ -219,8 +220,6 @@ export class NewEventPage implements OnInit {
this.setIntervenientCC.emit(this.taskParticipantsCc);
this.setDefaultTime();
} else {
this.hasChangeCalendar = true
}
@@ -548,7 +547,8 @@ export class NewEventPage implements OnInit {
}
async save_v2() {
@XTracerAsync({name:'desktop/create-event', bugPrint: true})
async save_v2(tracing?: TracingType) {
this.injectValidation()
this.runValidation()
@@ -567,16 +567,22 @@ export class NewEventPage implements OnInit {
const calendar = await this.agendaDataRepository.getCalendarByUserId(this.selectedUserCalendar)
if(calendar.isOk()) {
this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value).subscribe((value) => {
try {
const value = await this.agendaDataRepository.createEvent(this.postEvent, this.documents, calendar.value, tracing).toPromise()
console.log(value)
this.afterSave();
this.hhtpErrorHandle.httpsSucessMessagge('new event')
loader.remove();
}, ((error) => {
tracing.setAttribute('outcome', 'success')
} catch (error) {
console.log('create event error: ', error)
tracing.setAttribute('outcome', 'failed')
loader.remove();
this.hhtpErrorHandle.httpStatusHandle(error.status)
}));
}
} else {
}
@@ -634,7 +640,8 @@ export class NewEventPage implements OnInit {
segment: this.segment,
CalendarName: this.CalendarName,
documents: this.documents,
selectedUserCalendar: this.selectedUserCalendar
selectedUserCalendar: this.selectedUserCalendar,
hasChangeCalendar: this.hasChangeCalendar
}
}
@@ -655,6 +662,7 @@ export class NewEventPage implements OnInit {
this.CalendarName = restoredData.CalendarName
this.documents = restoredData.documents
this.selectedUserCalendar = restoredData.selectedUserCalendar
this.hasChangeCalendar = restoredData.hasChangeCalendar
// restore dater for date and hours picker
@@ -184,7 +184,7 @@
</div>
</div>
</div> -->
<!--
<!--
<div *ngIf="eventProcess.workflowInstanceDataFields.OccurrenceType != '-1'"
class="container-div width-100">
<div class="ion-item-class-2 d-flex">
@@ -15,6 +15,7 @@ import { NavigationExtras, Router } from '@angular/router';
import { ThemeService } from 'src/app/services/theme.service'
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
@@ -51,7 +52,6 @@ export class EditEventToApproveComponent implements OnInit {
public stepHour = 1;
public stepMinute = 15;
public stepSecond = 5;
recurringTypes: any;
selectedRecurringType: any;
currentDate = new Date()
@@ -135,7 +135,6 @@ export class EditEventToApproveComponent implements OnInit {
ngOnInit() {
console.log('Here you ares')
this.getTask()
this.getRecurrenceTypes();
}
ngOnDestroy() {
@@ -199,12 +198,6 @@ export class EditEventToApproveComponent implements OnInit {
/* }) */
}
getRecurrenceTypes() {
this.eventsService.getRecurrenceTypes().subscribe(res => {
this.recurringTypes = res;
});
}
onSelectedRecurringChanged(ev: any) {
@@ -270,7 +263,8 @@ export class EditEventToApproveComponent implements OnInit {
this.modalController.dismiss();
}
async save() {
@XTracerAsync({name:'desktop/edit-event', bugPrint: true, daley: 4000})
async save(tracing?: TracingType) {
// set dates to eventProcess object
this.taskParticipantsCc.forEach(e => {
@@ -319,20 +313,23 @@ export class EditEventToApproveComponent implements OnInit {
const calendar = await this.agendaDataRepository.getCalendarByUserId((this.eventProcess as any).owner.wxUserId)
if(calendar.isOk()) {
this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event,false, calendar.value).subscribe((value) => {
this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event,false, calendar.value, tracing).subscribe((value) => {
console.log(value)
this.httpErroHalde.httpsSucessMessagge('Editar evento')
window['approve-event-getTask']()
this.close();
tracing.setAttribute('outcome', 'success')
}, ((error) => {
this.httpErroHalde.httpStatusHandle(error)
console.log('edit event error: ', error)
tracing.setAttribute('outcome', 'failed')
}));
this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, this.eventProcess.workflowInstanceDataFields.ParticipantsList).subscribe((value) => {
console.log(value)
}, ((error) => {
console.log('add Attendee error: ', error)
tracing.setAttribute('failed.attendees', 'true')
}));
@@ -342,6 +339,7 @@ export class EditEventToApproveComponent implements OnInit {
}, ((error) => {
this.showLoader = false
console.log('add attachment error: ', error)
tracing.setAttribute('failed.add.attachment', 'true')
}));
}
@@ -351,6 +349,7 @@ export class EditEventToApproveComponent implements OnInit {
}, ((error) => {
this.showLoader = false
console.log('remove attachment error: ', error)
tracing.setAttribute('failed.remove.attachment', 'true')
}));
}
+6 -6
View File
@@ -1,11 +1,11 @@
export let versionData = {
"shortSHA": "558810ab8",
"SHA": "558810ab83f47b59507765552673fd0b687155f2",
"shortSHA": "0c14b9be9",
"SHA": "0c14b9be979f22b13e627b978767be4a173d9768",
"branch": "feature/agenda-api-peter",
"lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Fri Jun 21 16:43:02 2024 +0100'",
"lastCommitMessage": "include husky change to the commit",
"lastCommitNumber": "5835",
"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/pages/agenda/edit-event/edit-event.page.html\n\tmodified: src/app/pages/agenda/new-event/new-event.page.html\n\tmodified: src/app/pages/agenda/new-event/new-event.page.ts\n\tmodified: src/app/pages/gabinete-digital/event-list/event-list.page.html\n\tmodified: src/app/pages/gabinete-digital/event-list/event-list.page.ts\n\tmodified: src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts\n\tmodified: src/app/services/Repositorys/Agenda/utils.ts\n\tmodified: src/app/services/decorator/api-validate-schema.decorator.ts\n\tmodified: src/app/services/task.service.ts\n\tmodified: src/app/shared/agenda/event-list/event-list.page.html\n\tmodified: src/app/shared/agenda/new-event/new-event.page.ts\n\tmodified: src/app/shared/gabinete-digital/events-to-approve/events-to-approve.page.html\n\tmodified: version/git-version.ts",
"lastCommitTime": "'Fri Jun 21 23:33:29 2024 +0100'",
"lastCommitMessage": "fix ownertype and category type",
"lastCommitNumber": "5836",
"changeStatus": "On branch feature/agenda-api-peter\nYour branch is ahead of 'origin/feature/agenda-api-peter' by 7 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: angular.json\n\tmodified: src/app/interceptors/metter.interceptor.ts\n\tmodified: src/app/pages/agenda/edit-event/edit-event.page.html\n\tmodified: src/app/pages/agenda/edit-event/edit-event.page.ts\n\tmodified: src/app/pages/agenda/new-event/new-event.page.ts\n\tmodified: src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts\n\tmodified: src/app/services/Repositorys/Agenda/model/eventInputDTO.ts\n\tmodified: src/app/services/Repositorys/Agenda/model/eventListDTOOutput.ts\n\tmodified: src/app/services/Repositorys/Agenda/model/eventToApproveListOutputDTO.ts\n\tnew file: src/app/services/Repositorys/Agenda/model/eventUpdateInputDtO.ts\n\tmodified: src/app/services/monitoring/opentelemetry/tracer.ts\n\tmodified: src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts\n\tmodified: src/app/shared/agenda/edit-event/edit-event.page.ts\n\tmodified: src/app/shared/agenda/new-event/new-event.page.ts\n\tmodified: src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html\n\tmodified: src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts\n\tmodified: version/git-version.ts",
"changeAuthor": "peter.maquiran"
}