Offline web almost done

This commit is contained in:
Eudes Inácio
2022-01-31 15:02:26 +01:00
parent e4f335b805
commit 629b8a71c7
4 changed files with 192 additions and 75 deletions
+26 -1
View File
@@ -21,6 +21,7 @@ import { NetworkConnectionService } from 'src/app/services/network-connection.se
import { BackgroundService } from 'src/app/services/background.service';
import { momentG } from 'src/plugin/momentG';
import { ThemeService } from 'src/app/services/theme.service'
import { Storage } from '@ionic/storage';
@Component({
selector: 'app-events',
templateUrl: './events.page.html',
@@ -95,7 +96,8 @@ export class EventsPage implements OnInit {
private sqliteservice: SqliteService,
private networkconnection: NetworkConnectionService,
private backgroundservice: BackgroundService,
public ThemeService: ThemeService
public ThemeService: ThemeService,
private storage: Storage
) {
/* this.existingScreenOrientation = this.screenOrientation.type;
console.log(this.existingScreenOrientation); */
@@ -317,6 +319,9 @@ export class EventsPage implements OnInit {
addEventToDb(list) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.set('events', list).then(() => {
console.log('Init events saved')
})
} else {
if (list.length > 0) {
list.forEach(element => {
@@ -359,6 +364,9 @@ export class EventsPage implements OnInit {
addProcessToDb(list) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.set('process', list).then(() => {
console.log('Init process saved')
})
} else {
if (list.length > 0) {
list.forEach(element => {
@@ -376,6 +384,23 @@ export class EventsPage implements OnInit {
let dateToday = date.getFullYear() + "-" + month + "-" + date.getDate();
console.log('dateeeeee', dateToday)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.storage.get('events').then((events: any[]) => {
console.log('Today events',events)
let todayEvents = new Array()
this.listToPresent = events
this.totalEvent = this.listToPresent.length
this.currentEvent = this.listToPresent[0].Subject
this.currentHoursMinutes = this.listToPresent[0].StartDate
console.log("All events from local,", events)
})
this.storage.get('process').then((process: any[]) => {
console.log('OFOFOFOOF22222', process)
const ExpedienteTask = process.map(e => this.expedienteTaskPipe.transform(e))
this.listToPresentexpediente = ExpedienteTask;
})
this.showLoader = false;
} else {
this.sqliteservice.getAllEvents().then((event: any[]) => {