Skip to content

Commit

Permalink
C:/Program Files/Git/v1 ZEBRA upd
Browse files Browse the repository at this point in the history
Signed-off-by: Salisu Ali <[email protected]>
  • Loading branch information
salisbuk7897 committed Nov 27, 2021
1 parent ec48281 commit a17528e
Show file tree
Hide file tree
Showing 10 changed files with 473 additions and 110 deletions.
Binary file added Documentation/Images/mtrpage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 130 additions & 0 deletions src/app_server/routes/mainRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ try{
let grafanabaseurl = Zconfig.grafanaurl;
let grafanabaseport = Zconfig.grafanaport;
let grafanahttptype = Zconfig.grafanahttptype;
let zhttp = Zconfig.zebra_httptype;
let appurl = Zconfig.appurl;
let appport = Zconfig.appport;
const axios = require('axios');
const { send } = require('process');
const grafanaServer = `${grafanahttptype}://${grafanabaseurl}:${grafanabaseport}`

const REPORTS = require("../../constants").REPORTS;
const { keys } = require('lodash');


function parameters(fn){
parms = {
Expand Down Expand Up @@ -60,6 +66,130 @@ function parameters(fn){
fn(parms); //return the parameters
}

router.get('/mtrfile', (req, res) => {
fs.readFile('metrics.json', (err, data) => {
if (err) throw err;
let metricsfile = JSON.parse(data);
let keyss = Object.keys(metricsfile);
res.send({mtr: keyss, jsn:metricsfile});
});
});

router.post('/delmtr', (req, res) => {
fs.readFile('metrics.json', (err, data) => {
if (err) throw err;
let metricsfile = JSON.parse(data);
delete metricsfile[req.body.ky];
fs.writeFile("metrics.json", JSON.stringify(metricsfile, null, '\t'), 'utf-8', function(err, data) {
res.send("Metric Deleted Successfully");
});
});
});

router.post('/savemtr', (req, res) => {
try{
var lpar = req.body.lpar;
var rpt = req.body.rpt;
var nid = req.body.nid;
var snvl = req.body.snvl;
var vid = req.body.vid;
var umi = req.body.umi;
var umd = req.body.umd;
var rst = req.body.rst;
var key = `${lpar}_${snvl}_${umi}`;
var mtr = JSON.parse(`{
"lpar": "${lpar}",
"request": {
"report": "${rpt}",
"resource": "${rst}"
},
"identifiers": [
{
"key": "${nid}",
"value": "${snvl}"
}
],
"field": "${vid}",
"desc": "${umd}"
}`)
fs.readFile('metrics.json', (err, data) => {
if (err) throw err;
let metricsfile = JSON.parse(data);
metricsfile[`${key}`] = mtr
fs.writeFile("metrics.json", JSON.stringify(metricsfile, null, '\t'), 'utf-8', function(err, data) {
res.send("Metric Added Successfully");
});
});

}catch(err){
res.send("error")
}
})

router.post('/getnvl', (req, res) => {
try{
var lpar = req.body.lpar;
var rpt = req.body.rpt;
var nid = req.body.nid;
var c = [];
var RMF3URL = `${zhttp}://${appurl}:${appport}/v1/${lpar}/rmf3/${rpt}`; //Dynamically create URL
axios.get(RMF3URL)
.then(function (response) {
// handle success
var dat = response.data
for(i in dat["table"]){
c.push(dat["table"][i][nid])
}
//console.log(c);
res.send({sc:c});
//console.log(response.data);
//res.json({sc:["columnhead"]});
})
.catch(function (error) {
// handle error
res.send("error")
})
}catch(err){
res.send("error")

}

})

router.post('/getrpt', (req, res) => {
try{
var lpar = req.body.lpar;
var rpt = req.body.rpt;
var RMF3URL = `${zhttp}://${appurl}:${appport}/v1/${lpar}/rmf3/${rpt}`; //Dynamically create URL
axios.get(RMF3URL)
.then(function (response) {
// handle success
var columns = response.data
res.send({sc:columns["columnhead"]});
//console.log(response.data);
//res.json({sc:["columnhead"]});
})
.catch(function (error) {
// handle error
res.send("error")
})
}catch(err){
res.send("error")

}

})
router.get('/metrics', (req, res) => {
//console.log(Zconfig.dds["RPRT"])
resource = [];
var lpar_details = Zconfig["dds"];
var lpar = Object.keys(lpar_details);
for(i in lpar){
resource.push(lpar_details[lpar[i]]["mvsResource"])
}
//console.log(c);
res.render("metrics", {resources:resource, lpars:lpar, reports:REPORTS.RMFM3});
})
// Checks if user login session is available in browser
var sessionChecker = (req, res, next) => {
if (req.session.name && req.cookies.user_sid) { //If user login session is available
Expand Down
7 changes: 6 additions & 1 deletion src/app_server/v1_Controllers/RMF3Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ async function RMFIIIJSON(req, res, status){
switch(status){
case "OK" : // If the flow is Okay, No Obstruction
var lpar = ddsconfig["dds"][req.params.lpar];
var lspr = lpar["PCI"];
try{
var lspr = lpar["PCI"];
}catch(err){
var lspr = 0;
}

var urlReport = req.params.report
var urlResource = lpar["mvsResource"];
var ulrParm; //variable for parm parameter in the User Specified URL
Expand Down
2 changes: 2 additions & 0 deletions src/app_server/views/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ html
a.nav-link(href='https://github.com/zowe/zebra/tree/main/Documentation') Documentation
li.nav-item.active
a.nav-link(href='/setting') Configuration
li.nav-item.active
a.nav-link(href='/metrics') Metrics
li.nav-item.active
a.nav-link(href='/about') About
if(msg)
Expand Down
Loading

0 comments on commit a17528e

Please sign in to comment.