Merge branch 'feature/agenda-new-api-peter' into feature/agenda-new-api-eudes

This commit is contained in:
Eudes Inácio
2024-06-02 13:55:04 +01:00
17 changed files with 166 additions and 214 deletions
+42 -46
View File
@@ -611,7 +611,7 @@ export class AgendaPage implements OnInit {
delete this.loadRequest[index]
}
loadRangeEventRun(startTime: Date, endTime: Date) {
async loadRangeEventRun(startTime: Date, endTime: Date) {
if (SessionStore.user.OwnerCalendars.length == 0 && SessionStore.user.SharedCalendars.length == 0) {
return false
@@ -630,60 +630,52 @@ export class AgendaPage implements OnInit {
try {
this.myCal.update();
this.myCal.loadEvents();
} catch (error) {
}
} catch (error) {}
let load = 0;
for (const selectedCalendar of selectedCalendarIds) {
(async () => {
const response = await this.AgendaDataRepositoryService.EventList({userId: selectedCalendar.OwnerUserId, calendarOwnerName: selectedCalendar['FullName'] })
if(response.isOk()) {
let label;
const response = await this.AgendaDataRepositoryService.EventList({userId: selectedCalendar.OwnerUserId, calendarOwnerName: selectedCalendar['FullName'] })
if(response.isOk()) {
let label;
if (SessionStore.user.Profile == 'PR') {
label = "pr"
} else if (SessionStore.user.OwnerCalendars.find(e => e.CalendarId == selectedCalendar.CalendarId)) {
label = 'md'
} else {
label = "pr"
}
let eventsList = response.value;
this.CalendarStore.pushEvent(eventsList, label);
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.showTimelinePR = true;
load++
if (load == selectedCalendarIds.length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.updateEventListBox()
if (SessionStore.user.Profile == 'PR') {
label = "pr"
} else if (selectedCalendar.OwnerUserId == SessionStore.user.UserId as any) {
label = 'md'
} else {
load++
if (load == selectedCalendarIds.length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
console.log('111b')
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.updateEventListBox()
label = "pr"
}
})()
this.CalendarStore.removeRangeForCalendar(startTime, endTime, null , selectedCalendar.OwnerUserId as any)
let eventsList = response.value;
this.CalendarStore.pushEvent(eventsList, label, selectedCalendar.OwnerUserId);
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.showTimelinePR = true;
load++
if (load == selectedCalendarIds.length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.updateEventListBox()
} else {
load++
if (load == selectedCalendarIds.length) {
this.showLoader = false;
}
this.myCal.update();
this.myCal.loadEvents();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.updateEventListBox()
}
}
@@ -695,9 +687,13 @@ export class AgendaPage implements OnInit {
if (this.CalendarName == 'PR+MDGPR') {
const pr = this.SessionStore.user.SharedCalendars.filter(e => e.CalendarRoleId == this.RoleIdService.PRES.toString())
return[{
...this.eventService.calendarNamesType['Meu calendario'],
OwnerUserId: this.SessionStore.user.UserId
}, {
...pr[0]
}]
} else {
@@ -19,6 +19,7 @@ import { SessionStore } from 'src/app/store/session.service';
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';
@Component({
selector: 'app-view-event',
@@ -71,7 +72,8 @@ export class ViewEventPage implements OnInit {
private RouteService: RouteService,
private httpErrorHandle: HttpErrorHandle,
private attachmentsService: AttachmentsService,
private dateService: DateService
private dateService: DateService,
private agendaDataRepository: AgendaDataRepositoryService
) {
@@ -187,65 +189,25 @@ export class ViewEventPage implements OnInit {
this.TimeZoneString = this.loadedEvent.TimeZone.split(')')[1]
}
loadEvent() {
async loadEvent() {
const loader = this.toastService.loading();
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.getEvent(this.eventId).subscribe(res => {
let res = await this.agendaDataRepository.getEventById(this.eventId)
console.log('Loaded Event', res)
res = this.dateService.fixDate(res as any)
this.loadedEvent = res;
this.setTimeZone()
// this.addEventToDb(res);
loader.remove()
}, (error) => {
if (error.status === 0) {
this.getFromDb();
} else {
this.httpErrorHandle.httpStatusHandle(error)
loader.remove()
this.modalController.dismiss('Eevent not Foud');
this.RouteService.goBack();
}
loader.remove()
});
if(res.isOk()) {
console.log('Loaded Event', res.value)
loader.remove()
let changeDate = this.dateService.fixDate(res.value as any) as any
this.loadedEvent = changeDate as any;
this.setTimeZone()
} else {
if(this.CalendarId) {
this.eventsService.genericGetEvent(this.eventId, this.CalendarId).subscribe(res => {
console.log('Loaded Event', res)
/* const div = document.createElement("div")
div.innerHTML = res.Body.Text
res.Body.Text = div.innerText */
res = this.dateService.fixDate(res as any)
this.loadedEvent = res;
console.log('pass,',res)
this.setTimeZone()
// 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()
});
}
this.httpErrorHandle.httpStatusHandle(res.error)
loader.remove()
this.toastService.badRequest('Este evento já não existe na sua agenda')
this.RouteService.goBack();
}
}
loadEvent1() {
+17 -8
View File
@@ -233,18 +233,27 @@ export class EventsPage implements OnInit {
let end = date.getFullYear() + "-" + month + "-" + date.getDate() + " 23:59:59";
if(SessionStore.user) {
let onwEvent:any = await this.eventService.getAllOwnEvents(start, end).catch((error) => {
this.showLoader = false;
this.showAgendaLoader = false;
console.error(error)
const response = await this.AgendaDataRepositoryService.EventList({
userId: SessionStore.user.UserId,
calendarOwnerName: SessionStore.user.FullName,
startDate: date.toISOString(),
endDate: new Date(end).toISOString()
})
this.listToPresent = onwEvent;
if(onwEvent?.length) {
this.totalEvent = onwEvent.length;
if(response.isOk()) {
this.listToPresent = response.value;
if(response.value?.length) {
this.totalEvent = response.value.length;
}
} else {
}
this.storage.set('events', this.listToPresent)
this.showLoader = false;
this.showAgendaLoader = false;
this.storage.set('events', this.listToPresent)
}
this.showLoader = false;
@@ -5,7 +5,7 @@
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="right-icons font-28" src="assets/images/icons-received-event.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov'" class="right-icons font-28" src="assets/images/theme/gov/icons-received-event.svg"></ion-icon>
<div style="color: black;">
Evento Pendente de Aprovação 5
Evento Pendente de Aprovação
</div>
<!-- Events to approve details mobile -->
</div>
@@ -104,7 +104,7 @@
</div>
</div>
<div *ngIf="loadedAttachments" class="aside-right flex-column height-100">
<div class="aside-right flex-column height-100">
<div class="aside-buttons" >
<button (click)="editar(loadedEvent.serialNumber)" full class="btn-cancel" shape="round" *ngIf="loadedEvent.activityInstanceName == 'Aprovar Evento'">Editar evento</button>
<button (click)="approveTask(loadedEvent.serialNumber)" full class="btn-cancel" shape="round" *ngIf="loadedEvent.activityInstanceName == 'Aprovar Evento'">Aprovar</button>
@@ -95,39 +95,6 @@ export class ApproveEventPage implements OnInit {
}
addProcessToDB(data) {
}
getProcessFromDB() {
}
getTask1 = () => {
this.processes.GetTask(this.serialNumber).subscribe(async res => {
this.loadedEvent = res
this.addProcessToDB(this.loadedEvent)
try {
this.today = new Date(this.loadedEvent.workflowInstanceDataFields.StartDate);
this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]);
} catch(error) {
// console.log(this.loadedEvent)
throw(error)
}
}, (error) => {
if(error.status == 0) {
this.getProcessFromDB();
} else {
this.httpErrorHandle.httpStatusHandle(error)
}
})
}
async getTask () {
const res = await this.AgendaDataRepositoryService.getEventToApproveById(this.serialNumber)
@@ -14,6 +14,7 @@ import { RouteService } from 'src/app/services/route.service';
import { EventsService } from 'src/app/services/events.service';
import { SessionStore } from 'src/app/store/session.service';
import { environment } from 'src/environments/environment';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
@Component({
selector: 'app-event-list',
@@ -48,7 +49,7 @@ export class EventListPage implements OnInit {
}
SessionStore = SessionStore;
constructor(
private processes: ProcessesService,
private modalController: ModalController,
@@ -59,6 +60,7 @@ export class EventListPage implements OnInit {
private RouteService: RouteService,
public eventService: EventsService,
public TaskService: TaskService,
public AgendaDataRepositoryService: AgendaDataRepositoryService
) { }
ngOnInit() {
@@ -66,7 +68,7 @@ export class EventListPage implements OnInit {
if(window.location.pathname.includes('gabinete-digital')) {
this.showFilter = true
}
this.eventService.onCalendarFinishLoad.subscribe(() => {
if(!this.segment) {
@@ -75,7 +77,7 @@ export class EventListPage 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) {
@@ -93,7 +95,7 @@ export class EventListPage implements OnInit {
funx:() => {
this.dynamicSearch()
}
})
@@ -127,14 +129,14 @@ export class EventListPage implements OnInit {
}
ngOnDestroy() {
this.listSubscription.delete()
}
ngAfterViewInit(): void {
ngAfterViewInit(): void {
}
@@ -149,7 +151,7 @@ export class EventListPage 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();
@@ -174,43 +176,35 @@ export class EventListPage implements OnInit {
this.showLoader = true;
this.skeletonLoader = true
const segment = this.segment
const segment: any = 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 eventsList
let genericEvents = await this.processes.eventsToApprove(SessionStore.user.UserId,'mobile agenda').toPromise()
try {
eventsList = this.sortService.sortArrayByDate(genericEvents).reverse();
} catch (error) {
this.skeletonLoader = false
eventsList = [];
}
this.eventoaprovacaostore.save(segment, eventsList as any)
this.dynamicSearch()
} else if(segment) {
this.color = 'pr'
let eventsList = []
let allEvents = await this.processes.eventsToApprove(segment,'mobile agenda').toPromise()
try {
eventsList = this.sortService.sortArrayByDate(allEvents).reverse();
} catch(error) {
this.skeletonLoader = false
eventsList = []
userId = segment
}
let allEvents = await this.AgendaDataRepositoryService.eventToApproveList({userId})
if(allEvents.isOk()) {
if(allEvents.value.length >= 1) {
const eventsList = this.sortService.sortArrayByDate(allEvents.value).reverse();
this.eventoaprovacaostore.save(segment, eventsList)
} else {
this.eventoaprovacaostore.save(segment, [])
}
this.showLoader = false;
this.eventoaprovacaostore.save(segment, eventsList)
this.dynamicSearch()
} else {
this.eventoaprovacaostore.save(segment, [])
// this.showLoader = false;
}
this.showLoader = false;
@@ -235,7 +229,7 @@ export class EventListPage implements OnInit {
}
goToEventToApproveDetail(serialNumber: string) {
/* let navigationExtras: NavigationExtras = {
queryParams: {