Skip to content

Commit

Permalink
Add button to clear entire baseline reference
Browse files Browse the repository at this point in the history
  • Loading branch information
erssebaggala committed Oct 6, 2019
1 parent 3fd7181 commit 5e2f57e
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 6 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
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-beta.3",
"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
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.3.0-beta.3";
export const VERSION = "0.3.0-beta.4";

export default VERSION;

0 comments on commit 5e2f57e

Please sign in to comment.