mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
trying migration from cordova to capacitor
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
/* eslint-disable */
|
||||
/* tslint:disable */
|
||||
///<reference path="../../../plugins/cordova-plugin-mfp/typings/worklight.d.ts" />
|
||||
///<reference path="../../../plugins/cordova-plugin-mfp-push/typings/mfppush.d.ts" />
|
||||
|
||||
import { Component, OnInit, NgZone } from '@angular/core';
|
||||
import { Event } from '../models/event.model';
|
||||
import { NotificationsService } from '../services/notifications.service';
|
||||
@@ -121,7 +120,6 @@ export class HomePage implements OnInit {
|
||||
this.backgroundservice.online()
|
||||
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
this.webnotification.webconnection();
|
||||
this.webnotification.register();
|
||||
} else {
|
||||
this.mobilefirstConnect();
|
||||
this.notificationsService.onReceviNotification();
|
||||
@@ -148,7 +146,7 @@ export class HomePage implements OnInit {
|
||||
|
||||
console.log("Mobileconecct");
|
||||
|
||||
if (window['WLAuthorizationManager']) {
|
||||
/* if (window['WLAuthorizationManager']) {
|
||||
if (window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
window['WLAuthorizationManager'].obtainAccessToken("").then((token) => {
|
||||
|
||||
@@ -172,13 +170,10 @@ export class HomePage implements OnInit {
|
||||
}, (error) => {
|
||||
console.log('MobileFirst Server connect: failure ' + error.responseText);
|
||||
console.log(JSON.stringify(error))
|
||||
/* this.zone.run(() => {
|
||||
console.log("Bummer...");
|
||||
console.log("Failed to connect to MobileFirst Server");
|
||||
}); */
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
///<reference path="../../../../plugins/cordova-plugin-mfp/typings/worklight.d.ts" />
|
||||
///<reference path="../../../../plugins/cordova-plugin-mfp-jsonstore/typings/jsonstore.d.ts" />
|
||||
|
||||
import { Component, OnInit, NgZone } from '@angular/core';
|
||||
import { Router, NavigationExtras } from '@angular/router';
|
||||
import { AnimationController, ModalController,Platform } from '@ionic/angular';
|
||||
@@ -132,7 +131,7 @@ export class ProfilePage implements OnInit {
|
||||
Status: element.Status
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.DataArray.push(notificationObject)
|
||||
});
|
||||
@@ -168,7 +167,7 @@ export class ProfilePage implements OnInit {
|
||||
else if (Service === "agenda" && Object === "event-list") {
|
||||
//this.zone.run(() => this.router.navigate(['/home/gabinete-digital/event-list/approve-event',IdObject, 'agenda']));
|
||||
this.zone.run(() =>this.router.navigate(['/home/agenda/event-list/approve-event',IdObject, 'agenda']));
|
||||
|
||||
|
||||
} else if (Service === "gabinete-digital" && Object === "despachos") {
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', IdObject, 'gabinete-digital'], { replaceUrl: true }));
|
||||
@@ -195,7 +194,7 @@ export class ProfilePage implements OnInit {
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', IdObject, 'gabinete-digital']));
|
||||
}
|
||||
else if (Service === "gabinete-digital" && Object === "diplomas-assinar") {
|
||||
|
||||
|
||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar',IdObject,'gabinete-digital']));
|
||||
}
|
||||
else if (Service === "gabinete-digital" && Object === "expedientes-pr") {
|
||||
@@ -215,7 +214,7 @@ export class ProfilePage implements OnInit {
|
||||
deleteNotification(index){
|
||||
console.log("Delete notification first stata", this.notificationdata)
|
||||
this.notificationdata = this.notificationdata.filter(item=>item.index !=index );
|
||||
|
||||
|
||||
this.storageservice.store("Notifications",JSON.stringify(this.notificationdata)).then(() =>{
|
||||
this.storageservice.get("Notifications").then((value) =>{
|
||||
console.log("notfication state", value, )
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
///<reference path="../../../plugins/cordova-plugin-mfp/typings/worklight.d.ts" />
|
||||
///<reference path="../../../plugins/cordova-plugin-mfp-jsonstore/typings/jsonstore.d.ts" />
|
||||
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
@Injectable({
|
||||
@@ -8,7 +7,7 @@ import { Injectable } from "@angular/core";
|
||||
|
||||
export class JsonStore {
|
||||
|
||||
createCollection(name, data) {
|
||||
/* createCollection(name, data) {
|
||||
|
||||
var collectionName = name;
|
||||
var addOptions = {
|
||||
@@ -32,7 +31,7 @@ export class JsonStore {
|
||||
console.log(err)
|
||||
});
|
||||
|
||||
}
|
||||
} */
|
||||
|
||||
getCollection(collectionName) {
|
||||
|
||||
@@ -50,11 +49,11 @@ export class JsonStore {
|
||||
JSONStoreCollections[collectionName] = {};
|
||||
JSONStoreCollections[collectionName].searchFields = { UserId: 'integer' };
|
||||
|
||||
WL.JSONStore.init(JSONStoreCollections)
|
||||
/* WL.JSONStore.init(JSONStoreCollections)
|
||||
.then(function () {
|
||||
WL.Logger.debug('Find all colletion data');
|
||||
console.log('Find all colletion data');
|
||||
|
||||
|
||||
|
||||
}).fail(function (err) {
|
||||
WL.Logger.error(err);
|
||||
@@ -66,8 +65,8 @@ export class JsonStore {
|
||||
return JSON.parse(value);
|
||||
});
|
||||
|
||||
|
||||
return data
|
||||
|
||||
return data */
|
||||
|
||||
//return notificationData
|
||||
}
|
||||
@@ -90,7 +89,7 @@ export class JsonStore {
|
||||
JSONStoreCollections[collectionName] = {};
|
||||
JSONStoreCollections[collectionName].searchFields = { UserId: 'integer' };
|
||||
|
||||
WL.JSONStore.init(JSONStoreCollections)
|
||||
/* WL.JSONStore.init(JSONStoreCollections)
|
||||
.then(function () {
|
||||
WL.Logger.debug('Find colletion data by id');
|
||||
console.log('Find colletion data by id');
|
||||
@@ -101,30 +100,30 @@ export class JsonStore {
|
||||
}).fail(function (err) {
|
||||
WL.Logger.error(err);
|
||||
console.log(err)
|
||||
});
|
||||
}); */
|
||||
|
||||
}
|
||||
|
||||
replaceDocument(collectionName: string, document: any) {
|
||||
/* var document = { Example of how identify the document to replace
|
||||
/* var document = { Example of how identify the document to replace
|
||||
_id: 1, json: {name: 'chevy', age: 23}
|
||||
}; */
|
||||
var options = {};
|
||||
|
||||
WL.JSONStore.get(collectionName).replace(document, options).then(function (numberOfDocsReplaced) {
|
||||
/* WL.JSONStore.get(collectionName).replace(document, options).then(function (numberOfDocsReplaced) {
|
||||
console.log("JsonStore replace document sucess: ", numberOfDocsReplaced)
|
||||
}).fail(function (error) {
|
||||
console.log("JsonStore replace document error: ", error)
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
removeDocument(collectionName: any,query: any,) {
|
||||
/* var query = { _id: 1 }; Exemple of query*/
|
||||
var options = { exact: true };
|
||||
WL.JSONStore.get(collectionName).remove(query, options).then(function (numberOfDocsRemoved) {
|
||||
/* WL.JSONStore.get(collectionName).remove(query, options).then(function (numberOfDocsRemoved) {
|
||||
console.log("JsonStore remove document sucess: ", numberOfDocsRemoved)
|
||||
}).fail(function (error) {
|
||||
console.log("JsonStore remove document erro: ", error)
|
||||
});
|
||||
}); */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable */
|
||||
/* tslint:disable */
|
||||
///<reference path="../../../plugins/cordova-plugin-mfp-push/typings/mfppush.d.ts" />
|
||||
import { Injectable, NgZone } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router'
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
@@ -45,10 +44,10 @@ export class NotificationsService {
|
||||
private activeroute: ActivatedRoute,
|
||||
private jsonstore: JsonStore,
|
||||
private eventtrigger: EventTrigger,
|
||||
private backgroundservice: BackgroundService) {
|
||||
private backgroundservice: BackgroundService) {
|
||||
|
||||
this.storageService.get("Notifications").then((value) => {
|
||||
|
||||
|
||||
}).catch(()=>{
|
||||
|
||||
this.storageService.store("Notifications",[])
|
||||
@@ -96,7 +95,7 @@ export class NotificationsService {
|
||||
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
console.log('Push Notification: Success ' + token);
|
||||
|
||||
|
||||
window['MFPPush'].initialize(
|
||||
function (successResponse) {
|
||||
console.log("Push notification Successfully Service intialized: " + successResponse);
|
||||
@@ -105,7 +104,7 @@ export class NotificationsService {
|
||||
console.log("Push notification failure Service intialized: " + failureResponse);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
window['MFPPush'].registerDevice(null, async (successResponse) => {
|
||||
console.log("Successfully registered: " + JSON.stringify(successResponse));
|
||||
console.log('token: ', successResponse.deviceId)
|
||||
@@ -127,7 +126,7 @@ export class NotificationsService {
|
||||
console.log('TOKEN USER MIDLE', data);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
},
|
||||
function (failureResponse) {
|
||||
@@ -157,7 +156,7 @@ export class NotificationsService {
|
||||
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
console.log('Push Notification: Success ' + token);
|
||||
|
||||
|
||||
window['MFPPush'].initialize(
|
||||
function (successResponse) {
|
||||
console.log("Push notification Successfully intialized: " + successResponse);
|
||||
@@ -172,7 +171,7 @@ export class NotificationsService {
|
||||
this.DataArray.push(message)
|
||||
console.log("On ReceiveNotification", this.DataArray)
|
||||
this.storageService.store("Notifications",this.DataArray)
|
||||
|
||||
|
||||
console.log(message);
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
@@ -180,11 +179,11 @@ export class NotificationsService {
|
||||
var data = JSON.parse(message.payload);
|
||||
|
||||
//synchro.$send(data)
|
||||
|
||||
|
||||
console.log('data.Service', data.Service); // module
|
||||
console.log('data.IdObject', data.IdObject); // Object id
|
||||
console.log('data.Object', data.Object); // details
|
||||
|
||||
|
||||
if(message.actionName){
|
||||
this.notificatinsRoutes(data);
|
||||
} else {
|
||||
@@ -192,7 +191,7 @@ export class NotificationsService {
|
||||
//this.notificatinsRoutes(data);
|
||||
console.log(data)
|
||||
}
|
||||
|
||||
|
||||
this.callbacks.forEach( e=> {
|
||||
if(e.type == data.Object || e.type == "any") {
|
||||
e.funx()
|
||||
|
||||
@@ -7,7 +7,6 @@ import { Token } from '../models/token.model';
|
||||
import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular';
|
||||
import { NavigationExtras, Router } from '@angular/router';
|
||||
import { ToastService } from './toast.service';
|
||||
import MFPPush from 'ibm-mfp-web-push';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -39,18 +38,12 @@ export class WebNotificationsService {
|
||||
}
|
||||
|
||||
|
||||
MFPPush.initialize({
|
||||
appId: "com.gpr.gabinetedigital",
|
||||
mfpContextRoot: "/mfp",
|
||||
});
|
||||
|
||||
|
||||
|
||||
/* MFPPush.initialize({
|
||||
appId: "com.gpr.gabinetedigital",
|
||||
mfpContextRoot: "/mfp",
|
||||
}); */
|
||||
|
||||
|
||||
/* MFPPush.registerDevice()
|
||||
.then((res) => {
|
||||
console.log("WEB Successfully Registered Device...");
|
||||
@@ -72,60 +65,6 @@ export class WebNotificationsService {
|
||||
}); */
|
||||
}
|
||||
|
||||
register(){
|
||||
MFPPush.registerDevice()
|
||||
.then((res) => {
|
||||
console.log("WEB Successfully Registered Device...", res);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("WEB Registration Failed" + err);
|
||||
});
|
||||
}
|
||||
|
||||
async onReceviNotificationWeb() {
|
||||
|
||||
if (window['WLAuthorizationManager']) {
|
||||
if (window['WLAuthorizationManager'].obtainAccessToken) {
|
||||
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
console.log('Push Notification: Success ' + token);
|
||||
|
||||
MFPPush.initialize(
|
||||
function (successResponse) {
|
||||
console.log("Push notification Successfully intialized: " + successResponse);
|
||||
MFPPush.registerNotificationsCallback(notificationReceived);
|
||||
},
|
||||
function (failureResponse) {
|
||||
console.log("Push notification failure intialized: " + failureResponse);
|
||||
}
|
||||
);
|
||||
var notificationReceived = (message) => {
|
||||
console.log(message);
|
||||
var data = JSON.parse(message.payload);
|
||||
console.log(data.Service);
|
||||
console.log(data.IdObject);
|
||||
console.log(data.Object);
|
||||
|
||||
if (message.actionName) {
|
||||
//this.notificatinsRoutes(data);
|
||||
console.log("Web notification")
|
||||
} else {
|
||||
console.log("Web notification")
|
||||
//this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data);
|
||||
}
|
||||
|
||||
}
|
||||
}, (error) => {
|
||||
console.log('Push notification recived: failure ' + error.responseText);
|
||||
console.log(JSON.stringify(error));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* getTokenByUserIdAndId(user, userID) {
|
||||
const geturl = environment.apiURL + 'notifications/user/' + userID;
|
||||
|
||||
@@ -138,11 +77,11 @@ export class WebNotificationsService {
|
||||
} else {
|
||||
|
||||
const geturl = environment.apiURL + 'notifications/token'; */
|
||||
/*
|
||||
/*
|
||||
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
console.log('Push Notification: Success ' + token);
|
||||
|
||||
|
||||
MFPPush.initialize(
|
||||
function (successResponse) {
|
||||
console.log("Push notification Successfully Service intialized: " + successResponse);
|
||||
@@ -151,7 +90,7 @@ export class WebNotificationsService {
|
||||
console.log("Push notification failure Service intialized: " + failureResponse);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
MFPPush.registerDevice(null, (successResponse) => {
|
||||
console.log("Successfully registered: " + JSON.stringify(successResponse));
|
||||
console.log('token: ', successResponse.deviceId)
|
||||
@@ -171,7 +110,7 @@ export class WebNotificationsService {
|
||||
console.log('TOKEN USER MIDLE', data);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
},
|
||||
function (failureResponse) {
|
||||
@@ -184,14 +123,14 @@ export class WebNotificationsService {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
} */
|
||||
/*
|
||||
/*
|
||||
async onReceviNotification() {
|
||||
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
|
||||
(token) => {
|
||||
console.log('Push Notification: Success ' + token);
|
||||
|
||||
|
||||
MFPPush.initialize(
|
||||
function (successResponse) {
|
||||
console.log("Push notification Successfully intialized: " + successResponse);
|
||||
@@ -207,13 +146,13 @@ export class WebNotificationsService {
|
||||
console.log(data.Service);
|
||||
console.log(data.IdObject);
|
||||
console.log(data.Object);
|
||||
|
||||
|
||||
if(message.actionName){
|
||||
this.notificatinsRoutes(data);
|
||||
} else {
|
||||
this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}, (error) => {
|
||||
console.log('Push notification recived: failure ' + error.responseText);
|
||||
|
||||
Reference in New Issue
Block a user