Commit 1f93e106 authored by a001188's avatar a001188
Browse files

Sort implemented

parent db4d9ea2
......@@ -38,7 +38,7 @@ function ciColumnDef(){
width: '5%',
sorting: true
},
ci_kst: {
economy: {
sorting: false,
title: 'Ekonomi',
width: '3%'
......@@ -59,28 +59,16 @@ function ciColumnDef(){
account: {
sorting: false,
title: 'Konto',
// options: function(data) {
// if(data.source==='list')
// return '/cmdb/api/v1/options/accounts/';
// else
// return data.record.id;
// },
width: '5%'
},
group: {
sorting: false,
title: 'Grupp',
// options: function(data) {
// if(data.source==='list')
// return '/cmdb/api/v1/options/groups/';
// else
// return data.record.id;
// },
width: '5%'
},
contacts: {
contact_information: {
sorting: false,
title: 'Kontaktperson',
title: 'Kontaktinformation',
width: '5%'
},
prev: {
......
......@@ -68,10 +68,16 @@ router.post('/infrastructure/list', (req, res, next) => {
function getSQLSearchQuery(query_type, family_type, family_name, req){
var jtSorting = req.query['jtSorting'].trim();
var sql_select ="select ci1.id as ci_id, ci1.parent_id as ci_parent_id, ci1.class_information, ci1.attribute_information, f.id as f_id, ft.id as ft_id, ci1.display_name as ci_name, ci1.kst as ci_kst, ci1.description as ci_description, f.display_name as family_name, ft.display_name as family_type_name, ";
var sql_select ="select ci1.id as ci_id, ci1.parent_id as ci_parent_id, ci1.class_information, ci1.attribute_information, f.id as f_id, ft.id as ft_id, ci1.display_name as ci_name, ci1.description as ci_description, f.display_name as family_name, ft.display_name as family_type_name, ";
sql_select+="concat('<b>Kst: </b>' , ci1.kst, '<br><b>Prod: </b>', ci1.product) as economy, ";
sql_select+="(select string_agg(ci_account.display_name, '<br>') from cmdb.ci_family_account ci_account where ci_account.parent_id = ci1.id) as account, ";//f.display_name <> 'Access') as childs, ";
sql_select+="(select string_agg(ci_group.display_name, '<br>') from cmdb.ci_family_group ci_group where ci_group.parent_id = ci1.id) as group, ";//f.display_name <> 'Access') as childs, ";
sql_select+="(select count(*) from cmdb.ci ci2 inner join cmdb.family f2 on ci2.family_id = f2.id where ci2.parent_id = ci1.id and f2.display_name <> 'Access') as childs, ";//f.display_name <> 'Access') as childs, ";
sql_select+="(select count(*) from cmdb.ci ci2 where ci1.parent_id = ci2.id and ci2.id > 0) as parents, ";
sql_select+="(select count(*) from cmdb.ci ci2 inner join cmdb.family f2 on ci2.family_id = f2.id where ci2.parent_id = ci1.parent_id and f2.display_name <> 'Access') as siblings ";//f.display_name <> 'Access') as childs, ";
var sql_select_contact =", (select string_agg(concat('<b>', rt.display_name, ':</b> ', ci_from.display_name, '<br>', ci_from.attribute_information), '<br>') ";
sql_select_contact+="from (((cmdb.relation r inner join cmdb.relation_type rt on r.relation_type_id = rt.id) inner join cmdb.relation_type_group rtg on rtg.id = rt.relation_type_group_id) inner join cmdb.ci ci_to on ci_to.id = r.to_ci_id) inner join cmdb.ci ci_from on ci_from.id = r.from_ci_id ";
sql_select_contact+="where ci1.id = r.to_ci_id and rtg.display_name not like 'Access') as contact_information ";
var sql_from = "from (cmdb.ci ci1 inner join cmdb.family f on f.id=ci1.family_id) inner join cmdb.family_type ft on ci1.family_type_id=ft.id ";
......@@ -91,6 +97,8 @@ function getSQLSearchQuery(query_type, family_type, family_name, req){
sql_where_search+="or upper(ci1.description) like $1 ";
sql_where_search+="or upper(ci1.class_information) like $1 ";
sql_where_search+="or upper(ci1.attribute_information) like $1 ";
sql_where_search+="or upper(ci1.kst) like $1 ";
sql_where_search+="or upper(ci1.product) like $1 ";
sql_where_search+="or upper(ci1.contact_information) like $1 ";
sql_where_search+="or upper(f.display_name) like $1 ";
sql_where_search+="or upper(ft.display_name) like $1 ";
......@@ -100,7 +108,7 @@ function getSQLSearchQuery(query_type, family_type, family_name, req){
if(query_type === MAIN)
sql = sql_select + sql_from + sql_where_list + sql_where_search + sql_order_by;
sql = sql_select + sql_select_contact + sql_from + sql_where_list + sql_where_search + sql_order_by;
else if(query_type === CHILD)
sql = sql_select + sql_from + sql_where_child + sql_order_by;
else if(query_type === PARENT)
......@@ -430,3 +438,4 @@ limit 10
module.exports = router;
......@@ -7,7 +7,7 @@ block menu
td(style='text-align: left')
p(class='cmdbguiSmallText') CMDB-Viewer by Peter Lundin
td(style='text-align: center')
p(class='cmdbguiSmallText') databaseschema: jasper.cmdb on postresql-utv.smhi.se user jasper.u
p(class='cmdbguiSmallText') databaseschema: jasper.cmdb on postresql-utv.smhi.se user jasper.u (testdata DM225081)
td(style='text-align: right')
a(class='cmdbguiSmallText' href="https://git.smhi.se/a001188/cmdb") git.smhi.se/a001188/cmdb
nav
......
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