diff --git a/package.json b/package.json
index 7ed2ff043..f5052ffa4 100644
--- a/package.json
+++ b/package.json
@@ -163,7 +163,8 @@
"cordova-plugin-androidx": {},
"cordova-plugin-androidx-adapter": {},
"cordova-plugin-fingerprint-aio": {},
- "cordova-plugin-mfp-push": {}
+ "cordova-plugin-mfp-push": {},
+ "cordova-plugin-mfp-jsonstore": {}
},
"platforms": [
"browser",
@@ -177,4 +178,4 @@
"url": "git+https://Kayaya@bitbucket.org/equilibriumito/gabinete-digital.git"
},
"license": "ISC"
-}
+}
\ No newline at end of file
diff --git a/resources/icon.png b/resources/icon.png
index bee77667f..86ef8522f 100644
Binary files a/resources/icon.png and b/resources/icon.png differ
diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts
index b0b25c3e9..3479894a3 100644
--- a/src/app/home/home.page.ts
+++ b/src/app/home/home.page.ts
@@ -85,15 +85,15 @@ export class HomePage implements OnInit {
if(this.platform.is('desktop') || this.platform.is('mobileweb')) {
console.log('Notifications not supported')
} else {
- /* this.mobilefirstConnect();
- this.notificatinsservice.onReceviNotification(); */
+ this.mobilefirstConnect();
+ this.notificatinsservice.onReceviNotification();
}
}
mobilefirstConnect() {
- //try {
+
window['WLAuthorizationManager'].obtainAccessToken("").then( (token) => {
console.log('MobileFirst Server connect: Success ' + token);
@@ -121,7 +121,6 @@ export class HomePage implements OnInit {
alert("Failed to connect to MobileFirst Server");
}); */
});
- //} catch {}
}
diff --git a/src/app/services/jsonStore.service.spec.ts b/src/app/services/jsonStore.service.spec.ts
new file mode 100644
index 000000000..ed030373c
--- /dev/null
+++ b/src/app/services/jsonStore.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { JsonStore } from './jsonStore.service';
+
+describe('JsonStore', () => {
+ let service: JsonStore;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(JsonStore);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/src/app/services/jsonStore.service.ts b/src/app/services/jsonStore.service.ts
new file mode 100644
index 000000000..4d1811258
--- /dev/null
+++ b/src/app/services/jsonStore.service.ts
@@ -0,0 +1,121 @@
+///
+///
+import { Injectable } from "@angular/core";
+
+@Injectable({
+ providedIn: 'root'
+})
+
+export class JsonStore {
+
+ createCollection(name, data) {
+
+ var collectionName = name;
+ var addOptions = {
+ // Mark data as dirty (true = yes, false = no), default true.
+ markDirty: true
+ };
+
+ var JSONStoreCollections = {};
+ JSONStoreCollections[collectionName] = {};
+ JSONStoreCollections[collectionName].searchFields = { UserId: 'integer' };
+
+ WL.JSONStore.init(JSONStoreCollections)
+
+ .then(function () {
+ WL.Logger.debug('Init done');
+ console.log('Init done');
+ return WL.JSONStore.get(collectionName).add(data, addOptions);
+
+ }).fail(function (err) {
+ WL.Logger.error(err);
+ console.log(err)
+ });
+
+ }
+
+ getCollection(collectionName) {
+
+ var allOptions = {
+ // Returns a maximum of 10 documents, default no limit.
+ limit: 10,
+ // Skip 0 documents, default no offset.
+ offset: 0,
+ // Search fields to return, default: ['_id', 'json'].
+ filter: ['UserId', 'json'],
+ // How to sort the returned values, default no sort.}]
+ };
+
+ var JSONStoreCollections = {};
+ JSONStoreCollections[collectionName] = {};
+ JSONStoreCollections[collectionName].searchFields = { UserId: 'integer' };
+
+ WL.JSONStore.init(JSONStoreCollections)
+ .then(function () {
+ WL.Logger.debug('Find all colletion data');
+ console.log('Find all colletion data');
+ return WL.JSONStore.get(collectionName).findAll(allOptions).then((value) => {
+ console.log('Find all colletion data', value);
+ });
+ }).fail(function (err) {
+ WL.Logger.error(err);
+ console.log("JsonStore getColletion error ",err)
+ });
+ }
+
+ getColletionById(collectionName, value) {
+
+ var query = { UserId: value };
+
+ var allOptions = {
+ // Returns a maximum of 10 documents, default no limit.
+ limit: 10,
+ // Skip 0 documents, default no offset.
+ offset: 0,
+ // Search fields to return, default: ['_id', 'json'].
+ filter: ['UserId', 'json'],
+ // How to sort the returned values, default no sort.}]
+ };
+
+ var JSONStoreCollections = {};
+ JSONStoreCollections[collectionName] = {};
+ JSONStoreCollections[collectionName].searchFields = { UserId: 'integer' };
+
+ WL.JSONStore.init(JSONStoreCollections)
+ .then(function () {
+ WL.Logger.debug('Find colletion data by id');
+ console.log('Find colletion data by id');
+
+ return WL.JSONStore.get(collectionName).find(query, allOptions).then((value) => {
+ console.log('Find colletion data by id', value);
+ });
+ }).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
+ _id: 1, json: {name: 'chevy', age: 23}
+ }; */
+ var options = {};
+
+ 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) {
+ console.log("JsonStore remove document sucess: ", numberOfDocsRemoved)
+ }).fail(function (error) {
+ console.log("JsonStore remove document erro: ", error)
+ });
+ }
+}
\ No newline at end of file
diff --git a/src/app/services/notifications.service.ts b/src/app/services/notifications.service.ts
index 6759832fa..8e8522375 100644
--- a/src/app/services/notifications.service.ts
+++ b/src/app/services/notifications.service.ts
@@ -12,6 +12,7 @@ import { ModalController, AlertController, AnimationController, Platform } from
import { NavigationExtras,Router } from '@angular/router';
import { ToastService } from '../services/toast.service';
import { Optional } from '@angular/core';
+import { JsonStore } from './jsonStore.service';
@Injectable({
providedIn: 'root'
@@ -31,7 +32,8 @@ export class NotificationsService {
private router: Router,
private toastService: ToastService,
private zone: NgZone,
- private activeroute: ActivatedRoute) { }
+ private activeroute: ActivatedRoute,
+ private jsonstore: JsonStore) { }
getTokenByUserIdAndId(user, userID) {
const geturl = environment.apiURL + 'notifications/user/' + userID;
@@ -40,6 +42,7 @@ export class NotificationsService {
}
getAndpostToken(username) {
+
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
console.log('Notifications not supported')
} else {
@@ -109,6 +112,9 @@ export class NotificationsService {
}
);
var notificationReceived = (message) => {
+ this.jsonstore.createCollection('Notifications',message);
+ this.jsonstore.getCollection('Notifications')
+ console.log("Notification Store: ", this.jsonstore.getCollection('Notifications')[0]);
console.log(message);
var data = JSON.parse(message.payload);
console.log(data.Service);