mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
save
This commit is contained in:
@@ -22,6 +22,8 @@ import { StorageService } from 'src/app/services/storage.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { CalendarService } from 'src/app/store/calendar.service';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -55,7 +57,7 @@ export class ViewEventPage implements OnInit {
|
||||
header = true
|
||||
task: ExpedientTaskModalPageNavParamsTask;
|
||||
LoadedDocument: any = null;
|
||||
|
||||
sesseionStora = SessionStore
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
/* private navParams: NavParams, */
|
||||
@@ -75,7 +77,8 @@ export class ViewEventPage implements OnInit {
|
||||
private storage: StorageService,
|
||||
public ThemeService: ThemeService,
|
||||
private RouteService: RouteService,
|
||||
private ionicStorage: Storage
|
||||
private ionicStorage: Storage,
|
||||
private CalendarService: CalendarService
|
||||
) {
|
||||
this.isEventEdited = false;
|
||||
this.loadedEvent = new Event();
|
||||
@@ -137,6 +140,23 @@ export class ViewEventPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
getEventsFromDB () {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
this.storage.get('agendaResponse').then((events) => {
|
||||
resolve(events)
|
||||
})
|
||||
} else {
|
||||
this.sqliteservice.getAllEvents().then((events: any[]) => {
|
||||
resolve(events)
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
close() {
|
||||
|
||||
this.modalController.dismiss(this.isEventEdited);
|
||||
@@ -166,27 +186,62 @@ export class ViewEventPage implements OnInit {
|
||||
|
||||
loadEvent() {
|
||||
const loader = this.toastService.loading();
|
||||
this.eventsService.getEvent(this.eventId).subscribe(res => {
|
||||
this.loadedEvent = res;
|
||||
this.addEventToDb(res);
|
||||
console.log('Loaded one event', res)
|
||||
/* this.today = new Date(res.StartDate);
|
||||
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */
|
||||
loader.remove()
|
||||
}, (error) => {
|
||||
|
||||
console.log('errorstatus ss',error.status)
|
||||
|
||||
if (error.status === 0) {
|
||||
this.getFromDb();
|
||||
} else {
|
||||
this.toastService.badRequest('Este evento já não existe na sua agenda')
|
||||
|
||||
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
|
||||
this.eventsService.getEvent(this.eventId).subscribe(res => {
|
||||
this.loadedEvent = res;
|
||||
this.addEventToDb(res);
|
||||
console.log('Loaded one event', res)
|
||||
/* this.today = new Date(res.StartDate);
|
||||
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */
|
||||
loader.remove()
|
||||
this.modalController.dismiss('Eevent not Foud');
|
||||
this.RouteService.goBack();
|
||||
}, (error) => {
|
||||
|
||||
console.log('errorstatus ss',error.status)
|
||||
|
||||
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()
|
||||
});
|
||||
} else {
|
||||
|
||||
const event = this.CalendarService.eventSource.find((ele) => ele.id == this.eventId)
|
||||
|
||||
if(event?.CalendarId) {
|
||||
|
||||
this.eventsService.genericGetEvent(this.eventId, event.CalendarId).subscribe(res => {
|
||||
this.loadedEvent = res;
|
||||
this.addEventToDb(res);
|
||||
console.log('Loaded one event', res)
|
||||
/* this.today = new Date(res.StartDate);
|
||||
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */
|
||||
loader.remove()
|
||||
}, (error) => {
|
||||
|
||||
console.log('errorstatus ss',error.status)
|
||||
|
||||
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()
|
||||
});
|
||||
}
|
||||
loader.remove()
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
deleteEvent() {
|
||||
|
||||
Reference in New Issue
Block a user