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

Some functions work

parent a8f01407
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
</div> </div>
<form class='cmdbguiSearchForm'>Sök:<input type="text" name="searchString" id="searchString"/></form> <form class='cmdbguiSearchForm'>Sök:<input type="text" name="searchString" id="searchString"/></form>
<p class='cmdbguiSmallText'>Innehåll</p> <p class='cmdbguiSmallText'>Innehåll</p>
<div id="displayarea"></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>
......
This diff is collapsed.
subOrg1: {
title: '',
width: '1%',
sorting: false,
edit: false,
create: false,
delete: false,
display: function(data){
var $imgSubOrg = $('<img src="/images/organisation.png" title="Nivå 2" />');
$imgSubOrg.click(function () {
$('#displayarea').jtable('openChildTable', $imgSubOrg.closest('tr'),{
title: 'Organisation nivå 2',
showCloseButton: false,
actions: {
listAction: '/cmdb/api/v1/organisation/list/5' , // select all rows with parent === data.record.id
},
fields: {
closeChild: {
title: '',
width: '1%',
sorting: false,
edit: false,
create: false,
delete: false,
display: function(){
var $imgClose = $('img src="/images/cross.png');
$imgClose.click(function() {
$('#displayarea').jtable('closeChildTable', $($imgClose.closest('tr')));
});
return $imgClose;
}
},
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;
}
},
$(document).ready(function () { $(document).ready(function () {
$('#displayarea').jtable({ $('#cmdb-table').jtable({
title: "Organisation", title: "Organisation",
paging: false, //Enable paging paging: false, //Enable paging
pageSize: 10, //Set page size (default: 10) pageSize: 10, //Set page size (default: 10)
pageList: 'minimal', pageList: 'minimal',
sorting: true, //Enable sorting sorting: false, //Enable sorting
multiSorting: true, multiSorting: false,
defaultSorting: 'display_name ASC', //Set default sorting defaultSorting: 'display_name ASC', //Set default sorting
actions: { actions: {
listAction: '/cmdb/api/v1/organisation/list/0', listAction: '/cmdb/api/v1/organisation/list/0',
createAction: '/cmdb/api/v1/organisation/create', createAction: '/cmdb/api/v1/organisation/create',
updateAction: function(postData) { updateAction: function(postData) {
return $.Deferred(function ($dfd) { return $.Deferred(function ($dfd) {
$.ajax({ $.ajax({
url: '/cmdb/api/v1/organisation/update', url: '/cmdb/api/v1/organisation/update',
type: 'POST', type: 'POST',
dataType: 'json', dataType: 'json',
data: postData, data: postData,
success: function (data) { success: function (data) {
$dfd.resolve(data); $dfd.resolve(data);
var records = data['Records']; var records = data['Records'];
}, },
error: function () { error: function () {
$dfd.reject(); $dfd.reject();
} }
});
}); });
}, });
deleteAction: '/cmdb/api/v1/organisation/delete'
}, },
fields: { deleteAction: '/cmdb/api/v1/organisation/delete'
subOrg1: { },
title: '', fields: {
width: '1%', subOrg1: {
sorting: false, title: '',
edit: false, width: '1%',
create: false, sorting: false,
delete: false, edit: false,
create: false,
delete: false,
display: function(data){ 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 () {
$('#displayarea').jtable('openChildTable', $imgSubOrg.closest('tr'),{ $('#cmdb-table').jtable('openChildTable', $imgSubOrg.closest('tr'),{
title: 'Organisation nivå 2', title: parentOrganisation.record.display_name + ':s underliggande organisationer',
showCloseButton: false, showCloseButton: true,
actions: { actions: {
listAction: '/cmdb/api/v1/organisation/list/' + data.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: {
id: {
title: 'id',
width: '15%',
list: false,
key: true
}, },
fields: { display_name: {
closeChild: { title: 'Namn',
title: '', width: '15%'
width: '1%',
sorting: false,
edit: false,
create: false,
delete: false,
display: function(){
var $imgClose = $('img src="/images/cross.png');
$imgClose.click(function() {
$('#displayarea').jtable('closeChildTable', $($imgClose.closest('tr')));
});
return $imgClose;
}
},
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%'
}
}, },
}, description: {
function(data){ title: 'Beskrivning',
data.childTable.jtable('load'); 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; return $imgSubOrg;
} }
}, },
...@@ -134,15 +119,7 @@ $(document).ready(function () { ...@@ -134,15 +119,7 @@ $(document).ready(function () {
width: '15%', width: '15%',
} }
} }
}); });
$('#cmdb-table').jtable('load');
//Re-load records when user click 'load records' button.
$('#displayarea').click(function (e) {
e.preventDefault();
$('#displayarea').jtable('load');
});
//Load all records when page is first shown
$('#displayarea').click();
}); });
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