Skip to content

Commit

Permalink
Merge pull request #63 from kiranrajbs/local_master
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
ase-101 authored May 19, 2021
2 parents f05c8b7 + 94fa02d commit c4d9a83
Show file tree
Hide file tree
Showing 19 changed files with 347 additions and 175 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="body">

<mat-form-field appearance="fill">
<mat-label>Process</mat-label>
<mat-select [(ngModel)]="selectedProcess">
<mat-option class="option" *ngFor="let obj of masterData.process;" [value]="obj ">{{obj}}</mat-option>
<mat-label>Purpose</mat-label>
<mat-select [(ngModel)]="selectedPurpose">
<mat-option class="option" *ngFor="let obj of masterData.purpose;" [value]="obj ">{{obj}}</mat-option>
</mat-select>
</mat-form-field><br/>

Expand Down Expand Up @@ -31,8 +31,8 @@

<mat-form-field appearance="fill">
<mat-label>SBI version</mat-label>
<mat-select [(ngModel)]="selectedMdsVersion">
<mat-option class="option" *ngFor="let obj of masterData.mdsSpecificationVersion;" [value]="obj ">{{obj}}</mat-option>
<mat-select [(ngModel)]="selectedSbiVersion">
<mat-option class="option" *ngFor="let obj of masterData.sbiSpecificationVersion;" [value]="obj ">{{obj}}</mat-option>
</mat-select>
</mat-form-field>
<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class CreateRunComponent implements OnInit {
selectedTests = [];
selectedBiometricType: any;
selectedDeviceType: any;
selectedMdsVersion: any;
selectedProcess: any;
selectedSbiVersion: any;
selectedPurpose: any;
email = '';
runName: '';

Expand All @@ -40,8 +40,8 @@ export class CreateRunComponent implements OnInit {
const requestBody = {
biometricType: this.selectedBiometricType.type,
deviceSubType: this.selectedDeviceType,
mdsSpecificationVersion: this.selectedMdsVersion,
process: this.selectedProcess
sbiSpecificationVersion: this.selectedSbiVersion,
purpose: this.selectedPurpose
};
// console.log(requestBody);
this.dataService.getTests(requestBody)
Expand All @@ -55,8 +55,8 @@ export class CreateRunComponent implements OnInit {
const requestBody = {
biometricType: this.selectedBiometricType.type,
deviceSubType: this.selectedDeviceType,
mdsSpecificationVersion: this.selectedMdsVersion,
process: this.selectedProcess,
sbiSpecificationVersion: this.selectedSbiVersion,
purpose: this.selectedPurpose,
tests: this.selectedTests,
email: this.email,
runName: this.runName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<br/>

<button mat-stroked-button color="primary" (click)="scan(host.value)">Scan
<button mat-stroked-button color="primary" (click)="scanSync(host.value)">Scan
<mat-icon *ngIf="scanning"><mat-spinner color="accent" diameter="20">
</mat-spinner></mat-icon></button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,22 @@ export class DiscoverDevicesComponent implements OnInit {

ngOnInit(): void {
this.scanning = false;
this.localStorageService.clearAllInfos();

this.availablePorts = this.localStorageService.getAvailablePorts();
this.mdshost = '';
}

onClear(): void {
this.discoveryResponse = null;
this.infoResponse = null;
this.availablePorts = [];
this.devices = [];
this.localStorageService.clearDeviceDiscover();
this.localStorageService.clearDeviceInfos();
}


discover(port: string) {
this.mdsService.discover(this.mdshost, port).subscribe(
response => this.discoveryResponse = response,
Expand All @@ -57,6 +69,8 @@ export class DiscoverDevicesComponent implements OnInit {

OnPortSelect(port) {
this.devices = this.localStorageService.getDevicesByPortNumber(port);
if (!this.devices.length)
window.alert(JSON.stringify(this.devices));
}

scan(host) {
Expand All @@ -81,6 +95,26 @@ export class DiscoverDevicesComponent implements OnInit {
);
}

async scanSync(host) {
if(host === '') {
window.alert("Please enter SBI host")
}
this.onClear();
this.mdshost = host;
this.scanning = true;
await this.mdsService.scanSync(this.mdshost);

this.scanning = false;
this.availablePorts = this.localStorageService.getAvailablePorts();

if(this.availablePorts && !this.availablePorts.length)
this.openDialog("Alert", "Scan Complete, No devices discovered.");
else
this.openDialog("Message", "Scan Complete");

console.log("scanSync>>Error>" + host + "<<<<availablePorts>>>");
}

openSnackBar(message: string, action: string) {
this.snackBar.open(message, action, {
duration: 2000,
Expand Down
16 changes: 8 additions & 8 deletions mds-test-ui/src/app/components/new-test/new-test.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@
<mat-step label="Select run configration" state="phone">

<mat-form-field appearance="fill">
<mat-label>Process</mat-label>
<mat-select [(ngModel)]="selectedProcess">
<mat-option class="option" *ngFor="let obj of masterData.process;" [value]="obj ">{{obj}}</mat-option>
<mat-label>Purpose</mat-label>
<mat-select [(ngModel)]="selectedPurpose">
<mat-option class="option" *ngFor="let obj of masterData.purpose;" [value]="obj ">{{obj}}</mat-option>
</mat-select>
</mat-form-field><br/>

<mat-form-field appearance="fill">
<mat-label>Biometric type</mat-label>
<mat-label>Biometric Device Type</mat-label>
<mat-select [(ngModel)]="selectedBiometricType" (selectionChange)='OnBiometricSelect($event)' name="sel2">
<mat-option *ngFor="let obj of masterData.biometricType;" [value]="obj ">{{obj.type}}</mat-option>
</mat-select>
</mat-form-field>

<br/>
<mat-form-field appearance="fill">
<mat-label>Device type</mat-label>
<mat-label>Device Sub Type</mat-label>
<mat-select [(ngModel)]="selectedDeviceType">
<mat-option *ngFor="let obj of deviceTypes;" [value]="obj">{{obj}}</mat-option>
</mat-select>
</mat-form-field>
<br/>

<mat-form-field appearance="fill">
<mat-label>SBI version</mat-label>
<mat-select [(ngModel)]="selectedMdsVersion">
<mat-option class="option" *ngFor="let obj of masterData.mdsSpecificationVersion;" [value]="obj ">{{obj}}</mat-option>
<mat-label>SBI Spec Version</mat-label>
<mat-select [(ngModel)]="selectedSbiVersion">
<mat-option class="option" *ngFor="let obj of masterData.sbiSpecificationVersion;" [value]="obj ">{{obj}}</mat-option>
</mat-select>
</mat-form-field>
<br/>
Expand Down
12 changes: 6 additions & 6 deletions mds-test-ui/src/app/components/new-test/new-test.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export class NewTestComponent implements OnInit {
selectedTests = [];
selectedBiometricType: any;
selectedDeviceType: any;
selectedMdsVersion: any;
selectedProcess: any;
selectedSbiVersion: any;
selectedPurpose: any;
email = '';
runName = '';

Expand All @@ -42,8 +42,8 @@ export class NewTestComponent implements OnInit {
const requestBody = {
biometricType: this.selectedBiometricType.type,
deviceSubType: this.selectedDeviceType,
mdsSpecificationVersion: this.selectedMdsVersion,
process: this.selectedProcess
sbiSpecificationVersion: this.selectedSbiVersion,
purpose: this.selectedPurpose
};
// console.log(requestBody);
this.dataService.getTests(requestBody)
Expand All @@ -57,8 +57,8 @@ export class NewTestComponent implements OnInit {
const requestBody = {
biometricType: this.selectedBiometricType.type,
deviceSubType: this.selectedDeviceType,
mdsSpecVersion: this.selectedMdsVersion,
process: this.selectedProcess,
mdsSpecVersion: this.selectedSbiVersion,
purpose: this.selectedPurpose,
tests: this.selectedTests,
email: this.email,
runName: this.runName
Expand Down
2 changes: 1 addition & 1 deletion mds-test-ui/src/app/components/run/run.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<mat-form-field appearance="fill">
<mat-label>Device</mat-label>
<mat-select [(ngModel)]="selectedDevice">
<mat-option *ngFor="let obj of devices;" [value]="obj">{{obj.purpose + obj.deviceId}}</mat-option>
<mat-option *ngFor="let obj of devices;" [value]="obj">{{'Purpose[' + obj.purpose + '] - BiometricDeviceType[' + obj.digitalIdDis.type + '] - DeviceSubType[' + obj.digitalIdDis.deviceSubType + ']' + ' - DeviceId[' + obj.deviceId+ ']'}}</mat-option>
</mat-select>
</mat-form-field>
<button mat-raised-button
Expand Down
4 changes: 3 additions & 1 deletion mds-test-ui/src/app/components/run/run.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export class RunComponent implements OnInit {
ngOnInit(): void {
console.log(history.state.data);
this.run = history.state.data;
this.availablePorts = this.localStorageService.getAvailablePorts();
this.availablePorts = this.localStorageService.getAvailablePortsForDevice();

// this.availablePorts = this.localStorageService.getAvailablePorts();
//this.fetchReport();
this.panelOpenState = false;
}
Expand Down
151 changes: 116 additions & 35 deletions mds-test-ui/src/app/services/local-storage/local-storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import {Observable} from 'rxjs';
export class LocalStorageService {
constructor() { }

clearAllInfos() {
;//localStorage.clear();
}

clearDeviceInfos() {
if (localStorage.getItem('deviceInfo')) {
localStorage.removeItem('deviceInfo');
}
}

addDeviceInfos(port: string, decodedDeviceInfo: any) {
console.log(decodedDeviceInfo);
// const devices = {
Expand All @@ -24,54 +34,125 @@ export class LocalStorageService {
localStorage.setItem('deviceInfo', JSON.stringify(deviceInfo));
}

clearDeviceDiscover() {
if (localStorage.getItem('discover')) {
localStorage.removeItem('discover');
}
}

addDeviceDiscover(port: string, deviceDiscover: any) {
console.log(deviceDiscover);
// const devices = {
// port: port,
// devices: decodedDeviceInfo
// };
// const devices = {};
// devices[port] = decodedDeviceInfo;
let discover = {};
//if (!localStorage.getItem('discover')) {
localStorage.setItem('discover', JSON.stringify(discover));
//}
discover = JSON.parse(localStorage.getItem('discover'));
discover[port] = deviceDiscover;
localStorage.setItem('discover', JSON.stringify(discover));
var discoverNew = {port: port + "", deviceDiscoverInfo: JSON.stringify(deviceDiscover)};
var discoverOld = [];

if (!localStorage.getItem('discover')) {
localStorage.setItem('discover', JSON.stringify(discoverOld));
}
discoverOld = JSON.parse(localStorage.getItem('discover'));
if (discoverOld.length <= 0)
{
discoverOld.push (discoverNew);
}
else if (discoverOld.length > 0)
{
var found = false;
for(var index = 0; index < discoverOld.length; index++)
{
var discoverInfo = discoverOld[index];
if (parseInt (discoverInfo.port + "") == parseInt (port))
{
discoverOld[index] = discoverNew;
found = true;
break
}
}
if (!found)
{
discoverOld.push(discoverNew);
}
}
localStorage.setItem('discover', JSON.stringify(discoverOld));
}
// using device info
// getAvailablePorts() {
// if (!localStorage.getItem('deviceInfo')) {
// return [];
// }
// const ports = Object.keys(JSON.parse(localStorage.getItem('deviceInfo')));
// // console.log(ports);
// return ports;
// }

getAvailablePorts() {
if (!localStorage.getItem('discover')) {
return [];
}
const ports = Object.keys(JSON.parse(localStorage.getItem('discover')));
// console.log(ports);
return ports;

var ports = [];
var discoverInfo = JSON.parse(localStorage.getItem('discover'));
for(var index = 0; index < discoverInfo.length; index++)
{
ports.push(discoverInfo[index].port + "");
}
return ports.sort(function(a, b){return a - b});
}
// using device info
// getDevicesByPortNumber(port: string) {
// if (!localStorage.getItem('deviceInfo')) {
// return [];
// }
// return JSON.parse(localStorage.getItem('deviceInfo'))[port];
// }

getAvailablePortsForDevice() {
if (!localStorage.getItem('discover')) {
return [];
}

let deviceDiscoverInfo = [];
var ports = [];
var discoverInfo = JSON.parse(localStorage.getItem('discover'));
for(var index = 0; index < discoverInfo.length; index++)
{
deviceDiscoverInfo = JSON.parse(discoverInfo[index].deviceDiscoverInfo);
var noError = false;
if (deviceDiscoverInfo)
{
for(var dindex = 0; dindex < deviceDiscoverInfo.length; dindex++)
{
var discoverObj = JSON.parse(JSON.stringify(deviceDiscoverInfo[dindex]));
//console.log("getAvailablePortsForDevice>>" + JSON.stringify(discoverObj));

var errorObj = discoverObj.error;
if (parseInt (errorObj.errorCode) == 100)
{
noError = true;
}
else
{
noError = false;
}
}
if (noError)
{
ports.push(discoverInfo[index].port + "");
}
}
}
return ports.sort(function(a, b){return a - b});
}

getDevicesByPortNumber(port: string) {
if (!localStorage.getItem('discover')) {
return [];
}
return JSON.parse(localStorage.getItem('discover'))[port];
}

let deviceDiscoverInfo = [];
let deviceDiscoverInfoNew = [];
var discoverInfo = JSON.parse(localStorage.getItem('discover'));
for(var index = 0; index < discoverInfo.length; index++)
{
if (parseInt (discoverInfo[index].port + "") == parseInt (port))
{
deviceDiscoverInfo = JSON.parse(discoverInfo[index].deviceDiscoverInfo);
if (deviceDiscoverInfo)
{
for(var dindex = 0; dindex < deviceDiscoverInfo.length; dindex++)
{
var discoverObj = JSON.parse(JSON.stringify(deviceDiscoverInfo[dindex]));
var digitalIdDisObj = JSON.parse(atob (discoverObj.digitalId));
//created new obj to add digitalIdDis: digitalIdDisObj for display purpose only
var discoverObjNew = {deviceId:discoverObj.deviceId, purpose:discoverObj.purpose, deviceSubId:discoverObj.deviceSubId, digitalId: discoverObj.digitalId, digitalIdDis: digitalIdDisObj, deviceStatus:discoverObj.deviceStatus, deviceCode:discoverObj.deviceCode, error:discoverObj.error, certification:discoverObj.certification, specVersion: discoverObj.specVersion, callbackId: discoverObj.callbackId, serviceVersion:discoverObj.serviceVersion};
deviceDiscoverInfo[dindex] = discoverObjNew;
}
}
break;
}
}
//console.log("getDevicesByPortNumber>>" + JSON.stringify(deviceDiscoverInfo));
return JSON.parse(JSON.stringify(deviceDiscoverInfo));
}
}
Loading

0 comments on commit c4d9a83

Please sign in to comment.