Commit e8d6e69f authored by a001188's avatar a001188
Browse files

Improvement

parent 655e0315
......@@ -40,7 +40,10 @@ function accessGraph(node_id){
var network = new vis.Network(container, data, options);
network.on("doubleClick", function (params){
accessGraph(params.nodes[0]);
var node_id = params.nodes[0];
for(var i = 0; i < data.nodes.length; i++)
if(data.nodes[i].type_id > 0 && data.nodes[i].id === node_id )
accessGraph(node_id);
});
});
});
......
function accessNodesTable(){
$('#cmdb-table').jtable({
title: "Konton och grupper",
paging: false, //Enable paging
paging: true, //Enable paging
pageSize: 10, //Set page size (default: 10)
pageList: 'minimal',
sorting: true, //Enable sorting
multiSorting: true,
defaultSorting: 'display_name ASC', //Set default sorting
actions: {
listAction: '/cmdb/api/v1/access/security/list'
//listAction: '/cmdb/api/v1/access/security/list'
listAction: function(postData, jtParams){
var search_string = document.getElementById("ci_search_field").value;
if(postData !== undefined)
postData['search_string']=search_string;
else
postData = {search_string:search_string};
return $.Deferred(function ($dfd) {
$.ajax({
url: '/cmdb/api/v1/access/security/list?jtStartIndex=' + jtParams.jtStartIndex + '&jtPageSize=' + jtParams.jtPageSize + '&jtSorting=' + jtParams.jtSorting,
type: 'POST',
dataType: 'json',
data: postData,
success: function (data) {
$dfd.resolve(data);
},
error: function () {
$dfd.reject();
}
});
});
}
},
fields: {
id: {
......
......@@ -44,6 +44,7 @@ router.post('/security/list', (req, res, next) => {
var jtStartIndex = req.query['jtStartIndex'];
var jtPageSize = req.query['jtPageSize'];
var jtSorting = req.query['jtSorting'];
var ci_search = '%' + req.body.search_string.toUpperCase() + '%';
var pool = new pg.Pool({
connectionString: connectionString
......@@ -61,16 +62,17 @@ router.post('/security/list', (req, res, next) => {
_sql+= "union ";
_sql+= "select *, account_type_id as class_id from cmdb.ci_family_account ";
_sql+= "order by $3 limit $2 OFFSET $1";
var sql = "SELECT sub.* ";
sql+= "FROM (";
sql+= "SELECT *, (select display_name from cmdb.ci ci2 where ci2.id=ci1.parent_id) as owner, group_type_id as class_id from cmdb.ci_family_group ci1 ";
sql+= "SELECT *, (select display_name from cmdb.ci ci2 where ci2.id=ci1.parent_id) as owner, group_type_id as class_id from cmdb.ci_family_group ci1 where upper(ci1.display_name) like $3 ";
sql+= "union all ";
sql+= "SELECT *, (select display_name from cmdb.ci ci4 where ci4.id=ci3.parent_id) as owner, account_type_id as class_id from cmdb.ci_family_account ci3 ";
sql+= "SELECT *, (select display_name from cmdb.ci ci4 where ci4.id=ci3.parent_id) as owner, account_type_id as class_id from cmdb.ci_family_account ci3 where upper(ci3.display_name) like $3 ";
sql+= ") as sub ";
sql+= "order by $3 ";
sql+= "order by sub." + jtSorting + " ";
sql+= "limit $2 offset $1";
var parameter = [jtStartIndex, jtPageSize, jtSorting];
var parameter = [jtStartIndex, jtPageSize, ci_search];
winston.log('info', '/security/list', {
paramter: parameter,
......@@ -79,7 +81,7 @@ router.post('/security/list', (req, res, next) => {
client.query(sql, parameter, function(err, result){
done();
if (err){
return res.json(JSON.parse('{"Result":"ERROR", "Message":"' + err + '"}'));
return res.json(JSON.parse('{"Result":"ERROR", "Message":"' + sql + '"}'));
}
else {
var response = '{"Result":"OK", "Records":';
......
......@@ -215,7 +215,7 @@ router.post('/parent/list/:family_type/:family_name/:id', (req, res, next) => {
var sql = getSQLSearchQuery(PARENT, family_type, family_name, req);
var parameter = [req.params['id']];
winston.log('info', '*** PARENT TRACE ***', {
winston.log('info', '*** PARENT-TRACE ***', {
parameter:parameter,
sql:sql
});
......@@ -224,6 +224,9 @@ router.post('/parent/list/:family_type/:family_name/:id', (req, res, next) => {
});
pool.connect(function(err, client, done){
if(err) {
winston.log('error', '*** ERROR ***', {
err:err
});
done();
return res.status(500).json({success: false , data: err});
}
......
......@@ -2,6 +2,7 @@ extends menu
block content
p(class='cmdbguiSmallText') #{title}
input(type='text', id='ci_search_field', onkeyup='ciTable()')
table(style="width: 100%")
tr
td(style="width: 30%; vertical-align: top;")
......
extends menu
block content
p(class='cmdbguiSmallText') #{title}
form(method='GET', action='/view/search/3')
input(type='text', id='ci_search', oninput='eventFire(document.getElementByName("submittButton").item(0), "click")')
button(name='submittButton', type='submit') Sök!
#cmdb-table
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