Commit caa9599f authored by Peter Lundin's avatar Peter Lundin
Browse files

Some functions work

parent 3d397750
...@@ -16,9 +16,14 @@ ...@@ -16,9 +16,14 @@
<body onhashchange="logoutcmdbgui(event)"> <body onhashchange="logoutcmdbgui(event)">
<script type="text/javascript" src="/javascripts/menu.js"></script> <script type="text/javascript" src="/javascripts/menu.js"></script>
<script type="text/javascript" src="/javascripts/vis/dist/vis.js"></script> <script type="text/javascript" src="/javascripts/vis/dist/vis.js"></script>
<script type="text/javascript" src="/javascripts/dashlets/organisation-table.js"></script> <script type="text/javascript" src="/javascripts/dashlets/organisation-table.js"></script>
<script type="text/javascript" src="/javascripts/dashlets/organisation-graph.js"></script> <script type="text/javascript" src="/javascripts/dashlets/organisation-graph.js"></script>
<script type="text/javascript" src="/javascripts/jtable/jquery.jtable.min.js"></script> -->
<!-- <script type="text/javascript" src="/javascripts/dashlets/structure-table.js"></script>
<script type="text/javascript" src="/javascripts/dashlets/structure-graph.js"></script>
-->
<script type="text/javascript" src="/javascripts/jtable/jquery.jtable.min.js"></script>
<script type="text/javascript" src="/javascripts/jtable/jquery.jtable.js"></script> <script type="text/javascript" src="/javascripts/jtable/jquery.jtable.js"></script>
<script type="text/javascript" src="/javascripts/jtable/localization/jquery.jtable.se.js"></script> <script type="text/javascript" src="/javascripts/jtable/localization/jquery.jtable.se.js"></script>
...@@ -67,6 +72,8 @@ ...@@ -67,6 +72,8 @@
<p class='cmdbguiSmallText'>Innehåll</p> <p class='cmdbguiSmallText'>Innehåll</p>
<div id="cmdb-table"></div> <div id="cmdb-table"></div>
<p class='cmdbguiSmallText'>Relationer</p> <p class='cmdbguiSmallText'>Relationer</p>
<div id="mynetwork"></div> <div id="mynetwork"></div>
</body> </body>
</html> </html>
\ No newline at end of file
$(document).ready(function () { $(document).ready(function () {
updateGraph(0);
});
function updateGraph(centralNode){
$.ajax({ $.ajax({
url: '/cmdb/api/v1/organisation/list/nodes' url: '/cmdb/api/v1/organisation/list/nodes/' + centralNode
}).then(function(nodes) { }).then(function(nodes) {
$.ajax({ $.ajax({
url: '/cmdb/api/v1/organisation/list/edges' url: '/cmdb/api/v1/organisation/list/edges/' + centralNode
}).then(function(edges) { }).then(function(edges) {
// create a network // create a network
...@@ -14,12 +19,31 @@ $(document).ready(function () { ...@@ -14,12 +19,31 @@ $(document).ready(function () {
nodes: nodes, nodes: nodes,
edges: edges edges: edges
}; };
var options = {};
var options = {
layout: {
randomSeed: undefined,
improvedLayout:true,
hierarchical: {
enabled:true,
levelSeparation: 150,
nodeSpacing: 100,
treeSpacing: 200,
blockShifting: true,
edgeMinimization: true,
parentCentralization: true,
direction: 'DU', // UD, DU, LR, RL
sortMethod: 'directed' // hubsize, directed
}
}
};
// options.nodes = {
// color: 'gray'
// }
// initialize your network! // initialize your network!
var network = new vis.Network(container, data, options); var network = new vis.Network(container, data, options);
}); });
}); });
}); }
\ No newline at end of file
\ No newline at end of file
...@@ -42,13 +42,188 @@ $(document).ready(function () { ...@@ -42,13 +42,188 @@ $(document).ready(function () {
display: function(parentOrganisation){ display: function(parentOrganisation){
var $imgSubOrg = $('<img src="/images/organisation.png" title="Nivå 2" />'); var $imgSubOrg = $('<img src="/images/organisation.png" title="Nivå 2" />');
$imgSubOrg.click(function () { $imgSubOrg.click(function () {
updateGraph(parentOrganisation.record.id);
$('#cmdb-table').jtable('openChildTable', $imgSubOrg.closest('tr'),{ $('#cmdb-table').jtable('openChildTable', $imgSubOrg.closest('tr'),{
title: parentOrganisation.record.display_name + ':s underliggande organisationer', title: parentOrganisation.record.display_name + ':s underliggande organisationer',
showCloseButton: true, showCloseButton: true,
actions: { actions: {
listAction: '/cmdb/api/v1/organisation/list/' + parentOrganisation.record.id , // select all rows with parent === data.record.id listAction: '/cmdb/api/v1/organisation/list/' + parentOrganisation.record.id // select all rows with parent === data.record.id
}, },
fields: { fields: {
subOrg2: {
title: '',
width: '1%',
sorting: false,
edit: false,
create: false,
delete: false,
display: function(parentOrganisation){
var $imgSubOrg = $('<img src="/images/organisation.png" title="Nivå 3" />');
$imgSubOrg.click(function () {
updateGraph(parentOrganisation.record.id);
$('#cmdb-table').jtable('openChildTable', $imgSubOrg.closest('tr'),{
title: parentOrganisation.record.display_name + ':s underliggande organisationer',
showCloseButton: true,
actions: {
listAction: '/cmdb/api/v1/organisation/list/' + parentOrganisation.record.id , // select all rows with parent === data.record.id
},
fields: {
subOrg3: {
title: '',
width: '1%',
sorting: false,
edit: false,
create: false,
delete: false,
display: function(parentOrganisation){
var $imgSubOrg = $('<img src="/images/organisation.png" title="Nivå 4" />');
$imgSubOrg.click(function () {
updateGraph(parentOrganisation.record.id);
$('#cmdb-table').jtable('openChildTable', $imgSubOrg.closest('tr'),{
title: parentOrganisation.record.display_name + ':s underliggande organisationer',
showCloseButton: true,
actions: {
listAction: '/cmdb/api/v1/organisation/list/' + parentOrganisation.record.id , // select all rows with parent === data.record.id
},
fields: {
subOrg4: {
title: '',
width: '1%',
sorting: false,
edit: false,
create: false,
delete: false,
display: function(parentOrganisation){
var $imgSubOrg = $('<img src="/images/organisation.png" title="Nivå 5" />');
$imgSubOrg.click(function () {
updateGraph(parentOrganisation.record.id);
$('#cmdb-table').jtable('openChildTable', $imgSubOrg.closest('tr'),{
title: parentOrganisation.record.display_name + ':s underliggande organisationer',
showCloseButton: true,
actions: {
listAction: '/cmdb/api/v1/organisation/list/' + parentOrganisation.record.id , // select all rows with parent === data.record.id
},
fields: {
id: {
title: 'id',
width: '15%',
list: false,
key: true
},
display_name: {
title: 'Namn',
width: '15%'
},
description: {
title: 'Beskrivning',
width: '30%'
},
organisation_type: {
title: 'Typ',
options: '/cmdb/api/v1/organisation/class_list/0',
width: '15%'
},
organisation_level: {
title: 'Nivå',
options: '/cmdb/api/v1/organisation/class_list/1',
width: '15%'
},
parent_organisation_id: {
list: false,
title: 'Överordnad organisation',
options: '/cmdb/api/v1/organisation/class_list2',
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%'
},
organisation_type: {
title: 'Typ',
options: '/cmdb/api/v1/organisation/types',
width: '15%'
},
organisation_level: {
title: 'Nivå',
options: '/cmdb/api/v1/organisation/levels',
width: '15%'
},
parent_organisation_id: {
list: false,
title: 'Överordnad organisation',
options: '/cmdb/api/v1/organisation/parents',
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%'
},
organisation_type: {
title: 'Typ',
options: '/cmdb/api/v1/organisation/types',
width: '15%'
},
organisation_level: {
title: 'Nivå',
options: '/cmdb/api/v1/organisation/levels',
width: '15%'
},
parent_organisation_id: {
list: false,
title: 'Överordnad organisation',
options: '/cmdb/api/v1/organisation/parents',
width: '15%'
}
}
},
function(data){
data.childTable.jtable('load');
});
});
return $imgSubOrg;
}
},
id: { id: {
title: 'id', title: 'id',
width: '15%', width: '15%',
...@@ -104,19 +279,19 @@ $(document).ready(function () { ...@@ -104,19 +279,19 @@ $(document).ready(function () {
}, },
organisation_type: { organisation_type: {
title: 'Typ', title: 'Typ',
options: '/cmdb/api/v1/organisation/types', options: '/cmdb/api/v1/organisation/class_list/0',
width: '15%' width: '15%'
}, },
organisation_level: { organisation_level: {
title: 'Nivå', title: 'Nivå',
options: '/cmdb/api/v1/organisation/levels', options: '/cmdb/api/v1/organisation/class_list/2',
width: '15%' width: '15%'
}, },
parent_organisation_id: { parent_organisation_id: {
list: false, list: false,
title: 'Överordnad organisation', title: 'Överordnad organisation',
options: '/cmdb/api/v1/organisation/parents', options: '/cmdb/api/v1/organisation/parent',
width: '15%', width: '15%'
} }
} }
}); });
......
$(document).ready(function () {
updateGraph(0);
});
function updateGraph(centralNode){
$.ajax({
url: '/cmdb/api/v1/organisation/list/nodes/' + centralNode
}).then(function(nodes) {
$.ajax({
url: '/cmdb/api/v1/organisation/list/edges/' + centralNode
}).then(function(edges) {
// create a network
var container = document.getElementById('mynetwork');
// provide the data in the vis format
var data = {
nodes: nodes,
edges: edges
};
var options = {
layout: {
randomSeed: undefined,
improvedLayout:true,
hierarchical: {
enabled:true,
levelSeparation: 150,
nodeSpacing: 100,
treeSpacing: 200,
blockShifting: true,
edgeMinimization: true,
parentCentralization: true,
direction: 'DU', // UD, DU, LR, RL
sortMethod: 'directed' // hubsize, directed
}
}
};
// options.nodes = {
// color: 'gray'
// }
// initialize your network!
var network = new vis.Network(container, data, options);
});
});
}
\ No newline at end of file
$(document).ready(function () {
$('#cmdb-table').jtable({
title: "Typer av CI-familjer",
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/structure/family_type',
createAction: '/cmdb/api/v1/structure/create',
updateAction: function(postData) {
return $.Deferred(function ($dfd) {
$.ajax({
url: '/cmdb/api/v1/structure/update',
type: 'POST',
dataType: 'json',
data: postData,
success: function (data) {
$dfd.resolve(data);
var records = data['Records'];
},
error: function () {
$dfd.reject();
}
});
});
},
deleteAction: '/cmdb/api/v1/structure/delete'
},
fields: { //family_type
id: {
title: 'id',
width: '15%',
list: false,
key: true
},
display_name: {
title: 'Namn',
width: '15%'
},
description: {
title: 'Beskrivning',
width: '30%'
}
}
});
$('#cmdb-table').jtable('load');
});
Supports Markdown
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