This commit is contained in:
Peter Maquiran
2021-08-31 09:00:33 +01:00
parent 23d73c6d5f
commit 6b61630abc
11 changed files with 157 additions and 58 deletions
+8 -7
View File
@@ -5,6 +5,7 @@ import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
import { LoginUserRespose } from '../models/user.model';
import { EventList } from '../models/agenda/AgendaEventList';
@Injectable({
@@ -107,7 +108,7 @@ export class EventsService {
} */
getAllPrOficialEvents(startdate:string, enddate:string): Observable<Event[]>{
getAllPrOficialEvents(startdate:string, enddate:string): Observable<EventList[]>{
let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/')
@@ -120,10 +121,10 @@ export class EventsService {
headers: this.headersPrOficial,
params: params
};
return this.http.get<Event[]>(`${geturl}`, options);
return this.http.get<EventList[]>(`${geturl}`, options);
}
getAllPrPessoalEvents(startdate:string, enddate:string): Observable<Event[]>{
getAllPrPessoalEvents(startdate:string, enddate:string): Observable<EventList[]>{
let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/')
@@ -136,10 +137,10 @@ export class EventsService {
headers: this.headersPrPessoal,
params: params
};
return this.http.get<Event[]>(`${geturl}`, options);
return this.http.get<EventList[]>(`${geturl}`, options);
}
async getAllPrEvents(startdate:string, enddate:string){
async getAllPrEvents(startdate:string, enddate:string): Promise<EventList[]>{
let prO = await this.getAllPrOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllPrPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP);
@@ -148,7 +149,7 @@ export class EventsService {
})
}
getAllMdOficialEvents(startdate:string, enddate:string): any{
getAllMdOficialEvents(startdate:string, enddate:string): Observable<EventList[]>{
let geturl = environment.apiURL + 'calendar/md';
let params = new HttpParams();
@@ -160,7 +161,7 @@ export class EventsService {
headers: this.headersMdOficial,
params: params
};
return this.http.get<any>(`${geturl}`, options);
return this.http.get<EventList[]>(`${geturl}`, options);
}
getAllMdPessoalEvents(startdate:string, enddate:string): any{
+45 -10
View File
@@ -1,30 +1,65 @@
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
import { AnimationController, ModalController,Platform } from '@ionic/angular';
import { SHA1 } from 'crypto-js'
import { localstoreService } from '../store/localstore.service';
/* import { Plugins } from '@capacitor/core';
const { Storage } = Plugins; */
@Injectable({
providedIn: 'root'
})
export class StorageService {
constructor(private storage:Storage,) {}
private keyName: string;
constructor(private storage:Storage,
private platform: Platform
) {}
key(key) {
this.keyName = (SHA1('service'+this.constructor.name+'key')).toString()
}
// Store the value
async store(key: string, value: any){
const encryptedValue = btoa(escape(JSON.stringify(value)));
await this.storage.set(key, encryptedValue);
async store(key: string, value: any) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
await localstoreService.set(this.key(key), value)
} else {
const encryptedValue = btoa(escape(JSON.stringify(value)));
await this.storage.set(key, encryptedValue);
}
}
// Get the value
async get(key: string) {
const ret = await this.storage.get(key).then((val) => { return val; });
try {
return JSON.parse(unescape(atob(ret)));
} catch (error) {
return unescape(atob(ret))
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
return new Promise((resolve, reject)=>{
const data = localstoreService.get(this.key(key), false)
if(data) resolve(data)
else reject(data)
})
} else {
const ret = await this.storage.get(key).then((val) => { return val; });
try {
return JSON.parse(unescape(atob(ret)));
} catch (error) {
return unescape(atob(ret))
}
}
}
async remove(key: string){
await this.storage.remove(key);
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
await localstoreService.delete(this.key(key))
} else {
await this.storage.remove(key);
}
}