mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
Inicio page is offline
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { AlertController, ModalController, PopoverController } from '@ionic/angular';
|
||||
import { AlertController, ModalController, PopoverController, Platform } from '@ionic/angular';
|
||||
import { EventBody } from 'src/app/models/eventbody.model';
|
||||
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||
import { EventsService } from 'src/app/services/events.service';
|
||||
@@ -12,6 +12,8 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
import { EliminateEventPage } from 'src/app/modals/eliminate-event/eliminate-event.page';
|
||||
import { Location } from '@angular/common'
|
||||
import { SqliteService } from 'src/app/services/sqlite.service';
|
||||
import { synchro } from '../../../services/socket/synchro.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-event',
|
||||
@@ -42,6 +44,7 @@ export class ViewEventPage implements OnInit {
|
||||
dicIndex = 0;
|
||||
isModal = false
|
||||
header = true
|
||||
synch = synchro;
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
@@ -55,7 +58,11 @@ export class ViewEventPage implements OnInit {
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toastService: ToastService,
|
||||
private location: Location
|
||||
private location: Location,
|
||||
public platform: Platform,
|
||||
private sqliteservice: SqliteService
|
||||
|
||||
|
||||
)
|
||||
{
|
||||
this.isEventEdited = false;
|
||||
@@ -88,8 +95,29 @@ export class ViewEventPage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.loadEvent();
|
||||
synchro.registerCallback('Online', () => {
|
||||
this.loadEvent();
|
||||
console.log('Onlineee view-event')
|
||||
|
||||
})
|
||||
|
||||
synchro.registerCallback('Offline', () => {
|
||||
this.platform.ready().then(() => {
|
||||
this.sqliteservice.getEventById(this.eventId).then((event) => {
|
||||
this.loadedEvent = event[0];
|
||||
console.log("Event ditails local,", event[0])
|
||||
})
|
||||
console.log('Offlineee')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
/* this.sqliteservice.getEventById(this.eventId).then((event) => {
|
||||
this.loadedEvent = event[0];
|
||||
console.log("Event ditails local,", event[0])
|
||||
})
|
||||
this.loadEvent(); */
|
||||
|
||||
|
||||
window.onresize = (event) => {
|
||||
// if not mobile remove all component
|
||||
@@ -126,6 +154,7 @@ export class ViewEventPage implements OnInit {
|
||||
const loader = this.toastService.loading();
|
||||
this.eventsService.getEvent(this.eventId).subscribe(res => {
|
||||
this.loadedEvent = res;
|
||||
this.sqliteservice.addEvent(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()
|
||||
@@ -289,4 +318,25 @@ export class ViewEventPage implements OnInit {
|
||||
this.dicIndex = index
|
||||
}
|
||||
|
||||
getEventsFromLocalDb() {
|
||||
console.log("event id details ", this.eventId)
|
||||
|
||||
synchro.registerCallback('Online', () => {
|
||||
this.loadEvent();
|
||||
console.log('Onlineee view-event')
|
||||
|
||||
})
|
||||
|
||||
synchro.registerCallback('Offline', () => {
|
||||
this.platform.ready().then(() => {
|
||||
this.sqliteservice.getEventById(this.eventId).then((event) => {
|
||||
this.loadedEvent = event[0];
|
||||
console.log("Event ditails local,", event[0])
|
||||
})
|
||||
console.log('Offlineee')
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user