Skip to content

Commit

Permalink
Update sector color on GIS Module (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
erssebaggala authored Oct 6, 2019
2 parents f20f385 + 5e2f57e commit 4b173b3
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 38 deletions.
14 changes: 13 additions & 1 deletion background/background-process.html
Original file line number Diff line number Diff line change
Expand Up @@ -851,9 +851,21 @@ <h1>Background process</h1>
}catch(err){
log.error(err)
sendLogToUI(task,'error', "Error occured while importing file. Check logs for details.");
}
}

// clear_baseline_reference
try{
if(task === 'clear_baseline_reference'){
const result = await utils.clearBaselineReference();
sendLogToUI(task, result.status, result.message);
}
}catch(err){
log.error(err)
sendLogToUI(task,'error', "Error occured while clearing the baseline reference. Check logs for details.");
}
}


ipcRenderer.on('parse-cm-job', (event, task, args) => {
log.info(`Backgroup process: task: ${task} args: ${args}`);
const obj = JSON.parse(args)
Expand Down
11 changes: 11 additions & 0 deletions background/background-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,17 @@ async function importGISFile(fileName, format, truncateTable){
}
}

async function clearBaselineReference(){
try{
await queryHelper.runQuery("TRUNCATE TABLE baseline.configuration RESTART IDENTITY");
return {status: 'success', message: `Successfully cleared baseline reference` };
}catch(e){
log.error(e);
return {status: 'error', message: `Error occured while importing ${format} file. Check logs for details.`};
}
}

exports.clearBaselineReference = clearBaselineReference;
exports.importGISFile = importGISFile;
exports.addParamToBaselineRef = addParamToBaselineRef;
exports.runBaseline = runBaseline;
Expand Down
11 changes: 7 additions & 4 deletions background/baseline.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ FROM
ericsson_cm."${mo}" t1
WHERE
t1.data->>'BSC_NAME' IS NOT NULL
AND TRIM(t1.data->>'BSC_NAME') != ''
GROUP BY
t1.data->>'BSC_NAME',
t1.data->>'${parameter}'
Expand All @@ -249,6 +250,7 @@ FROM
ericsson_cm."${mo}" t1
WHERE
t1.data->>'SubNetwork_2_id' IS NOT NULL
AND TRIM(t1.data->>'SubNetwork_2_id') != ''
GROUP BY
t1.data->>'SubNetwork_2_id',
t1.data->>'${parameter}'
Expand Down Expand Up @@ -292,17 +294,18 @@ async function computeZTEBaselineScore(tech, mo, parameter){
INSERT INTO baseline.scores
(vendor, technology, cluster, mo, parameter, value, score)
SELECT
'ERICSSON' as vendor,
'ZTE' as vendor,
'${tech}' as technology,
t1.data->>'SubNetwork_2_id' AS "cluster",
'${mo}' AS "mo",
'${parameter}' AS "parameter",
t1.data->>'${parameter}' as "value",
COUNT(1) AS "score"
FROM
ericsson_cm."${mo}" t1
zte_cm."${mo}" t1
WHERE
t1.data->>'SubNetwork_2_id' IS NOT NULL
AND TRIM(t1.data->>'SubNetwork_2_id') != ''
GROUP BY
t1.data->>'SubNetwork_2_id',
t1.data->>'${parameter}'
Expand All @@ -317,15 +320,15 @@ ON CONFLICT ON CONSTRAINT unq_scores DO UPDATE SET
INSERT INTO baseline.scores
(vendor, technology, cluster, mo, parameter, value, score)
SELECT
'ERICSSON' as vendor,
'ZTE' as vendor,
'${tech}' as technology,
t1.data->>'meContext_id' AS "cluster",
'${mo}' AS "mo",
'${parameter}' AS "parameter",
t1.data->>'${parameter}' as "value",
COUNT(1) AS "score"
FROM
ericsson_cm."${mo}" t1
zte_cm."${mo}" t1
WHERE
TRIM(t1.data->>'meContext_id') IS NOT NULL
AND TRIM(t1.data->>'meContext_id') != ''
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.3.0",
"version": "0.3.0-beta.4",
"description": "Boda-Lite is a telecommunication network management application",
"private": true,
"homepage": "./",
Expand Down
56 changes: 53 additions & 3 deletions src/modules/baseline/Baseline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export default class Baseline extends React.Component {
this.baselineRefDownloadListener = null;
this.addToBaselineRefListener = null;
this.deleteBaselineListener = null;
this.clearBaselineRefListener = null;

}

Expand Down Expand Up @@ -220,7 +221,7 @@ export default class Baseline extends React.Component {
}

/**
* Delete parameter
* Delete parameter's baseline reference
*/
deleteParameter = (vendor, technology, mo, parameter) => {
let payload = {
Expand Down Expand Up @@ -271,6 +272,54 @@ export default class Baseline extends React.Component {

}

/**
* Clear all parameters in the baseline reference
*/
clearBaselineReference = () => {
let payload = {
};

//Set processing to true
this.setState({processing: true });

ipcRenderer.send('parse-cm-request', 'clear_baseline_reference', JSON.stringify(payload));

this.clearBaselineRefListener = (event, task, args) => {
const obj = JSON.parse(args)
if(task !== 'clear_baseline_reference') return;

//error
if(obj.status === 'error' && task === 'clear_baseline_reference' ){
this.setState({
notice: {type: 'danger', message: obj.message},
processing: false
});
ipcRenderer.removeListener("parse-cm-request", this.clearBaselineRefListener);
}

//info
if(obj.status === 'info' && task === 'clear_baseline_reference' ){
this.setNotice('info', obj.message)
}

if(obj.status === "success" && task === 'clear_baseline_reference' ){
this.setState({
notice: {
type: 'success',
message: obj.message
},
processing: false
});

ipcRenderer.removeListener("parse-cm-request", this.clearBaselineRefListener);
this.refreshData();
}

}
ipcRenderer.on('parse-cm-request', this.clearBaselineRefListener);

}


/*
* Update the cluster state variable
Expand Down Expand Up @@ -576,15 +625,16 @@ export default class Baseline extends React.Component {
<FormGroup>
<Button icon="refresh" onClick={this.refreshData} minimal={true}></Button>
<Button icon="download" onClick={this.downloadBaselineReference} minimal={true}></Button>
| &nbsp;
<Button icon="trash" onClick={this.clearBaselineReference} minimal={true} />
&nbsp;| &nbsp;

<HTMLSelect options={this.VENDOR_LIST} className="mr-2" onChange={this.handleVendorSelect} name="vendor"/>
<HTMLSelect options={this.TECH_LIST} className="mr-2" onChange={this.handleTechSelect} name="tech"/>
<HTMLSelect options={this.MO_LIST} className="mr-2" onChange={this.handleMOSelect} name="mo"/>
<HTMLSelect options={this.PARAM_LIST} className="mr-2" onChange={this.handleParameterSelect} name="parameter"/>
<input className="bp3-input" placeholder="Baseline value" name="baseline_value" defaultValue={this.state.baselineValue} onChange={this.handleValueChange}/>
&nbsp;
<Icon icon="add" className="mr-2" onClick={this.addToBaselineReference}/>
<Button icon="add" onClick={this.addToBaselineReference} minimal={true}></Button>
</FormGroup>
</div>
<div className="ag-theme-balham" style={{width: '100%', height: "100%", boxSizing: "border-box"}}>
Expand Down
92 changes: 66 additions & 26 deletions src/modules/gis/GISMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ import {
ProgressBar,
Switch
} from "@blueprintjs/core";
import { gisGetCells, gisGetNbrs, gisHideCellNbrs, gisHideRelation, gisClear } from './gis-actions';
import {
gisGetCells,
gisGetNbrs,
gisHideCellNbrs,
gisHideRelation,
gisClear,
gisFetchPlanFrequencies,
gisUpdateCarrierColor,
gisUpdateSectorRadius
} from './gis-actions';
import { SemiCircle, SemiCircleMarker } from 'react-leaflet-semicircle';
import 'react-leaflet-fullscreen-control'
import { FaRss } from "react-icons/fa";
Expand Down Expand Up @@ -151,8 +160,6 @@ class GISMap extends React.Component{
const target = event.target;
const value = target.type === 'checkbox' ? target.checked : target.value;
const name = target.name;

console.log("handleEnabledChange:", value, name);

this.setState({
[name]: value
Expand Down Expand Up @@ -198,6 +205,9 @@ class GISMap extends React.Component{
componentDidMount () {
this.map = this.refs.map.leafletElement;
const map = this.refs.map.leafletElement;

//Update carrier colors
this.props.dispatch(gisFetchPlanFrequencies());

//By the time the GIS tab is shown, the GIS component has already
//been mounted. As a result, leaflet does not display correctly because
Expand Down Expand Up @@ -265,6 +275,9 @@ class GISMap extends React.Component{
});
}

updateCarrierColor = (e) => {
this.props.dispatch(gisUpdateCarrierColor(e.target.name, e.target.value));
}

importMapData = () => {
//Show error notice if user tries to upload empty file.
Expand Down Expand Up @@ -341,27 +354,17 @@ class GISMap extends React.Component{
this.setState({clearBeforeLoading: !this.state.clearBeforeLoading});
}

handleGSMRadiusChange = (e) => {
if(isNaN(e.target.value) || e.target.value <= 0 ) return;
this.techRadii['gsm'] = e.target.value;
this.setState({gsmRadius: e.target.value});
}

handleUMTSRadiusChange = (e) => {
if(isNaN(e.target.value) || e.target.value <= 0 ) return;
this.techRadii['umts'] = e.target.value;
this.setState({umtsRadius: e.target.value});
}

handleLTERadiusChange = (e) => {
if(isNaN(e.target.value) || e.target.value <= 0 ) return;
this.techRadii['lte'] = e.target.value;
this.setState({lteRadius: e.target.value});
handleRadiusChange = (e) => {
const tech = e.target.name.replace("Radius", "");
const radius = e.target.value;
this.props.dispatch(gisUpdateSectorRadius(tech, radius));
}


render(){

console.log('Rendering....');

const position = [this.state.lat, this.state.lng]
const height = this.state.height;
let center = [this.state.lat, this.state.lng]
Expand Down Expand Up @@ -403,10 +406,18 @@ class GISMap extends React.Component{
const cell = this.props.cells[cellid];
const beamWidth = parseInt(cell.antenna_beam) > 0 && parseInt(cell.antenna_beam) !== NaN ? cell.antenna_beam : 30;
const lcTech = cell.technology.toLowerCase();
const radius = this.techRadii[lcTech] || 500;

//Radius. Adjust by twice the last digit in the ci
const lastDigit = cell.ci.toString()[cell.ci.toString().length-1] || 0;

let radius = this.props.sectorRadius[lcTech] || 500 ;
radius = parseInt(radius) + (lastDigit-1)*4;

const color = this.props.carrierColors[cell.frequency] || null;
return (
<React.Fragment key={cell.ci}>
<SemiCircle
color={color}
position={[cell.latitude, cell.longitude]}
radius={radius}
startAngle={cell.azimuth + this.angularOffset[lcTech]}
Expand Down Expand Up @@ -655,8 +666,9 @@ class GISMap extends React.Component{
>
<InputGroup
id="gsm_radius"
defaultValue={this.techRadii['gsm']}
onChange={this.handleGSMRadiusChange}
name="gsmRadius"
defaultValue={this.props.sectorRadius['gsm']}
onChange={this.handleRadiusChange}
/>
</FormGroup>
</div>
Expand All @@ -672,8 +684,9 @@ class GISMap extends React.Component{
>
<InputGroup
id="umts_radius"
defaultValue={this.techRadii['umts']}
onChange={this.handleUMTSRadiusChange}
name="umtsRadius"
defaultValue={this.props.sectorRadius['umts']}
onChange={this.handleRadiusChange}
/>
</FormGroup>
</div>
Expand All @@ -687,11 +700,36 @@ class GISMap extends React.Component{
inline={true}
className="mb-1"
>
<InputGroup id="lte_radius" defaultValue={this.techRadii['lte']} onChange={this.handleLTERadiusChange}/>
<InputGroup
name="lteRadius"
id="lte_radius"
defaultValue={this.props.sectorRadius['lte']}
onChange={this.handleRadiusChange}/>
</FormGroup>
</div>
</div>
</div>

<div>
<h6 className="horizontal-line">
<span className="horizontal-line-text">Carrier Colors</span>
</h6>
<div>
{Object.keys(this.props.carrierColors).map((v, i) => (
<div className="row">
<div className="col-3">{v}</div>
<div className="col-2">
<input
type="color"
name={v}
value={this.props.carrierColors[v]}
onChange={this.updateCarrierColor}/>
</div>

</div>
))}

</div>
</div>

</div>
Expand All @@ -713,7 +751,9 @@ function mapStateToProps(state){
cells: state.gis.cells || {},
relations: state.gis.relations || {},
redraw: state.gis.redraw,
hiddenRelations: state.gis.hiddenRelations || {}
hiddenRelations: state.gis.hiddenRelations || {},
carrierColors: state.gis.carrierColorMap,
sectorRadius: state.gis.sectorRadius
};
}

Expand Down
Loading

0 comments on commit 4b173b3

Please sign in to comment.