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
@@ -15,7 +15,7 @@ import { Router } from '@angular/router';
import { SessionStore } from '../store/session.service';
import { environment } from "src/environments/environment";
import { PermissionService } from '../services/permission.service';
import { NetworkServiceService, ConnectionStatus } from 'src/app/services/network-service.service';
import { NetworkServiceService } from 'src/app/services/network-service.service';
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
@Injectable()
+26 -4
View File
@@ -16,7 +16,7 @@ import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expedient
import { RouteService } from 'src/app/services/route.service';
import { SessionStore } from 'src/app/store/session.service';
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service';
@Component({
selector: 'app-view-event',
@@ -64,7 +64,8 @@ export class ViewEventPage implements OnInit {
private backgroundservice: BackgroundService,
private storage: StorageService,
public ThemeService: ThemeService,
private httpErrorHandle: HttpErrorHandle
private httpErrorHandle: HttpErrorHandle,
private agendaDataRepository: AgendaDataRepositoryService
) {
this.eventId = this.navParams.get('eventId');
this.CalendarId = this.navParams.get('CalendarId');
@@ -106,7 +107,6 @@ export class ViewEventPage implements OnInit {
}
close() {
this.modalController.dismiss(this.isEventEdited);
}
@@ -119,7 +119,7 @@ export class ViewEventPage implements OnInit {
ev.target.complete();
}
loadEvent() {
async loadEvent() {
const loader = this.toastService.loading();
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
@@ -168,6 +168,28 @@ export class ViewEventPage implements OnInit {
}
let res = await this.agendaDataRepository.getEventById(this.eventId)
if(res.isOk()) {
this.loadedEvent = res.value as any;
// this.addEventToDb(res);
loader.remove()
} else {
if (res.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()
}
}
deleteEvent() {
+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: {
@@ -1,15 +1,13 @@
import { Injectable } from '@angular/core';
import { AgendaDataService } from './agenda-data.service';
import { catchError, map } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import { ListEventMapper } from './mapper/EventListMapper';
import { EventMapper } from './mapper/EventDetailsMapper';
import { Utils } from './utils';
import { EventInputDTO } from './agendaDataModels';
import { Event } from 'src/app/models/event.model';
import { SessionStore } from 'src/app/store/session.service';
import { EventListToApproveMapper } from './mapper/eventToApproveListMapper';
import { err, ok } from 'neverthrow';
import { of } from 'rxjs';
import { HttpErrorResponse } from '@angular/common/http';
import { EventToApproveDetailsMapper } from './mapper/EventToApproveDetailsMapper';
@@ -64,7 +64,7 @@ export class EventToApproveDetailsMapper {
// "OriginatorComments": "",
"Status": "Active",
//"TimeZone": "",
"Agenda": "Oficial",
"Agenda": category ,
"EventType": "Reunião",
//"EventID": "",
//"HasAttachments": true,
@@ -26,12 +26,13 @@ export class EventListToApproveMapper {
if(dto.ownerType == 'PR') {
color = 'PR'
workflowDisplayName = `Agenda ${category} ${color}`
} else if(dto.ownerType == 'MD') {
} else {
color = 'MDGPR'
workflowDisplayName = `Agenda ${category} ${color}`
} else {
workflowDisplayName = `Agenda ${category}`
}
// else {
// workflowDisplayName = `Agenda ${category}`
// }
return {
serialNumber: dto.id,
@@ -47,7 +47,7 @@ export const EventOutputDTOSchema = z.object({
startDate: z.string(),
endDate: z.string(),
type: z.string(),
category: z.string(),
category: z.enum(['Oficial','Pessoal']),
attendees: z.array(AttendeeSchema),
isRecurring: z.boolean(),
eventRecurrence: z.null(),
+11 -7
View File
@@ -1,5 +1,6 @@
import { HttpClient, HttpHeaderResponse, HttpHeaders } from '@angular/common/http';
import { HttpClient, HttpErrorResponse, HttpHeaderResponse, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ok, err } from 'neverthrow';
import { environment } from 'src/environments/environment';
@Injectable({
@@ -9,16 +10,19 @@ export class HttpService {
constructor(private http:HttpClient) { }
post(serviceName:string, data:any){
const headers = new HttpHeaders();;
const options = {header: headers, withCredentials: false};
async post(serviceName:string, data:any) {
const headers = new HttpHeaders();
const url = environment.apiChatUrl+serviceName;
const body = {"user": "admin","password": "tabteste@006"};
return this.http.post(url, /* JSON.stringify( */data/* ), options */)
try {
const result = await this.http.post(url, {}).toPromise()
return ok (result)
} catch (e) {
return err(e as HttpErrorResponse)
}
}
get(serviceName:string, options:any){
async get(serviceName:string, options:any) {
const url = environment.apiChatUrl+serviceName;
return this.http.get(url, options);
}
+12 -12
View File
@@ -83,21 +83,21 @@ export class ProcessesService {
return this.http.get<fullTaskList[]>(`${geturl}`, options);
}
eventsToApprove(userid, caller) {
const geturl = environment.apiURL + 'tasks/events-to-approve';
let params = new HttpParams();
// eventsToApprove(userid, caller) {
// const geturl = environment.apiURL + 'tasks/events-to-approve';
// let params = new HttpParams();
params = params.set("pageNum", 1);
params = params.set("pageSize", 500);
params = params.set("userid", userid);
// params = params.set("pageNum", 1);
// params = params.set("pageSize", 500);
// params = params.set("userid", userid);
let options = {
headers: this.headers,
params: params
};
// let options = {
// headers: this.headers,
// params: params
// };
return this.http.get<fullTaskList[]>(`${geturl}`, options);
}
// return this.http.get<fullTaskList[]>(`${geturl}`, options);
// }
GetTaskListExpediente(onlycount1): Observable<ExpedienteFullTask[]> {
const processname = "Expediente"
@@ -46,6 +46,7 @@
<p>
<span class="location">{{loadedEvent.workflowInstanceDataFields.Location}}</span>
{{ loadedEvent.workflowDisplayName }}
<span class="event-type-{{loadedEvent.workflowInstanceDataFields.Agenda}}" *ngIf="loadedEvent.workflowDisplayName == 'Agenda Oficial MDGPR' " style="background-color: #ffb703;">
{{loadedEvent.workflowInstanceDataFields.Agenda}}
</span>
@@ -74,8 +74,6 @@ export class ViewEventPage implements OnInit {
this.loadedEvent = new Event();
this.eventBody = { BodyType : "1", Text : ""};
this.loadedEvent.Body = this.eventBody;
}
ngOnInit() {
+2 -2
View File
@@ -72,7 +72,7 @@ export class CalendarService {
})
}
pushEvent(eventsList: EventList, profile: 'pr' | 'md') {
pushEvent(eventsList: EventList, profile: 'pr' | 'md', CalendarId: string) {
let news = []
eventsList.forEach((element, eventIndex) => {
@@ -85,7 +85,7 @@ export class CalendarService {
calendarName: element.CalendarName,
profile: profile,
id: element.EventId,
CalendarId: element.CalendarId
CalendarId: CalendarId
});
});