Skip to content

Commit ee711d0

Browse files
authored
Check if java installed (#149)
* Check if Java is installed on user's pc * Fix bug causing kml module to hang
1 parent e5de3e6 commit ee711d0

File tree

9 files changed

+161
-20
lines changed

9 files changed

+161
-20
lines changed

.vsconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "1.0",
3+
"components": [
4+
"Microsoft.VisualStudio.Workload.NativeDesktop",
5+
"microsoft.visualstudio.component.debugger.justintime",
6+
"microsoft.visualstudio.component.vc.diagnostictools",
7+
"microsoft.visualstudio.component.vc.cmake.project",
8+
"microsoft.visualstudio.component.vc.atl",
9+
"microsoft.visualstudio.component.vc.testadapterforboosttest",
10+
"microsoft.visualstudio.component.vc.testadapterforgoogletest"
11+
]
12+
}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ platform telecommunication management desktop app.
1010
* Parsing and loading telecommunication performance management(PM) network dumps
1111
* Reports module that supports tabular, graphs, and composite(dashboard-like) reports
1212
* Advanced GIS module
13+
* Network baseline audit
14+
* Utilities: CSV to Excel, KML Generator
1315

1416
## Built with
1517
* [Electron](https://electronjs.org)

background/kml.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,21 @@ async function generate(options, type){
363363
continue;
364364
}
365365

366+
367+
if( worksheet[XLSX.utils.encode_cell({c:longitudeIndex, r:R})] === undefined){
368+
log.warn(`LONGITUDE value is missing! for row=${R} and column=${longitudeIndex+1}`);
369+
continue;
370+
}
371+
372+
if( worksheet[XLSX.utils.encode_cell({c:azimuthIndex, r:R})] === undefined){
373+
log.warn(`AZIMUTH value is missing! for row=${R} and column=${azimuthIndex+1}`);
374+
continue;
375+
}
376+
366377
const latitude = worksheet[XLSX.utils.encode_cell({c:latitudeIndex, r:R})].v;
367378
const longitude = worksheet[XLSX.utils.encode_cell({c:longitudeIndex, r:R})].v;
368379
const azimuth = worksheet[XLSX.utils.encode_cell({c:azimuthIndex, r:R})].v;
369-
const cellLabel = worksheet[XLSX.utils.encode_cell({c:cellLabelIndex, r:R})].v ;
380+
const cellLabel = worksheet[XLSX.utils.encode_cell({c:cellLabelIndex, r:R})].v || "UNDEFINED" ;
370381
const height = getSomeValue(options.height, R);
371382
const azSteps = 6;
372383
const radius = getSomeValue(options.radius, R);
@@ -493,16 +504,16 @@ async function generate(options, type){
493504

494505
var fs = require('fs');
495506

496-
await new Promise((resolve, reject) => {
507+
var retStatus = await new Promise((resolve, reject) => {
497508
var stream = fs.createWriteStream(fileName, {emitClose: true});
498509
stream.on('error', function (err) {
499-
log.err(err);
500-
reject()
510+
log.error(err);
511+
reject({status: 'success', message: 'Parsing finished'});
501512
throw new Error("Error creating kml file.");
502513
});
503514

504515
stream.on('finish', function () {
505-
resolve();
516+
resolve({status: 'success', message: 'Parsing finished'});
506517
});
507518

508519

@@ -526,7 +537,12 @@ async function generate(options, type){
526537
// <size x="0" y="0" xunits="pixels" yunits="pixels"/>
527538
//</ScreenOverlay>`);
528539

529-
processFolders(options.folders, stream, {});
540+
try{
541+
processFolders(options.folders, stream, {});
542+
}catch(e){
543+
log.error(e)
544+
reject({message: 'Error occurred', status: 'error'});
545+
}
530546

531547
stream.write('</Document>\n');
532548
stream.write('</kml>\n');
@@ -536,7 +552,7 @@ async function generate(options, type){
536552
});
537553

538554
})
539-
555+
540556
return fileName;
541557

542558
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Boda-Lite",
3-
"version": "0.4.3",
3+
"version": "0.4.4",
44
"description": "Boda-Lite is a telecommunication network management application",
55
"private": true,
66
"homepage": "./",

src/app-reducer.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import settings from './modules/settings/settings-reducer';
88
import reports from './modules/reports/reports-reducer';
99
import gis from './modules/gis/gis-reducer';
1010
import kml from './modules/utilities/kml-reducer';
11-
11+
import dashboard from './modules/dashboard/dashboard-reducer';
1212
const appReducer = combineReducers({
1313
session,
1414
help,
@@ -18,7 +18,8 @@ const appReducer = combineReducers({
1818
settings,
1919
reports,
2020
gis,
21-
kml
21+
kml,
22+
dashboard
2223
});
2324

2425
export default appReducer;

src/modules/dashboard/Dashboard.jsx

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
33
import './dashboard.css';
44
import { connect } from 'react-redux';
55
import { addTab, setSidePanel } from '../layout/uilayout-actions';
6+
import { checkIfJavaIsInstalled, clearNotice } from './dashboard-actions';
67
import { Toaster, Intent } from "@blueprintjs/core";
78

89
const { shell } = window.require('electron').remote;
@@ -21,6 +22,14 @@ class Dashboard extends React.Component {
2122
this.setSidePanel = this.setSidePanel.bind(this);
2223

2324
this.toaster = new Toaster();
25+
26+
const that = this;
27+
28+
//Check if Java is installed
29+
setTimeout(() => {
30+
that.props.dispatch(checkIfJavaIsInstalled());
31+
},1000);
32+
2433

2534
}
2635

@@ -69,6 +78,10 @@ class Dashboard extends React.Component {
6978
let tabId = options.component;
7079
this.props.dispatch(addTab(tabId, options.component, {title: options.title}));
7180
}
81+
82+
dismissNotice = () => {
83+
this.props.dispatch(clearNotice());
84+
}
7285

7386
showGISModule= (options) => (e) => {
7487
e.preventDefault();
@@ -82,9 +95,22 @@ class Dashboard extends React.Component {
8295
}
8396

8497
render(){
98+
99+
let notice = null;
100+
if(this.props.notice !== null ){
101+
notice = (<div className={`alert alert-${this.props.notice.type} p-2 mt-2`} role="alert">{this.props.notice.message}
102+
<button type="button" className="close" aria-label="Close" onClick={this.dismissNotice}>
103+
<span aria-hidden="true">&times;</span>
104+
</button>
105+
</div>)
106+
}
107+
108+
console.log(this.props.notice);
109+
85110
return (
86111

87112
<div>
113+
{notice}
88114
<fieldset className="col-md-12 fieldset">
89115
<legend className="legend">Radio Access Network</legend>
90116

@@ -227,12 +253,10 @@ class Dashboard extends React.Component {
227253

228254
}
229255

230-
//function mapStateToProps(state) {
231-
// return {
232-
// tabs: state.tabs
233-
// }
234-
//}
235-
//
236-
//export default connect(mapStateToProps)(Dashboard);
237-
238-
export default connect()(Dashboard)
256+
function mapStateToProps(state) {
257+
return {
258+
notice: state.dashboard.notice
259+
}
260+
}
261+
262+
export default connect(mapStateToProps)(Dashboard);
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
const log = window.require('electron-log');
2+
3+
export const DASHBOARD_ADD_NOTICE = 'DASHBOARD_ADD_NOTICE';
4+
5+
export const DASHBOARD_CLEAR_NOTICE = 'DASHBOARD_CLEAR_NOTICE';
6+
7+
8+
export function clearNotice(){
9+
return {
10+
type: DASHBOARD_CLEAR_NOTICE
11+
};
12+
}
13+
14+
export function addDashboardNotice(notice){
15+
return {
16+
type: DASHBOARD_ADD_NOTICE,
17+
notice: notice
18+
};
19+
}
20+
21+
/*
22+
* Check if is installed
23+
*/
24+
export function checkIfJavaIsInstalled(){
25+
return (dispatch, getState) => {
26+
var spawn = window.require('child_process').spawn('java', ['-version']);
27+
spawn.on('error', function(err){
28+
//return callback(err, null);
29+
log.error(err);
30+
})
31+
32+
spawn.stdout.on('data', function(data) {
33+
console.log("spawn.stdout.on:", data);
34+
});
35+
36+
spawn.stderr.on('data', function(data) {
37+
38+
//Check if java is in string data
39+
var javaCheck = new RegExp('java', 'i').test(data);
40+
41+
//
42+
data = data.toString().split('\n')[0];
43+
var javaVersion = new RegExp('java version').test(data) ? data.split(' ')[2].replace(/"/g, '') : false;
44+
45+
if (javaCheck != false) {
46+
// TODO: We have Java installed
47+
dispatch(clearNotice());
48+
49+
} else {
50+
log.error("Java cannot be detected on your system. It is required by the application. Download Java from https://www.java.com/en/download");
51+
dispatch(addDashboardNotice({
52+
message: "Java cannot be detected on your system. It is required by the application. Download Java from https://www.java.com/en/download",
53+
type: 'danger'
54+
}))
55+
//@TODO: No Java installed
56+
}
57+
});
58+
59+
}
60+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {
2+
DASHBOARD_ADD_NOTICE,
3+
DASHBOARD_CLEAR_NOTICE
4+
} from './dashboard-actions';
5+
6+
const INITIAL_DASHBOARD_STATE = {
7+
//{message, type}
8+
notice: null
9+
}
10+
11+
export default function dashboard(state = INITIAL_DASHBOARD_STATE, action){
12+
switch (action.type) {
13+
case DASHBOARD_ADD_NOTICE:
14+
return {
15+
...state,
16+
notice: action.notice
17+
};
18+
case DASHBOARD_CLEAR_NOTICE:
19+
return {
20+
...state,
21+
notice: null
22+
}
23+
default:
24+
return state;
25+
}
26+
}

src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const VERSION = "0.4.3";
1+
export const VERSION = "0.4.4";
22

33
export default VERSION;

0 commit comments

Comments
 (0)