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
3dcbea3a
Commit
3dcbea3a
authored
Dec 28, 2017
by
a001188
Browse files
Some functions works
parent
b68ff579
Changes
9
Hide whitespace changes
Inline
Side-by-side
public/javascripts/dashlets/ci-table.js
→
public/javascripts/dashlets/
ec-
ci-table.js
View file @
3dcbea3a
function
ciTable
(){
$
(
'
#cmdb-table
'
).
jtable
(
createTable
(
c
olumnDef
()));
function
ec_
ciTable
(){
$
(
'
#cmdb-table
'
).
jtable
(
create
EcCi
Table
(
ec_ciC
olumnDef
()));
$
(
'
#cmdb-table
'
).
jtable
(
'
load
'
);
}
function
c
olumnDef
(){
function
ec_ciC
olumnDef
(){
var
cd
=
{
next
:
{
title
:
'
Nästa
'
,
width
:
'
1%
'
,
display
:
renderSubTable
display
:
render
EcCi
SubTable
},
family_type_id
:
{
title
:
'
Familjetyp
'
,
...
...
@@ -72,9 +72,9 @@ function columnDef(){
function
createTable
(
columnDef
){
function
create
EcCi
Table
(
c
iC
olumnDef
){
var
table
=
{
title
:
"
Konfigurationselement
"
,
title
:
"
Konfigurationselement
CI
"
,
paging
:
false
,
//Enable paging
pageSize
:
10
,
//Set page size (default: 10)
pageList
:
'
minimal
'
,
...
...
@@ -84,37 +84,36 @@ function columnDef(){
actions
:
{
listAction
:
'
/cmdb/api/v1/ci/enterprise_service/list
'
},
fields
:
columnDef
fields
:
c
iC
olumnDef
};
return
table
;
}
function
renderSubTable
(
data
)
{
//updateGraph(parentOrganisation.record.id);
function
renderEcCiSubTable
(
data
)
{
if
(
data
.
record
.
childs
>
0
){
return
$
(
'
<img src="/images/structure.png" title="Nästa nivå"/>
'
).
click
(
function
()
{
createSubTable
(
data
,
$
(
this
).
closest
(
'
tr
'
));
create
EcCi
SubTable
(
data
,
$
(
this
).
closest
(
'
tr
'
));
});
}
}
function
createSubTable
(
data
,
row
){
function
create
EcCi
SubTable
(
data
,
row
){
$
(
'
#cmdb-table
'
).
jtable
(
'
openChildTable
'
,
row
,
{
title
:
'
Komponenter till
'
+
data
.
record
.
display_name
,
actions
:
{
listAction
:
'
/cmdb/api/v1/ci/child/list/
'
+
data
.
record
.
id
},
fields
:
c
olumnDef
()
fields
:
ec_ciC
olumnDef
()
},
function
(
data
)
{
//opened handler
data
.
childTable
.
jtable
(
'
load
'
);
});
}
function
getFamilyId
(
data
){
function
get
EcCi
FamilyId
(
data
){
return
data
.
record
.
family_type_id
;
}
\ No newline at end of file
public/javascripts/dashlets/organisation-graph.js
View file @
3dcbea3a
function
org
anisation
Graph
(
centralNode
){
function
orgGraph
(
centralNode
){
$
.
ajax
({
url
:
'
/cmdb/api/v1/organisation/list/nodes/
'
+
centralNode
}).
then
(
function
(
nodes
)
{
...
...
@@ -16,6 +16,17 @@ function organisationGraph(centralNode){
edges
:
edges
};
for
(
var
i
=
0
;
i
<
nodes
.
length
;
i
++
){
if
(
nodes
[
i
].
type_id
===
11
)
data
.
nodes
[
i
].
color
=
'
#ffa0a0
'
;
if
(
nodes
[
i
].
type_id
===
11
)
data
.
nodes
[
i
].
color
=
'
#ffa0a0
'
;
if
(
nodes
[
i
].
type_id
===
11
)
data
.
nodes
[
i
].
color
=
'
#ffa0a0
'
;
else
data
.
nodes
[
i
].
color
=
'
#d0d0ff
'
;
}
var
options
=
{
height
:
'
800px
'
,
layout
:
{
...
...
public/javascripts/dashlets/organisation-table.js
View file @
3dcbea3a
function
org
anisation
Table
(){
$
(
'
#cmdb-table
'
).
jtable
(
createTable
(
c
olumnDef
()));
function
orgTable
(){
$
(
'
#cmdb-table
'
).
jtable
(
create
Org
Table
(
orgC
olumnDef
()));
$
(
'
#cmdb-table
'
).
jtable
(
'
load
'
);
}
function
c
olumnDef
(){
function
orgC
olumnDef
(){
var
cd
=
{
next
:
{
title
:
'
Nästa
'
,
width
:
'
1%
'
,
display
:
renderSubTable
display
:
render
Org
SubTable
},
id
:
{
title
:
'
id
'
,
...
...
@@ -48,7 +48,7 @@ function columnDef(){
function
createTable
(
c
olumnDef
){
function
create
Org
Table
(
orgC
olumnDef
){
var
table
=
{
title
:
"
Organisation
"
,
paging
:
false
,
//Enable paging
...
...
@@ -60,37 +60,36 @@ function columnDef(){
actions
:
{
listAction
:
'
/cmdb/api/v1/organisation/list/0
'
},
fields
:
c
olumnDef
fields
:
orgC
olumnDef
};
return
table
;
}
function
renderSubTable
(
data
)
{
//updateGraph(parentOrganisation.record.id);
function
renderOrgSubTable
(
data
)
{
if
(
data
.
record
.
childs
>
0
){
return
$
(
'
<img src="/images/structure.png" title="Nästa nivå"/>
'
).
click
(
function
()
{
createSubTable
(
data
,
$
(
this
).
closest
(
'
tr
'
));
create
Org
SubTable
(
data
,
$
(
this
).
closest
(
'
tr
'
));
});
}
}
function
createSubTable
(
data
,
row
){
function
create
Org
SubTable
(
data
,
row
){
$
(
'
#cmdb-table
'
).
jtable
(
'
openChildTable
'
,
row
,
{
title
:
'
Underordnade organisationer
'
+
data
.
record
.
display_name
,
actions
:
{
listAction
:
'
/cmdb/api/v1/organisation/list/
'
+
data
.
record
.
id
},
fields
:
c
olumnDef
()
fields
:
orgC
olumnDef
()
},
function
(
data
)
{
//opened handler
data
.
childTable
.
jtable
(
'
load
'
);
});
}
function
getFamilyId
(
data
){
function
get
Org
FamilyId
(
data
){
return
data
.
record
.
family_type_id
;
}
\ No newline at end of file
public/javascripts/dashlets/tfo-ci-table.js
0 → 100644
View file @
3dcbea3a
function
tfo_ciTable
(){
$
(
'
#cmdb-table
'
).
jtable
(
createTfoCiTable
(
tfo_ciColumnDef
()));
$
(
'
#cmdb-table
'
).
jtable
(
'
load
'
);
}
function
tfo_ciColumnDef
(){
var
cd
=
{
next
:
{
title
:
'
Nästa
'
,
width
:
'
1%
'
,
display
:
renderTfoCiSubTable
},
family_type_id
:
{
title
:
'
Familjetyp
'
,
options
:
'
/cmdb/api/v1/options/family_type
'
,
width
:
'
5%
'
},
family_id
:
{
title
:
'
Familj
'
,
options
:
'
/cmdb/api/v1/options/families
'
,
width
:
'
5%
'
},
id
:
{
title
:
'
id
'
,
width
:
'
1%
'
,
list
:
false
,
key
:
true
},
display_name
:
{
title
:
'
Namn
'
,
width
:
'
10%
'
},
description
:
{
title
:
'
Beskrivning
'
,
width
:
'
15%
'
},
kst
:
{
title
:
'
Kostnadsställe
'
,
width
:
'
5%
'
},
product
:
{
title
:
'
Produkt
'
,
width
:
'
5%
'
},
sla
:
{
title
:
'
SLA
'
,
width
:
'
5%
'
},
class_information
:
{
title
:
'
Klasser
'
,
width
:
'
15%
'
},
attribute_information
:
{
title
:
'
Attribut
'
,
width
:
'
20%
'
},
// account_group: {
// title: 'Grupper',
// width: '15%'
// },
// account_id: {
// title: 'Konton',
// width: '15%'
// },
// contacts: {
// title: 'Kontaktpersoner',
// width: '15%'
// }
}
return
cd
;
}
function
createTfoCiTable
(
ciColumnDef
){
var
table
=
{
title
:
"
Konfigurationselement CI
"
,
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/ci/infrastructure/list
'
},
fields
:
ciColumnDef
};
return
table
;
}
function
renderTfoCiSubTable
(
data
)
{
if
(
data
.
record
.
childs
>
0
){
return
$
(
'
<img src="/images/structure.png" title="Nästa nivå"/>
'
).
click
(
function
()
{
createTfoCiSubTable
(
data
,
$
(
this
).
closest
(
'
tr
'
));
});
}
}
function
createTfoCiSubTable
(
data
,
row
){
$
(
'
#cmdb-table
'
).
jtable
(
'
openChildTable
'
,
row
,
{
title
:
'
Komponenter till
'
+
data
.
record
.
display_name
,
actions
:
{
listAction
:
'
/cmdb/api/v1/ci/child/list/
'
+
data
.
record
.
id
},
fields
:
columnDef
()
},
function
(
data
)
{
//opened handler
data
.
childTable
.
jtable
(
'
load
'
);
});
}
function
getTfoCiFamilyId
(
data
){
return
data
.
record
.
family_type_id
;
}
\ No newline at end of file
public/javascripts/select.js
View file @
3dcbea3a
...
...
@@ -4,12 +4,15 @@ $(document).ready(function () {
if
(
ref
.
includes
(
'
/family-and-class/
'
)){
structureTable
();
}
if
(
ref
.
includes
(
'
/ci/
'
)){
ciTable
();
if
(
ref
.
includes
(
'
/ec-ci/
'
)){
ec_ciTable
();
}
if
(
ref
.
includes
(
'
/tfo-ci/
'
)){
tfo_ciTable
();
}
if
(
ref
.
includes
(
'
/organisation/
'
)){
org
anisation
Table
();
org
anisation
Graph
(
1
);
orgTable
();
orgGraph
(
1
);
}
if
(
ref
.
includes
(
'
/relation-types/
'
)){
relationTypesTable
();
...
...
routes/ci.js
View file @
3dcbea3a
...
...
@@ -34,7 +34,32 @@ router.post('/enterprise_service/list', (req, res, next) => {
});
});
//select * , (select count(*) from cmdb.ci child where child.parent_id = id) as childs from cmdb.ci where parent_id = 27 order by display_name
router
.
post
(
'
/infrastructure/list
'
,
(
req
,
res
,
next
)
=>
{
var
pool
=
new
pg
.
Pool
({
connectionString
:
connectionString
,
});
pool
.
connect
(
function
(
err
,
client
,
done
){
if
(
err
)
{
done
();
return
res
.
status
(
500
).
json
({
success
:
false
,
data
:
err
});
}
var
sql
=
"
select * , (select count(*) from cmdb.ci c where c.parent_id = id) as childs from cmdb.ci where family_type_id = 5 and id > 0 order by family_type_id, family_id, display_name
"
;
client
.
query
(
sql
,
[],
function
(
err
,
result
){
done
();
if
(
err
){
return
res
.
json
(
JSON
.
parse
(
'
{"Result":"ERROR", "Message":"
'
+
sql
+
'
"}
'
));
}
else
{
var
response
=
'
{"Result":"OK", "Records":
'
;
response
+=
JSON
.
stringify
(
result
.
rows
);
response
+=
'
,"TotalRecordCount":
'
+
result
.
rowCount
+
'
}
'
;
return
res
.
json
(
JSON
.
parse
(
response
));
}
});
});
});
router
.
post
(
'
/child/list/:parent_id
'
,
(
req
,
res
,
next
)
=>
{
...
...
routes/organisation.js
View file @
3dcbea3a
...
...
@@ -8,16 +8,15 @@ const pg = require('pg');
const
winston
=
require
(
'
winston
'
);
const
connectionString
=
process
.
env
.
DATABASE_URL
||
config
.
storageConfig
;
router
.
get
(
'
/list/nodes/:centralNode
'
,
(
req
,
res
,
next
)
=>
{
var
pool
=
new
pg
.
Pool
({
connectionString
:
connectionString
connectionString
:
connectionString
});
// Get a Postgres client from the connection pool
pool
.
connect
(
function
(
err
,
client
,
done
){
// Handle connection errors
pool
.
connect
(
function
(
err
,
client
,
done
){
if
(
err
)
{
done
();
return
res
.
status
(
500
).
json
({
success
:
false
,
data
:
err
});
done
();
return
res
.
status
(
500
).
json
({
success
:
false
,
data
:
err
});
}
// all leaf
...
...
views/layout.pug
View file @
3dcbea3a
...
...
@@ -18,7 +18,8 @@ html
script(type='text/javascript', src='/javascripts/vis/dist/vis.js')
script(type='text/javascript', src='/javascripts/select.js')
script(type='text/javascript', src='/javascripts/dashlets/ci-table.js')
script(type='text/javascript', src='/javascripts/dashlets/ec-ci-table.js')
script(type='text/javascript', src='/javascripts/dashlets/tfo-ci-table.js')
script(type='text/javascript', src='/javascripts/dashlets/organisation-table.js')
script(type='text/javascript', src='/javascripts/dashlets/organisation-graph.js')
script(type='text/javascript', src='/javascripts/dashlets/family_and_classes-table.js')
...
...
views/menu.pug
View file @
3dcbea3a
...
...
@@ -22,9 +22,9 @@ block menu
a(href="#") Teknisk konfiguration
ul
li
a(href="/view/ci/1")
Konfigurationselement
a(href="/view/
ec-
ci/1")
Företagstjänster (CI)
li
a(href="/view/
infrastructure
/1") Infrastruktur
a(href="/view/
tfo-ci
/1") Infrastruktur
(CI)
li
a(href="/view/access/2") Behörighet
li
...
...
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