Commit f97d53ca authored by a001188's avatar a001188
Browse files

Added label on edges

parent e2c9241d
......@@ -20,7 +20,7 @@ function accessNodesTable(){
click: {
title: 'Visa',
display: function(data){
return '<img src="/images/structure.png" title="Nästa nivå" onclick="accessGraph(' + data.record.id + ')"></img>';
return '<img src="/images/structure.png" title="Visa behörighetsgraf" onclick="accessGraph(' + data.record.id + ')"></img>';
},
width: '5%'
},
......
......@@ -176,16 +176,24 @@ router.get('/edges', (req, res, next) => {
done();
return res.status(500).json({success: false , data: err});
}
// {from: 1, to: 2, label: 'middle', font: {align: 'middle'}},
// SQL Query > Select Data
var sql = "select from_ci_id as from, to_ci_id as to from cmdb.relation;";
var sql = "select from_ci_id as from, to_ci_id as to, rt.display_name as label, '__FONT__' as font from cmdb.relation r inner join cmdb.relation_type rt on r.relation_type_id=rt.id;";
client.query(sql, [], function(err, result){
done();
if (err){
return res.json(JSON.parse('{"Result":"ERROR", "Message":"' + sql + '"}'));
}
else {
return res.json(result.rows);
var f = {align: 'middle'};
var jsonResponse = JSON.parse(JSON.stringify(result.rows));
for(var i=0; i<jsonResponse.length; i++)
jsonResponse[i].font = f;
winston.debug('info', '/edges', {
jsonResponse: jsonResponse
})
return res.json(jsonResponse);
}
});
});
......@@ -211,17 +219,17 @@ router.get('/node/:id', (req, res, next) => {
}
// SQL Query > Select Data
var sql = "select c.id, c.display_name as label, (select class_type_id from cmdb.class c2 where c2.id=c.group_type_id) as type_id from cmdb.ci_family_group c inner join cmdb.relation r on r.from_ci_id = c.id where r.relation_type_id=0 and r.to_ci_id = $1 ";
var sql = "select c.id, concat('grupp: ', c.display_name) as label, (select class_type_id from cmdb.class c2 where c2.id=c.group_type_id) as type_id from cmdb.ci_family_group c inner join cmdb.relation r on r.from_ci_id = c.id where r.relation_type_id=0 and r.to_ci_id = $1 ";
sql+= "UNION ";
sql+= "select c.id, c.display_name as label, (select class_type_id from cmdb.class c2 where c2.id=c.group_type_id) as type_id from cmdb.ci_family_group c inner join cmdb.relation r on r.to_ci_id = c.id where r.relation_type_id=0 and r.from_ci_id = $1 ";
sql+= "select c.id, concat('grupp: ', c.display_name) as label, (select class_type_id from cmdb.class c2 where c2.id=c.group_type_id) as type_id from cmdb.ci_family_group c inner join cmdb.relation r on r.to_ci_id = c.id where r.relation_type_id=0 and r.from_ci_id = $1 ";
sql+= "UNION ";
sql+= "select c.id, c.display_name as label, (select class_type_id from cmdb.class c2 where c2.id=c.group_type_id) as type_id from cmdb.ci_family_group c where c.id = $1 ";
sql+= "select c.id, concat('grupp: ', c.display_name) as label, (select class_type_id from cmdb.class c2 where c2.id=c.group_type_id) as type_id from cmdb.ci_family_group c where c.id = $1 ";
sql+= "UNION ";
sql+= "select c.id, c.display_name as label, (select class_type_id from cmdb.class c2 where c2.id=c.account_type_id) as type_id from cmdb.ci_family_account c inner join cmdb.relation r on r.from_ci_id = c.id where r.relation_type_id=0 and r.to_ci_id = $1 ";
sql+= "select c.id, concat('användare: ', c.display_name) as label, (select class_type_id from cmdb.class c2 where c2.id=c.account_type_id) as type_id from cmdb.ci_family_account c inner join cmdb.relation r on r.from_ci_id = c.id where r.relation_type_id=0 and r.to_ci_id = $1 ";
sql+= "UNION ";
sql+= "select c.id, c.display_name as label, (select class_type_id from cmdb.class c2 where c2.id=c.account_type_id) from cmdb.ci_family_account c inner join cmdb.relation r on r.to_ci_id = c.id where r.relation_type_id=0 and r.from_ci_id = $1 ";
sql+= "select c.id, concat('användare: ', c.display_name) as label, (select class_type_id from cmdb.class c2 where c2.id=c.account_type_id) from cmdb.ci_family_account c inner join cmdb.relation r on r.to_ci_id = c.id where r.relation_type_id=0 and r.from_ci_id = $1 ";
sql+= "UNION ";
sql+= "select c.id, c.display_name as label, (select class_type_id from cmdb.class c2 where c2.id=c.account_type_id) from cmdb.ci_family_account c where c.id = $1 ";
sql+= "select c.id, concat('användare: ', c.display_name) as label, (select class_type_id from cmdb.class c2 where c2.id=c.account_type_id) from cmdb.ci_family_account c where c.id = $1 ";
var parameter = [req.params['id']];
client.query(sql, parameter, function(err, result){
......@@ -255,7 +263,9 @@ router.get('/edge/:id', (req, res, next) => {
}
// SQL Query > Select Data
var sql = "select from_ci_id as from, to_ci_id as to from cmdb.relation where from_ci_id = $1 or to_ci_id = $1;";
var sql = "select from_ci_id as from, to_ci_id as to, rt.display_name as label, '__FONT__' as font from cmdb.relation r inner join cmdb.relation_type rt on r.relation_type_id=rt.id ";
sql+="where from_ci_id = $1 or to_ci_id = $1;";
var parameter = [req.params['id']];
client.query(sql, parameter, function(err, result){
done();
......@@ -263,7 +273,15 @@ router.get('/edge/:id', (req, res, next) => {
return res.json(JSON.parse('{"Result":"ERROR", "Message":"' + sql + '"}'));
}
else {
return res.json(result.rows);
var f = {align: 'middle'};
var jsonResponse = JSON.parse(JSON.stringify(result.rows));
for(var i=0; i<jsonResponse.length; i++)
jsonResponse[i].font = f;
winston.debug('info', '/edges/:id', {
jsonResponse: jsonResponse
})
return res.json(jsonResponse);
}
});
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment