This commit is contained in:
tiago.kayaya
2021-10-19 14:34:51 +01:00
34 changed files with 1795 additions and 1505 deletions
+24
View File
@@ -5,6 +5,12 @@ import { Injectable } from '@angular/core';
})
export class BackgroundService {
callBacks: {
type: 'Offline' | 'Online' | 'Notification',
object?: string
funx: Function
}[] = []
constructor() { }
online() {
@@ -13,6 +19,11 @@ export class BackgroundService {
document.body.style.setProperty(`--color3`, "#0782C9");
document.body.style.setProperty(`--color4`, "#0782c9f0");
document.body.style.setProperty(`--color5`, "#45BAFF");
this.callBacks.forEach((e) => {
if (e.type == 'Online') {
e.funx()
}
})
}
offline() {
@@ -21,5 +32,18 @@ export class BackgroundService {
document.body.style.setProperty(`--color3`, "#ffb703");
document.body.style.setProperty(`--color4`, "#ffb703");
document.body.style.setProperty(`--color5`, "#ffb703");
this.callBacks.forEach((e) => {
if (e.type == 'Offline') {
e.funx()
}
})
}
registerBackService(type: 'Offline' | 'Online' | 'Notification', funx: Function, object = '') {
this.callBacks.push({
type,
funx,
object
})
}
}
+83 -76
View File
@@ -1,12 +1,16 @@
import { Injectable } from '@angular/core';
import { Event, EventToApproveEdit } from '../models/event.model';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Observable, from } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AuthService } from '../services/auth.service';
import { UserSession } from '../models/user.model';
import { EventList } from '../models/agenda/AgendaEventList';
import { ChangeProfileService } from './change-profile.service';
import { OfflineManagerService } from 'src/app/services/offline-manager.service';
import { catchError } from "rxjs/operators";
import { Storage } from '@ionic/storage';
import { BackgroundService } from 'src/app/services/background.service';
@Injectable({
@@ -28,10 +32,12 @@ export class EventsService {
headersSharedPessoal: HttpHeaders;
constructor(
private http: HttpClient,
private http: HttpClient,
public user: AuthService,
private changeProfileService: ChangeProfileService)
{
private changeProfileService: ChangeProfileService,
private offlinemanager: OfflineManagerService,
private storage: Storage,
private backgroundservice: BackgroundService) {
this.loggeduser = this.user.ValidatedUser;
@@ -44,9 +50,9 @@ export class EventsService {
this.headersSharedOficial = new HttpHeaders();
this.headersSharedPessoal = new HttpHeaders();
this.setHeader()
this.changeProfileService.registerCallback(()=>{
this.changeProfileService.registerCallback(() => {
this.loggeduser = this.user.ValidatedUser;
this.setHeader()
})
@@ -55,16 +61,16 @@ export class EventsService {
setHeader() {
if(this.loggeduser){
if(this.loggeduser.Profile == 'MDGPR') {
if (this.loggeduser) {
if (this.loggeduser.Profile == 'MDGPR') {
this.loggeduser.OwnerCalendars.forEach(calendar => {
if(calendar.CalendarName == 'Oficial') {
if (calendar.CalendarName == 'Oficial') {
this.headersMdOficial = this.headersMdOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersMdOficial = this.headersMdOficial.set('CalendarId', calendar.CalendarId);
this.headersMdOficial = this.headersMdOficial.set('CalendarRoleId', calendar.CalendarRoleId);
}
else if(calendar.CalendarName == 'Pessoal') {
else if (calendar.CalendarName == 'Pessoal') {
this.headersMdPessoal = this.headersMdPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersMdPessoal = this.headersMdPessoal.set('CalendarId', calendar.CalendarId);
this.headersMdPessoal = this.headersMdPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
@@ -73,27 +79,27 @@ export class EventsService {
});
this.loggeduser.SharedCalendars.forEach(sharedCalendar => {
if(sharedCalendar.CalendarName == 'Oficial') {
if (sharedCalendar.CalendarName == 'Oficial') {
this.headersSharedOficial = this.headersSharedOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersSharedOficial = this.headersSharedOficial.set('CalendarId', sharedCalendar.CalendarId);
this.headersSharedOficial = this.headersSharedOficial.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
}
else if(sharedCalendar.CalendarName == 'Pessoal') {
else if (sharedCalendar.CalendarName == 'Pessoal') {
this.headersSharedPessoal = this.headersSharedPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarId', sharedCalendar.CalendarId);
this.headersSharedPessoal = this.headersSharedPessoal.set('CalendarRoleId', sharedCalendar.CalendarRoleId);
}
});
}
else if(this.loggeduser.Profile == 'PR') {
else if (this.loggeduser.Profile == 'PR') {
this.loggeduser.OwnerCalendars.forEach(calendar =>{
if(calendar.CalendarName == 'Oficial'){
this.loggeduser.OwnerCalendars.forEach(calendar => {
if (calendar.CalendarName == 'Oficial') {
this.headersPrOficial = this.headersPrOficial.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersPrOficial = this.headersPrOficial.set('CalendarId', calendar.CalendarId);
this.headersPrOficial = this.headersPrOficial.set('CalendarRoleId', calendar.CalendarRoleId);
}
else if(calendar.CalendarName == 'Pessoal') {
else if (calendar.CalendarName == 'Pessoal') {
this.headersPrPessoal = this.headersPrPessoal.set('Authorization', this.loggeduser.BasicAuthKey);
this.headersPrPessoal = this.headersPrPessoal.set('CalendarId', calendar.CalendarId);
this.headersPrPessoal = this.headersPrPessoal.set('CalendarRoleId', calendar.CalendarRoleId);
@@ -122,9 +128,9 @@ export class EventsService {
} */
getAllPrOficialEvents(startdate:string, enddate:string): Observable<EventList[]>{
getAllPrOficialEvents(startdate: string, enddate: string): Observable<EventList[]> {
let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/')
geturl = geturl.replace('/V4/', '/V5/')
let params = new HttpParams();
@@ -138,9 +144,9 @@ export class EventsService {
return this.http.get<EventList[]>(`${geturl}`, options);
}
getAllPrPessoalEvents(startdate:string, enddate:string): Observable<EventList[]>{
getAllPrPessoalEvents(startdate: string, enddate: string): Observable<EventList[]> {
let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/')
geturl = geturl.replace('/V4/', '/V5/')
let params = new HttpParams();
@@ -154,17 +160,17 @@ export class EventsService {
return this.http.get<EventList[]>(`${geturl}`, options);
}
async getAllPrEvents(startdate:string, enddate:string): Promise<EventList[]>{
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);
return new Promise(resolve =>{
return new Promise(resolve => {
return resolve(resFinal)
})
}
getAllMdOficialEvents(startdate:string, enddate:string): Observable<EventList[]>{
let geturl = environment.apiURL + 'calendar/md';
getAllMdOficialEvents(startdate: string, enddate: string): Observable<EventList[]> {
let geturl = environment.apiURL + 'calendar/md';
let params = new HttpParams();
@@ -178,7 +184,7 @@ export class EventsService {
return this.http.get<EventList[]>(`${geturl}`, options);
}
getAllMdPessoalEvents(startdate:string, enddate:string): any{
getAllMdPessoalEvents(startdate: string, enddate: string): any {
let geturl = environment.apiURL + 'calendar/md';
let params = new HttpParams();
@@ -193,30 +199,30 @@ export class EventsService {
return this.http.get<any>(`${geturl}`, options)
}
async getAllMdEvents(startdate:string, enddate:string) {
async getAllMdEvents(startdate: string, enddate: string) {
let prO = await this.getAllMdOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllMdPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP);
return new Promise(resolve =>{
return new Promise(resolve => {
return resolve(resFinal)
});
}
async getAllSharedEvents(startdate:string, enddate:string) {
async getAllSharedEvents(startdate: string, enddate: string) {
let prO = await this.getAllSharedOficialEvents(startdate, enddate).toPromise();
let prP = await this.getAllSharedPessoalEvents(startdate, enddate).toPromise();
const resFinal = prO.concat(prP);
return new Promise(resolve =>{
return new Promise(resolve => {
return resolve(resFinal)
});
}
getAllSharedOficialEvents(startdate:string, enddate:string): Observable<Event[]>{
getAllSharedOficialEvents(startdate: string, enddate: string): Observable<Event[]> {
let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/')
geturl = geturl.replace('/V4/', '/V5/')
let params = new HttpParams();
@@ -232,9 +238,9 @@ export class EventsService {
return this.http.get<Event[]>(`${geturl}`, options);
}
getAllSharedPessoalEvents(startdate:string, enddate:string): Observable<Event[]>{
getAllSharedPessoalEvents(startdate: string, enddate: string): Observable<Event[]> {
let geturl = environment.apiURL + 'calendar/pr';
geturl = geturl.replace('/V4/','/V5/')
geturl = geturl.replace('/V4/', '/V5/')
let params = new HttpParams();
@@ -249,7 +255,7 @@ export class EventsService {
}
getRecurrenceTypes(): any{
getRecurrenceTypes(): any {
const geturl = environment.apiURL + 'Calendar/RecurrenceTypes';
let options = {
headers: this.headers,
@@ -258,7 +264,7 @@ export class EventsService {
}
getEvents(calendarname:string, startdate:string, enddate:string): Observable<Event[]>{
getEvents(calendarname: string, startdate: string, enddate: string): Observable<Event[]> {
const geturl = environment.apiURL + 'calendar/GetEvents';
let params = new HttpParams();
@@ -273,7 +279,7 @@ export class EventsService {
return this.http.get<Event[]>(`${geturl}`, options);
}
getEvent(eventid: string): Observable<Event>{
getEvent(eventid: string): Observable<Event> {
let geturl = environment.apiURL + 'calendar/GetEvent';
let params = new HttpParams();
@@ -287,8 +293,7 @@ export class EventsService {
return this.http.get<Event>(`${geturl}`, options);
}
putEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number, sharedagenda:string): Observable<Event>
{
putEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number, sharedagenda: string): Observable<Event> {
const puturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'PutEvent');
let params = new HttpParams();
@@ -304,32 +309,32 @@ export class EventsService {
return this.http.put<Event>(`${puturl}`, event, options)
}
editEvent(event: Event, conflictResolutionMode:number, sendInvitationsOrCancellationsMode:number): Observable<Event>
{
editEvent(event: Event, conflictResolutionMode: number, sendInvitationsOrCancellationsMode: number): Observable<Event> {
let arrayReq = [];
arrayReq.push(event);
const puturl = environment.apiURL + 'calendar/PutEvent';
let params = new HttpParams();
params = params.set("conflictResolutionMode", conflictResolutionMode.toString());
params = params.set("sendInvitationsOrCancellationsMode", sendInvitationsOrCancellationsMode.toString());
params.set('CalendarId', event.CalendarId)
params.set('CalendarName', event.CalendarName)
this.headers['CalendarId'] = event.CalendarId
this.headers['CalendarName'] = event.CalendarName
this.headers['CalendarId'] = event.CalendarId
this.headers['CalendarName'] = event.CalendarName
if(event.CalendarName == 'Oficial'){
if(this.loggeduser.Profile == 'MDGPR'){
if (event.CalendarName == 'Oficial') {
if (this.loggeduser.Profile == 'MDGPR') {
this.headers = this.headersMdOficial;
}
else if(this.loggeduser.Profile == 'PR'){
else if (this.loggeduser.Profile == 'PR') {
this.headers = this.headersPrOficial;
}
}
else{
if(this.loggeduser.Profile == 'MDGPR'){
else {
if (this.loggeduser.Profile == 'MDGPR') {
this.headers = this.headersMdPessoal;
}
else if(this.loggeduser.Profile == 'PR'){
else if (this.loggeduser.Profile == 'PR') {
this.headers = this.headersPrPessoal;
}
}
@@ -339,10 +344,15 @@ export class EventsService {
params: params
};
return this.http.put<Event>(`${puturl}`, event, options)
return this.http.put<Event>(`${puturl}`, event, options).pipe(
catchError(err => {
this.offlinemanager.storeRequest(puturl, 'PUT', arrayReq);
throw new Error(err);
})
)
}
changeAgenda(body:any){
changeAgenda(body: any) {
const puturl = environment.apiURL + 'Calendar/MoveEvent';
let options = {
headers: this.headers,
@@ -365,14 +375,13 @@ export class EventsService {
return this.http.post<Event>(`${puturl}`, event, options)
} */
postEventMd(event:Event, calendarName:string)
{
postEventMd(event: Event, calendarName: string) {
const puturl = environment.apiURL + 'calendar/md';
let params = new HttpParams();
params = params.set("CalendarName", calendarName);
let options:any;
let options: any;
switch (calendarName) {
case 'Oficial':
console.log(calendarName);
@@ -394,14 +403,13 @@ export class EventsService {
return this.http.post<string>(`${puturl}`, event, options)
}
postEventPr(event:Event, calendarName:string)
{
postEventPr(event: Event, calendarName: string) {
const puturl = environment.apiURL + 'calendar/pr';
let params = new HttpParams();
params = params.set("CalendarName", calendarName);
let options:any;
let options: any;
switch (calendarName) {
case 'Oficial':
console.log(calendarName);
@@ -423,8 +431,7 @@ export class EventsService {
return this.http.post<string>(`${puturl}`, event, options)
}
deleteEvent(eventid:string, eventDeleteType:number, calendarName:string)
{
deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) {
const puturl = environment.apiURL + 'calendar/DeleteEvent';
let params = new HttpParams();
@@ -436,13 +443,13 @@ export class EventsService {
switch (this.loggeduser.Profile) {
case 'MDGPR':
if(calendarName == 'Pessoal'){
if (calendarName == 'Pessoal') {
options = {
headers: this.headersMdPessoal,
params: params
};
}
else if(calendarName == 'Oficial'){
else if (calendarName == 'Oficial') {
options = {
headers: this.headersMdOficial,
params: params
@@ -450,13 +457,13 @@ export class EventsService {
}
break;
case 'PR':
if(calendarName == 'Pessoal'){
if (calendarName == 'Pessoal') {
options = {
headers: this.headersPrPessoal,
params: params
};
}
else if(calendarName == 'Oficial'){
else if (calendarName == 'Oficial') {
options = {
headers: this.headersPrOficial,
params: params
@@ -467,8 +474,8 @@ export class EventsService {
return this.http.delete(`${puturl}`, options)
}
postExpedientEvent(docId:any, body:any, sharedagenda:string, serialNumber:any, applicationID:any){
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente')+'/event';
postExpedientEvent(docId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) {
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/event';
let params = new HttpParams();
let options;
@@ -478,13 +485,13 @@ export class EventsService {
switch (this.loggeduser.Profile) {
case 'MDGPR':
if(body.CalendarName == 'Pessoal'){
if (body.CalendarName == 'Pessoal') {
options = {
headers: this.headersMdPessoal,
params: params
};
}
else if(body.CalendarName == 'Oficial'){
else if (body.CalendarName == 'Oficial') {
options = {
headers: this.headersMdOficial,
params: params
@@ -492,13 +499,13 @@ export class EventsService {
}
break;
case 'PR':
if(body.CalendarName == 'Pessoal'){
if (body.CalendarName == 'Pessoal') {
options = {
headers: this.headersPrPessoal,
params: params
};
}
else if(body.CalendarName == 'Oficial'){
else if (body.CalendarName == 'Oficial') {
options = {
headers: this.headersPrOficial,
params: params
@@ -508,8 +515,8 @@ export class EventsService {
}
return this.http.post<any>(`${geturl}`, body, options)
}
createTaskEvent(folderId:any, body:any, sharedagenda:string, serialNumber:any, applicationID:any){
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente')+'/dispatch';
createTaskEvent(folderId: any, body: any, sharedagenda: string, serialNumber: any, applicationID: any) {
const geturl = environment.apiURL + 'calendar/' + ((sharedagenda != '') ? sharedagenda : 'CreateEventExpediente') + '/dispatch';
let params = new HttpParams();
let options;
@@ -519,13 +526,13 @@ export class EventsService {
switch (this.loggeduser.Profile) {
case 'MDGPR':
if(body.CalendarName == 'Pessoal'){
if (body.CalendarName == 'Pessoal') {
options = {
headers: this.headersMdPessoal,
params: params
};
}
else if(body.CalendarName == 'Oficial'){
else if (body.CalendarName == 'Oficial') {
options = {
headers: this.headersMdOficial,
params: params
@@ -533,20 +540,20 @@ export class EventsService {
}
break;
case 'PR':
if(body.CalendarName == 'Pessoal'){
if (body.CalendarName == 'Pessoal') {
options = {
headers: this.headersPrPessoal,
params: params
};
}
else if(body.CalendarName == 'Oficial'){
else if (body.CalendarName == 'Oficial') {
options = {
headers: this.headersPrOficial,
params: params
};
}
break;
}
}
return this.http.post<any>(`${geturl}`, body, options)
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { NetworkConnectionService } from './network-connection.service';
describe('NetworkConnectionService', () => {
let service: NetworkConnectionService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(NetworkConnectionService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs'
import { Platform } from '@ionic/angular'
@Injectable({
providedIn: 'root'
})
export class NetworkConnectionService {
online: boolean = true;
constructor(){}
checkOnline() {
window.addEventListener('online', (on) => {
this.online === true;
console.log('Became online');
});
}
checkOffline() {
window.addEventListener('offline', (off) => {
this.online === false;
console.log('Became offline')
});
}
}
+8 -5
View File
@@ -12,7 +12,7 @@ import { ModalController, AlertController, AnimationController, Platform } from
import { NavigationExtras,Router } from '@angular/router';
import { ToastService } from '../services/toast.service';
import { JsonStore } from './jsonStore.service';
import { synchro } from './socket/synchro.service';
import { BackgroundService } from './background.service';
import { v4 as uuidv4 } from 'uuid';
import { EventTrigger } from '../services/eventTrigger.service';
import { SessionStore } from '../store/session.service';
@@ -44,7 +44,8 @@ export class NotificationsService {
private zone: NgZone,
private activeroute: ActivatedRoute,
private jsonstore: JsonStore,
private eventtrigger: EventTrigger) {
private eventtrigger: EventTrigger,
private backgroundservice: BackgroundService) {
this.storageService.get("Notifications").then((value) => {
@@ -60,7 +61,7 @@ export class NotificationsService {
const id = uuidv4()
this.callbacks.push({type, funx, id})
if(!object.hasOwnProperty('desktop') && object['desktop'] != false) {
synchro.registerCallback('Notification',funx, type)
this.backgroundservice.registerBackService('Notification',funx, type)
}
return id;
@@ -108,7 +109,9 @@ export class NotificationsService {
window['MFPPush'].registerDevice(null, async (successResponse) => {
console.log("Successfully registered: " + JSON.stringify(successResponse));
console.log('token: ', successResponse.deviceId)
await this.storageService.store(username, successResponse.deviceId);
await this.storageService.store(username, successResponse.deviceId).then((tokennoti) => {
console.log('token store',tokennoti)
});
await this.storageService.get(username).then(value => {
console.log('STORAGE TOKEN', value)
this.storageService.get(AuthConnstants.USER).then(res => {
@@ -176,7 +179,7 @@ export class NotificationsService {
})
var data = JSON.parse(message.payload);
synchro.$send(data)
//synchro.$send(data)
console.log('data.Service', data.Service); // module
console.log('data.IdObject', data.IdObject); // Object id
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { OfflineManagerService } from './offline-manager.service';
describe('OfflineManagerService', () => {
let service: OfflineManagerService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(OfflineManagerService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,94 @@
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
import { Observable, from, of, forkJoin } from 'rxjs';
import { switchMap, finalize } from 'rxjs/operators';
import { HttpClient } from '@angular/common/http';
import { ToastController } from '@ionic/angular';
const STORAGE_REQ_KEY = 'storedreq';
interface StoredRequest {
url: string,
type: string,
data: any,
time: number,
id: string
}
@Injectable({
providedIn: 'root'
})
export class OfflineManagerService {
constructor(
private storage: Storage,
private http: HttpClient,
private toastController: ToastController) { }
checkForEvents(): Observable<any> {
return from(this.storage.get(STORAGE_REQ_KEY)).pipe(
switchMap(storedOperations => {
let storedObj = JSON.parse(storedOperations);
if (storedObj && storedObj.length > 0) {
return this.sendRequests(storedObj).pipe(
finalize(() => {
let toast = this.toastController.create({
message: `Local data succesfully synced to API!`,
duration: 3000,
position: 'bottom'
});
toast.then(toast => toast.present());
this.storage.remove(STORAGE_REQ_KEY);
})
);
} else {
console.log('no local events to sync');
return of(false);
}
})
)
}
storeRequest(url, type, data) {
let toast = this.toastController.create({
message: `Your data is stored locally because you seem to be offline.`,
duration: 3000,
position: 'bottom'
});
toast.then(toast => toast.present());
let action: StoredRequest = {
url: url,
type: type,
data: data,
time: new Date().getTime(),
id: Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5)
};
return this.storage.get(STORAGE_REQ_KEY).then(storedOperations => {
let storedObj = JSON.parse(storedOperations);
if (storedObj) {
storedObj.push(action);
} else {
storedObj = [action];
}
// Save old & new local transactions back to Storage
return this.storage.set(STORAGE_REQ_KEY, JSON.stringify(storedObj));
});
}
sendRequests(operations: StoredRequest[]) {
let obs = [];
for (let op of operations) {
console.log('Make one request: ', op);
let oneObs = this.http.request(op.type, op.url, op.data);
obs.push(oneObs);
}
// Send out all local events and return once they are finished
return forkJoin(obs);
}
}
+6 -6
View File
@@ -21,7 +21,7 @@ export interface wss {
providedIn: 'root'
})
class SynchroService {
[x: string]: any;
/* [x: string]: any;
private connection!: WebSocket;
private id: string = uuidv4();
@@ -86,7 +86,7 @@ class SynchroService {
//if (this._connected === true) {
this.BackgroundService.online()
//this.BackgroundService.online()
console.log('Online', this._connected)
this.callBacks.forEach((e) => {
if (e.type == 'Online') {
@@ -183,7 +183,7 @@ class SynchroService {
// if (this._connected === false) {
this.BackgroundService.offline();
// this.BackgroundService.offline();
console.log('Offline', this._connected)
this.callBacks.forEach((e) => {
if (e.type == 'Offline') {
@@ -204,12 +204,12 @@ class SynchroService {
private onerror = (event: any) => {
console.log(`[error] ${event.message}`);
}
} */
}
export const synchro = new SynchroService()
/* export const synchro = new SynchroService()
synchro.setUrl()
synchro.connect()
window['synchro'] = synchro
window['synchro'] = synchro */
+15
View File
@@ -182,6 +182,20 @@ export class SqliteService {
});
}
//updateevent
public updateEvent(data) {
this.dbInstance.executeSql(`
INSERT OR REPLACE INTO ${this.events} (EventId,Subject,HasAttachments,Location,CalendarId,CalendarName,StartDate,EndDate,EventType,Attendees,IsMeeting,IsRecurring,IsAllDayEvent,AppointmentState,TimeZone,Organizer,Category,EventRecurrence,Attachments,Body,Profile,HumanDate )
VALUES ('${data.EventId}','${data.Subject}','${data.HasAttachments}','${data.Location}','${data.CalendarId}','${data.CalendarName}','${data.StartDate}','${data.EndDate}','${data.EventType}','${data.Attendees}','${data.IsMeeting}','${data.IsRecurring}',
'${data.IsAllDayEvent}','${data.AppointmentState}','${data.TimeZone}','${data.Organizer}','${data.Category}','${data.EventRecurrence}','${data.Attachments}','${data.Body}','${data.Profile}','${data.HumanDate}')`, [])
.then(() => {
console.log("event update with Success");
}, (e) => {
console.log(JSON.stringify(e));
});
}
//updateActions
public updateactions(id,data) {
console.log("update action data", data )
@@ -359,6 +373,7 @@ export class SqliteService {
if (res.rows.length > 0) {
for (var i = 0; i < res.rows.length; i++) {
this.ALLPROCESS.push(res.rows.item(i));
console.log('getEXPEDIENTE DB LOOP')
}
return this.ALLPROCESS;
}