mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
Offline web almost done
This commit is contained in:
@@ -9,6 +9,7 @@ import { momentG } from 'src/plugin/momentG';
|
||||
import { DomSanitizer } from "@angular/platform-browser";
|
||||
import { EventPerson } from 'src/app/models/eventperson.model';
|
||||
import { removeDuplicate } from 'src/plugin/removeDuplicate.js';
|
||||
import { Storage } from '@ionic/storage';
|
||||
|
||||
// showTimeline
|
||||
import { setHours, setMinutes } from 'date-fns';
|
||||
@@ -179,7 +180,8 @@ export class AgendaPage implements OnInit {
|
||||
private sqliteservice: SqliteService,
|
||||
private platform: Platform,
|
||||
private backgroundservice: BackgroundService,
|
||||
public ThemeService: ThemeService
|
||||
public ThemeService: ThemeService,
|
||||
private storage:Storage
|
||||
) {
|
||||
|
||||
this.dateAdapter.setLocale('es');
|
||||
@@ -770,6 +772,27 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
addEventToDB(response, profile) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
let responseArray = [];
|
||||
response.forEach(element => {
|
||||
let event = {
|
||||
CalendarId: element.CalendarId,
|
||||
CalendarName: element.CalendarName,
|
||||
EndDate: element.EndDate,
|
||||
EventId: element.EventId,
|
||||
HasAttachments: element.HasAttachments,
|
||||
HumanDate: element.HumanDate,
|
||||
IsAllDayEvent: element.IsAllDayEvent,
|
||||
Location: element.Location,
|
||||
StartDate: element.StartDate,
|
||||
Subject: element.Subject,
|
||||
Profile: profile
|
||||
}
|
||||
responseArray.push(event)
|
||||
|
||||
});
|
||||
this.storage.set('agendaResponse',responseArray).then(() => {
|
||||
console.log('Agenda data saved')
|
||||
})
|
||||
} else {
|
||||
if (response.length > 0) {
|
||||
|
||||
@@ -796,21 +819,35 @@ export class AgendaPage implements OnInit {
|
||||
|
||||
getFromDB() {
|
||||
console.log('ALL EVENTS FROM DB AGENDA OFFLINE')
|
||||
this.sqliteservice.getAllEvents().then((events: any[]) => {
|
||||
console.log('ALL EVENTS FROM DB', events)
|
||||
let eventArray = [];
|
||||
|
||||
this.trasnformDataDB(events)
|
||||
this.updateEventListBox()
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
|
||||
this.showLoader = false;
|
||||
this.showTimeline = true;
|
||||
|
||||
|
||||
})
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
this.storage.get('agendaResponse').then((events) => {
|
||||
this.trasnformDataDB(events)
|
||||
this.updateEventListBox()
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
|
||||
this.showLoader = false;
|
||||
this.showTimeline = true;
|
||||
})
|
||||
} else {
|
||||
this.sqliteservice.getAllEvents().then((events: any[]) => {
|
||||
console.log('ALL EVENTS FROM DB', events)
|
||||
let eventArray = [];
|
||||
|
||||
this.trasnformDataDB(events)
|
||||
this.updateEventListBox()
|
||||
|
||||
this.myCal.update();
|
||||
this.myCal.loadEvents();
|
||||
|
||||
this.showLoader = false;
|
||||
this.showTimeline = true;
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
updateEventListBox() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import { BackgroundService } from 'src/app/services/background.service';
|
||||
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';
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -74,6 +75,7 @@ export class ViewEventPage implements OnInit {
|
||||
private storage: StorageService,
|
||||
public ThemeService: ThemeService,
|
||||
private RouteService: RouteService,
|
||||
private ionicStorage: Storage
|
||||
) {
|
||||
this.isEventEdited = false;
|
||||
this.loadedEvent = new Event();
|
||||
@@ -394,6 +396,9 @@ export class ViewEventPage implements OnInit {
|
||||
|
||||
addEventToDb(data) {
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
this.ionicStorage.set('eventDetails', data).then(() => {
|
||||
console.log('Details event saved')
|
||||
})
|
||||
} else {
|
||||
let event = {
|
||||
Attendees: JSON.stringify(data.Attendees) || JSON.stringify(''),
|
||||
@@ -423,33 +428,40 @@ export class ViewEventPage implements OnInit {
|
||||
|
||||
getFromDb() {
|
||||
const loader = this.toastService.loading();
|
||||
this.sqliteservice.getEventById(this.eventId).then((event) => {
|
||||
let arrayevent = [];
|
||||
console.log('EVENT ATTENDEES',event[0].Attendees)
|
||||
let elemet = {
|
||||
Attendees: (typeof JSON.parse(event[0].Attendees) === 'undefined') ? "" : JSON.parse(event[0].Attendees),
|
||||
Body: JSON.parse(event[0].Body) || "",
|
||||
CalendarId: event[0].CalendarId,
|
||||
CalendarName: event[0].CalendarName,
|
||||
Category: event[0].Category,
|
||||
EndDate: event[0].EndDate,
|
||||
EventId: event[0].EventId,
|
||||
EventRecurrence: JSON.parse(event[0].EventRecurrence) || "",
|
||||
EventType: event[0].EventType,
|
||||
HasAttachments: event[0].HasAttachments,
|
||||
IsAllDayEvent: event[0].IsAllDayEvent,
|
||||
IsMeeting: event[0].IsMeeting,
|
||||
IsRecurring: event[0].IsRecurring,
|
||||
Location: event[0].Location,
|
||||
Organizer: JSON.parse(event[0].Organizer) || "",
|
||||
StartDate: event[0].StartDate,
|
||||
Subject: event[0].Subject,
|
||||
TimeZone: event[0].TimeZone
|
||||
}
|
||||
arrayevent.push(elemet);
|
||||
this.loadedEvent = arrayevent[0];
|
||||
console.log("Event ditails local,", elemet)
|
||||
})
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
this.ionicStorage.get('eventDetails').then((events) =>{
|
||||
this.loadedEvent = events;
|
||||
})
|
||||
} else {
|
||||
this.sqliteservice.getEventById(this.eventId).then((event) => {
|
||||
let arrayevent = [];
|
||||
console.log('EVENT ATTENDEES',event[0].Attendees)
|
||||
let elemet = {
|
||||
Attendees: (typeof JSON.parse(event[0].Attendees) === 'undefined') ? "" : JSON.parse(event[0].Attendees),
|
||||
Body: JSON.parse(event[0].Body) || "",
|
||||
CalendarId: event[0].CalendarId,
|
||||
CalendarName: event[0].CalendarName,
|
||||
Category: event[0].Category,
|
||||
EndDate: event[0].EndDate,
|
||||
EventId: event[0].EventId,
|
||||
EventRecurrence: JSON.parse(event[0].EventRecurrence) || "",
|
||||
EventType: event[0].EventType,
|
||||
HasAttachments: event[0].HasAttachments,
|
||||
IsAllDayEvent: event[0].IsAllDayEvent,
|
||||
IsMeeting: event[0].IsMeeting,
|
||||
IsRecurring: event[0].IsRecurring,
|
||||
Location: event[0].Location,
|
||||
Organizer: JSON.parse(event[0].Organizer) || "",
|
||||
StartDate: event[0].StartDate,
|
||||
Subject: event[0].Subject,
|
||||
TimeZone: event[0].TimeZone
|
||||
}
|
||||
arrayevent.push(elemet);
|
||||
this.loadedEvent = arrayevent[0];
|
||||
console.log("Event ditails local,", elemet)
|
||||
})
|
||||
}
|
||||
|
||||
loader.remove()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user