mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
add log for endpoints
This commit is contained in:
@@ -17,6 +17,8 @@ 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';
|
||||
|
||||
@Component({
|
||||
selector: 'app-approve-event',
|
||||
@@ -95,19 +97,30 @@ 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('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')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ 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'
|
||||
@@ -58,16 +59,23 @@ export class AgendaDataRepositoryService {
|
||||
}
|
||||
}
|
||||
|
||||
async getEventToApproveById(id: string) {
|
||||
async getEventToApproveById(id: string, tracing?: TracingType) {
|
||||
|
||||
try {
|
||||
const result = await this.agendaDataService.getEvent(id).pipe(
|
||||
map((response) => {
|
||||
return EventToApproveDetailsMapper.toDomain(response.data)
|
||||
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())
|
||||
} else {
|
||||
tracing?.setAttribute('map.error', 'true')
|
||||
tracing?.setAttribute('map.error.context', JSON.stringify(e))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
@@ -74,7 +76,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
|
||||
})),
|
||||
|
||||
@@ -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) {
|
||||
@@ -36,7 +38,7 @@ export class EventToApproveDetailsMapper {
|
||||
} else if(dto.ownerType == EEventOwnerType.Others) {
|
||||
ownerType = 'Other'
|
||||
}
|
||||
|
||||
|
||||
let activityInstanceName;
|
||||
let taskStatus;
|
||||
|
||||
|
||||
@@ -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,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().nullable(),
|
||||
startDate: z.string().datetime(),
|
||||
endDate: z.string().datetime(),
|
||||
startDate: z.string().datetime({ offset: true }),
|
||||
endDate: z.string().datetime({ offset: true }),
|
||||
type: z.nativeEnum(EEventType),
|
||||
category: z.nativeEnum(EEventCategory),
|
||||
isRecurring: z.boolean(),
|
||||
|
||||
@@ -27,6 +27,10 @@ export class CaptureLogService {
|
||||
|
||||
}
|
||||
|
||||
setToken() {
|
||||
|
||||
}
|
||||
|
||||
interceptLogs() {
|
||||
(() => {
|
||||
const originalConsoleLog = console.log;
|
||||
|
||||
@@ -169,8 +169,6 @@ export class EventsToApprovePage implements OnInit {
|
||||
this.list = this.TaskService.reorderList(this.ordinance, list)
|
||||
}
|
||||
|
||||
console.log(this.list)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -217,6 +215,7 @@ export class EventsToApprovePage implements OnInit {
|
||||
}
|
||||
|
||||
if(userId) {
|
||||
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
|
||||
userId,
|
||||
status: EEventFilterStatus.Pending
|
||||
@@ -231,7 +230,6 @@ export class EventsToApprovePage implements OnInit {
|
||||
this.eventoaprovacaostore.save(segment, [])
|
||||
}
|
||||
|
||||
this.showLoader = false;
|
||||
} else {
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
@@ -240,12 +238,14 @@ export class EventsToApprovePage implements OnInit {
|
||||
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() {}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<rewrite>
|
||||
<rules>
|
||||
<rule name="AngularRewrite" stopProcessing="true">
|
||||
<match url=".*" />
|
||||
<conditions logicalGrouping="MatchAll">
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
|
||||
</conditions>
|
||||
<action type="Rewrite" url="/" />
|
||||
</rule>
|
||||
</rules>
|
||||
</rewrite>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<!-- Iframe on the same host only -->
|
||||
<add name="Content-Security-Policy" value="frame-ancestors https://gdviewer-dev.dyndns.info/" />
|
||||
<!-- HTTPS on -->
|
||||
<add name="Strict-Transport-Security" value="max-age=31536000" />
|
||||
<add name="Referrer-Policy" value="no-referrer" />
|
||||
<add name="X-Content-Type-Options" value="nosniff" />
|
||||
<!-- <add e="Expect-CT" value="enforce, max-age=86400" /> -->
|
||||
<!-- Permision -->
|
||||
<add name="Permissions-Policy" value="camera=(), microphone=*" />
|
||||
<!-- same origin only -->
|
||||
<add name="Cross-Origin-Resource-Policy" value="cross-origin" />
|
||||
<!-- same origin only -->
|
||||
<add name="Cross-Origin-Opener-Policy" value="require-corp" />
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
|
||||
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
@@ -1,5 +1,5 @@
|
||||
export let versionData = {
|
||||
"shortSHA": "680f573P46",
|
||||
"shortSHA": "680f573P466",
|
||||
"SHA": "680f57313f4d97d944e96c6e3457b7f1a9f379f0",
|
||||
"branch": "notification-header/feature",
|
||||
"lastCommitAuthor": "'Peter Maquiran'",
|
||||
|
||||
Reference in New Issue
Block a user