fix
This commit is contained in:
@@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "com.mermsemr.providers"
|
applicationId "com.mermsemr.providers"
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 1026
|
versionCode 1027
|
||||||
versionName "1.0.26"
|
versionName "1.0.27"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
<img src="./../../assets/imgs/avatar.svg">
|
<img src="./../../assets/imgs/avatar.svg">
|
||||||
</ion-avatar>
|
</ion-avatar>
|
||||||
<ion-label>
|
<ion-label>
|
||||||
<h2>Rey</h2>
|
<h2>Rey Dashe</h2>
|
||||||
<h3>I can handle myself</h3>
|
<h3>I can handle myself</h3>
|
||||||
<p>You will remove these restraints and leave...</p>
|
<p>You will remove these restraints and leave...</p>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Router, NavigationExtras } from '@angular/router'
|
import { Router, NavigationExtras } from '@angular/router'
|
||||||
import { MermsServiceProviderService } from './../providers/merms-service-provider.service';
|
import { MermsServiceProviderService } from './../providers/merms-service-provider.service';
|
||||||
|
import { MermsSessionService } from './../merms-session.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -17,17 +18,45 @@ export class MermsDashPage implements OnInit {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private mermsServiceProviderService: MermsServiceProviderService
|
private mermsServiceProviderService: MermsServiceProviderService,
|
||||||
|
private mermsSessionService : MermsSessionService
|
||||||
) {
|
) {
|
||||||
this.welcomeName = "Dr. Something"
|
this.welcomeName = "Dr. Something"
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
alert(100);
|
this.getDashData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentProviderData: {
|
||||||
|
sessionid: string,
|
||||||
|
member_id: number,
|
||||||
|
card_count: number
|
||||||
|
card_type: number
|
||||||
|
};
|
||||||
|
|
||||||
|
cardData: any;
|
||||||
|
|
||||||
getDashData() {
|
getDashData() {
|
||||||
|
console.log('MermsServiceProviderService::getDashData() ######## @@@@ ########');
|
||||||
|
this.currentProviderData = {
|
||||||
|
sessionid: this.mermsSessionService.session,
|
||||||
|
member_id: this.mermsSessionService.member_id,
|
||||||
|
card_count: 100,
|
||||||
|
card_type: 22000
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.mermsServiceProviderService.genericGetService('provider/recentencounter', this.currentProviderData).subscribe(cardData => {
|
||||||
|
console.log("card data result 22k: ", this.cardData);
|
||||||
|
if (cardData.hasOwnProperty('result_list') && Array.isArray(cardData['result_list'])) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export class MermsSessionService {
|
|||||||
top_card = '' // "https://www.float.sg/float/static_top.png";
|
top_card = '' // "https://www.float.sg/float/static_top.png";
|
||||||
firstname = ''
|
firstname = ''
|
||||||
lastname = ''
|
lastname = ''
|
||||||
session = ''
|
session = 'YESADUMMUFORNOW'
|
||||||
balance = 0
|
balance = 0
|
||||||
username = ''
|
username = ''
|
||||||
last_login = ''
|
last_login = ''
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'
|
||||||
import { Injectable, Injector } from '@angular/core'
|
import { Injectable, Injector } from '@angular/core'
|
||||||
//import 'rxjs/add/operator/map'
|
//import 'rxjs/add/operator/map'
|
||||||
//import { Observable, from } from 'rxjs'
|
import { Observable, from } from 'rxjs'
|
||||||
import { MermsSessionService } from './../merms-session.service';
|
import { MermsSessionService } from './../merms-session.service';
|
||||||
//import * as CryptoBrowserify from 'crypto-browserify'
|
//import * as CryptoBrowserify from 'crypto-browserify'
|
||||||
//import { CONFIG } from './app-config'
|
//import { CONFIG } from './app-config'
|
||||||
@@ -15,30 +15,48 @@ export class MermsServiceProviderService {
|
|||||||
|
|
||||||
//config = CONFIG[CONFIG.app.environment]()
|
//config = CONFIG[CONFIG.app.environment]()
|
||||||
//apiKey = this.config.apiKey
|
//apiKey = this.config.apiKey
|
||||||
url = ''
|
url = '';
|
||||||
// oauth_url: string = this.config.baseURL + '/SAVVY/oauth2/api'
|
apiKey = 'AMEYE';
|
||||||
// account_endpoint: string = this.config.baseURL + '/SAVVY/banklogin/api'
|
clientId = '1010101010';
|
||||||
// booking_endpoint: string = this.config.baseURL + '/SAVVY/booking/api'
|
|
||||||
// advice_endpoint: string = this.config.baseURL + '/SAVVY/advice/api'
|
|
||||||
// trip_endpoint: string = this.config.baseURL + '/SAVVY/trips/api'
|
|
||||||
// messaging_endpoint: string = this.config.baseURL + '/SAVVY/messaging/api'
|
|
||||||
// blog_endpoint: string = this.config.baseURL + '/SAVVY/blog/api'
|
|
||||||
// clientId: string = CONFIG.clientId
|
|
||||||
|
|
||||||
// encryptionKey: string = this.config.encryptionKey
|
|
||||||
// encryptionIV: string = this.config.encryptionIV
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor(public http: HttpClient,
|
constructor(public http: HttpClient,
|
||||||
private mermsSessionService:MermsSessionService) { }
|
private mermsSessionService: MermsSessionService) {
|
||||||
|
this.url="http://api.dev.mermsemr.com"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
genericPostService(endpoint: string, callData: any) {
|
||||||
|
if (this.mermsSessionService.session !== '') {
|
||||||
|
console.log('***** GENERIC SERVICE CALLED *****')
|
||||||
|
// Session & MemberId needed for all - pass in the header
|
||||||
|
return this.sendPostRequest('1', '/' + endpoint, callData)
|
||||||
|
} else {
|
||||||
|
console.log('***** NO SESSION *****')
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
genericGetService(endpoint: string, callData: any) {
|
||||||
|
if (this.mermsSessionService.session !== '') {
|
||||||
|
console.log('***** GENERIC SERVICE CALLED *****')
|
||||||
|
// Session & MemberId needed for all - pass in the header
|
||||||
|
return this.sendGetRequest('1', '/' + endpoint, callData)
|
||||||
|
} else {
|
||||||
|
console.log('***** NO SESSION *****')
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
loginUser(loginData) {
|
loginUser(loginData) {
|
||||||
// this.http.post(this.url + '/userlogin', loginData);
|
// this.http.post(this.url + '/userlogin', loginData);
|
||||||
return this.sendPostRequest('1', '/userlogin', loginData)
|
return this.sendPostRequest('1', '/userlogin', loginData)
|
||||||
}
|
}
|
||||||
|
|
||||||
sendPostRequest(grp: string, endPoint: string, sendData: any) {
|
|
||||||
|
|
||||||
|
sendGetRequest(grp: string, endPoint: string, sendData: any) {
|
||||||
// grp - will be used to change URL
|
// grp - will be used to change URL
|
||||||
let endpointString = ''
|
let endpointString = ''
|
||||||
console.log('GRP->' + grp)
|
console.log('GRP->' + grp)
|
||||||
@@ -49,7 +67,15 @@ export class MermsServiceProviderService {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
(async () => {
|
const httpParams = new HttpParams()
|
||||||
|
if (sendData) {
|
||||||
|
for (const k in sendData) {
|
||||||
|
if (k != null && sendData.hasOwnProperty(k)) {
|
||||||
|
httpParams.set(k, sendData[k])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;(async () => {
|
||||||
// const id = Math.floor(100 * Math.random());
|
// const id = Math.floor(100 * Math.random());
|
||||||
const id = (Math.random() * (10000 - 1000) + 1000).toFixed(0)
|
const id = (Math.random() * (10000 - 1000) + 1000).toFixed(0)
|
||||||
const d1 = new Date()
|
const d1 = new Date()
|
||||||
@@ -58,9 +84,136 @@ export class MermsServiceProviderService {
|
|||||||
const d2 = new Date()
|
const d2 = new Date()
|
||||||
console.log('[' + id + '] after semaphore: ' + d2.getTime())
|
console.log('[' + id + '] after semaphore: ' + d2.getTime())
|
||||||
})()
|
})()
|
||||||
|
return from(
|
||||||
|
new Promise((resolve) => {
|
||||||
|
const httpOptions = {
|
||||||
|
params: httpParams,
|
||||||
|
headers: new HttpHeaders({
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Access-Control-Allow-Credentials' : 'true',
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
'Access-Control-Allow-Methods': 'GET, POST, PATCH, DELETE, PUT, OPTIONS',
|
||||||
|
'Access-Control-Allow-Headers': 'Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With',
|
||||||
|
authorization: 'Token ' + this.apiKey,
|
||||||
|
'client_id': this.clientId,
|
||||||
|
'x-session-id': this.mermsSessionService.session,
|
||||||
|
'x-devicetoken': this.mermsSessionService.access_token,
|
||||||
|
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
// alert(100);
|
||||||
|
this.http.get(endpointString + endPoint, httpOptions).subscribe(
|
||||||
|
(data) => {
|
||||||
|
console.log(data);
|
||||||
|
console.log("*************************************************");
|
||||||
|
let payload = ''
|
||||||
|
if (data != null && data.hasOwnProperty('payload')) {
|
||||||
|
|
||||||
|
// console.log(payload);
|
||||||
|
} else {
|
||||||
|
payload = JSON.stringify(data)
|
||||||
|
}
|
||||||
|
let res = {}
|
||||||
|
try {
|
||||||
|
res = JSON.parse(payload)
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
if (this.queued > 0) {
|
||||||
|
this.queued--
|
||||||
|
}
|
||||||
|
|
||||||
|
this.checkSessionValid(res);
|
||||||
|
|
||||||
|
resolve(res)
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
if (this.queued > 0) {
|
||||||
|
this.queued--
|
||||||
|
}
|
||||||
|
resolve(this.getResponseError(error))
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
console.log('OK!')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendPostRequest(grp: string, endPoint: string, sendData: any) {
|
||||||
|
// grp - will be used to change URL
|
||||||
|
let endpointString = ''
|
||||||
|
console.log('GRP->' + grp)
|
||||||
|
switch (grp) {
|
||||||
|
case '1':
|
||||||
|
endpointString = this.url
|
||||||
|
break
|
||||||
|
}
|
||||||
|
; (async () => {
|
||||||
|
// const id = Math.floor(100 * Math.random());
|
||||||
|
const id = (Math.random() * (10000 - 1000) + 1000).toFixed(0)
|
||||||
|
const d1 = new Date()
|
||||||
|
console.log('[' + id + '] before semaphore: ' + d1.getTime())
|
||||||
|
await this.semaphore(id)
|
||||||
|
const d2 = new Date()
|
||||||
|
console.log('[' + id + '] after semaphore: ' + d2.getTime())
|
||||||
|
})()
|
||||||
|
return from(
|
||||||
|
new Promise((resolve) => {
|
||||||
|
// this.locationTrackerProvider = this.injector.get(LocationTrackerProvider);
|
||||||
|
const httpOptions = {
|
||||||
|
headers: new HttpHeaders({
|
||||||
|
authorization: 'Token ' + this.apiKey,
|
||||||
|
'client_id': this.clientId,
|
||||||
|
'x-session-id': this.mermsSessionService.session,
|
||||||
|
'x-devicetoken': this.mermsSessionService.access_token,
|
||||||
|
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
this.http
|
||||||
|
.post(endpointString + endPoint, sendData, httpOptions)
|
||||||
|
.subscribe(
|
||||||
|
(data) => {
|
||||||
|
// console.log(data);
|
||||||
|
// console.log("*************************************************");
|
||||||
|
let payload = ''
|
||||||
|
if (data != null && data.hasOwnProperty('payload')) {
|
||||||
|
payload = data['payload'];
|
||||||
|
// console.log(payload);
|
||||||
|
} else {
|
||||||
|
payload = JSON.stringify(data)
|
||||||
|
}
|
||||||
|
let res = {}
|
||||||
|
try {
|
||||||
|
res = JSON.parse(payload)
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
if (this.queued > 0) {
|
||||||
|
this.queued--
|
||||||
|
}
|
||||||
|
|
||||||
|
this.checkSessionValid(res);
|
||||||
|
|
||||||
|
resolve(res)
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
if (this.queued > 0) {
|
||||||
|
this.queued--
|
||||||
|
}
|
||||||
|
resolve(this.getResponseError(error))
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
console.log('OK!')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
getResponseError(error) {
|
getResponseError(error) {
|
||||||
// console.log("Error:" + JSON.stringify(error));
|
// console.log("Error:" + JSON.stringify(error));
|
||||||
console.log(error)
|
console.log(error)
|
||||||
@@ -75,34 +228,34 @@ export class MermsServiceProviderService {
|
|||||||
authUser(authData) {
|
authUser(authData) {
|
||||||
return this.sendPostRequest('4', '/auth', authData)
|
return this.sendPostRequest('4', '/auth', authData)
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
encrypt(iv: string, text: string, password: string) {
|
encrypt(iv: string, text: string, password: string) {
|
||||||
const cipher = CryptoBrowserify.createCipheriv('aes-256-ctr', password, iv)
|
const cipher = CryptoBrowserify.createCipheriv('aes-256-ctr', password, iv)
|
||||||
let crypted = cipher.update(text, 'utf8', 'hex')
|
let crypted = cipher.update(text, 'utf8', 'hex')
|
||||||
crypted += cipher.final('hex')
|
crypted += cipher.final('hex')
|
||||||
return crypted
|
return crypted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
decrypt(iv: string, text: string, password: string) {
|
||||||
|
const decipher = CryptoBrowserify.createDecipheriv(
|
||||||
|
'aes-256-ctr',
|
||||||
|
password,
|
||||||
|
iv
|
||||||
|
)
|
||||||
|
let dec = decipher.update(text, 'hex', 'utf8')
|
||||||
|
dec += decipher.final('utf8')
|
||||||
|
return dec
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Checks if the response from the server returns invalid session error
|
||||||
|
*
|
||||||
|
* @param response_data response from the server
|
||||||
|
*/
|
||||||
|
checkSessionValid(response_data: any) {
|
||||||
|
|
||||||
decrypt(iv: string, text: string, password: string) {
|
if ("session_valid" in response_data) {
|
||||||
const decipher = CryptoBrowserify.createDecipheriv(
|
if (response_data['session_valid'] === "INVALID_SESSION") {
|
||||||
'aes-256-ctr',
|
|
||||||
password,
|
|
||||||
iv
|
|
||||||
)
|
|
||||||
let dec = decipher.update(text, 'hex', 'utf8')
|
|
||||||
dec += decipher.final('utf8')
|
|
||||||
return dec
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Checks if the response from the server returns invalid session error
|
|
||||||
*
|
|
||||||
* @param response_data response from the server
|
|
||||||
*/
|
|
||||||
checkSessionValid(response_data: any){
|
|
||||||
|
|
||||||
if("session_valid" in response_data){
|
|
||||||
if(response_data['session_valid'] === "INVALID_SESSION") {
|
|
||||||
return this.doLogout();
|
return this.doLogout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,8 +263,8 @@ export class MermsServiceProviderService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
doLogout(){
|
doLogout() {
|
||||||
// this.floatEventsService.publish('DoLogout', {});
|
// this.floatEventsService.publish('DoLogout', {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -129,22 +282,22 @@ export class MermsServiceProviderService {
|
|||||||
this.lastQueued = sec
|
this.lastQueued = sec
|
||||||
console.log(
|
console.log(
|
||||||
'[' +
|
'[' +
|
||||||
marker +
|
marker +
|
||||||
'] inside semaphore: wait (queued: ' +
|
'] inside semaphore: wait (queued: ' +
|
||||||
this.queued +
|
this.queued +
|
||||||
', lastQueued: ' +
|
', lastQueued: ' +
|
||||||
this.lastQueued +
|
this.lastQueued +
|
||||||
')'
|
')'
|
||||||
)
|
)
|
||||||
await this.delay(1000)
|
await this.delay(1000)
|
||||||
console.log(
|
console.log(
|
||||||
'[' +
|
'[' +
|
||||||
marker +
|
marker +
|
||||||
'] inside semaphore: done (queued: ' +
|
'] inside semaphore: done (queued: ' +
|
||||||
this.queued +
|
this.queued +
|
||||||
', lastQueued: ' +
|
', lastQueued: ' +
|
||||||
this.lastQueued +
|
this.lastQueued +
|
||||||
')'
|
')'
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -152,22 +305,22 @@ export class MermsServiceProviderService {
|
|||||||
this.queued++
|
this.queued++
|
||||||
console.log(
|
console.log(
|
||||||
'[' +
|
'[' +
|
||||||
marker +
|
marker +
|
||||||
'] inside semaphore: wait (queued: ' +
|
'] inside semaphore: wait (queued: ' +
|
||||||
this.queued +
|
this.queued +
|
||||||
', lastQueued: ' +
|
', lastQueued: ' +
|
||||||
this.lastQueued +
|
this.lastQueued +
|
||||||
')'
|
')'
|
||||||
)
|
)
|
||||||
await this.delay(1000 + 1000 * this.queued)
|
await this.delay(1000 + 1000 * this.queued)
|
||||||
console.log(
|
console.log(
|
||||||
'[' +
|
'[' +
|
||||||
marker +
|
marker +
|
||||||
'] inside semaphore: done (queued: ' +
|
'] inside semaphore: done (queued: ' +
|
||||||
this.queued +
|
this.queued +
|
||||||
', lastQueued: ' +
|
', lastQueued: ' +
|
||||||
this.lastQueued +
|
this.lastQueued +
|
||||||
')'
|
')'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user