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
4d14bd94
Commit
4d14bd94
authored
Dec 22, 2017
by
a001188
Browse files
Some functions works
parent
9df48e67
Changes
5
Hide whitespace changes
Inline
Side-by-side
public/javascripts/dashlets/_structure-graph.js
deleted
100644 → 0
View file @
9df48e67
function
structureGraph
(
centralNode
){
$
.
ajax
({
url
:
'
/cmdb/api/v1/structure/list/nodes/
'
+
centralNode
}).
then
(
function
(
nodes
)
{
$
.
ajax
({
url
:
'
/cmdb/api/v1/structure/list/edges/
'
+
centralNode
}).
then
(
function
(
edges
)
{
// create a network
var
container
=
document
.
getElementById
(
'
cmdb-net
'
);
// provide the data in the vis format
var
data
=
{
nodes
:
nodes
,
edges
:
edges
};
var
options
=
{
height
:
'
1200px
'
,
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/family_and_classes-table__old.js
deleted
100644 → 0
View file @
9df48e67
function
structureTable
(){
$
(
'
#cmdb-table
'
).
jtable
(
createTable
(
columnDef
()));
$
(
'
#cmdb-table
'
).
jtable
(
'
load
'
);
}
function
columnDef
(){
var
cd
=
{
next
:
{
title
:
'
Nästa
'
,
width
:
'
1%
'
,
display
:
renderSubTable
},
id
:
{
title
:
'
id
'
,
width
:
'
3%
'
,
list
:
true
,
key
:
true
},
display_name
:
{
title
:
'
Namn
'
,
width
:
'
25%
'
},
description
:
{
title
:
'
Beskrivning
'
,
width
:
'
70%
'
}
}
return
cd
;
}
function
createTable
(
columnDef
){
var
table
=
{
title
:
"
Konfigurationselement
"
,
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/enterprise_service/list
'
},
fields
:
columnDef
};
return
table
;
}
function
renderSubTable
(
data
)
{
//updateGraph(parentOrganisation.record.id);
if
(
data
.
record
.
childs
>
0
){
return
$
(
'
<img src="/images/structure.png" title="Nästa nivå"/>
'
).
click
(
function
()
{
createSubTable
(
data
,
$
(
this
).
closest
(
'
tr
'
));
});
}
}
function
createSubTable
(
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
getFamilyId
(
data
){
return
data
.
record
.
family_type_id
;
}
\ No newline at end of file
public/javascripts/dashlets/organisation-table.js
View file @
4d14bd94
function
organiationTable
(){
$
(
'
#cmdb-table
'
).
jtable
({
title
:
"
Organisation
"
,
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
,
display
:
function
(
parentOrganisation
){
var
$imgSubOrg
=
$
(
'
<img src="/images/structure.png" title="Avdelningar" />
'
);
$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
:
{
subOrg2
:
{
title
:
''
,
width
:
'
1%
'
,
sorting
:
false
,
edit
:
false
,
create
:
false
,
delete
:
false
,
display
:
function
(
parentOrganisation
){
var
$imgSubOrg
=
$
(
'
<img src="/images/structure.png" title="Enheter" />
'
);
$imgSubOrg
.
click
(
function
(
data
)
{
$
(
'
#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
,
function
organisationTable
(){
$
(
'
#cmdb-table
'
).
jtable
(
createTable
(
columnDef
()));
$
(
'
#cmdb-table
'
).
jtable
(
'
load
'
);
}
display
:
function
(
parentOrganisation
){
var
$imgSubOrg
=
$
(
'
<img src="/images/structure.png" title="Grupper" />
'
);
$imgSubOrg
.
click
(
function
(
data
)
{
$
(
'
#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%
'
},
family_id
:
{
title
:
'
Typ
'
,
options
:
'
/cmdb/api/v1/options/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/options/classes/0
'
,
//class_type_id
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%
'
},
family_id
:
{
title
:
'
Typ
'
,
options
:
'
/cmdb/api/v1/options/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/options/classes/0
'
,
//class_type_id
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%
'
},
family_id
:
{
title
:
'
Typ
'
,
options
:
'
/cmdb/api/v1/options/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/options/classes/0
'
,
//class_type_id
width
:
'
15%
'
}
}
},
function
(
data
){
data
.
childTable
.
jtable
(
'
load
'
);
});
});
return
$imgSubOrg
;
}
},
function
columnDef
(){
var
cd
=
{
next
:
{
title
:
'
Nästa
'
,
width
:
'
1%
'
,
display
:
renderSubTable
},
id
:
{
title
:
'
id
'
,
width
:
'
15%
'
,
...
...
@@ -193,21 +20,77 @@ function organiationTable(){
title
:
'
Namn
'
,
width
:
'
15%
'
},
description
:
{
title
:
'
Beskrivning
'
,
width
:
'
30%
'
},
//
description: {
//
title: 'Beskrivning',
//
width: '30%'
//
},
family_id
:
{
title
:
'
Typ
'
,
options
:
'
/cmdb/api/v1/options/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/options/classes/0
'
,
//class_type_id
class_information
:
{
title
:
'
Klassinformation
'
,
width
:
'
15%
'
},
attribute_information
:
{
title
:
'
Attributinformation
'
,
width
:
'
15%
'
}
},
// level_id: {
// title: 'Nivå',
// options: '/cmdb/api/v1/options/classes/0', //class_type_id
// width: '15%'
// }
};
return
cd
;
}
function
createTable
(
columnDef
){
var
table
=
{
title
:
"
Organisation
"
,
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
'
},
fields
:
columnDef
};
return
table
;
}
function
renderSubTable
(
data
)
{
//updateGraph(parentOrganisation.record.id);
if
(
data
.
record
.
childs
>
0
){
return
$
(
'
<img src="/images/structure.png" title="Nästa nivå"/>
'
).
click
(
function
()
{
createSubTable
(
data
,
$
(
this
).
closest
(
'
tr
'
));
});
}
});
$
(
'
#cmdb-table
'
).
jtable
(
'
load
'
);
}
}
function
createSubTable
(
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
:
columnDef
()
},
function
(
data
)
{
//opened handler
data
.
childTable
.
jtable
(
'
load
'
);
});
}
function
getFamilyId
(
data
){
return
data
.
record
.
family_type_id
;
}
\ No newline at end of file
public/javascripts/select.js
View file @
4d14bd94
...
...
@@ -8,7 +8,7 @@ $(document).ready(function () {
ciTable
();
}
if
(
ref
.
includes
(
'
/organisation/
'
)){
organiationTable
(
1
);
organi
s
ationTable
();
organisationGraph
(
1
);
}
if
(
ref
.
includes
(
'
/relation-types/
'
)){
...
...
routes/organisation.js
View file @
4d14bd94
...
...
@@ -120,7 +120,8 @@ router.post('/list/:parent_id', (req, res, next) => {
}
// SQL Query > Select Data
var
sql
=
"
select * from cmdb.ci_family_organisation where id>0 and parent_id = $1;
"
;
var
sql
=
"
select * ,(select count(*) as childs from cmdb.ci child where child.parent_id = parent.id and family_type_id=0) as childs
"
;
sql
+=
"
from cmdb.ci parent where parent.family_type_id=0 and parent.id>0 and parent.parent_id = $1;
"
;
var
parameter
=
req
.
params
[
'
parent_id
'
];
client
.
query
(
sql
,
[
parameter
],
function
(
err
,
result
){
done
();
...
...
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