Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Peter Lundin
cmdb
Commits
caa9599f
Commit
caa9599f
authored
Dec 07, 2017
by
Peter Lundin
Browse files
Some functions work
parent
3d397750
Changes
7
Hide whitespace changes
Inline
Side-by-side
public/images/structure.png
0 → 100644
View file @
caa9599f
1.23 KB
public/index.html
View file @
caa9599f
...
...
@@ -16,9 +16,14 @@
<body
onhashchange=
"logoutcmdbgui(event)"
>
<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/dashlets/organisation-table.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/localization/jquery.jtable.se.js"
></script>
...
...
@@ -67,6 +72,8 @@
<p
class=
'cmdbguiSmallText'
>
Innehåll
</p>
<div
id=
"cmdb-table"
></div>
<p
class=
'cmdbguiSmallText'
>
Relationer
</p>
<div
id=
"mynetwork"
></div>
</body>
</html>
\ No newline at end of file
public/javascripts/dashlets/organisation-graph.js
View file @
caa9599f
$
(
document
).
ready
(
function
()
{
updateGraph
(
0
);
});
function
updateGraph
(
centralNode
){
$
.
ajax
({
url
:
'
/cmdb/api/v1/organisation/list/nodes
'
url
:
'
/cmdb/api/v1/organisation/list/nodes
/
'
+
centralNode
}).
then
(
function
(
nodes
)
{
$
.
ajax
({
url
:
'
/cmdb/api/v1/organisation/list/edges
'
url
:
'
/cmdb/api/v1/organisation/list/edges
/
'
+
centralNode
}).
then
(
function
(
edges
)
{
// create a network
...
...
@@ -14,12 +19,31 @@ $(document).ready(function () {
nodes
:
nodes
,
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!
var
network
=
new
vis
.
Network
(
container
,
data
,
options
);
});
});
});
\ No newline at end of file
}
\ No newline at end of file
public/javascripts/dashlets/organisation-table.js
View file @
caa9599f
...
...
@@ -42,13 +42,188 @@ $(document).ready(function () {
display
:
function
(
parentOrganisation
){
var
$imgSubOrg
=
$
(
'
<img src="/images/organisation.png" title="Nivå 2" />
'
);
$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
listAction
:
'
/cmdb/api/v1/organisation/list/
'
+
parentOrganisation
.
record
.
id
// select all rows with parent === data.record.id
},
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
:
{
title
:
'
id
'
,
width
:
'
15%
'
,
...
...
@@ -104,19 +279,19 @@ $(document).ready(function () {
},
organisation_type
:
{
title
:
'
Typ
'
,
options
:
'
/cmdb/api/v1/organisation/
types
'
,
options
:
'
/cmdb/api/v1/organisation/
class_list/0
'
,
width
:
'
15%
'
},
organisation_level
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/organisation/
levels
'
,
options
:
'
/cmdb/api/v1/organisation/
class_list/2
'
,
width
:
'
15%
'
},
parent_organisation_id
:
{
list
:
false
,
title
:
'
Överordnad organisation
'
,
options
:
'
/cmdb/api/v1/organisation/parent
s
'
,
width
:
'
15%
'
,
options
:
'
/cmdb/api/v1/organisation/parent
'
,
width
:
'
15%
'
}
}
});
...
...
public/javascripts/dashlets/structure-graph.js
0 → 100644
View file @
caa9599f
$
(
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
public/javascripts/dashlets/structure-table.js
0 → 100644
View file @
caa9599f
$
(
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
'
);
});
public/javascripts/jtable/themes/lightcolor/blue/lightcolor/blue/loading.gif
0 → 100644
View file @
caa9599f
723 Bytes
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment