mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
add filter
This commit is contained in:
@@ -41,6 +41,7 @@ import { map } from 'rxjs/operators';
|
||||
import { EEventFilterStatus } from 'src/app/services/Repositorys/Agenda/model/enums';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
@Component({
|
||||
selector: 'app-agenda',
|
||||
templateUrl: './agenda.page.html',
|
||||
@@ -197,6 +198,7 @@ export class AgendaPage implements OnInit {
|
||||
public p: PermissionService,
|
||||
public RoleIdService: RoleIdService,
|
||||
public AgendaDataRepositoryService: AgendaDataRepositoryService,
|
||||
private toastService: ToastService,
|
||||
) {
|
||||
|
||||
this.selectedUserCalendar = SessionStore.user.UserId
|
||||
@@ -675,7 +677,7 @@ export class AgendaPage implements OnInit {
|
||||
});
|
||||
};
|
||||
|
||||
@XTracerAsync({name:'AgendaPage/loadRangeEventRun', log: false, bugPrint: false})
|
||||
@XTracerAsync({name:'AgendaPage/loadRangeEventRun', log: false, bugPrint: true})
|
||||
async loadRangeEventRun(startTime: Date, endTime: Date, tracing?: TracingType) {
|
||||
|
||||
tracing.addEvent('load range start')
|
||||
@@ -744,6 +746,10 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
} else {
|
||||
|
||||
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')
|
||||
}
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.bugFlag()
|
||||
|
||||
@@ -763,10 +769,10 @@ export class AgendaPage implements OnInit {
|
||||
console.log('not user', JSON.stringify(selectedCalendar))
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
tracing.setAttribute('error', 'selectedCalendar.wxUserId')
|
||||
this.toastService._badRequest('Pedimos desculpa mas não foi possível executar a acção. Por favor, contacte o apoio técnico. #2')
|
||||
tracing.bugFlag()
|
||||
}
|
||||
|
||||
|
||||
tracing.addEvent('load range end')
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@ import { map } from 'rxjs/operators';
|
||||
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 { EEventFilterStatus } from 'src/app/services/Repositorys/Agenda/model/enums';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-event-list',
|
||||
templateUrl: './event-list.page.html',
|
||||
@@ -67,6 +73,7 @@ export class EventListPage implements OnInit {
|
||||
public TaskService: TaskService,
|
||||
public AgendaDataRepositoryService: AgendaDataRepositoryService,
|
||||
public RoleIdService: RoleIdService,
|
||||
private toastService: ToastService,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
@@ -210,7 +217,8 @@ export class EventListPage implements OnInit {
|
||||
this.LoadToApproveEvents();
|
||||
}
|
||||
|
||||
async LoadToApproveEvents() {
|
||||
@XTracerAsync({name:'EventListPage/LoadToApproveEvents', log: false, bugPrint: true})
|
||||
async LoadToApproveEvents(tracing?: TracingType) {
|
||||
console.log('aprove event')
|
||||
this.showLoader = true;
|
||||
this.skeletonLoader = true
|
||||
@@ -232,8 +240,13 @@ export class EventListPage implements OnInit {
|
||||
}
|
||||
|
||||
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
|
||||
userId,
|
||||
status: EEventFilterStatus.Pending
|
||||
})
|
||||
|
||||
if(allEvents.isOk()) {
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
|
||||
if(allEvents.value.length >= 1) {
|
||||
const eventsList = this.sortService.sortArrayByDate(allEvents.value).reverse();
|
||||
@@ -242,6 +255,12 @@ export class EventListPage implements OnInit {
|
||||
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')
|
||||
}
|
||||
this.eventoaprovacaostore.save(segment, [])
|
||||
// this.showLoader = false;
|
||||
}
|
||||
|
||||
@@ -83,13 +83,14 @@ 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))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
}
|
||||
|
||||
async eventToApproveList({ userId, startDate = null, endDate = null, status = EEventFilterStatus.Pending, category = null, type = null, calendarOwnerName = '' }) {
|
||||
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(
|
||||
@@ -100,6 +101,12 @@ export class AgendaDataRepositoryService {
|
||||
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
if(isHttpError(e)) {
|
||||
tracing?.setAttribute('status.code', e.status.toString())
|
||||
} else {
|
||||
console.error(e)
|
||||
tracing?.setAttribute('map.error', JSON.stringify(e.error))
|
||||
}
|
||||
return err(e as HttpErrorResponse)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ export class AgendaDataService {
|
||||
}
|
||||
|
||||
|
||||
if(status == -1 || status == undefined) {
|
||||
if(status != null || status != undefined) {
|
||||
params = params.set('status', status);
|
||||
}
|
||||
|
||||
|
||||
if (startDate !== null && startDate !== undefined) {
|
||||
params = params.set('startDate', startDate);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ export class ListBoxService {
|
||||
// daysObject[day] = object[day]
|
||||
// }
|
||||
|
||||
console.log('newStracture', newStracture)
|
||||
// console.log('newStracture', newStracture)
|
||||
|
||||
return this.display(newStracture, selectedDate).year
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Device.getInfo().then(e => {
|
||||
device = e
|
||||
});
|
||||
|
||||
export function XTracerAsync({name, log, bugPrint}: any) {
|
||||
export function XTracerAsync({ name, log, bugPrint }: any, p0?: any) {
|
||||
return (
|
||||
target: unknown,
|
||||
propertyKey: string,
|
||||
@@ -26,12 +26,14 @@ export function XTracerAsync({name, log, bugPrint}: any) {
|
||||
|
||||
const requestId = uuidv4()
|
||||
const span = tracerInstance.startSpan(name);
|
||||
|
||||
let hasBug:Boolean
|
||||
|
||||
const createTracingInstance = (): TracingType => {
|
||||
const logs: any[] = []
|
||||
const data = {
|
||||
event: {},
|
||||
tags: {}
|
||||
}
|
||||
|
||||
const createTracingInstance = (): TracingType => {
|
||||
|
||||
return {
|
||||
span: span as any,
|
||||
@@ -42,27 +44,23 @@ export function XTracerAsync({name, log, bugPrint}: any) {
|
||||
span.setStatus(status);
|
||||
},
|
||||
addEvent: (context: string, message?: any, obj?: any) => {
|
||||
if(log == true) {
|
||||
// logger.error(obj, context, message)
|
||||
} else {
|
||||
logs.push({context, message: message, obj})
|
||||
}
|
||||
|
||||
data.event[context] = message;
|
||||
|
||||
const value = [JSON.stringify(message)] as any
|
||||
span.addEvent(context, value);
|
||||
},
|
||||
LocalLogEvent:(context: string, message: any, obj: any) => {
|
||||
logs.push({context, message, obj})
|
||||
data.tags[context] = message;
|
||||
},
|
||||
setAttribute: (key: string, value: string) => {
|
||||
data.tags[key] = value;
|
||||
span.setAttribute(key, value);
|
||||
},
|
||||
finish: () => {
|
||||
span.end();
|
||||
if(bugPrint && hasBug) {
|
||||
for(const {context, message, obj} of logs) {
|
||||
// logger.error(obj, context, message)
|
||||
}
|
||||
console.error(name, data)
|
||||
}
|
||||
},
|
||||
bugFlag:() => {
|
||||
@@ -76,7 +74,7 @@ export function XTracerAsync({name, log, bugPrint}: any) {
|
||||
|
||||
const tracing = createTracingInstance()
|
||||
tracing.setAttribute('current.page', window.location.pathname);
|
||||
tracing.setAttribute('device.name', device.name || device.model)
|
||||
tracing.setAttribute('device.name', device?.name || device?.model)
|
||||
|
||||
args.push(tracing)
|
||||
|
||||
@@ -111,9 +109,12 @@ export function XTracer({name, log, bugPrint}: any) {
|
||||
|
||||
let hasBug:Boolean
|
||||
|
||||
const createTracingInstance = (): TracingType => {
|
||||
const logs: any[] = []
|
||||
const data = {
|
||||
event: {},
|
||||
tags: {}
|
||||
}
|
||||
|
||||
const createTracingInstance = (): TracingType => {
|
||||
|
||||
return {
|
||||
span: span as any,
|
||||
@@ -124,27 +125,23 @@ export function XTracer({name, log, bugPrint}: any) {
|
||||
span.setStatus(status);
|
||||
},
|
||||
addEvent: (context: string, message?: any, obj?: any) => {
|
||||
if(log == true) {
|
||||
// logger.error(obj, context, message)
|
||||
} else {
|
||||
logs.push({context, message: message, obj})
|
||||
}
|
||||
|
||||
data.event[context] = message;
|
||||
|
||||
const value = [JSON.stringify(message)] as any
|
||||
span.addEvent(context, value);
|
||||
},
|
||||
LocalLogEvent:(context: string, message: any, obj: any) => {
|
||||
logs.push({context, message, obj})
|
||||
data.tags[context] = message;
|
||||
},
|
||||
setAttribute: (key: string, value: any) => {
|
||||
setAttribute: (key: string, value: string) => {
|
||||
data.tags[key] = value;
|
||||
span.setAttribute(key, value);
|
||||
},
|
||||
finish: () => {
|
||||
span.end();
|
||||
if(bugPrint && hasBug) {
|
||||
for(const {context, message, obj} of logs) {
|
||||
// logger.error(obj, context, message)
|
||||
}
|
||||
console.error(name, data)
|
||||
}
|
||||
},
|
||||
bugFlag:() => {
|
||||
@@ -158,7 +155,7 @@ export function XTracer({name, log, bugPrint}: any) {
|
||||
|
||||
const tracing = createTracingInstance()
|
||||
tracing.setAttribute('current.page', window.location.pathname);
|
||||
tracing.setAttribute('device.name', device.name || device.model)
|
||||
tracing.setAttribute('device.name', device?.name || device?.model)
|
||||
|
||||
args.push(tracing)
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ import { ChangeProfileService } from './change-profile.service';
|
||||
import { PermissionService } from './permission.service';
|
||||
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
|
||||
import { SortService } from './functions/sort.service';
|
||||
import { TracingType, XTracerAsync } from './monitoring/opentelemetry/tracer';
|
||||
import { EEventFilterStatus } from './Repositorys/Agenda/model/enums';
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -311,7 +313,8 @@ export class TaskService {
|
||||
}
|
||||
|
||||
|
||||
async loadEventosParaAprovacao() {
|
||||
@XTracerAsync({name:'taskService/loadEventosParaAprovacao', log: false, bugPrint: true})
|
||||
async loadEventosParaAprovacao(tracing?: TracingType) {
|
||||
this.showLoaderNum++
|
||||
console.log('PR')
|
||||
// PR dont have event to approve
|
||||
@@ -328,8 +331,13 @@ export class TaskService {
|
||||
userId = calendar.OwnerUserId
|
||||
}
|
||||
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
|
||||
userId,
|
||||
status: EEventFilterStatus.Pending
|
||||
})
|
||||
|
||||
if(allEvents.isOk()) {
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
|
||||
let eventsList = []
|
||||
if(allEvents.value.length >= 1) {
|
||||
@@ -338,6 +346,9 @@ export class TaskService {
|
||||
} else {
|
||||
this.eventoaprovacaostore.save(userId, [])
|
||||
}
|
||||
} else {
|
||||
|
||||
tracing.setAttribute('outcome', 'failed')
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -15,7 +15,10 @@ import { RoleIdService } from 'src/app/services/role-id.service'
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
|
||||
|
||||
import { EEventFilterStatus } from 'src/app/services/Repositorys/Agenda/model/enums';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
@Component({
|
||||
selector: 'app-event-list',
|
||||
templateUrl: './event-list.page.html',
|
||||
@@ -52,6 +55,7 @@ export class EventListPage implements OnInit {
|
||||
public eventService: EventsService,
|
||||
public AgendaDataRepositoryService: AgendaDataRepositoryService,
|
||||
public RoleIdService: RoleIdService,
|
||||
private toastService: ToastService,
|
||||
) {
|
||||
this.loggeduser = SessionStore.user;
|
||||
|
||||
@@ -115,7 +119,8 @@ export class EventListPage implements OnInit {
|
||||
return new Date(e).toDateString()
|
||||
}
|
||||
|
||||
async LoadToApproveEvents() {
|
||||
@XTracerAsync({name:'EventListPageShared/LoadToApproveEvents', log: false, bugPrint: true})
|
||||
async LoadToApproveEvents(tracing?: TracingType) {
|
||||
|
||||
this.showLoader = true;
|
||||
const segment = this.selectedUserCalendar
|
||||
@@ -137,20 +142,40 @@ export class EventListPage implements OnInit {
|
||||
userId = this.selectedUserCalendar
|
||||
}
|
||||
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})
|
||||
if(allEvents.isOk()) {
|
||||
if(userId) {
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({
|
||||
userId,
|
||||
status: EEventFilterStatus.Pending
|
||||
})
|
||||
if(allEvents.isOk()) {
|
||||
|
||||
if(allEvents.value.length >= 1) {
|
||||
this.eventsList = this.sortService.sortArrayByDate(allEvents.value).reverse();
|
||||
this.eventoaprovacaostore.save(this.selectedUserCalendar, this.eventsList)
|
||||
} else {
|
||||
this.eventoaprovacaostore.save(this.selectedUserCalendar, [])
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
|
||||
if(allEvents.value.length >= 1) {
|
||||
this.eventsList = this.sortService.sortArrayByDate(allEvents.value).reverse();
|
||||
this.eventoaprovacaostore.save(this.selectedUserCalendar, this.eventsList)
|
||||
} else {
|
||||
this.eventoaprovacaostore.save(this.selectedUserCalendar, [])
|
||||
}
|
||||
} 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. #3')
|
||||
console.log(allEvents.error)
|
||||
}
|
||||
|
||||
this.eventsList = [];
|
||||
}
|
||||
} else {
|
||||
this.eventsList = [];
|
||||
|
||||
this.showLoader = false;
|
||||
} else {
|
||||
console.warn('calling to early eventlistpageshared/loadtoapproveevents')
|
||||
}
|
||||
|
||||
this.showLoader = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ import { map } from 'rxjs/operators';
|
||||
import { RoleIdService } from 'src/app/services/role-id.service'
|
||||
import { TableSharedCalendar } from 'src/app/services/Repositorys/Agenda/agenda-local-data-source.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { EEventFilterStatus } from 'src/app/services/Repositorys/Agenda/model/enums';
|
||||
import { isHttpError } from 'src/app/services/http.service';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-events-to-approve',
|
||||
@@ -64,7 +68,8 @@ export class EventsToApprovePage implements OnInit {
|
||||
public ThemeService: ThemeService,
|
||||
public AgendaDataRepositoryService: AgendaDataRepositoryService,
|
||||
public RoleIdService: RoleIdService,
|
||||
)
|
||||
private toastService: ToastService,
|
||||
)
|
||||
{}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -190,7 +195,8 @@ export class EventsToApprovePage implements OnInit {
|
||||
this.dynamicSearch()
|
||||
}
|
||||
|
||||
async LoadToApproveEvents() {
|
||||
@XTracerAsync({name:'Events-to-approve/LoadToApproveEvents', log: false, bugPrint: true})
|
||||
async LoadToApproveEvents(tracing?: TracingType) {
|
||||
this.showLoader = true;
|
||||
const segment = this.selectedUserCalendar
|
||||
|
||||
@@ -210,8 +216,13 @@ export class EventsToApprovePage implements OnInit {
|
||||
userId = this.selectedUserCalendar
|
||||
}
|
||||
|
||||
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({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)
|
||||
@@ -221,6 +232,13 @@ export class EventsToApprovePage implements OnInit {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user