mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix view event in some component
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -73,8 +73,6 @@ export class ViewEventPage implements OnInit {
|
||||
this.loadedEvent = new Event();
|
||||
this.eventBody = { BodyType : "1", Text : ""};
|
||||
this.loadedEvent.Body = this.eventBody;
|
||||
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
Reference in New Issue
Block a user