This commit is contained in:
Eudes Inácio
2021-10-07 16:22:31 +01:00
parent b6614f5c6c
commit 15840100a2
10 changed files with 7693 additions and 12848 deletions
+2 -102
View File
@@ -46,106 +46,6 @@
<splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
<splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<icon height="57" src="resources/ios/icon/icon.png" width="57" />
<icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
<icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
<icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
<icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
<icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
<icon height="40" src="resources/ios/icon/icon-20@2x.png" width="40" />
<icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
<icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
<icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
<icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
<icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
<icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
<icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
<icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
<icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
<icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
<icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
<icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
<icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
<icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
<icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
<icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
<icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
<icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
<icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
<icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
<icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
<icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
<icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
<splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
<splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
<splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
<splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
<splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
<splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
<splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
<splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
<splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
<splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
<splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
<splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
<splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
<splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
<icon height="57" src="resources/ios/icon/icon.png" width="57" />
<icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
<icon height="20" src="resources/ios/icon/icon-20.png" width="20" />
<icon height="40" src="resources/ios/icon/icon-20@2x.png" width="40" />
<icon height="60" src="resources/ios/icon/icon-20@3x.png" width="60" />
<icon height="29" src="resources/ios/icon/icon-29.png" width="29" />
<icon height="58" src="resources/ios/icon/icon-29@2x.png" width="58" />
<icon height="87" src="resources/ios/icon/icon-29@3x.png" width="87" />
<icon height="48" src="resources/ios/icon/icon-24@2x.png" width="48" />
<icon height="55" src="resources/ios/icon/icon-27.5@2x.png" width="55" />
<icon height="88" src="resources/ios/icon/icon-44@2x.png" width="88" />
<icon height="172" src="resources/ios/icon/icon-86@2x.png" width="172" />
<icon height="196" src="resources/ios/icon/icon-98@2x.png" width="196" />
<icon height="216" src="resources/ios/icon/icon-108@2x.png" width="216" />
<icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
<icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
<icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
<icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
<icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
<icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
<icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
<icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
<icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
<icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
<icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
<icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
<icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
<icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
<splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
<splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
<splash height="2688" src="resources/ios/splash/Default-2688h~iphone.png" width="1242" />
<splash height="1242" src="resources/ios/splash/Default-Landscape-2688h~iphone.png" width="2688" />
<splash height="1792" src="resources/ios/splash/Default-1792h~iphone.png" width="828" />
<splash height="828" src="resources/ios/splash/Default-Landscape-1792h~iphone.png" width="1792" />
<splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
<splash height="1125" src="resources/ios/splash/Default-Landscape-2436h.png" width="2436" />
<splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
<splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
<splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
<splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
<splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
<splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
<splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
<splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
<splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
<splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
</platform>
<plugin name="cordova-plugin-statusbar" spec="2.4.2" />
<plugin name="cordova-plugin-device" spec="2.0.2" />
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
<mfp:android>
<mfp:sdkChecksum>3077110622</mfp:sdkChecksum>
<mfp:appChecksum>3619450036</mfp:appChecksum>
@@ -154,7 +54,7 @@
</mfp:security>
</mfp:android>
<mfp:ios>
<mfp:sdkChecksum>246097737</mfp:sdkChecksum>
<mfp:sdkChecksum>1979143311</mfp:sdkChecksum>
<mfp:appChecksum>1328564293</mfp:appChecksum>
<mfp:security>
<mfp:testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3" />
@@ -181,7 +81,7 @@
</mfp:windows10>
<mfp:appChecksum>0</mfp:appChecksum>
</mfp:windows>
<mfp:platformVersion>8.0.0.00-20210308-063916</mfp:platformVersion>
<mfp:platformVersion>8.0.0.00-20210905-154328</mfp:platformVersion>
<mfp:clientCustomInit enabled="false" />
<mfp:server runtime="mfp" url="http://gpr-dev-10.gabinetedigital.local:9080" />
<mfp:serverUri url="" />
+7468 -12608
View File
File diff suppressed because it is too large Load Diff
+9 -7
View File
@@ -50,11 +50,11 @@
"@ionic-native/ionic-webview": "^5.35.0",
"@ionic-native/local-notifications": "^4.20.0",
"@ionic-native/media": "^5.36.0",
"@ionic-native/network": "^5.35.0",
"@ionic-native/network": "^5.36.0",
"@ionic-native/screen-orientation": "^5.35.0",
"@ionic-native/splash-screen": "^5.31.1",
"@ionic-native/sqlite": "^5.36.0",
"@ionic-native/sqlite-porter": "^5.31.1",
"@ionic-native/sqlite-porter": "^4.20.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic-native/wheel-selector": "^5.31.1",
"@ionic/angular": "^5.5.4",
@@ -93,6 +93,7 @@
"ionic-selectable": "^4.7.1",
"ionic2-alpha-scroll": "^2.0.1",
"ionic2-calendar": "^0.6.6",
"ionicons": "^5.5.3",
"jest-puppeteer": "^5.0.4",
"jetifier": "^1.6.6",
"lite-server": "^2.6.1",
@@ -126,13 +127,13 @@
"@types/jest": "^26.0.24",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"cordova-android": "^9.0.0",
"cordova-android": "^9.1.0",
"cordova-browser": "^6.0.0",
"cordova-ios": "^6.2.0",
"cordova-plugin-androidx": "^3.0.0",
"cordova-plugin-androidx-adapter": "^1.1.3",
"cordova-plugin-camera": "git+https://github.com/PieterVanPoyer/cordova-plugin-camera.git#bugfix/issue-665-save-instance-restore-bug",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-crosswalk-webview": "git+https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview.git",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-file": "^6.0.2",
@@ -163,7 +164,8 @@
"ts-jest-puppeteer": "0.0.5",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "^4.3.5"
"typescript": "^4.3.5",
"uk.co.workingedge.cordova.plugin.sqliteporter": "^1.1.1"
},
"description": "An Ionic project",
"cordova": {
@@ -189,11 +191,11 @@
},
"cordova-plugin-media": {
"KEEP_AVAUDIOSESSION_ALWAYS_ACTIVE": "NO"
}
},
"uk.co.workingedge.cordova.plugin.sqliteporter": {}
},
"platforms": [
"browser",
"ios",
"android"
]
},
+29 -19
View File
@@ -21,6 +21,9 @@ import { File } from '@ionic-native/file/ngx';
import { WebNotificationPopupService } from '../services/notification/web-notification-popup.service';
import { DocumentCounterService } from '../services/worker/document-counter.service';
import { PermissionService } from '../services/worker/permission.service';
import { Network } from '@ionic-native/network/ngx';
import { BackgroundService } from 'src/app/services/background.service';
@Component({
selector: 'app-home',
@@ -63,8 +66,8 @@ export class HomePage implements OnInit {
synchro = synchro
status:string="";
audioName:string="";
status: string = "";
audioName: string = "";
constructor(
private zone: NgZone,
private router: Router,
@@ -78,7 +81,9 @@ export class HomePage implements OnInit {
private despachoRule: DespachoService,
private inativityService: InativityService,
private storageService: StorageService,
private webNotificationPopupService: WebNotificationPopupService) {
private webNotificationPopupService: WebNotificationPopupService,
private network: Network,
private backgroundservice: BackgroundService) {
this.webNotificationPopupService.askNotificationPermission()
@@ -89,7 +94,7 @@ export class HomePage implements OnInit {
window['platform'] = platform
window['inactivity/function'] = () => {
if(window.location.pathname != '/inactivity') {
if (window.location.pathname != '/inactivity') {
const pathname = window.location.pathname
SessionStore.setUrlBeforeInactivity(pathname)
@@ -104,14 +109,19 @@ export class HomePage implements OnInit {
this.router.navigate([url])
}
refreshing() {}
refreshing() { }
ngOnInit() {
/* this.network.checkNetworkConnection;
this.network.checkNetworkDisconnection; */
// console.log('Active route ', this.router.url)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
window.addEventListener('online', () => {
console.log('Became online')
this.backgroundservice.online()
});
window.addEventListener('offline', () => {
console.log('Became offline')
this.backgroundservice.offline()
});
this.webnotification.webconnection();
this.webnotification.register();
} else {
@@ -121,9 +131,9 @@ export class HomePage implements OnInit {
this.updateList()
var myWorker = new Worker(new URL('./nice.worker.js', import.meta.url) );
var myWorker = new Worker(new URL('./nice.worker.js', import.meta.url));
myWorker.onmessage = function(oEvent) {
myWorker.onmessage = function (oEvent) {
console.log('Worker said : ' + oEvent.data);
}
@@ -134,8 +144,8 @@ export class HomePage implements OnInit {
console.log("Mobileconecct");
if(window['WLAuthorizationManager']) {
if(window['WLAuthorizationManager'].obtainAccessToken) {
if (window['WLAuthorizationManager']) {
if (window['WLAuthorizationManager'].obtainAccessToken) {
window['WLAuthorizationManager'].obtainAccessToken("").then((token) => {
console.log('MobileFirst Server connect: Success ' + token);
@@ -172,35 +182,35 @@ export class HomePage implements OnInit {
this.notificationsService.registerCallback(
'despachos',
() => {
this.despachoRule.getList({updateStore: true})
this.despachoRule.getList({ updateStore: true })
}
)
synchro.registerCallback('Online',()=>{
synchro.registerCallback('Online', () => {
console.log('Onlineee')
})
synchro.registerCallback('Offline',()=>{
synchro.registerCallback('Offline', () => {
console.log('Offlineee')
})
synchro.conected
synchro.registerCallback('Notification', (DataArray)=> {
synchro.registerCallback('Notification', (DataArray) => {
this.webNotificationPopupService.sendNotification(DataArray)
this.storageService.get('Notifications').then((data:any)=>{
this.storageService.get('Notifications').then((data: any) => {
data.push(DataArray)
this.storageService.store("Notifications", data)
}).catch(()=>{
}).catch(() => {
const a = []
a.push(DataArray)
this.storageService.store("Notifications",a)
this.storageService.store("Notifications", a)
})
}, 'any')
+2 -1
View File
@@ -500,7 +500,7 @@ export class AgendaPage implements OnInit {
this.eventService.getAllMdEvents( momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59') ).then(
(response:any) => {
console.log('All events MD', response)
// calendar
this.CalendarStore.removeRange(startTime, endTime, 'md')
@@ -524,6 +524,7 @@ export class AgendaPage implements OnInit {
else if(this.profile == "pr" && this.loggeduser.Profile == 'MDGPR') {
this.eventService.getAllSharedEvents(momentG(new Date(startTime),'yyyy-MM-dd HH:mm:ss'), momentG(new Date(endTime),'yyyy-MM-dd 23:59:59')).then((response:any) => {
console.log('All events PR', response)
this.CalendarStore.removeRange(startTime, endTime, 'pr')
// calendar
@@ -94,23 +94,16 @@ export class ViewEventPage implements OnInit {
}
ngOnInit() {
synchro.registerCallback('Online', () => {
if(synchro.connected === true) {
this.loadEvent();
console.log('Onlineee view-event')
})
synchro.registerCallback('Offline', () => {
this.platform.ready().then(() => {
this.sqliteservice.getEventById(this.eventId).then((event) => {
this.loadedEvent = event[0];
console.log("Event ditails local,", event[0])
})
console.log('Offlineee')
} else {
this.sqliteservice.getEventById(this.eventId).then((event) => {
this.loadedEvent = event[0];
console.log("Event ditails local,", event[0])
})
})
console.log('Offlineee')
}
/* this.sqliteservice.getEventById(this.eventId).then((event) => {
this.loadedEvent = event[0];
@@ -160,6 +153,7 @@ export class ViewEventPage implements OnInit {
this.eventsService.getEvent(this.eventId).subscribe(res => {
this.loadedEvent = res;
this.sqliteservice.addEvent(res);
console.log('Loaded one event', res)
/* this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); */
loader.remove()
+90 -12
View File
@@ -18,6 +18,7 @@ import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
import { SqliteService } from 'src/app/services/sqlite.service';
import { synchro } from '../../services/socket/synchro.service';
import { BackgroundService } from 'src/app/services/background.service'
@Component({
selector: 'app-events',
@@ -92,6 +93,7 @@ export class EventsPage implements OnInit {
private screenOrientation: ScreenOrientation,
public platform: Platform,
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService
) {
this.existingScreenOrientation = this.screenOrientation.type;
console.log(this.existingScreenOrientation);
@@ -106,10 +108,13 @@ export class EventsPage implements OnInit {
});
try {
this.sqliteservice.databaseConn();
} catch (error) {
console.log("Error creating local database: ", error)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
try {
this.sqliteservice.databaseConn();
} catch (error) {
console.log("Error creating local database: ", error)
}
}
}
@@ -119,6 +124,20 @@ export class EventsPage implements OnInit {
this.segment = "Combinada";
this.profile = "mdgpr";
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
this.showGreeting();
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents();
setTimeout(() => {
this.LoadList();
}, 1500)
}
});
this.hideSearch();
}
this.getEventsFromLocalDb();
//this.checkScreenOrientation();
@@ -185,9 +204,14 @@ export class EventsPage implements OnInit {
const list = mdOficialEvents.concat(mdPessoalEvents);
console.log("getAllMdOficialPessoalEvents", list)
/* list.forEach(element => {
this.sqliteservice.addEvent(element)
}); */
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
if(list.length > 0) {
list.forEach(element => {
this.sqliteservice.addEvent(element)
});
}
}
this.listToPresent = list
@@ -208,10 +232,14 @@ export class EventsPage implements OnInit {
const list = prOficialEvents.concat(prPessoalEvents);
console.log("getAllPrOficialPessoalEvents", list)
/* list.forEach(element => {
this.sqliteservice.addEvent(element)
}); */
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
if(list.length > 0) {
list.forEach(element => {
this.sqliteservice.addEvent(element)
});
}
}
if (list.length > 0) {
this.currentEvent = list[0].Subject;
this.currentHoursMinutes = list[0].StartDate;
@@ -296,6 +324,52 @@ export class EventsPage implements OnInit {
getEventsFromLocalDb() {
window.addEventListener('online',() => {
this.showGreeting();
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd && event.url == '/home/events') {
this.RefreshEvents();
setTimeout(() => {
this.LoadList();
}, 1500)
}
});
this.hideSearch();
})
window.addEventListener('offline', () => {
this.sqliteservice.getAllEvents().then((event:any[]) => {
this.listToPresent = event
this.totalEvent = this.listToPresent.length
this.currentEvent = this.listToPresent[0].Subject
this.currentHoursMinutes = this.listToPresent[0].StartDate
console.log("All events from local,", event)
})
this.sqliteservice.getprocessByworkflow("Expediente").then((process: any[]) => {
var expedientlist = [];
process.forEach((element) => {
let task = {
CreateDate: element.taskStartDate,
DocumentsQty: element.totalDocuments,
Senders: JSON.parse(element.workflowInstanceDataFields).Sender,
SerialNumber: element.serialNumber,
Status: JSON.parse(element.workflowInstanceDataFields).Status,
Subject: JSON.parse(element.workflowInstanceDataFields).Subject,
WorkflowName: element.workflowDisplayName,
activityInstanceName: element.activityInstanceName,
taskStartDate: element.taskStartDate,
}
expedientlist.push(task);
})
const ExpedienteTask = expedientlist.map(e => this.expedienteTaskPipe.transform(e))
this.listToPresentexpediente = ExpedienteTask;
})
})
if (synchro.connected === true) {
this.showGreeting();
@@ -396,7 +470,11 @@ export class EventsPage implements OnInit {
LoadList() {
this.processes.GetTaskListExpediente(false).subscribe(result => {
console.log("Expediente", result);
this.sqliteservice.addProcess(result)
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
this.sqliteservice.addProcess(result)
}
const ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e))
+3 -3
View File
@@ -106,11 +106,11 @@ export class NotificationsService {
}
);
window['MFPPush'].registerDevice(null, (successResponse) => {
window['MFPPush'].registerDevice(null, async (successResponse) => {
console.log("Successfully registered: " + JSON.stringify(successResponse));
console.log('token: ', successResponse.deviceId)
this.storageService.store(username, successResponse.deviceId);
this.storageService.get(username).then(value => {
await this.storageService.store(username, successResponse.deviceId);
await this.storageService.get(username).then(value => {
console.log('STORAGE TOKEN', value)
this.storageService.get(AuthConnstants.USER).then(res => {
console.log('USERID', res);
+60 -59
View File
@@ -5,7 +5,7 @@ import { BackgroundService } from '../background.service';
import { environment } from 'src/environments/environment';
import { EventTrigger } from '../eventTrigger.service'
export interface wss{
export interface wss {
url: string,
type: 'reflect' | 'emit'
@@ -21,24 +21,24 @@ export interface wss{
providedIn: 'root'
})
class SynchroService {
[x: string]: any;
[x: string]: any;
private connection!: WebSocket;
private connection!: WebSocket;
private id: string = uuidv4();
public conected = false
private url: string = ''
callback = function(){}
callback = function () { }
private _connected = false;
private eventtrigger: EventTrigger;
private BackgroundService = new BackgroundService()
callBacks: {
type: 'Offline' | 'Online' | 'Onmessage' | 'Chat' | 'Notification' | 'Notifications' | '',
type: 'Offline' | 'Online' | 'Onmessage' | 'Chat' | 'Notification' | 'Notifications' | '',
object?: string
funx: Function
}[] = []
private msgQueue = []
constructor() {
constructor() {
// alert(SessionStore.user.FullName)
}
@@ -48,13 +48,13 @@ class SynchroService {
setUrl() {
let header ={
id:'1234',
let header = {
id: '1234',
bluePrint: '12312123',
jwt: uuidv4()
}
let wss: wss ={
let wss: wss = {
header,
url: 'wss://sychro-offline.herokuapp.com/ws/some_url/',
type: 'reflect'
@@ -63,7 +63,7 @@ class SynchroService {
this.url = `${wss.url}${wss.header.id}/${wss.header.jwt}/${wss.header.bluePrint}/${this.id}/`
}
registerCallback(type: 'Offline' | 'Online' | 'Onmessage' | 'Chat' | 'Notifications' | 'Notification', funx: Function, object='') {
registerCallback(type: 'Offline' | 'Online' | 'Onmessage' | 'Chat' | 'Notifications' | 'Notification', funx: Function, object = '') {
this.callBacks.push({
type,
funx,
@@ -71,29 +71,29 @@ class SynchroService {
})
}
connect() {
connect() {
this.connection = new WebSocket(this.url);
// bind function
this.connection.onopen = this.onopen;
this.connection.onmessage = this.onmessage;
this.connection.onclose = this.onclose;
this.connection.onerror = this.onerror;
}
this.connection = new WebSocket(this.url);
// bind function
this.connection.onopen = this.onopen;
this.connection.onmessage = this.onmessage;
this.connection.onclose = this.onclose;
this.connection.onerror = this.onerror;
}
private onopen = () =>{
private onopen = () => {
if(this._connected === true) {
//if (this._connected === true) {
this.BackgroundService.online()
console.log('Online',this._connected)
this.callBacks.forEach((e)=>{
if(e.type == 'Online') {
console.log('Online', this._connected)
this.callBacks.forEach((e) => {
if (e.type == 'Online') {
e.funx()
}
})
}
//}
console.log('open ======================= welcome to socket server')
@@ -105,15 +105,15 @@ class SynchroService {
object.splice(index, 1);
})
}
}
public $send(object: any) {
if(!this._connected) { // save data to send when back online
if (!this._connected) { // save data to send when back online
this.msgQueue.push(object)
}
let payload = {
let payload = {
message: JSON.stringify(object) || '{"person.adress.country":"1Angola"}',
username: SessionStore.user.FullName,
idConnection: this.id
@@ -126,7 +126,7 @@ class SynchroService {
this.connection.send(sendData);
}
private onmessage = async (event: any)=> {
private onmessage = async (event: any) => {
let data = JSON.parse(event.data)
@@ -135,30 +135,30 @@ class SynchroService {
const idConnection = payload.idConnection
const username = payload.username
if(idConnection != this.id ) {
if (idConnection != this.id) {
if(window['platform'].is('desktop') || this.platform.is('mobileweb')) {}
if (window['platform'].is('desktop') || this.platform.is('mobileweb')) { }
else return false
if(environment.production) return false
if (environment.production) return false
this.callBacks.forEach((e)=> {
this.callBacks.forEach((e) => {
if(payload.message[0]) {
if(payload.message[0].Service && payload.message[0].Object && payload.message[0].IdObject) {
if(e.type == '' && !e.object) {
if(username == SessionStore.user.FullName) {
if (payload.message[0]) {
if (payload.message[0].Service && payload.message[0].Object && payload.message[0].IdObject) {
if (e.type == '' && !e.object) {
if (username == SessionStore.user.FullName) {
e.funx(payload.message, data)
}
}
if(e.type == 'Notifications' ) {
if (e.type == 'Notifications') {
e.funx(payload.message, data)
}
}
} else if(payload.message.Service && payload.message.Object && payload.message.IdObject) {
if(e.type == 'Notification' && e.object == payload.message.Object || e.type == 'Notification' && e.object == 'any' ) {
} else if (payload.message.Service && payload.message.Object && payload.message.IdObject) {
if (e.type == 'Notification' && e.object == payload.message.Object || e.type == 'Notification' && e.object == 'any') {
e.funx(payload.message, data)
}
}
@@ -167,29 +167,30 @@ class SynchroService {
}
this.callback()
}
}
private onclose=(event:any)=> {
setTimeout(() => {
if (event.wasClean) {
console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
} else {
// e.g. server process killed or network down
// event.code is usually 1006 in this case
console.log('[close] Connection died');
private onclose = (event: any) => {
console.log('Websocket close')
setTimeout(() => {
if (event.wasClean) {
console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
} else {
// e.g. server process killed or network down
// event.code is usually 1006 in this case
console.log('[close] Connection died');
console.log('Reconnect')
if(this._connected === false){
// if (this._connected === false) {
this.BackgroundService.offline();
console.log('Offline',this._connected)
this.callBacks.forEach((e)=>{
if(e.type == 'Offline') {
console.log('Offline', this._connected)
this.callBacks.forEach((e) => {
if (e.type == 'Offline') {
e.funx()
}
})
}
//}
// status
@@ -197,13 +198,13 @@ class SynchroService {
// reconnect
this.connect()
}
}, 100);
}
}
}, 100);
}
private onerror=(event: any)=>{
console.log(`[error] ${event.message}`);
}
private onerror = (event: any) => {
console.log(`[error] ${event.message}`);
}
}
+1 -2
View File
@@ -13,8 +13,7 @@
<script src="node_modules/ibm-mfp-web-sdk/ibmmfpfanalytics.js"></script> -->
<!-- <script src="assets/js/index.js"></script> -->
<link rel="manifest" href="assets/manifest.json">
<script src="assets/js/wldirectudpate.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<!-- <script src="assets/js/wldirectudpate.js"></script> -->
<script>
if (navigator.serviceWorker) {