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:
@@ -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