fix loader

This commit is contained in:
Peter Maquiran
2024-05-31 12:49:49 +01:00
parent 4fad0e306f
commit c982708972
12 changed files with 170 additions and 137 deletions
@@ -13,7 +13,6 @@ 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 { HttpResponseBase } from '@angular/common/http';
@Component({
selector: 'app-approve-event',
@@ -85,6 +84,7 @@ export class ApproveEventPage implements OnInit {
if(res.isOk()) {
this.loadedEvent = 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()]);
@@ -113,14 +113,22 @@ export class EventListPage implements OnInit {
userId = segment
}
try {
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId}).toPromise()
this.eventsList = this.sortService.sortArrayByDate(allEvents).reverse();
this.eventoaprovacaostore.save(segment, this.eventsList)
} catch (e) {
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})
if(allEvents.isOk()) {
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 {
this.eventsList = [];
this.showLoader = false;
// this.showLoader = false;
}
this.showLoader = false;
}
async LoadToApproveEventsNoLoader() {
@@ -12,6 +12,7 @@ import { EventsService } from 'src/app/services/events.service';
import { environment } from 'src/environments/environment';
import { TaskService } from 'src/app/services/task.service'
import { ThemeService } from 'src/app/services/theme.service'
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
@Component({
selector: 'app-events-to-approve',
@@ -33,9 +34,9 @@ export class EventsToApprovePage implements OnInit {
eventoaprovacaostore = EventoAprovacaoStore;
environment = environment
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos'
//
//
showSearch = false
searchSubject = ''
list = []
@@ -57,11 +58,12 @@ export class EventsToApprovePage implements OnInit {
public eventService: EventsService,
public TaskService: TaskService,
public ThemeService: ThemeService,
public AgendaDataRepositoryService: AgendaDataRepositoryService
)
{}
ngOnInit() {
this.eventService.onCalendarFinishLoad.subscribe(() => {
if(!this.segment) {
if(this.eventService.calendarNamesAry.includes('Meu calendario')) {
@@ -69,7 +71,7 @@ export class EventsToApprovePage implements OnInit {
} else {
this.segment = this.eventService.calendarNamesAry[0].OwnerUserId
}
// select pr by default
const pr = this.eventService.calendarNamesAry.find( e => e.Role == 'Presidente da República')
if(pr) {
@@ -80,7 +82,7 @@ export class EventsToApprovePage implements OnInit {
} else {
this.dynamicSearch();
}
})
this.LoadToApproveEvents()
@@ -90,7 +92,7 @@ export class EventsToApprovePage implements OnInit {
funx:() => {
this.dynamicSearch()
}
})
@@ -116,7 +118,7 @@ export class EventsToApprovePage implements OnInit {
ngOnDestroy() {
this.listSubscription.delete()
this.routerSubscription?.unsubscribe();
}
@@ -132,7 +134,7 @@ export class EventsToApprovePage implements OnInit {
async dynamicSearch() {
if(this.showSearch && this.searchSubject) {
const list = this.eventoaprovacaostore.get(this.segment).filter((task) => {
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
subject = subject.toLowerCase();
@@ -176,52 +178,39 @@ export class EventsToApprovePage implements OnInit {
this.showLoader = true;
const segment = this.segment
let userId;
if(this.segment == 'Meu calendario') {
// color
if(SessionStore.user.Profile == 'PR') {
this.color = 'pr'
} else {
this.color = 'mdgpr'
}
userId = SessionStore.user.UserId
let genericEvents = await this.processes.eventsToApprove(SessionStore.user.UserId,'mobile agenda').toPromise()
try {
this.eventsList = this.sortService.sortArrayByDate(genericEvents).reverse();
} catch (error) {
this.eventsList = [];
}
this.eventoaprovacaostore.save(segment, this.eventsList)
this.dynamicSearch()
} else {
this.color = 'pr'
let allEvents = await this.processes.eventsToApprove(segment, 'gabinete').toPromise()
try {
this.eventsList = this.sortService.sortArrayByDate(allEvents).reverse();
} catch(error) {
this.eventsList = []
}
this.eventsList = this.eventsList
this.eventsList = this.eventsList
this.showLoader = false;
this.eventoaprovacaostore.save(segment, this.eventsList)
this.dynamicSearch()
userId = segment
}
this.showLoader = false;
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})
if(allEvents.isOk()) {
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 {
this.showLoader = false;
}
}
getFromDB() {}
toDateString(e) {
return new Date(e).toDateString()
}