Merge with migraCapacitor

This commit is contained in:
Eudes Inácio
2021-11-05 10:29:49 +01:00
20 changed files with 1066 additions and 307 deletions
+2 -1
View File
@@ -20,7 +20,6 @@
<preference name="SplashShowOnlyFirstTime" value="false" /> <preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" /> <preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" /> <preference name="SplashScreenDelay" value="3000" />
<preference name="android-minSdkVersion" value="20" />
<platform name="android"> <platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android"> <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" /> <application android:networkSecurityConfig="@xml/network_security_config" />
@@ -50,4 +49,6 @@
<allow-navigation href="http://localhost:8100" sessionid="9714472a" /> <allow-navigation href="http://localhost:8100" sessionid="9714472a" />
<allow-navigation href="http://localhost:8101" sessionid="4721f88c" /> <allow-navigation href="http://localhost:8101" sessionid="4721f88c" />
<plugin name="cordova-plugin-dbcopy" spec="https://github.com/an-rahulpandey/cordova-plugin-dbcopy.git" /> <plugin name="cordova-plugin-dbcopy" spec="https://github.com/an-rahulpandey/cordova-plugin-dbcopy.git" />
<engine name="browser" />
<engine name="android" />
</widget> </widget>
View File
+777 -109
View File
File diff suppressed because it is too large Load Diff
+9 -6
View File
@@ -31,8 +31,13 @@
"@angular/platform-browser": "~12.1.2", "@angular/platform-browser": "~12.1.2",
"@angular/platform-browser-dynamic": "~12.1.2", "@angular/platform-browser-dynamic": "~12.1.2",
"@angular/router": "~12.1.2", "@angular/router": "~12.1.2",
"@capacitor/android": "3.3.0", "@capacitor/android": "^3.3.0",
"@capacitor/app": "^1.0.5",
"@capacitor/core": "^3.3.0", "@capacitor/core": "^3.3.0",
"@capacitor/haptics": "^1.1.2",
"@capacitor/keyboard": "^1.1.2",
"@capacitor/push-notifications": "^1.0.7",
"@capacitor/status-bar": "^1.0.5",
"@fortawesome/angular-fontawesome": "^0.9.0", "@fortawesome/angular-fontawesome": "^0.9.0",
"@fortawesome/fontawesome-free": "^5.15.3", "@fortawesome/fontawesome-free": "^5.15.3",
"@fortawesome/fontawesome-svg-core": "^1.2.35", "@fortawesome/fontawesome-svg-core": "^1.2.35",
@@ -48,7 +53,6 @@
"@ionic-native/file": "^5.36.0", "@ionic-native/file": "^5.36.0",
"@ionic-native/file-path": "^5.30.0", "@ionic-native/file-path": "^5.30.0",
"@ionic-native/fingerprint-aio": "^4.20.0", "@ionic-native/fingerprint-aio": "^4.20.0",
"@ionic-native/firebase-x": "^5.36.0",
"@ionic-native/http": "^5.31.1", "@ionic-native/http": "^5.31.1",
"@ionic-native/image-picker": "^5.36.0", "@ionic-native/image-picker": "^5.36.0",
"@ionic-native/in-app-browser": "^5.28.0", "@ionic-native/in-app-browser": "^5.28.0",
@@ -94,6 +98,7 @@
"dotenv": "^10.0.0", "dotenv": "^10.0.0",
"duration": "^0.2.2", "duration": "^0.2.2",
"faker": "^5.5.3", "faker": "^5.5.3",
"firebase": "^9.3.0",
"global": "^4.4.0", "global": "^4.4.0",
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"http-server": "^0.12.3", "http-server": "^0.12.3",
@@ -103,7 +108,7 @@
"ionic2-calendar": "^0.6.6", "ionic2-calendar": "^0.6.6",
"ionicons": "^5.5.3", "ionicons": "^5.5.3",
"jest-puppeteer": "^5.0.4", "jest-puppeteer": "^5.0.4",
"jetifier": "^1.6.6", "jetifier": "^1.6.8",
"lite-server": "^2.6.1", "lite-server": "^2.6.1",
"moment": "^2.29.1", "moment": "^2.29.1",
"ng2-pdf-viewer": "^7.0.1", "ng2-pdf-viewer": "^7.0.1",
@@ -146,10 +151,8 @@
"cordova-plugin-compat": "^1.2.0", "cordova-plugin-compat": "^1.2.0",
"cordova-plugin-device": "^2.0.2", "cordova-plugin-device": "^2.0.2",
"cordova-plugin-dialogs": "^2.0.2", "cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-fcm-with-dependecy-updated": "^7.2.0",
"cordova-plugin-file": "^6.0.2", "cordova-plugin-file": "^6.0.2",
"cordova-plugin-fingerprint-aio": "^4.0.2", "cordova-plugin-fingerprint-aio": "^4.0.2",
"cordova-plugin-firebasex": "^13.0.1",
"cordova-plugin-globalization": "^1.11.0", "cordova-plugin-globalization": "^1.11.0",
"cordova-plugin-inappbrowser": "^4.0.0", "cordova-plugin-inappbrowser": "^4.0.0",
"cordova-plugin-ionic-keyboard": "^2.2.0", "cordova-plugin-ionic-keyboard": "^2.2.0",
@@ -238,4 +241,4 @@
"url": "git+https://Kayaya@bitbucket.org/equilibriumito/gabinete-digital.git" "url": "git+https://Kayaya@bitbucket.org/equilibriumito/gabinete-digital.git"
}, },
"license": "ISC" "license": "ISC"
} }
+4 -4
View File
@@ -65,8 +65,8 @@ import { Media } from '@ionic-native/media/ngx';
import { StreamingMedia } from '@ionic-native/streaming-media/ngx'; import { StreamingMedia } from '@ionic-native/streaming-media/ngx';
import { PhotoViewer } from '@ionic-native/photo-viewer/ngx'; import { PhotoViewer } from '@ionic-native/photo-viewer/ngx';
import { FCM } from '@ionic-native/fcm/ngx'; /* import { FCM } from '@ionic-native/fcm/ngx';
import { FirebaseX } from '@ionic-native/firebase-x/ngx'; import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
//import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx'; //import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
@NgModule({ @NgModule({
@@ -115,8 +115,8 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx';
//File, //File,
WebView, WebView,
FilePath, FilePath,
FCM, /* FCM,
FirebaseX, FirebaseX, */
WebsocketService, WebsocketService,
ChatService, ChatService,
ScreenOrientation, ScreenOrientation,
+28 -14
View File
@@ -3,7 +3,7 @@
import { Component, OnInit, NgZone } from '@angular/core'; import { Component, OnInit, NgZone } from '@angular/core';
import { Event } from '../models/event.model'; import { Event } from '../models/event.model';
import { NotificationsService } from '../services/notifications.service'; import { NotificationsService } from '../services/notifications.service';
import { WebNotificationsService } from '../services/webnotifications.service'; /*import { WebNotificationsService } from '../services/webnotifications.service'; */
import { AlertController, Platform } from '@ionic/angular'; import { AlertController, Platform } from '@ionic/angular';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import { ToDayEventStorage } from '../store/to-day-event-storage.service'; import { ToDayEventStorage } from '../store/to-day-event-storage.service';
@@ -14,7 +14,7 @@ import { InativityService } from '../services/inativity.service';
import { SessionStore } from '../store/session.service'; import { SessionStore } from '../store/session.service';
import { StorageService } from '../services/storage.service'; import { StorageService } from '../services/storage.service';
import { File } from '@ionic-native/file/ngx'; import { File } from '@ionic-native/file/ngx';
import { WebNotificationPopupService } from '../services/notification/web-notification-popup.service'; /* import { WebNotificationPopupService } from '../services/notification/web-notification-popup.service'; */
import { DocumentCounterService } from '../services/worker/document-counter.service'; import { DocumentCounterService } from '../services/worker/document-counter.service';
import { PermissionService } from '../services/worker/permission.service'; import { PermissionService } from '../services/worker/permission.service';
import { Network } from '@ionic-native/network/ngx'; import { Network } from '@ionic-native/network/ngx';
@@ -24,7 +24,10 @@ import { Storage } from '@ionic/storage';
import { EventsService } from 'src/app/services/events.service'; import { EventsService } from 'src/app/services/events.service';
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx'; import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
<<<<<<< HEAD
=======
>>>>>>> migraCapacitor
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
templateUrl: './home.page.html', templateUrl: './home.page.html',
@@ -73,20 +76,24 @@ export class HomePage implements OnInit {
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private platform: Platform, private platform: Platform,
private activeroute: ActivatedRoute, private activeroute: ActivatedRoute,
private webnotification: WebNotificationsService, /* private webnotification: WebNotificationsService, */
public p: PermissionService, public p: PermissionService,
public documentCounterService: DocumentCounterService, public documentCounterService: DocumentCounterService,
private despachoRule: DespachoService, private despachoRule: DespachoService,
private inativityService: InativityService, private inativityService: InativityService,
private storageService: StorageService, private storageService: StorageService,
private webNotificationPopupService: WebNotificationPopupService, /* private webNotificationPopupService: WebNotificationPopupService, */
private backgroundservice: BackgroundService, private backgroundservice: BackgroundService,
private offlinemanager: OfflineManagerService, private offlinemanager: OfflineManagerService,
private storage: Storage, private storage: Storage,
private eventservice: EventsService, private eventservice: EventsService,
<<<<<<< HEAD
private screenOrientation: ScreenOrientation) { private screenOrientation: ScreenOrientation) {
=======
private screenOrientation: ScreenOrientation,) {
>>>>>>> migraCapacitor
this.webNotificationPopupService.askNotificationPermission() /* this.webNotificationPopupService.askNotificationPermission() */
this.router.events.subscribe((val) => { this.router.events.subscribe((val) => {
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove()) document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
@@ -114,17 +121,24 @@ export class HomePage implements OnInit {
ngOnInit() { ngOnInit() {
<<<<<<< HEAD
this.notificationsService.onReceviNotification(); this.notificationsService.onReceviNotification();
=======
this.notificationsService.onReciveForeground();
this.notificationsService.onReciveBackground();
>>>>>>> migraCapacitor
window.addEventListener('online', () => { window.addEventListener('online', () => {
console.log('Became online') console.log('Became online')
this.backgroundservice.online() this.backgroundservice.online()
if (this.platform.is('desktop') || this.platform.is('mobileweb')) { if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
<<<<<<< HEAD
this.webnotification.webconnection(); this.webnotification.webconnection();
=======
>>>>>>> migraCapacitor
} else { } else {
this.notificationsService.onReceviNotification(); /* this.notificationsService.onReceviNotification(); */
//this.mobilefirstConnect();
//this.notificationsService.onReceviNotification();
this.offlinemanager.synchnize() this.offlinemanager.synchnize()
} }
}); });
@@ -146,12 +160,12 @@ export class HomePage implements OnInit {
updateList() { updateList() {
this.notificationsService.registerCallback( /* this.notificationsService.registerCallback(
'despachos', 'despachos',
() => { () => {
this.despachoRule.getList({ updateStore: true }) this.despachoRule.getList({ updateStore: true })
} }
) ) */
document.addEventListener('pause', function () { document.addEventListener('pause', function () {
// console.log('App going to background'); // console.log('App going to background');
+2 -2
View File
@@ -56,8 +56,8 @@
</div> </div>
<div class="approve-event-detail"> <div class="approve-event-detail">
<p *ngIf = "item.Service == 'agenda'">{{item.Location}}</p> <p *ngIf = "item.Service == 'agenda'">{{item.Location}}</p>
<h3 id="profile-title">{{item.alert}}</h3> <h3 id="profile-title">{{item.title}}</h3>
<p *ngIf = "item.Service != 'agenda'">{{item.desc}}</p> <p *ngIf = "item.Service != 'agenda'">{{item.body}}</p>
</div> </div>
<!-- <div class="notification-label-MD-official" *ngIf = "item.Service == 'agenda' && item.TypeAgenda == 'official' && item.Role == '100000011'" ></div> <!-- <div class="notification-label-MD-official" *ngIf = "item.Service == 'agenda' && item.TypeAgenda == 'official' && item.Role == '100000011'" ></div>
<div class="notification-label-MD-pessoal" *ngIf = "item.Service == 'agenda' && item.TypeAgenda == 'pessoal' && item.Role == '100000011'" ></div> <div class="notification-label-MD-pessoal" *ngIf = "item.Service == 'agenda' && item.TypeAgenda == 'pessoal' && item.Role == '100000011'" ></div>
+35 -30
View File
@@ -5,9 +5,8 @@ import { LoginUserRespose } from 'src/app/models/user.model';
import { AuthService } from 'src/app/services/auth.service'; import { AuthService } from 'src/app/services/auth.service';
import { LocalstoreService } from 'src/app/store/localstore.service'; import { LocalstoreService } from 'src/app/store/localstore.service';
import { EditProfilePage } from './edit-profile/edit-profile.page'; import { EditProfilePage } from './edit-profile/edit-profile.page';
import { JsonStore } from '../../services/jsonStore.service';
import { StorageService } from '../../services/storage.service'; import { StorageService } from '../../services/storage.service';
import { NotificationsService } from '../../services/notifications.service'; /* import { NotificationsService } from '../../services/notifications.service'; */
import { SessionStore } from 'src/app/store/session.service'; import { SessionStore } from 'src/app/store/session.service';
import { EventTrigger } from '../../services/eventTrigger.service'; import { EventTrigger } from '../../services/eventTrigger.service';
import { ThemeService } from 'src/app/services/theme.service' import { ThemeService } from 'src/app/services/theme.service'
@@ -37,12 +36,11 @@ export class ProfilePage implements OnInit {
private animationController: AnimationController, private animationController: AnimationController,
private router: Router, private router: Router,
private localstoreService: LocalstoreService, private localstoreService: LocalstoreService,
private jsonstore: JsonStore,
private storageservice: StorageService, private storageservice: StorageService,
private zone: NgZone, private zone: NgZone,
private notificationservice: NotificationsService, /* private notificationservice: NotificationsService, */
private platform: Platform, private platform: Platform,
private notificationsService: NotificationsService, /* private notificationsService: NotificationsService, */
private eventtrigger: EventTrigger, private eventtrigger: EventTrigger,
public ThemeService: ThemeService public ThemeService: ThemeService
) { ) {
@@ -61,14 +59,14 @@ export class ProfilePage implements OnInit {
this.getNotificationData(); this.getNotificationData();
} }
this.notificationsService.registerCallback( /* this.notificationsService.registerCallback(
'any', 'any',
() => { () => {
setTimeout(()=>{ setTimeout(()=>{
this.getNotificationData(); this.getNotificationData();
}, 100) }, 100)
} }
) ) */
} }
@@ -85,33 +83,40 @@ export class ProfilePage implements OnInit {
this.storageservice.get("Notifications").then((value) => { this.storageservice.get("Notifications").then((value) => {
console.log("Init get store", value) console.log("Init get store", value)
/* var data = JSON.parse(value); */
console.log("Init store parse", value)
if(typeof(value) == 'string') {
value = JSON.parse(value)
console.log("CSDfdvdf",value)
}
this.DataArray = [] this.DataArray = []
value.forEach((element,i) => { value.forEach((element,i) => {
console.log("ARaaAA", element) console.log("ARaaAA", element)
let notificationObject; let notificationObject = {
if(element.payload){ index: i,
title: element.title,
Service: element.data.Service,
Object: element.data.Object,
IdObject: element.data.IdObject,
FolderId: element.data.FolderId,
body: element.body,
dateInit: this.getFormatedTime(element.data.dateInit),
dateEnd: this.getFormatedTime(element.data.dateEnd),
Location: element.data.Location,
TypeAgenda: element.data.TypeAgenda,
Role: element.data.Role,
Status: element.data.Status
}
/* if(element.payload){
var payload = JSON.parse(element.payload) var payload = JSON.parse(element.payload)
notificationObject = { notificationObject = {
index: i, //index: i,
alert: element.alert, //alert: element.alert,
Service: payload.Service, Service: payload.Service,
Object: payload.Object, Object: payload.Object,
IdObject: payload.IdObject, IdObject: payload.IdObject,
FolderId: payload.FolderId, //FolderId: payload.FolderId,
desc: payload.desc, //desc: payload.desc,
dateInit: this.getFormatedTime(payload.dateInit), //dateInit: this.getFormatedTime(payload.dateInit),
dateEnd: this.getFormatedTime(payload.dateEnd), //dateEnd: this.getFormatedTime(payload.dateEnd),
Location: payload.Location, //Location: payload.Location,
TypeAgenda: payload.TypeAgenda, //TypeAgenda: payload.TypeAgenda,
Role: payload.Role, //Role: payload.Role,
Status: payload.Status //Status: payload.Status
} }
} else { } else {
notificationObject = { notificationObject = {
@@ -128,9 +133,9 @@ export class ProfilePage implements OnInit {
TypeAgenda: element.TypeAgenda, TypeAgenda: element.TypeAgenda,
Role: element.Role, Role: element.Role,
Status: element.Status Status: element.Status
} }
} }*/
this.DataArray.push(notificationObject) this.DataArray.push(notificationObject)
}); });
@@ -200,7 +205,7 @@ export class ProfilePage implements OnInit {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', IdObject, 'gabinete-digital'])); this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', IdObject, 'gabinete-digital']));
} }
this.notificationservice.tempClearArray(); //this.notificationservice.tempClearArray();
this.deleteNotification(index); this.deleteNotification(index);
this.eventtrigger.publishSomeData({ this.eventtrigger.publishSomeData({
notification: "deleted" notification: "deleted"
+1 -1
View File
@@ -1,4 +1,4 @@
export class Token { export class Tokenn {
UserId: number; UserId: number;
TokenId: string; TokenId: string;
Status: number; Status: number;
+1 -1
View File
@@ -26,7 +26,7 @@ import { NavigationStart, NavigationEnd, Router } from '@angular/router';
import { EventPerson } from 'src/app/models/eventperson.model'; import { EventPerson } from 'src/app/models/eventperson.model';
import { removeDuplicate } from 'src/plugin/removeDuplicate.js' import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { NotificationsService } from 'src/app/services/notifications.service'; //import { NotificationsService } from 'src/app/services/notifications.service';
import { TimeService } from 'src/app/services/functions/time.service'; import { TimeService } from 'src/app/services/functions/time.service';
import { ThemeService } from 'src/app/services/theme.service' import { ThemeService } from 'src/app/services/theme.service'
import { DataService } from 'src/app/services/data.service'; import { DataService } from 'src/app/services/data.service';
-6
View File
@@ -121,12 +121,6 @@ export class EventsPage implements OnInit {
ngOnInit() { ngOnInit() {
try {
this.sqliteservice.databaseConn();
} catch (error) {
console.log("Error creating local database: ", error)
}
this.segment = "Combinada"; this.segment = "Combinada";
this.profile = "mdgpr"; this.profile = "mdgpr";
@@ -19,7 +19,7 @@ import { WaitForDomService } from 'src/app/services/dom/wait-for-dom.service';
import { TotalDocumentStore } from 'src/app/store/total-document.service'; import { TotalDocumentStore } from 'src/app/store/total-document.service';
import { DeplomasStore } from 'src/app/store/deplomas.service'; import { DeplomasStore } from 'src/app/store/deplomas.service';
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe'; import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
import { NotificationsService } from 'src/app/services/notifications.service'; //import { NotificationsService } from 'src/app/services/notifications.service';
import { DespachoService } from 'src/app/Rules/despacho.service'; import { DespachoService } from 'src/app/Rules/despacho.service';
import { ChangeProfileService } from 'src/app/services/change-profile.service'; import { ChangeProfileService } from 'src/app/services/change-profile.service';
import { PermissionService } from 'src/app/services/worker/permission.service'; import { PermissionService } from 'src/app/services/worker/permission.service';
@@ -124,7 +124,7 @@ export class GabineteDigitalPage implements OnInit, DoCheck {
authService: AuthService, authService: AuthService,
public p: PermissionService, public p: PermissionService,
public waitForDomService: WaitForDomService, public waitForDomService: WaitForDomService,
private notificationsService: NotificationsService, //private notificationsService: NotificationsService,
private despachoRule: DespachoService, private despachoRule: DespachoService,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private platform: Platform, private platform: Platform,
+3 -1
View File
@@ -141,7 +141,9 @@ export class InactivityPage implements OnInit {
} }
getToken() { getToken() {
//this.notificatinsservice.getAndpostToken(this.username); this.notificatinsservice.requestPermissions();
this.notificatinsservice.registrationError();
this.notificatinsservice.getAndpostToken(this.username);
} }
setCode(code: string) { setCode(code: string) {
+2
View File
@@ -74,6 +74,8 @@ export class LoginPage implements OnInit {
} }
getToken() { getToken() {
this.notificatinsservice.requestPermissions();
this.notificatinsservice.registrationError();
this.notificatinsservice.getAndpostToken(this.username); this.notificatinsservice.getAndpostToken(this.username);
} }
@@ -1,16 +0,0 @@
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();
});
});
+171 -72
View File
@@ -6,18 +6,15 @@ import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { StorageService } from 'src/app/services/storage.service'; import { StorageService } from 'src/app/services/storage.service';
import { AuthConnstants } from 'src/app/config/auth-constants'; import { AuthConnstants } from 'src/app/config/auth-constants';
import { Token } from '../models/token.model'; import { Tokenn } from '../models/token.model';
import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular'; import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular';
import { NavigationExtras, Router } from '@angular/router'; import { NavigationExtras, Router } from '@angular/router';
import { ToastService } from '../services/toast.service'; import { ToastService } from '../services/toast.service';
import { JsonStore } from './jsonStore.service';
import { BackgroundService } from './background.service'; import { BackgroundService } from './background.service';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { EventTrigger } from '../services/eventTrigger.service'; import { EventTrigger } from '../services/eventTrigger.service';
import { SessionStore } from '../store/session.service'; import { SessionStore } from '../store/session.service';
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
import { FCM } from '@ionic-native/fcm/ngx';
//import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -26,7 +23,7 @@ export class NotificationsService {
adding: "intervenient" | "CC" = "intervenient"; adding: "intervenient" | "CC" = "intervenient";
folderId: string; folderId: string;
DataArray: Array<String> = []; DataArray = new Array();
callbacks: { callbacks: {
type: string, type: string,
@@ -45,9 +42,9 @@ export class NotificationsService {
private toastService: ToastService, private toastService: ToastService,
private zone: NgZone, private zone: NgZone,
private activeroute: ActivatedRoute, private activeroute: ActivatedRoute,
private jsonstore: JsonStore,
private eventtrigger: EventTrigger, private eventtrigger: EventTrigger,
private backgroundservice: BackgroundService) { private backgroundservice: BackgroundService,
/* private fcm: FCM */) {
this.storageService.get("Notifications").then((value) => { this.storageService.get("Notifications").then((value) => {
@@ -85,23 +82,128 @@ export class NotificationsService {
getTokenByUserIdAndId(user, userID) { getTokenByUserIdAndId(user, userID) {
const geturl = environment.apiURL + 'notifications/user/' + userID; const geturl = environment.apiURL + 'notifications/user/' + userID;
return this.http.get<Token[]>(`${geturl}`); return this.http.get<Tokenn[]>(`${geturl}`);
} }
requestPermissions() {
PushNotifications.requestPermissions().then(result => {
if (result.receive === 'granted') {
// Register with Apple / Google to receive push via APNS/FCM
PushNotifications.register();
} else {
// Show some error
}
});
}
getAndpostToken(username) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
console.log('Notifications not supported')
} else {
const geturl = environment.apiURL + 'notifications/token';
PushNotifications.addListener('registration',
(token: Token) => {
console.log('token: ', token.value)
this.storageService.store(username, token.value);
this.storageService.get(username).then(value => {
console.log('STORAGE TOKEN', value)
this.storageService.get(AuthConnstants.USER).then(res => {
console.log('USERID', res);
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
const body = {
UserId: res.UserId,
TokenId: token.value,
Status: 1,
Service: 1
};
this.http.post<Tokenn>(`${geturl}`, body, { headers }).subscribe(data => {
console.log('TOKEN USER MIDLE', data);
}, (error) => {
console.log('Post token to backend', error)
})
});
});
}
);
}
}
registrationError() {
PushNotifications.addListener('registrationError',
(error: any) => {
console.log('Error on registration: ' + JSON.stringify(error));
}
);
}
onReciveForeground() {
PushNotifications.addListener('pushNotificationReceived',
(notification: PushNotificationSchema) => {
console.log('Push received: ' + JSON.stringify(notification));
this.DataArray.push(notification)
console.log("On ReceiveNotification", this.DataArray)
this.storageService.store("Notifications", this.DataArray)
this.eventtrigger.publishSomeData({
notification: "recive"
})
}
);
}
onReciveBackground() {
PushNotifications.addListener('pushNotificationActionPerformed',
(notification: ActionPerformed) => {
console.log('Push action performed: ' + JSON.stringify(notification));
this.notificatinsRoutes(notification)
}
);
}
/*
async onReceviNotification() {
this.fcm.onNotification().subscribe(data => {
if (data.click_action) {
console.log("Received in background: ", data);
this.notificatinsRoutes(data)
} else {
console.log("Received in foreground: ", data);
console.log(data.Service)
console.log(data.Object)
console.log(data.IdObject)
this.DataArray.push(data)
console.log("On ReceiveNotification", this.DataArray)
this.storageService.store("Notifications", this.DataArray)
};
});
} */
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
/* getTokenByUserIdAndId(user, userID) { /* getTokenByUserIdAndId(user, userID) {
const geturl = environment.apiURL + 'notifications/user/' + userID; const geturl = environment.apiURL + 'notifications/user/' + userID;
return this.http.get<Token[]>(`${geturl}`); return this.http.get<Token[]>(`${geturl}`);
} }
*/ */
/* getAndpostToken(username) { /* getAndpostToken(username) {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) { if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
//console.log('Notifications not supported') //console.log('Notifications not supported')
} else { } else {
const geturl = environment.apiURL + 'notifications/token'; const geturl = environment.apiURL + 'notifications/token';
if(window['WLAuthorizationManager']) { if(window['WLAuthorizationManager']) {
if(window['WLAuthorizationManager'].obtainAccessToken) { if(window['WLAuthorizationManager'].obtainAccessToken) {
@@ -153,17 +255,17 @@ export class NotificationsService {
); );
} }
} }
} }
} */ } */
tempClearArray() { tempClearArray() {
this.DataArray = []; this.DataArray = new Array;
} }
/* async onReceviNotification() { /* async onReceviNotification() {
if(window['WLAuthorizationManager']) { if(window['WLAuthorizationManager']) {
if(window['WLAuthorizationManager'].obtainAccessToken) { if(window['WLAuthorizationManager'].obtainAccessToken) {
window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then( window['WLAuthorizationManager'].obtainAccessToken("push.mobileclient").then(
@@ -178,33 +280,30 @@ export class NotificationsService {
console.log("Push notification failure intialized: " + failureResponse); console.log("Push notification failure intialized: " + failureResponse);
} }
); );
var notificationReceived = (message) => {
window['MFPPush'].registerDevice(null, async (successResponse) => { //this.jsonstore.createCollection('Notifications',message);
console.log("Successfully registered: " + JSON.stringify(successResponse)); this.DataArray.push(message)
console.log('token: ', successResponse.deviceId) console.log("On ReceiveNotification", this.DataArray)
await this.storageService.store(username, successResponse.deviceId).then((tokennoti) => { this.storageService.store("Notifications",this.DataArray)
console.log('token store',tokennoti)
}); console.log(message);
await this.storageService.get(username).then(value => { this.eventtrigger.publishSomeData({
console.log('STORAGE TOKEN', value) notification: "recive"
this.storageService.get(AuthConnstants.USER).then(res => { })
console.log('USERID', res); var data = JSON.parse(message.payload);
const headers = { 'Authorization': SessionStore.user.BasicAuthKey };
const body = { //synchro.$send(data)
UserId: res.UserId,
TokenId: successResponse.deviceId, console.log('data.Service', data.Service); // module
Status: 1, console.log('data.IdObject', data.IdObject); // Object id
Service: 1 console.log('data.Object', data.Object); // details
};
this.http.post<Token>(`${geturl}`, body, { headers }).subscribe(data => { if(message.actionName){
console.log('TOKEN USER MIDLE', data); this.notificatinsRoutes(data);
}) } else {
}); /* this.toastService.notificationMessage(message.alert,this.notificatinsRoutes, data);
//this.notificatinsRoutes(data);
}); console.log(data)
},
function (failureResponse) {
console.log("Successfully failue: " + JSON.stringify(failureResponse));
} }
this.callbacks.forEach( e=> { this.callbacks.forEach( e=> {
@@ -212,7 +311,7 @@ export class NotificationsService {
e.funx() e.funx()
} }
}) })
} }
}, (error) => { }, (error) => {
console.log('Push notification recived: failure ' + error.responseText); console.log('Push notification recived: failure ' + error.responseText);
@@ -221,54 +320,54 @@ export class NotificationsService {
); );
} }
} }
} */ } */
notificatinsRoutes = (data) => { notificatinsRoutes = (notification) => {
if (data.Service === "agenda") { if (notification.data.Service === "agenda") {
this.zone.run(() => this.router.navigate(['/home/agenda', data.IdObject, 'agenda'])); this.zone.run(() => this.router.navigate(['/home/agenda', notification.data.IdObject, 'agenda']));
} }
else if (data.Service === "gabinete-digital" && data.Object === "expediente") { else if (notification.data.Service === "gabinete-digital" && notification.data.Object === "expediente") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', data.IdObject, 'gabinete-digital'])); this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expediente', notification.data.IdObject, 'gabinete-digital']));
} }
else if (data.Service === "agenda" && data.Object === "event-list") { else if (notification.data.Service === "agenda" && notification.data.Object === "event-list") {
this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', data.IdObject, 'agenda'])); this.zone.run(() => this.router.navigate(['/home/agenda/event-list/approve-event', notification.data.IdObject, 'agenda']));
} else if (data.Service === "gabinete-digital" && data.Object === "despachos") { } else if (notification.data.Service === "gabinete-digital" && notification.data.Object === "despachos") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', data.IdObject, 'gabinete-digital'], { replaceUrl: true })); this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos', notification.data.IdObject, 'gabinete-digital'], { replaceUrl: true }));
} }
else if (data.Service === "gabinete-digital" && data.Object === "parecer") { else if (notification.data.Service === "gabinete-digital" && notification.data.Object === "parecer") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', data.IdObject, 'gabinete-digital'])); this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.data.IdObject, 'gabinete-digital']));
} }
else if (data.Service === "gabinete-digital" && data.Object === "deferimento") { else if (notification.data.Service === "gabinete-digital" && notification.data.Object === "deferimento") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', data.IdObject, 'gabinete-digital'])); this.zone.run(() => this.router.navigate(['/home/gabinete-digital/pedidos', notification.data.IdObject, 'gabinete-digital']));
} }
else if (data.Service === "gabinete-digital" && data.Object === "despachos-pr") { else if (notification.data.Service === "gabinete-digital" && notification.data.Object === "despachos-pr") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', data.IdObject, 'gabinete-digital'])); this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', notification.data.IdObject, 'gabinete-digital']));
} }
else if (data.Service === "accoes" && data.Object === "accao") { else if (notification.data.Service === "accoes" && notification.data.Object === "accao") {
this.zone.run(() => this.router.navigate(['/home/publications', data.IdObject])); this.zone.run(() => this.router.navigate(['/home/publications', notification.data.IdObject]));
} }
else if (data.Service === "accoes" && data.Object === "publicacao") { else if (notification.data.Service === "accoes" && notification.data.Object === "publicacao") {
this.zone.run(() => this.router.navigate(['/home/publications/view-publications', data.FolderId, data.IdObject])); this.zone.run(() => this.router.navigate(['/home/publications/view-publications', notification.data.FolderId, notification.data.IdObject]));
} }
else if (data.Service === "gabinete-digital" && data.Object === "diplomas") { else if (notification.data.Service === "gabinete-digital" && notification.data.Object === "diplomas") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', data.IdObject, 'gabinete-digital'])); this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', notification.data.IdObject, 'gabinete-digital']));
} }
else if (data.Service === "gabinete-digital" && data.Object === "diplomas-assinar") { else if (notification.data.Service === "gabinete-digital" && notification.data.Object === "diplomas-assinar") {
let navigationExtras: NavigationExtras = { let navigationExtras: NavigationExtras = {
queryParams: { queryParams: {
"serialNumber": data.IdObject, "serialNumber": notification.data.IdObject,
} }
}; };
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar/diploma-assinar'], navigationExtras)); this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar/diploma-assinar'], navigationExtras));
} }
else if (data.Service === "gabinete-digital" && data.Object === "expedientes-pr") { else if (notification.data.Service === "gabinete-digital" && notification.data.Object === "expedientes-pr") {
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', data.IdObject, 'gabinete-digital'])); this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', notification.data.IdObject, 'gabinete-digital']));
} }
} }
+1 -1
View File
@@ -3,7 +3,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { StorageService } from 'src/app/services/storage.service'; import { StorageService } from 'src/app/services/storage.service';
import { AuthConnstants } from 'src/app/config/auth-constants'; import { AuthConnstants } from 'src/app/config/auth-constants';
import { Token } from '../models/token.model'; import { Tokenn } from '../models/token.model';
import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular'; import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular';
import { NavigationExtras, Router } from '@angular/router'; import { NavigationExtras, Router } from '@angular/router';
import { ToastService } from './toast.service'; import { ToastService } from './toast.service';
+4 -4
View File
@@ -6,7 +6,7 @@ import { LoginUserRespose } from 'src/app/models/user.model';
import { ProfilePage } from 'src/app/modals/profile/profile.page'; import { ProfilePage } from 'src/app/modals/profile/profile.page';
import { StorageService } from '../../services/storage.service'; import { StorageService } from '../../services/storage.service';
import { SessionStore } from 'src/app/store/session.service'; import { SessionStore } from 'src/app/store/session.service';
import { NotificationsService } from '../../services/notifications.service'; //import { NotificationsService } from '../../services/notifications.service';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { EventTrigger } from '../../services/eventTrigger.service'; import { EventTrigger } from '../../services/eventTrigger.service';
import { ThemeService } from '../../services/theme.service'; import { ThemeService } from '../../services/theme.service';
@@ -35,7 +35,7 @@ export class HeaderPage implements OnInit {
private animationController: AnimationController, private animationController: AnimationController,
private storageservice: StorageService, private storageservice: StorageService,
private platform: Platform, private platform: Platform,
private notificationsService: NotificationsService, //private notificationsService: NotificationsService,
private eventrigger: EventTrigger, private eventrigger: EventTrigger,
public ThemeService: ThemeService public ThemeService: ThemeService
) { ) {
@@ -67,7 +67,7 @@ export class HeaderPage implements OnInit {
} }
UpdateNotificationCount() { /* UpdateNotificationCount() {
this.notificationsService.registerCallback( this.notificationsService.registerCallback(
'any', 'any',
() => { () => {
@@ -76,7 +76,7 @@ export class HeaderPage implements OnInit {
}, 100) }, 100)
} }
) )
} } */
notificationLengthData() { notificationLengthData() {
this.storageservice.get("Notifications").then((value) => { this.storageservice.get("Notifications").then((value) => {
+23 -37
View File
@@ -1,42 +1,28 @@
function wlCommonInit() {
if(window['WLAuthorizationManager']) {
if(window['WLAuthorizationManager'].obtainAccessToken) {
window['WLAuthorizationManager'].obtainAccessToken("").then(
(token) => {
console.log('MobileFirst Server connect: Success ' + token);
var resourceRequest = new WLResourceRequest("/adapters/javaAdapter/resource/greet/",
WLResourceRequest.GET
);
resourceRequest.setQueryParameter("name", "world");
resourceRequest.send().then(
(response) => {
// Will display "Hello world" in an alert dialog.
console.log("Connect with JavaAdapter Success: " + response.responseText);
//this.MFPushNotification();
},
(error) => {
alert("Connect with JavaAdapter Failure: " + JSON.stringify(error));
}
);
}, (error) => {
console.log('MobileFirst Server connect: failure ' + error.responseText);
console.log(JSON.stringify(error))
/* this.zone.run(() => {
alert("Bummer...");
alert("Failed to connect to MobileFirst Server");
}); */
}
);
}
}
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.2.0/firebase-app.js";;
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.2.0/firebase-analytics.js";
import { getMessaging, getToken } from "https://www.gstatic.com/firebasejs/9.2.0/firebase-messaging.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyAAdHmTFznCMerdT99nrewJgISRvtxPqoY",
authDomain: "gabinete-digital-2020.firebaseapp.com",
databaseURL: "https://gabinete-digital-2020.firebaseio.com",
projectId: "gabinete-digital-2020",
storageBucket: "gabinete-digital-2020.appspot.com",
messagingSenderId: "800733765231",
appId: "1:800733765231:web:28e7792ab150006513779a",
measurementId: "G-8QN4BLZ8XK"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const messaging = getMessaging(app);
getToken({vapidKey: "BEuyzkUKcx4FSs-6GaIz_si2oV5Ut7e5ZEtcrVvr5L_tMVWZtS1NTqdtQkih5QCt2FZKuRUxZIaLm5GaxI6nJEw"});
}
+1
View File
@@ -65,6 +65,7 @@
<link rel="preconnect" href="https://fonts.gstatic.com"> <link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script type="module" src="./assets/js/index.js"></script>
</head> </head>
<body class='gov'> <body class='gov'>