Commit 5e835aea authored by a001188's avatar a001188
Browse files

Some functions work

parent 4a2a0051
public/images/structure.png

1.23 KB | W: | H:

public/images/structure.png

1.21 KB | W: | H:

public/images/structure.png
public/images/structure.png
public/images/structure.png
public/images/structure.png
  • 2-up
  • Swipe
  • Onion skin
function ciTable(){
$('#cmdb-table').jtable({
title: "Konfigurationselement",
paging: false, //Enable paging
pageSize: 10, //Set page size (default: 10)
pageList: 'minimal',
sorting: false, //Enable sorting
multiSorting: false,
defaultSorting: 'display_name ASC', //Set default sorting
actions: {
listAction: '/cmdb/api/v1/ci/enterprise_service/list'
},
fields: {
families:{
title: '',
width: '4%',
paging: false, //Enable paging
pageSize: 10, //Set page size (default: 10)
pageList: 'minimal',
sorting: false, //Enable sorting
multiSorting: false,
defaultSorting: 'display_name ASC', //Set default sorting
display: function(data){
var $imgSubOrg = $('<img src="/images/organisation.png" title="Underliggande komponenter" />');
$imgSubOrg.click(function () {
// updateGraph(parentOrganisation.record.id);
$('#cmdb-table').jtable('openChildTable', $imgSubOrg.closest('tr'),{
title: '+ Komponenter under ' + data.record.display_name,
actions: {
listAction: '/cmdb/api/v1/ci/child/list/' + data.record.id
},
fields: {
id: {
title: 'id',
width: '15%',
list: false,
key: true
},
$('#cmdb-table').jtable(createTable(columnDef()));
$('#cmdb-table').jtable('load');
}
display_name: {
title: 'Namn',
width: '15%'
},
description: {
title: 'Beskrivning',
width: '30%'
},
family_type_id: {
title: 'Familjetyp',
options: '/cmdb/api/v1/options/family_type', //+ data.options.family_type_id
width: '15%'
},
family_id: {
title: 'Familj',
display: function(data){
options: '/cmdb/api/v1/options/families/' + data.record.family_type_id;
},
width: '15%'
},
kst: {
title: 'Kostnadsställe',
width: '15%'
},
product: {
title: 'Produkt',
width: '15%'
},
sla: {
title: 'SLA',
width: '15%'
},
class_information: {
title: 'Klasser',
width: '15%'
},
attribute_information: {
title: 'Attribut',
width: '15%'
},
// account_group: {
// title: 'Grupper',
// width: '15%'
// },
// account_id: {
// title: 'Konton',
// width: '15%'
// },
// contacts: {
// title: 'Kontaktpersoner',
// width: '15%'
// }
}
},
function(data){
data.childTable.jtable('load');
});
});
return $imgSubOrg;
}
function columnDef(){
var cd = {
next: {
title: 'Nästa',
width: '1%',
display: renderSubTable
},
id: {
id: {
title: 'id',
width: '15%',
list: false,
key: true
},
display_name: {
title: 'Namn',
width: '15%'
......@@ -115,14 +26,12 @@ function ciTable(){
},
family_type_id: {
title: 'Familjetyp',
options: '/cmdb/api/v1/options/family_type',
options: '/cmdb/api/v1/options/family_type', //+ data.options.family_type_id
width: '15%'
},
family_id: {
title: 'Familj',
display: function(data){
options: '/cmdb/api/v1/options/families/' + data.record.family_type_id;
},
//options: '/cmdb/api/v1/options/families/' + data.record.family_type_id,
width: '15%'
},
kst: {
......@@ -145,19 +54,64 @@ function ciTable(){
title: 'Attribut',
width: '15%'
},
// account_group: {
// title: 'Grupper',
// width: '15%'
// },
// account_id: {
// title: 'Konton',
// width: '15%'
// },
// contacts: {
// title: 'Kontaktpersoner',
// width: '15%'
// }
account_group: {
title: 'Grupper',
width: '15%'
},
account_id: {
title: 'Konton',
width: '15%'
},
contacts: {
title: 'Kontaktpersoner',
width: '15%'
}
}
});
$('#cmdb-table').jtable('load');
}
return cd;
}
function createTable(columnDef){
var table = {
title: "Konfigurationselement",
paging: false, //Enable paging
pageSize: 10, //Set page size (default: 10)
pageList: 'minimal',
sorting: false, //Enable sorting
multiSorting: false,
defaultSorting: 'display_name ASC', //Set default sorting
actions: {
listAction: '/cmdb/api/v1/ci/enterprise_service/list'
},
fields: columnDef
};
return table;
}
function renderSubTable (data) {
//updateGraph(parentOrganisation.record.id);
if(data.record.childs > 0){
return $('<img src="/images/structure.png" title="Nästa nivå"/>').click(function () {
createSubTable(data, $(this).closest('tr'));
});
}
}
function createSubTable(data, row){
$('#cmdb-table').jtable('openChildTable', row, {
title: 'Komponenter till ' + data.record.display_name,
actions: {
listAction: '/cmdb/api/v1/ci/child/list/' + data.record.id
},
fields: columnDef()
},
function (data) { //opened handler
data.childTable.jtable('load');
});
}
function ciTable(){
$('#cmdb-table').jtable({
title: "Konfigurationselement",
paging: false, //Enable paging
pageSize: 10, //Set page size (default: 10)
pageList: 'minimal',
sorting: false, //Enable sorting
multiSorting: false,
defaultSorting: 'display_name ASC', //Set default sorting
actions: {
listAction: '/cmdb/api/v1/ci/enterprise_service/list'
},
fields: {
families:{
title: '',
width: '4%',
paging: false, //Enable paging
pageSize: 10, //Set page size (default: 10)
pageList: 'minimal',
sorting: false, //Enable sorting
multiSorting: false,
defaultSorting: 'display_name ASC', //Set default sorting
display: function(data){
var $imgSubOrg = $('<img src="/images/organisation.png" title="Underliggande komponenter" />');
$imgSubOrg.click(function () {
// updateGraph(parentOrganisation.record.id);
$('#cmdb-table').jtable('openChildTable', $imgSubOrg.closest('tr'),{
title: '+ Komponenter under ' + data.record.display_name,
actions: {
listAction: '/cmdb/api/v1/ci/child/list/' + data.record.id
},
fields: {
id: {
title: 'id',
width: '15%',
list: false,
key: true
},
display_name: {
title: 'Namn',
width: '15%'
},
description: {
title: 'Beskrivning',
width: '30%'
},
family_type_id: {
title: 'Familjetyp',
options: '/cmdb/api/v1/options/family_type', //+ data.options.family_type_id
width: '15%'
},
family_id: {
title: 'Familj',
display: function(data){
options: '/cmdb/api/v1/options/families/' + data.record.family_type_id;
},
width: '15%'
},
kst: {
title: 'Kostnadsställe',
width: '15%'
},
product: {
title: 'Produkt',
width: '15%'
},
sla: {
title: 'SLA',
width: '15%'
},
class_information: {
title: 'Klasser',
width: '15%'
},
attribute_information: {
title: 'Attribut',
width: '15%'
},
// account_group: {
// title: 'Grupper',
// width: '15%'
// },
// account_id: {
// title: 'Konton',
// width: '15%'
// },
// contacts: {
// title: 'Kontaktpersoner',
// width: '15%'
// }
}
},
function(data){
data.childTable.jtable('load');
});
});
return $imgSubOrg;
}
},
id: {
title: 'id',
width: '15%',
list: false,
key: true
},
display_name: {
title: 'Namn',
width: '15%'
},
description: {
title: 'Beskrivning',
width: '30%'
},
family_type_id: {
title: 'Familjetyp',
options: '/cmdb/api/v1/options/family_type',
width: '15%'
},
family_id: {
title: 'Familj',
display: function(data){
options: '/cmdb/api/v1/options/families/' + data.record.family_type_id;
},
width: '15%'
},
kst: {
title: 'Kostnadsställe',
width: '15%'
},
product: {
title: 'Produkt',
width: '15%'
},
sla: {
title: 'SLA',
width: '15%'
},
class_information: {
title: 'Klasser',
width: '15%'
},
attribute_information: {
title: 'Attribut',
width: '15%'
},
// account_group: {
// title: 'Grupper',
// width: '15%'
// },
// account_id: {
// title: 'Konton',
// width: '15%'
// },
// contacts: {
// title: 'Kontaktpersoner',
// width: '15%'
// }
}
});
$('#cmdb-table').jtable('load');
}
......@@ -19,7 +19,7 @@ router.post('/enterprise_service/list', (req, res, next) => {
done();
return res.status(500).json({success: false , data: err});
}
var sql = "select * from cmdb.ci where family_type_id = 1 and id > 0 order by display_name";
var sql = "select * , (select count(*) from cmdb.ci c where c.parent_id = id) as childs from cmdb.ci where family_type_id = 1 and id > 0 order by display_name";
client.query(sql, [], function(err, result){
done();
if (err){
......@@ -35,6 +35,8 @@ router.post('/enterprise_service/list', (req, res, next) => {
});
});
//select * , (select count(*) from cmdb.ci child where child.parent_id = id) as childs from cmdb.ci where parent_id = 27 order by display_name
router.post('/child/list/:parent_id', (req, res, next) => {
var pool = new pg.Pool({
......@@ -46,7 +48,7 @@ router.post('/child/list/:parent_id', (req, res, next) => {
console.log(err);
return res.status(500).json({success: false , data: err});
}
var sql = "select * from cmdb.ci where parent_id = $1 order by display_name";
var sql = "select * , (select count(*) as childs from cmdb.ci child where child.parent_id = parent.id) as childs from cmdb.ci parent where parent.parent_id = $1 order by display_name";
var parameter = [req.params['parent_id']];
client.query(sql, parameter, function(err, result){
done();
......
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