mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
merge made with peter branch
This commit is contained in:
@@ -17,6 +17,8 @@ import { RouteService } from 'src/app/services/route.service';
|
||||
import { SessionStore } from 'src/app/store/session.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';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-event',
|
||||
@@ -119,76 +121,32 @@ export class ViewEventPage implements OnInit {
|
||||
ev.target.complete();
|
||||
}
|
||||
|
||||
async loadEvent() {
|
||||
@XTracerAsync({name:'ViewEventPage/loadEvent', log: false, bugPrint: true})
|
||||
async loadEvent(tracing?: TracingType) {
|
||||
const loader = this.toastService.loading();
|
||||
|
||||
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
|
||||
this.eventsService.getEvent(this.eventId).subscribe(res => {
|
||||
this.loadedEvent = res;
|
||||
// this.addEventToDb(res);
|
||||
|
||||
loader.remove()
|
||||
}, (error) => {
|
||||
|
||||
|
||||
if (error.status === 0) {
|
||||
// this.getFromDb();
|
||||
} else {
|
||||
this.toastService.badRequest('Este evento já não existe na sua agenda')
|
||||
loader.remove()
|
||||
this.modalController.dismiss('Eevent not Foud');
|
||||
this.RouteService.goBack();
|
||||
}
|
||||
loader.remove()
|
||||
});
|
||||
} else {
|
||||
|
||||
if(this.CalendarId) {
|
||||
|
||||
this.eventsService.genericGetEvent(this.eventId, this.CalendarId).subscribe(res => {
|
||||
this.loadedEvent = res;
|
||||
// this.addEventToDb(res);
|
||||
|
||||
loader.remove()
|
||||
}, (error) => {
|
||||
|
||||
if (error.status === 0) {
|
||||
// this.getFromDb();
|
||||
} else {
|
||||
this.toastService.badRequest('Este evento já não existe na sua agenda')
|
||||
loader.remove()
|
||||
this.modalController.dismiss('Eevent not Foud');
|
||||
this.RouteService.goBack();
|
||||
}
|
||||
loader.remove()
|
||||
});
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
let res = await this.agendaDataRepository.getEventById(this.eventId)
|
||||
let res = await this.agendaDataRepository.getEventById(this.eventId, tracing)
|
||||
|
||||
if(res.isOk()) {
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
this.loadedEvent = res.value as any;
|
||||
// this.addEventToDb(res);
|
||||
|
||||
loader.remove()
|
||||
} else {
|
||||
if (res.error.status === 0) {
|
||||
// this.getFromDb();
|
||||
} else {
|
||||
this.toastService.badRequest('Este evento já não existe na sua agenda')
|
||||
loader.remove()
|
||||
this.modalController.dismiss('Eevent not Foud');
|
||||
this.RouteService.goBack();
|
||||
tracing.setAttribute('eventId', this.eventId)
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.bugFlag()
|
||||
|
||||
if(!isHttpError(res.error)) {
|
||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #13')
|
||||
} else if (isHttpError(res.error)) {
|
||||
|
||||
}
|
||||
loader.remove()
|
||||
this.modalController.dismiss('Eevent not Foud');
|
||||
this.RouteService.goBack();
|
||||
}
|
||||
|
||||
loader.remove()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
|
||||
|
||||
|
||||
import { EEventType } from "src/app/services/Repositorys/Agenda/model/enums";
|
||||
import { z } from "zod";
|
||||
|
||||
const ParticipantSchema = z.object({
|
||||
@@ -106,7 +107,7 @@ const WorkflowInstanceDataFieldsSchema = z.object({
|
||||
Status: z.string(),
|
||||
TimeZone: z.string().nullable(),
|
||||
Agenda: z.string(),
|
||||
EventType: z.string(),
|
||||
EventType: z.nativeEnum(EEventType),
|
||||
EventID: z.string().nullable(),
|
||||
HasAttachments: z.boolean(),
|
||||
ParticipantsList: z.array(ParticipantSchema),
|
||||
@@ -155,8 +156,16 @@ const Attachments = z.object({
|
||||
FileSize: z.number().optional(),
|
||||
});
|
||||
|
||||
const OwnerSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string(),
|
||||
});
|
||||
|
||||
|
||||
const EventToApproveDetails = z.object({
|
||||
owner: OwnerSchema,
|
||||
serialNumber: z.string(),
|
||||
taskStatus: z.string().nullable(),
|
||||
originator: OriginatorSchema,
|
||||
|
||||
@@ -700,8 +700,6 @@ export class AgendaPage implements OnInit {
|
||||
} catch (error) {}
|
||||
|
||||
|
||||
console.log('selectedCalendarIds', selectedCalendarIds)
|
||||
|
||||
let load = 0;
|
||||
for (const selectedCalendar of selectedCalendarIds) {
|
||||
|
||||
@@ -713,7 +711,7 @@ export class AgendaPage implements OnInit {
|
||||
calendarOwnerName: selectedCalendar.wxFullName,
|
||||
endDate: endTime.toISOString(),
|
||||
startDate: startTime.toISOString(),
|
||||
status: EEventFilterStatus.Approved
|
||||
status: EEventFilterStatus.AllToCommunicate
|
||||
}, tracing)
|
||||
|
||||
if(response.isOk()) {
|
||||
@@ -748,6 +746,7 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
if(!isHttpError(response.error)) {
|
||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #1')
|
||||
console.log(response.error)
|
||||
}
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
<ion-label class="width-100 d-flex " (click)="docIndex(i);LoadDocumentDetails()">
|
||||
<p class="flex-grow-1" >
|
||||
<span class="attach-title-item d-block">{{attach.SourceName || attach.subject || attach.sourceName || 'Sem título'}}</span>
|
||||
|
||||
|
||||
<span class="span-left d-block">{{attach.Stakeholders}}</span>
|
||||
</p>
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { DateService } from 'src/app/services/date.service';
|
||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-event',
|
||||
@@ -189,33 +191,51 @@ export class ViewEventPage implements OnInit {
|
||||
this.TimeZoneString = this.loadedEvent.TimeZone
|
||||
}
|
||||
|
||||
async loadEvent() {
|
||||
@XTracerAsync({name:'ViewEventPage/loadEvent', log: false, bugPrint: true})
|
||||
async loadEvent(tracing?: TracingType) {
|
||||
const loader = this.toastService.loading();
|
||||
|
||||
let res = await this.agendaDataRepository.getEventById(this.eventId)
|
||||
let res = await this.agendaDataRepository.getEventById(this.eventId, tracing)
|
||||
|
||||
if (res.isOk()) {
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
console.log('Loaded Event', res.value)
|
||||
loader.remove()
|
||||
/* let changeDate = this.dateService.fixDate(res.value as any) as any */
|
||||
this.loadedEvent = res.value as any;
|
||||
this.setTimeZone()
|
||||
} else {
|
||||
this.httpErrorHandle.httpStatusHandle(res.error)
|
||||
loader.remove()
|
||||
this.toastService.badRequest('Este evento já não existe na sua agenda')
|
||||
|
||||
tracing.setAttribute('eventId', this.eventId)
|
||||
if(!isHttpError(res.error)) {
|
||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #13')
|
||||
console.log(res.error)
|
||||
} else if (isHttpError(res.error)) {
|
||||
if(res.error.status == 404) {
|
||||
this.toastService._badRequest('Este evento já não existe')
|
||||
} else {
|
||||
this.httpErrorHandle.httpStatusHandle(res.error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.bugFlag()
|
||||
|
||||
// this.toastService.badRequest('Este evento já não existe na sua agenda')
|
||||
this.RouteService.goBack();
|
||||
}
|
||||
|
||||
loader.remove()
|
||||
|
||||
}
|
||||
|
||||
/* loadEvent1() {
|
||||
|
||||
|
||||
|
||||
|
||||
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
|
||||
this.eventsService.getEvent(this.eventId).subscribe(res => {
|
||||
|
||||
|
||||
res = this.dateService.fixDate(res as any)
|
||||
this.loadedEvent = res;
|
||||
this.setTimeZone()
|
||||
@@ -223,22 +243,22 @@ export class ViewEventPage implements OnInit {
|
||||
}, (error) => {
|
||||
});
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
|
||||
if(this.CalendarId) {
|
||||
this.eventsService.genericGetEvent(this.eventId, this.CalendarId).subscribe(res => {
|
||||
|
||||
|
||||
res = this.dateService.fixDate(res as any)
|
||||
this.loadedEvent = res;
|
||||
this.setTimeZone()
|
||||
|
||||
|
||||
}, (error) => {
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} */
|
||||
|
||||
deleteYesOrNo() {
|
||||
@@ -264,7 +284,7 @@ export class ViewEventPage implements OnInit {
|
||||
} else {
|
||||
this.deleteEvent(false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -299,7 +319,7 @@ export class ViewEventPage implements OnInit {
|
||||
res.present();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
deleteEvent(deleteAll) {
|
||||
@@ -337,7 +357,7 @@ export class ViewEventPage implements OnInit {
|
||||
header: 'Evento removido',
|
||||
buttons: ['OK']
|
||||
});
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
alert.dismiss();
|
||||
}, 1500);
|
||||
@@ -347,16 +367,16 @@ export class ViewEventPage implements OnInit {
|
||||
() => {
|
||||
loader.remove();
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, this.loadedEvent.CalendarId).subscribe(async () => {
|
||||
const alert = await this.alertController.create({
|
||||
cssClass: 'my-custom-class',
|
||||
header: 'Evento removido',
|
||||
buttons: ['OK']
|
||||
});
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
alert.dismiss();
|
||||
}, 1500);
|
||||
@@ -368,8 +388,8 @@ export class ViewEventPage implements OnInit {
|
||||
() => {
|
||||
loader.remove();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
} */
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import { ChangeProfileService } from 'src/app/services/change-profile.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { TaskService } from 'src/app/services/task.service';
|
||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||
import { EEventFilterStatus } from 'src/app/services/Repositorys/Agenda/model/enums';
|
||||
|
||||
@Component({
|
||||
selector: 'app-events',
|
||||
@@ -237,7 +238,8 @@ export class EventsPage implements OnInit {
|
||||
userId: SessionStore.user.UserId,
|
||||
calendarOwnerName: SessionStore.user.FullName,
|
||||
startDate: date.toISOString(),
|
||||
endDate: new Date(end).toISOString()
|
||||
endDate: new Date(end).toISOString(),
|
||||
status: EEventFilterStatus.AllToCommunicate
|
||||
})
|
||||
|
||||
if(response.isOk()) {
|
||||
|
||||
@@ -17,6 +17,9 @@ import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { TaskService } from 'src/app/services/task.service';
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
import { EventsService } from 'src/app/services/events.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-approve-event',
|
||||
@@ -59,7 +62,8 @@ export class ApproveEventPage implements OnInit {
|
||||
private httpErrorHandle: HttpErrorHandle,
|
||||
public TaskService: TaskService,
|
||||
private attachmentsService: AttachmentsService,
|
||||
public AgendaDataRepositoryService: AgendaDataRepositoryService
|
||||
public AgendaDataRepositoryService: AgendaDataRepositoryService,
|
||||
public EventsService: EventsService
|
||||
) {
|
||||
this.activatedRoute.paramMap.subscribe(params => {
|
||||
//
|
||||
@@ -95,19 +99,38 @@ export class ApproveEventPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
async getTask() {
|
||||
@XTracerAsync({name:'ApproveEventPage/getTask', log: false, bugPrint: true})
|
||||
async getTask(tracing?: TracingType) {
|
||||
|
||||
const res = await this.AgendaDataRepositoryService.getEventToApproveById(this.serialNumber)
|
||||
console.log(res)
|
||||
const res = await this.AgendaDataRepositoryService.getEventToApproveById(this.serialNumber, tracing)
|
||||
if (res.isOk()) {
|
||||
this.loadedEvent = res.value;
|
||||
this.today = new Date(res.value.workflowInstanceDataFields.StartDate);
|
||||
|
||||
//
|
||||
this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
|
||||
this.loadedAttachments = res.value.Attachments
|
||||
} else {
|
||||
console.log(res.error.status)
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
} else if(isHttpError(res.error)) {
|
||||
|
||||
tracing.setAttribute('eventId', this.serialNumber)
|
||||
|
||||
if(res.error.status == 404) {
|
||||
this.toastService._badRequest('Este evento já não existe')
|
||||
} else {
|
||||
this.httpErrorHandle.httpStatusHandle(res.error)
|
||||
}
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.bugFlag()
|
||||
|
||||
this.httpErrorHandle.httpStatusHandle(res.error)
|
||||
} else if(!isHttpError(res.error)) {
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.bugFlag()
|
||||
|
||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #12')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ export class EventListPage implements OnInit {
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
|
||||
userId,
|
||||
status: EEventFilterStatus.Pending
|
||||
})
|
||||
}, tracing)
|
||||
|
||||
if(allEvents.isOk()) {
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
|
||||
@@ -14,6 +14,10 @@ import { AgendaLocalDataSourceService } from './agenda-local-data-source.service
|
||||
import { EEventFilterStatus } from './model/enums';
|
||||
import { isHttpError } from '../../http.service';
|
||||
import { TracingType } from '../../monitoring/opentelemetry/tracer';
|
||||
import { APINODReturn, APIReturn } from '../../decorator/api-validate-schema.decorator';
|
||||
import { EventListDataOutputDTOSchema, EventListOutputDTOSchema } from './model/eventListDTOOutput';
|
||||
import { EventToApproveDataOutputDTOSchema } from './model/eventToApproveListOutputDTO';
|
||||
import { EventOutputDTOSchema } from './model/eventDTOOutput';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -40,33 +44,57 @@ export class AgendaDataRepositoryService {
|
||||
return this.agendaLocalDataSourceService.createCalendar(currentUserCalendar)
|
||||
}
|
||||
|
||||
async getEventById(id: string) {
|
||||
async getEventById(id: string, tracing?: TracingType) {
|
||||
try {
|
||||
const result = await this.agendaDataService.getEvent(id).pipe(
|
||||
map((response) => {
|
||||
console.log('Response', response.data)
|
||||
console.log('Output', EventMapper.toDomain(response.data))
|
||||
return EventMapper.toDomain(response.data)
|
||||
EventMapper.toDomain(response)
|
||||
return EventMapper.toDomain(response)
|
||||
})
|
||||
).toPromise()
|
||||
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?.bugFlag()
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
}
|
||||
|
||||
async getEventToApproveById(id: string) {
|
||||
async getEventToApproveById(id: string, tracing?: TracingType) {
|
||||
|
||||
try {
|
||||
const result = await this.agendaDataService.getEvent(id).pipe(
|
||||
map((response) => {
|
||||
console.log('response',response)
|
||||
console.log('ToDomain',EventToApproveDetailsMapper.toDomain(response.data))
|
||||
return EventToApproveDetailsMapper.toDomain(response.data)
|
||||
console.log('ToDomain',EventToApproveDetailsMapper.toDomain(response))
|
||||
APINODReturn(EventOutputDTOSchema, response, 'get/Events/${id}', tracing)
|
||||
return EventToApproveDetailsMapper.toDomain(response)
|
||||
})
|
||||
).toPromise()
|
||||
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?.bugFlag()
|
||||
tracing?.setAttribute('outcome', 'failed')
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
|
||||
@@ -77,7 +105,8 @@ export class AgendaDataRepositoryService {
|
||||
try {
|
||||
const result = await this.agendaDataService.getEvents(userId, startDate, endDate, status, category, type).pipe(
|
||||
map((response) => {
|
||||
return ListEventMapper.toDomain(response.data, calendarOwnerName, userId)
|
||||
APINODReturn(EventListDataOutputDTOSchema, response, 'get/Events', tracing)
|
||||
return ListEventMapper.toDomain(response, calendarOwnerName, userId)
|
||||
}
|
||||
)).toPromise()
|
||||
return ok(result)
|
||||
@@ -85,8 +114,8 @@ export class AgendaDataRepositoryService {
|
||||
if(isHttpError(e)) {
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
} else {
|
||||
console.error(e)
|
||||
tracing?.setAttribute('map.error', JSON.stringify(e.error))
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
@@ -95,9 +124,10 @@ export class AgendaDataRepositoryService {
|
||||
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).pipe(
|
||||
const result = await this.agendaDataService.getEvents(userId, startDate = null, endDate = null, status, category = null, type = null, tracing).pipe(
|
||||
map((response) => {
|
||||
return EventListToApproveMapper.toDomain(response.data, calendarOwnerName, userId)
|
||||
APINODReturn(EventToApproveDataOutputDTOSchema, response, 'get/ApproveList', tracing)
|
||||
return EventListToApproveMapper.toDomain(response, calendarOwnerName, userId)
|
||||
}
|
||||
)).toPromise()
|
||||
|
||||
@@ -106,8 +136,8 @@ export class AgendaDataRepositoryService {
|
||||
if(isHttpError(e)) {
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
} else {
|
||||
console.error(e)
|
||||
tracing?.setAttribute('map.error', JSON.stringify(e.error))
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import { SessionStore } from 'src/app/store/session.service';
|
||||
import { SharedCalendarListOutputDTO, SharedCalendarListOutputDTOSchema } from './model/sharedCalendarOutputDTO';
|
||||
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';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -45,7 +48,8 @@ export class AgendaDataService {
|
||||
return this.http.post<any>(`${this.baseUrl}/Events`, eventData);
|
||||
}
|
||||
|
||||
getEvents(userId: number, startDate: string, endDate: string, status: number, category: string, type: string): Observable<any> {
|
||||
// @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)
|
||||
|
||||
@@ -69,7 +73,7 @@ export class AgendaDataService {
|
||||
return this.http.get<any>(`${this.baseUrl}/Events`, { params });
|
||||
}
|
||||
|
||||
getEvent(id: string): Observable<any> {
|
||||
getEvent(id: string): Observable<EventOutputDTO> {
|
||||
return this.http.get<any>(`${this.baseUrl}/Events/${id}`);
|
||||
}
|
||||
|
||||
@@ -131,7 +135,7 @@ export class AgendaDataService {
|
||||
}
|
||||
|
||||
|
||||
@APIReturn(SharedCalendarListOutputDTOSchema)
|
||||
// @APIReturn(SharedCalendarListOutputDTOSchema, 'Users/${SessionStore.user.UserId}/ShareCalendar')
|
||||
async getSharedCalendar() {
|
||||
return await this.httpService.get<SharedCalendarListOutputDTO>(`${this.baseUrl}/Users/${SessionStore.user.UserId}/ShareCalendar`);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,9 @@ function getTextInsideParentheses(inputString) {
|
||||
export class EventMapper {
|
||||
|
||||
constructor() {}
|
||||
static toDomain(dto: EventOutputDTO) {
|
||||
static toDomain(_dto: EventOutputDTO) {
|
||||
|
||||
const dto = _dto.data;
|
||||
|
||||
let category;
|
||||
if(dto.category == EEventCategory.Oficial) {
|
||||
@@ -51,7 +53,9 @@ export class EventMapper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
"owner": dto.owner,
|
||||
"HasAttachments": dto.hasAttachments,
|
||||
"EventComunicationId": 1682,
|
||||
"EventId": dto.id,
|
||||
@@ -74,7 +78,7 @@ export class EventMapper {
|
||||
IsRequired: FEAttendeeType(e.attendeeType) == 'Required',
|
||||
UserType: "GD",
|
||||
// "IsPR": false,
|
||||
attendeeType: FEAttendeeType(e.attendeeType)
|
||||
attendeeType: FEAttendeeType(e.attendeeType)
|
||||
// "RoleDescription": null,
|
||||
// "RoleId": 0
|
||||
})),
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ListEventMapper {
|
||||
// @XTracer({name:'ListEventMapper/toDomain', log: false, bugPrint: false})
|
||||
static toDomain(dto: EventListOutputDTO, calendarOwnerName: string, userId: string): EventList {
|
||||
|
||||
return dto.map((e) => {
|
||||
return dto.data.map((e) => {
|
||||
|
||||
let category;
|
||||
if(e.category == EEventCategory.Oficial) {
|
||||
|
||||
@@ -16,7 +16,9 @@ function getTextInsideParentheses(inputString) {
|
||||
export class EventToApproveDetailsMapper {
|
||||
|
||||
constructor() {}
|
||||
static toDomain(dto: EventOutputDTO): EventToApproveDetails {
|
||||
static toDomain(_dto: EventOutputDTO): EventToApproveDetails {
|
||||
|
||||
let dto = _dto.data
|
||||
|
||||
let category;
|
||||
if(dto.category == EEventCategory.Oficial) {
|
||||
@@ -26,6 +28,11 @@ export class EventToApproveDetailsMapper {
|
||||
}
|
||||
|
||||
let color;
|
||||
if(dto.ownerType == EEventOwnerType.PR) {
|
||||
color = 'PR'
|
||||
} else {
|
||||
color = 'MDGPR'
|
||||
}
|
||||
|
||||
// if(dto.ownerType != 'PR') {
|
||||
let ownerType;
|
||||
@@ -36,7 +43,7 @@ export class EventToApproveDetailsMapper {
|
||||
} else if(dto.ownerType == EEventOwnerType.Others) {
|
||||
ownerType = 'Other'
|
||||
}
|
||||
|
||||
|
||||
let activityInstanceName;
|
||||
let taskStatus;
|
||||
|
||||
@@ -69,9 +76,11 @@ export class EventToApproveDetailsMapper {
|
||||
return 'Optional'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return {
|
||||
"owner": dto.owner,
|
||||
"serialNumber": dto.id,
|
||||
"taskStatus": taskStatus,
|
||||
"originator": {
|
||||
|
||||
@@ -19,7 +19,7 @@ export class EventListToApproveMapper {
|
||||
static toDomain(dtoList: EventToApproveListOutputDTO, calendarOwnerName: string, userId: string): EventToApproveList {
|
||||
|
||||
|
||||
return dtoList.map((dto) => {
|
||||
return dtoList.data.map((dto) => {
|
||||
|
||||
let category;
|
||||
if(dto.category == EEventCategory.Oficial) {
|
||||
@@ -27,7 +27,7 @@ export class EventListToApproveMapper {
|
||||
} else {
|
||||
category = 'Pessoal'
|
||||
}
|
||||
|
||||
|
||||
let color;
|
||||
let workflowDisplayName;
|
||||
|
||||
@@ -112,7 +112,3 @@ export class EventListToApproveMapper {
|
||||
// "InstanceId": "AAMkADVhOGY3ZDQzLTg4ZGEtNDYxMC1iMzc5LTJkMDgwNjMxOWFlZQBGAAAAAABEDW9nKs69TKQcVqQURj8YBwBR2HR2eO7pSpNdD9cc70l+AAAAAAFKAABR2HR2eO7pSpNdD9cc70l+AACK2Od9AAA=",
|
||||
// "originator": "dlima@gabinetedigital.local"
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { z } from 'zod';
|
||||
import { EAttendeeType, EEventCategory, EEventOwnerType, EEventStatus, EEventType } from './enums';
|
||||
|
||||
export const AttachmentInputDTOSchema = z.object({
|
||||
id: z.string().nullable(),
|
||||
@@ -7,7 +8,7 @@ export const AttachmentInputDTOSchema = z.object({
|
||||
description: z.string().nullable(),
|
||||
applicationId: z.number().int(),
|
||||
}).strict();
|
||||
const EAttendeeTypeDTO = z.enum(["Required", "Acknowledgment", "Optional"]);
|
||||
const EAttendeeTypeDTO = z.nativeEnum(EAttendeeType);
|
||||
|
||||
|
||||
const CommentSchema = z.object({
|
||||
@@ -18,7 +19,7 @@ const CommentSchema = z.object({
|
||||
const AttendeeSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
attendeeType: z.enum(["Required", "Acknowledgment", "Optional"]), // ["Required", "Acknowledgment", "Optional"] = [1,2,3]
|
||||
attendeeType: z.nativeEnum(EAttendeeType), // ["Required", "Acknowledgment", "Optional"] = [1,2,3]
|
||||
emailAddress: z.string(),
|
||||
wxUserId: z.number(),
|
||||
});
|
||||
@@ -47,27 +48,32 @@ const EventRecurrenceSchema = z.object({
|
||||
until: z.string()
|
||||
});
|
||||
|
||||
|
||||
export const EventOutputDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
owner: OwnerSchema,
|
||||
ownerType: z.number(), // ["PR", "MD", "Other"] = [1,2,3],
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string(),
|
||||
startDate: z.string(),
|
||||
endDate: z.string(),
|
||||
type: z.string(),
|
||||
category: z.number(), // ['Oficial', 'Pessoal'] = [1, 2]
|
||||
attendees: z.array(AttendeeSchema),
|
||||
isRecurring: z.boolean(),
|
||||
eventRecurrence: EventRecurrenceSchema,
|
||||
hasAttachments: z.boolean(),
|
||||
attachments: z.array(AttachmentInputDTOSchema),
|
||||
comments: z.array(CommentSchema),
|
||||
isPrivate: z.boolean(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
organizer: OrganizerSchema,
|
||||
status: z.number(), // ['Pending', 'Revision', 'Approved', 'Declined', 'Communicated', 'ToCommunicate'] = [1, 2, 3, 4, 5, 6]
|
||||
});
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
owner: OwnerSchema,
|
||||
ownerType: z.nativeEnum(EEventOwnerType), // ["PR", "MD", "Other"] = [1,2,3],
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string(),
|
||||
startDate: z.string(),
|
||||
endDate: z.string(),
|
||||
type: z.nativeEnum(EEventType),
|
||||
category: z.nativeEnum(EEventCategory), // ['Oficial', 'Pessoal'] = [1, 2]
|
||||
attendees: z.array(AttendeeSchema),
|
||||
isRecurring: z.boolean(),
|
||||
eventRecurrence: EventRecurrenceSchema,
|
||||
hasAttachments: z.boolean(),
|
||||
attachments: z.array(AttachmentInputDTOSchema),
|
||||
comments: z.array(CommentSchema),
|
||||
isPrivate: z.boolean(),
|
||||
isAllDayEvent: z.boolean(),
|
||||
organizer: OrganizerSchema,
|
||||
status: z.nativeEnum(EEventStatus), // ['Pending', 'Revision', 'Approved', 'Declined', 'Communicated', 'ToCommunicate'] = [1, 2, 3, 4, 5, 6]
|
||||
}),
|
||||
}).nullable();
|
||||
|
||||
export type EventOutputDTO = z.infer<typeof EventOutputDTOSchema>
|
||||
|
||||
@@ -1,25 +1,40 @@
|
||||
import { z } from 'zod';
|
||||
import { EEventCategory, EEventOwnerType, EEventStatus, EEventType } from './enums';
|
||||
|
||||
const EventSchema = z.array(z.object({
|
||||
|
||||
const OwnerSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string(),
|
||||
});
|
||||
|
||||
|
||||
export const EventListOutputDTOSchema = z.object({
|
||||
id: z.string(),
|
||||
owner: z.string().nullable(),
|
||||
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(),
|
||||
location: z.string(),
|
||||
location: z.string().nullable(),
|
||||
startDate: z.string().datetime({ offset: true }),
|
||||
endDate: z.string().datetime({ offset: true }),
|
||||
type: z.nativeEnum(EEventType), // ['Meeting', 'Travel'] = [1,2 ]
|
||||
// category: z.enum(['Oficial', 'Pessoal']), // Assuming "Oficial" is the only valid option based on provided data
|
||||
category: z.nativeEnum(EEventCategory),
|
||||
isRecurring: z.boolean(),
|
||||
eventRecurrence: z.null(),
|
||||
eventRecurrence: z.any().nullable(),
|
||||
hasAttachments: z.boolean(),
|
||||
isPrivate: z.boolean(),
|
||||
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
|
||||
}))
|
||||
})
|
||||
|
||||
export type EventListOutputDTO = z.infer<typeof EventSchema>;
|
||||
export const EventListDataOutputDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: z.array(EventListOutputDTOSchema),
|
||||
}).nullable();
|
||||
|
||||
export type EventListOutputDTO = z.infer<typeof EventListDataOutputDTOSchema>;
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
import { z } from "zod";
|
||||
import { EEventOwnerType, EEventType, EEventCategory, EEventStatus } from "./enums";
|
||||
|
||||
const OwnerSchema = z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string(),
|
||||
});
|
||||
|
||||
|
||||
|
||||
const EventToApproveList = z.array(z.object({
|
||||
id: z.string().uuid(),
|
||||
owner: z.string().nullable(),
|
||||
owner: OwnerSchema,
|
||||
ownerType: z.nativeEnum(EEventOwnerType),
|
||||
subject: z.string(),
|
||||
body: z.string(),
|
||||
location: z.string(),
|
||||
startDate: z.string().datetime(),
|
||||
endDate: z.string().datetime(),
|
||||
location: z.string().nullable(),
|
||||
startDate: z.string().datetime({ offset: true }),
|
||||
endDate: z.string().datetime({ offset: true }),
|
||||
type: z.nativeEnum(EEventType),
|
||||
category: z.nativeEnum(EEventCategory),
|
||||
isRecurring: z.boolean(),
|
||||
@@ -20,4 +29,11 @@ const EventToApproveList = z.array(z.object({
|
||||
status: z.nativeEnum(EEventStatus)
|
||||
}))
|
||||
|
||||
export type EventToApproveListOutputDTO = z.infer<typeof EventToApproveList>;
|
||||
export const EventToApproveDataOutputDTOSchema = z.object({
|
||||
success: z.boolean(),
|
||||
message: z.string(),
|
||||
data: EventToApproveList,
|
||||
}).nullable();
|
||||
|
||||
|
||||
export type EventToApproveListOutputDTO = z.infer<typeof EventToApproveDataOutputDTOSchema>;
|
||||
|
||||
@@ -186,7 +186,7 @@ export class AuthService {
|
||||
this.RochetChatConnectorService.logout();
|
||||
this.RochetChatConnectorService.connect();
|
||||
this.RochetChatConnectorService.login().then((message: any) => {
|
||||
console.log('Chat login', message)
|
||||
// console.log('Chat login', message)
|
||||
|
||||
SessionStore.user.RochetChatUserId = message.result.id
|
||||
SessionStore.save()
|
||||
|
||||
@@ -2,8 +2,9 @@ import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Result, err } from 'neverthrow';
|
||||
import { z, ZodError } from 'zod';
|
||||
import * as Sentry from '@sentry/capacitor';
|
||||
import { TracingType } from '../monitoring/opentelemetry/tracer';
|
||||
|
||||
export function APIReturn(schema: z.ZodTypeAny) {
|
||||
export function APIReturn(schema: z.ZodTypeAny, path: string) {
|
||||
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
||||
const originalMethod = descriptor.value;
|
||||
|
||||
@@ -19,13 +20,8 @@ export function APIReturn(schema: z.ZodTypeAny) {
|
||||
if (error instanceof ZodError) {
|
||||
// If validation fails, throw an error with the details
|
||||
//
|
||||
console.log('unexpected data structure')
|
||||
console.error('unexpected data structure', path)
|
||||
// Capture the Zod validation error with additional context
|
||||
Sentry.withScope((scope) => {
|
||||
scope.setTag('APIReturn', 'user');
|
||||
scope.setContext('data', { data: result.value });
|
||||
Sentry.captureException(error);
|
||||
});
|
||||
console.error('Validation failed:', error.errors);
|
||||
} else {
|
||||
console.log('failed to setup the connection successful')
|
||||
@@ -34,7 +30,7 @@ export function APIReturn(schema: z.ZodTypeAny) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log()
|
||||
// console.log()
|
||||
// result.error.
|
||||
}
|
||||
|
||||
@@ -43,3 +39,33 @@ export function APIReturn(schema: z.ZodTypeAny) {
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function APINODReturn(schema: z.ZodTypeAny, data , path: string, tracing?: TracingType) {
|
||||
|
||||
try {
|
||||
// Validate the result using the provided schema
|
||||
schema.parse(data);
|
||||
|
||||
} catch (error) {
|
||||
if (error instanceof ZodError) {
|
||||
// If validation fails, throw an error with the details
|
||||
//
|
||||
console.error('unexpected data structure', path)
|
||||
// Capture the Zod validation error with additional context
|
||||
console.error('Validation failed:', error.errors);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ export class EventsService {
|
||||
isMyEvent(event: any) {
|
||||
|
||||
const data: any = event
|
||||
return data.Organizer.Id == SessionStore.user.UserId
|
||||
return data.owner.wxUserId == SessionStore.user.UserId
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,10 @@ export class CaptureLogService {
|
||||
|
||||
}
|
||||
|
||||
setToken() {
|
||||
|
||||
}
|
||||
|
||||
interceptLogs() {
|
||||
(() => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
@@ -13,7 +13,7 @@ function createProvider(serviceName) {
|
||||
|
||||
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
|
||||
provider.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter({
|
||||
url: 'https://5.180.182.151/zipkin-endpoint/api/v2/spans',
|
||||
url: 'http://5.180.182.151:9411/api/v2/spans',
|
||||
serviceName: serviceName,
|
||||
// Uncomment and customize the following if needed
|
||||
// getExportRequestHeaders: () => {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Tracer, Span } from '@opentelemetry/sdk-trace-base';
|
||||
import { OpentelemetryAgendaProvider } from './opentelemetry';
|
||||
import { Device, DeviceInfo } from '@capacitor/device';
|
||||
|
||||
|
||||
const tracerInstance = OpentelemetryAgendaProvider.getTracer('example-tracer-hole', '111', {
|
||||
|
||||
})
|
||||
@@ -81,12 +82,18 @@ export function XTracerAsync({ name, log, bugPrint }: any, p0?: any) {
|
||||
try {
|
||||
const result = await originalMethod.apply(this, args);
|
||||
|
||||
tracing.finish()
|
||||
if(!window.location.origin.includes('https')) {
|
||||
tracing.finish()
|
||||
}
|
||||
|
||||
|
||||
return result
|
||||
} catch (e) {
|
||||
|
||||
tracing.finish()
|
||||
|
||||
if(!window.location.origin.includes('https')) {
|
||||
tracing.finish()
|
||||
}
|
||||
console.error(e);
|
||||
return false
|
||||
}
|
||||
@@ -162,12 +169,18 @@ export function XTracer({name, log, bugPrint}: any) {
|
||||
try {
|
||||
const result = originalMethod.apply(this, args);
|
||||
|
||||
tracing.finish()
|
||||
|
||||
if(!window.location.origin.includes('https')) {
|
||||
tracing.finish()
|
||||
}
|
||||
|
||||
return result
|
||||
} catch (e) {
|
||||
|
||||
tracing.finish()
|
||||
|
||||
if(!window.location.origin.includes('https')) {
|
||||
tracing.finish()
|
||||
}
|
||||
console.error(e);
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ export class TaskService {
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
|
||||
userId,
|
||||
status: EEventFilterStatus.Pending
|
||||
})
|
||||
}, tracing)
|
||||
|
||||
if(allEvents.isOk()) {
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
|
||||
@@ -13,6 +13,9 @@ import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { TaskService } from 'src/app/services/task.service'
|
||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||
import { EventToApproveDetails } from 'src/app/models/entiry/agenda/eventToApproveDetails';
|
||||
import { EventsService } from 'src/app/services/events.service';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
|
||||
@Component({
|
||||
selector: 'app-approve-event',
|
||||
@@ -53,7 +56,9 @@ export class ApproveEventPage implements OnInit {
|
||||
public ThemeService: ThemeService,
|
||||
private httpErroHandle: HttpErrorHandle,
|
||||
public TaskService: TaskService,
|
||||
private agendaDataRepository: AgendaDataRepositoryService
|
||||
private agendaDataRepository: AgendaDataRepositoryService,
|
||||
public EventsService: EventsService,
|
||||
private httpErrorHandle: HttpErrorHandle,
|
||||
) {
|
||||
// Event to approve list
|
||||
|
||||
@@ -77,19 +82,33 @@ export class ApproveEventPage implements OnInit {
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
|
||||
async getTask() {
|
||||
@XTracerAsync({name:'ApproveEventPage/getTask', log: false, bugPrint: true})
|
||||
async getTask(tracing?: TracingType) {
|
||||
|
||||
const res = await this.agendaDataRepository.getEventToApproveById(this.serialNumber)
|
||||
const res = await this.agendaDataRepository.getEventToApproveById(this.serialNumber, tracing)
|
||||
|
||||
if (res.isOk()) {
|
||||
this.loadedEvent = res.value;
|
||||
console.log('attachment', res.value)
|
||||
this.loadedAttachments = this.loadedEvent.Attachments
|
||||
this.today = new Date(res.value.workflowInstanceDataFields.StartDate);
|
||||
//
|
||||
this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
} else {
|
||||
console.log(res.error.status)
|
||||
tracing.setAttribute('eventId', this.serialNumber)
|
||||
|
||||
if(!isHttpError(res.error)) {
|
||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #133')
|
||||
console.log(res.error)
|
||||
} else if (isHttpError(res.error)) {
|
||||
|
||||
if(res.error.status == 404) {
|
||||
this.toastService._badRequest('Este evento já não existe')
|
||||
} else {
|
||||
this.httpErrorHandle.httpStatusHandle(res.error)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,10 +52,14 @@
|
||||
(click)="openApproveModal(event.serialNumber, event)"
|
||||
>
|
||||
<div class="event-{{color}}-{{event.workflowInstanceDataFields.Agenda}} width-100">
|
||||
<div class="approve-event-time">
|
||||
<div *ngIf="!event.workflowInstanceDataFields.IsAllDayEvent" class="approve-event-time">
|
||||
<p>{{event.workflowInstanceDataFields.StartDate | date: 'HH:mm'}}</p>
|
||||
<p>{{event.workflowInstanceDataFields.EndDate | date: 'HH:mm'}}</p>
|
||||
</div>
|
||||
<div *ngIf="event.workflowInstanceDataFields.IsAllDayEvent" class="approve-event-time">
|
||||
<p>Todo</p>
|
||||
<p>o dia</p>
|
||||
</div>
|
||||
<div class="approve-event-detail">
|
||||
<h3>{{event.workflowInstanceDataFields.Subject}}</h3>
|
||||
<p *ngIf="toDateString(event.workflowInstanceDataFields.StartDate) != toDateString(event.workflowInstanceDataFields.EndDate)">{{event.workflowInstanceDataFields.StartDate | date: 'd/M/yy' }} - {{ event.workflowInstanceDataFields.EndDate | date: 'dd/M/yy'}} | {{event.workflowInstanceDataFields.Location}}</p>
|
||||
|
||||
@@ -146,7 +146,7 @@ export class EventListPage implements OnInit {
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
|
||||
userId,
|
||||
status: EEventFilterStatus.Pending
|
||||
})
|
||||
}, tracing)
|
||||
if(allEvents.isOk()) {
|
||||
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<mat-select [(value)]="selectedUserCalendars" (selectionChange)="changeAgenda();changeSegmentCalendar()">
|
||||
<mat-select [(value)]="selectedUserCalendar" (selectionChange)="changeAgenda();changeSegmentCalendar()">
|
||||
|
||||
<mat-option *ngFor="let calendars of calendarData" value="{{calendars.wxUserId}}">
|
||||
|
||||
|
||||
@@ -148,7 +148,6 @@ export class NewEventPage implements OnInit {
|
||||
selectedUserCalendar:any;
|
||||
SessionStore = SessionStore
|
||||
hasChangeCalendar = false
|
||||
selectedUserCalendars
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
public eventService: EventsService,
|
||||
@@ -188,7 +187,7 @@ export class NewEventPage implements OnInit {
|
||||
)
|
||||
|
||||
|
||||
this.setCalendarByDefault(true)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -218,6 +217,7 @@ export class NewEventPage implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.setCalendarByDefault(true)
|
||||
console.log(' INTERVENIENTES', this.taskParticipants)
|
||||
this.changeProfileService.registerCallback(() => {
|
||||
this.initializeData()
|
||||
@@ -1041,7 +1041,8 @@ export class NewEventPage implements OnInit {
|
||||
allDayCheck: this.allDayCheck,
|
||||
segment: this.segment,
|
||||
CalendarName: this.CalendarName,
|
||||
documents: this.documents
|
||||
documents: this.documents,
|
||||
selectedUserCalendar: this.selectedUserCalendar
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1061,6 +1062,7 @@ export class NewEventPage implements OnInit {
|
||||
this.segment = restoredData.segment
|
||||
this.CalendarName = restoredData.CalendarName
|
||||
this.documents = restoredData.documents
|
||||
this.selectedUserCalendar = restoredData.selectedUserCalendar
|
||||
|
||||
// restore dater for date and hours picker
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ import { EventController } from 'src/app/controller/event'
|
||||
import { DateService } from 'src/app/services/date.service';
|
||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||
import { SearchList_v2 } from 'src/app/models/search-document';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-event',
|
||||
@@ -68,7 +70,7 @@ export class ViewEventPage implements OnInit {
|
||||
private httpErrorHandle: HttpErrorHandle,
|
||||
private router: Router,
|
||||
private dateService: DateService,
|
||||
private agendaDataRepository: AgendaDataRepositoryService
|
||||
private agendaDataRepository: AgendaDataRepositoryService,
|
||||
) {
|
||||
this.isEventEdited = false;
|
||||
this.loadedEvent = new Event();
|
||||
@@ -124,29 +126,47 @@ export class ViewEventPage implements OnInit {
|
||||
setTimeZone() {
|
||||
this.TimeZoneString = this.loadedEvent.TimeZone
|
||||
}
|
||||
async loadEvent() {
|
||||
@XTracerAsync({name:'ViewEventPage/loadEvent', log: false, bugPrint: true})
|
||||
async loadEvent(tracing?: TracingType) {
|
||||
|
||||
let res = await this.agendaDataRepository.getEventById(this.eventId)
|
||||
let res = await this.agendaDataRepository.getEventById(this.eventId, tracing)
|
||||
|
||||
if(res.isOk()) {
|
||||
console.log('Loaded Event', res.value)
|
||||
|
||||
console.log('newAttahcmentList', res.value.Attachments)
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
|
||||
/* let changeDate = this.dateService.fixDate(res.value as any) as any */
|
||||
this.loadedEvent = res.value as any;
|
||||
this.setTimeZone()
|
||||
} else {
|
||||
|
||||
tracing.setAttribute('eventId', this.eventId)
|
||||
if(!isHttpError(res.error)) {
|
||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #133')
|
||||
console.log(res.error)
|
||||
} else if (isHttpError(res.error)) {
|
||||
|
||||
if(res.error.status == 404) {
|
||||
this.toastService._badRequest('Este evento já não existe')
|
||||
} else {
|
||||
this.httpErrorHandle.httpStatusHandle(res.error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.bugFlag()
|
||||
|
||||
this.viewEventDetailDismiss.emit({
|
||||
type: 'close'
|
||||
})
|
||||
console.log(res.error)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
deleteYesOrNo() {
|
||||
if (this.loadedEvent.IsRecurring) {
|
||||
if (this.loadedEvent.IsRecurring) {
|
||||
this.alertController.create({
|
||||
header: 'Eliminar evento?',
|
||||
message: 'Este evento tem recorrência, deseja eliminar a Sequência de eventos?',
|
||||
@@ -200,7 +220,7 @@ export class ViewEventPage implements OnInit {
|
||||
res.present();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
deleteEvent_v2(deleteAll) {
|
||||
|
||||
@@ -169,8 +169,6 @@ export class EventsToApprovePage implements OnInit {
|
||||
this.list = this.TaskService.reorderList(this.ordinance, list)
|
||||
}
|
||||
|
||||
console.log(this.list)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -216,31 +214,38 @@ export class EventsToApprovePage implements OnInit {
|
||||
userId = this.selectedUserCalendar
|
||||
}
|
||||
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
|
||||
userId,
|
||||
status: EEventFilterStatus.Pending
|
||||
}, tracing)
|
||||
if(allEvents.isOk()) {
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
if(userId) {
|
||||
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
|
||||
userId,
|
||||
status: EEventFilterStatus.Pending
|
||||
}, tracing)
|
||||
if(allEvents.isOk()) {
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
|
||||
if(allEvents.value.length >= 1) {
|
||||
this.eventsList = this.sortService.sortArrayByDate(allEvents.value).reverse();
|
||||
this.eventoaprovacaostore.save(segment, this.eventsList)
|
||||
} else {
|
||||
this.eventoaprovacaostore.save(segment, [])
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.bugFlag()
|
||||
|
||||
if(!isHttpError(allEvents.error)) {
|
||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #4')
|
||||
}
|
||||
|
||||
if(allEvents.value.length >= 1) {
|
||||
this.eventsList = this.sortService.sortArrayByDate(allEvents.value).reverse();
|
||||
this.eventoaprovacaostore.save(segment, this.eventsList)
|
||||
} else {
|
||||
this.eventoaprovacaostore.save(segment, [])
|
||||
}
|
||||
|
||||
this.showLoader = false;
|
||||
} else {
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.bugFlag()
|
||||
|
||||
if(!isHttpError(allEvents.error)) {
|
||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #4')
|
||||
}
|
||||
this.showLoader = false;
|
||||
} else {
|
||||
tracing.setAttribute('calling', 'early')
|
||||
console.warn('calling to early Events-to-approve/LoadToApproveEvents')
|
||||
}
|
||||
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
getFromDB() {}
|
||||
|
||||
Reference in New Issue
Block a user