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

Some functions work

parent a8f01407
......@@ -65,7 +65,7 @@
</div>
<form class='cmdbguiSearchForm'>Sök:<input type="text" name="searchString" id="searchString"/></form>
<p class='cmdbguiSmallText'>Innehåll</p>
<div id="displayarea"></div>
<div id="cmdb-table"></div>
<p class='cmdbguiSmallText'>Relationer</p>
<div id="mynetwork"></div>
</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 () {
$('#displayarea').jtable({
$('#cmdb-table').jtable({
title: "Organisation",
paging: false, //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/organisation/list/0',
createAction: '/cmdb/api/v1/organisation/create',
updateAction: function(postData) {
return $.Deferred(function ($dfd) {
$.ajax({
url: '/cmdb/api/v1/organisation/update',
type: 'POST',
dataType: 'json',
data: postData,
success: function (data) {
$dfd.resolve(data);
var records = data['Records'];
},
error: function () {
$dfd.reject();
}
});
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/organisation/list/0',
createAction: '/cmdb/api/v1/organisation/create',
updateAction: function(postData) {
return $.Deferred(function ($dfd) {
$.ajax({
url: '/cmdb/api/v1/organisation/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/organisation/delete'
});
},
fields: {
subOrg1: {
title: '',
width: '1%',
sorting: false,
edit: false,
create: false,
delete: false,
deleteAction: '/cmdb/api/v1/organisation/delete'
},
fields: {
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/' + data.record.id, // select all rows with parent === data.record.id
display: function(parentOrganisation){
var $imgSubOrg = $('<img src="/images/organisation.png" title="Nivå 2" />');
$imgSubOrg.click(function () {
$('#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
},
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%'
}
display_name: {
title: 'Namn',
width: '15%'
},
},
function(data){
data.childTable.jtable('load');
});
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;
}
},
......@@ -134,15 +119,7 @@ $(document).ready(function () {
width: '15%',
}
}
});
//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();
});
$('#cmdb-table').jtable('load');
});
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