Skip to content

Commit

Permalink
Check if java installed (#149)
Browse files Browse the repository at this point in the history
* Check if Java is installed on user's pc

* Fix bug causing kml module to hang
  • Loading branch information
erssebaggala committed Nov 5, 2019
1 parent e5de3e6 commit ee711d0
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 20 deletions.
12 changes: 12 additions & 0 deletions .vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.NativeDesktop",
"microsoft.visualstudio.component.debugger.justintime",
"microsoft.visualstudio.component.vc.diagnostictools",
"microsoft.visualstudio.component.vc.cmake.project",
"microsoft.visualstudio.component.vc.atl",
"microsoft.visualstudio.component.vc.testadapterforboosttest",
"microsoft.visualstudio.component.vc.testadapterforgoogletest"
]
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ platform telecommunication management desktop app.
* Parsing and loading telecommunication performance management(PM) network dumps
* Reports module that supports tabular, graphs, and composite(dashboard-like) reports
* Advanced GIS module
* Network baseline audit
* Utilities: CSV to Excel, KML Generator

## Built with
* [Electron](https://electronjs.org)
Expand Down
30 changes: 23 additions & 7 deletions background/kml.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,21 @@ async function generate(options, type){
continue;
}


if( worksheet[XLSX.utils.encode_cell({c:longitudeIndex, r:R})] === undefined){
log.warn(`LONGITUDE value is missing! for row=${R} and column=${longitudeIndex+1}`);
continue;
}

if( worksheet[XLSX.utils.encode_cell({c:azimuthIndex, r:R})] === undefined){
log.warn(`AZIMUTH value is missing! for row=${R} and column=${azimuthIndex+1}`);
continue;
}

const latitude = worksheet[XLSX.utils.encode_cell({c:latitudeIndex, r:R})].v;
const longitude = worksheet[XLSX.utils.encode_cell({c:longitudeIndex, r:R})].v;
const azimuth = worksheet[XLSX.utils.encode_cell({c:azimuthIndex, r:R})].v;
const cellLabel = worksheet[XLSX.utils.encode_cell({c:cellLabelIndex, r:R})].v ;
const cellLabel = worksheet[XLSX.utils.encode_cell({c:cellLabelIndex, r:R})].v || "UNDEFINED" ;
const height = getSomeValue(options.height, R);
const azSteps = 6;
const radius = getSomeValue(options.radius, R);
Expand Down Expand Up @@ -493,16 +504,16 @@ async function generate(options, type){

var fs = require('fs');

await new Promise((resolve, reject) => {
var retStatus = await new Promise((resolve, reject) => {
var stream = fs.createWriteStream(fileName, {emitClose: true});
stream.on('error', function (err) {
log.err(err);
reject()
log.error(err);
reject({status: 'success', message: 'Parsing finished'});
throw new Error("Error creating kml file.");
});

stream.on('finish', function () {
resolve();
resolve({status: 'success', message: 'Parsing finished'});
});


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

processFolders(options.folders, stream, {});
try{
processFolders(options.folders, stream, {});
}catch(e){
log.error(e)
reject({message: 'Error occurred', status: 'error'});
}

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

})

return fileName;

}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Boda-Lite",
"version": "0.4.3",
"version": "0.4.4",
"description": "Boda-Lite is a telecommunication network management application",
"private": true,
"homepage": "./",
Expand Down
5 changes: 3 additions & 2 deletions src/app-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import settings from './modules/settings/settings-reducer';
import reports from './modules/reports/reports-reducer';
import gis from './modules/gis/gis-reducer';
import kml from './modules/utilities/kml-reducer';

import dashboard from './modules/dashboard/dashboard-reducer';
const appReducer = combineReducers({
session,
help,
Expand All @@ -18,7 +18,8 @@ const appReducer = combineReducers({
settings,
reports,
gis,
kml
kml,
dashboard
});

export default appReducer;
42 changes: 33 additions & 9 deletions src/modules/dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import './dashboard.css';
import { connect } from 'react-redux';
import { addTab, setSidePanel } from '../layout/uilayout-actions';
import { checkIfJavaIsInstalled, clearNotice } from './dashboard-actions';
import { Toaster, Intent } from "@blueprintjs/core";

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

this.toaster = new Toaster();

const that = this;

//Check if Java is installed
setTimeout(() => {
that.props.dispatch(checkIfJavaIsInstalled());
},1000);


}

Expand Down Expand Up @@ -69,6 +78,10 @@ class Dashboard extends React.Component {
let tabId = options.component;
this.props.dispatch(addTab(tabId, options.component, {title: options.title}));
}

dismissNotice = () => {
this.props.dispatch(clearNotice());
}

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

render(){

let notice = null;
if(this.props.notice !== null ){
notice = (<div className={`alert alert-${this.props.notice.type} p-2 mt-2`} role="alert">{this.props.notice.message}
<button type="button" className="close" aria-label="Close" onClick={this.dismissNotice}>
<span aria-hidden="true">&times;</span>
</button>
</div>)
}

console.log(this.props.notice);

return (

<div>
{notice}
<fieldset className="col-md-12 fieldset">
<legend className="legend">Radio Access Network</legend>

Expand Down Expand Up @@ -227,12 +253,10 @@ class Dashboard extends React.Component {

}

//function mapStateToProps(state) {
// return {
// tabs: state.tabs
// }
//}
//
//export default connect(mapStateToProps)(Dashboard);

export default connect()(Dashboard)
function mapStateToProps(state) {
return {
notice: state.dashboard.notice
}
}

export default connect(mapStateToProps)(Dashboard);
60 changes: 60 additions & 0 deletions src/modules/dashboard/dashboard-actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const log = window.require('electron-log');

export const DASHBOARD_ADD_NOTICE = 'DASHBOARD_ADD_NOTICE';

export const DASHBOARD_CLEAR_NOTICE = 'DASHBOARD_CLEAR_NOTICE';


export function clearNotice(){
return {
type: DASHBOARD_CLEAR_NOTICE
};
}

export function addDashboardNotice(notice){
return {
type: DASHBOARD_ADD_NOTICE,
notice: notice
};
}

/*
* Check if is installed
*/
export function checkIfJavaIsInstalled(){
return (dispatch, getState) => {
var spawn = window.require('child_process').spawn('java', ['-version']);
spawn.on('error', function(err){
//return callback(err, null);
log.error(err);
})

spawn.stdout.on('data', function(data) {
console.log("spawn.stdout.on:", data);
});

spawn.stderr.on('data', function(data) {

//Check if java is in string data
var javaCheck = new RegExp('java', 'i').test(data);

//
data = data.toString().split('\n')[0];
var javaVersion = new RegExp('java version').test(data) ? data.split(' ')[2].replace(/"/g, '') : false;

if (javaCheck != false) {
// TODO: We have Java installed
dispatch(clearNotice());

} else {
log.error("Java cannot be detected on your system. It is required by the application. Download Java from https://www.java.com/en/download");
dispatch(addDashboardNotice({
message: "Java cannot be detected on your system. It is required by the application. Download Java from https://www.java.com/en/download",
type: 'danger'
}))
//@TODO: No Java installed
}
});

}
}
26 changes: 26 additions & 0 deletions src/modules/dashboard/dashboard-reducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
DASHBOARD_ADD_NOTICE,
DASHBOARD_CLEAR_NOTICE
} from './dashboard-actions';

const INITIAL_DASHBOARD_STATE = {
//{message, type}
notice: null
}

export default function dashboard(state = INITIAL_DASHBOARD_STATE, action){
switch (action.type) {
case DASHBOARD_ADD_NOTICE:
return {
...state,
notice: action.notice
};
case DASHBOARD_CLEAR_NOTICE:
return {
...state,
notice: null
}
default:
return state;
}
}
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const VERSION = "0.4.3";
export const VERSION = "0.4.4";

export default VERSION;

0 comments on commit ee711d0

Please sign in to comment.