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
2383e8b1
Commit
2383e8b1
authored
Dec 14, 2017
by
a001188
Browse files
Some functions work
parent
0ba8a266
Changes
13
Hide whitespace changes
Inline
Side-by-side
app.js
View file @
2383e8b1
...
...
@@ -8,6 +8,8 @@ var lessMiddleware = require('less-middleware');
var
$
=
require
(
"
jquery
"
);
var
index
=
require
(
'
./routes/index
'
);
var
relation
=
require
(
'
./routes/relation
'
);
var
options
=
require
(
'
./routes/options
'
);
var
enterprise_service
=
require
(
'
./routes/enterprise_service
'
);
var
organisation
=
require
(
'
./routes/organisation
'
);
var
structure
=
require
(
'
./routes/structure
'
);
var
users
=
require
(
'
./routes/users
'
);
...
...
@@ -30,9 +32,11 @@ app.use(express.static(path.join(__dirname, 'public')));
app
.
use
(
'
/
'
,
index
);
app
.
use
(
'
/view
'
,
index
);
app
.
use
(
'
/users
'
,
users
);
app
.
use
(
'
/cmdb/api/v1/options
'
,
options
);
app
.
use
(
'
/cmdb/api/v1/relation
'
,
relation
);
app
.
use
(
'
/cmdb/api/v1/organisation
'
,
organisation
);
app
.
use
(
'
/cmdb/api/v1/structure
'
,
structure
);
app
.
use
(
'
/cmdb/api/v1/enterprise_service
'
,
enterprise_service
);
// catch 404 and forward to error handler
app
.
use
(
function
(
req
,
res
,
next
)
{
...
...
public/javascripts/dashlets/structure-graph.js
→
public/javascripts/dashlets/
_
structure-graph.js
View file @
2383e8b1
File moved
public/javascripts/dashlets/enterprise_service-table.js
0 → 100644
View file @
2383e8b1
function
enterpriseServiceTable
(){
$
(
'
#cmdb-table
'
).
jtable
({
title
:
"
Enterprise Service
"
,
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/enterprise_service/list
'
,
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
(
parent
){
var
$imgSubOrg
=
$
(
'
<img src="/images/organisation.png" title="Till nivå 2" />
'
);
$imgSubOrg
.
click
(
function
(
data
)
{
$
(
'
#cmdb-table
'
).
jtable
(
'
openChildTable
'
,
$imgSubOrg
.
closest
(
'
tr
'
),{
title
:
parentOrganisation
.
record
.
display_name
+
'
:s applikationer
'
,
showCloseButton
:
true
,
actions
:
{
listAction
:
'
/cmdb/api/v1//cmdb/api/v1/enterprise_service/list/
'
+
parent
.
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
(
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
,
display
:
function
(
parentOrganisation
){
var
$imgSubOrg
=
$
(
'
<img src="/images/organisation.png" title="Nivå 4" />
'
);
$imgSubOrg
.
click
(
function
(
data
)
{
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
(
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/organisation/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/organisation/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/organisation/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/organisation/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/organisation/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/organisation/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/structure/families/
'
+
data
.
records
.
family_id
,
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/structure/classes/
'
+
data
.
records
.
class_id
,
//class_type_id
width
:
'
15%
'
},
kst
:
{
title
:
'
Kostnadsställe
'
,
width
:
'
15%
'
},
product
:
{
title
:
'
Produkt
'
,
width
:
'
15%
'
},
max_service_level
:
{
title
:
'
Max servicenivå
'
,
options
:
'
/cmdb/api/v1/structure/classes/
'
+
data
.
records
.
class_id
,
//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
:
'
Familj
'
,
options
:
'
/cmdb/api/v1/options/families/1
'
,
//+ data.options.family_type_id
width
:
'
15%
'
},
max_service_level
:
{
title
:
'
Max servicenivå
'
,
options
:
'
/cmdb/api/v1/options/classes/9
'
,
//class_type_id
width
:
'
15%
'
},
service_level_id
:
{
title
:
'
Servicenivå
'
,
options
:
'
/cmdb/api/v1/options/classes/9
'
,
//class_type_id
width
:
'
15%
'
},
service_degree_id
:
{
title
:
'
Servicegrad
'
,
options
:
'
/cmdb/api/v1/options/classes/10
'
,
//class_type_id
width
:
'
15%
'
},
kst
:
{
title
:
'
Kostnadsställe
'
,
width
:
'
15%
'
},
product
:
{
title
:
'
Produkt
'
,
width
:
'
15%
'
},
sla
:
{
title
:
'
SLA
'
,
width
:
'
15%
'
},
sys_overview_ref
:
{
title
:
'
Systemöversikt
'
,
width
:
'
15%
'
},
sys_overview_date
:
{
title
:
'
Godkänd systemöversikt
'
,
width
:
'
15%
'
},
sys_operating_manual_ref
:
{
title
:
'
DHL
'
,
width
:
'
15%
'
},
sys_operating_manual_date
:
{
title
:
'
Godkänd DHL
'
,
width
:
'
15%
'
}
}
});
$
(
'
#cmdb-table
'
).
jtable
(
'
load
'
);
}
public/javascripts/dashlets/
structure
-table.js
→
public/javascripts/dashlets/
family_and_classes
-table.js
View file @
2383e8b1
File moved
public/javascripts/dashlets/organisation-table.js
View file @
2383e8b1
...
...
@@ -39,7 +39,7 @@ function organiationTable(){
delete
:
false
,
display
:
function
(
parentOrganisation
){
var
$imgSubOrg
=
$
(
'
<img src="/images/organisation.png" title="
Till nivå 2
" />
'
);
var
$imgSubOrg
=
$
(
'
<img src="/images/organisation.png" title="
Avdelningar
" />
'
);
$imgSubOrg
.
click
(
function
()
{
$
(
'
#cmdb-table
'
).
jtable
(
'
openChildTable
'
,
$imgSubOrg
.
closest
(
'
tr
'
),{
title
:
parentOrganisation
.
record
.
display_name
+
'
:s underliggande organisationer
'
,
...
...
@@ -57,7 +57,7 @@ function organiationTable(){
delete
:
false
,
display
:
function
(
parentOrganisation
){
var
$imgSubOrg
=
$
(
'
<img src="/images/organisation.png" title="
Nivå 3
" />
'
);
var
$imgSubOrg
=
$
(
'
<img src="/images/organisation.png" title="
Enheter
" />
'
);
$imgSubOrg
.
click
(
function
(
data
)
{
$
(
'
#cmdb-table
'
).
jtable
(
'
openChildTable
'
,
$imgSubOrg
.
closest
(
'
tr
'
),{
title
:
parentOrganisation
.
record
.
display_name
+
'
:s underliggande organisationer
'
,
...
...
@@ -75,9 +75,8 @@ function organiationTable(){
delete
:
false
,
display
:
function
(
parentOrganisation
){
var
$imgSubOrg
=
$
(
'
<img src="/images/organisation.png" title="
Nivå 4
" />
'
);
var
$imgSubOrg
=
$
(
'
<img src="/images/organisation.png" title="
Grupper
" />
'
);
$imgSubOrg
.
click
(
function
(
data
)
{
updateGraph
(
parentOrganisation
.
record
.
id
);
$
(
'
#cmdb-table
'
).
jtable
(
'
openChildTable
'
,
$imgSubOrg
.
closest
(
'
tr
'
),{
title
:
parentOrganisation
.
record
.
display_name
+
'
:s underliggande organisationer
'
,
showCloseButton
:
true
,
...
...
@@ -85,57 +84,6 @@ function organiationTable(){
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
(
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/organisation/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/organisation/classes/0
'
,
//class_type_id
width
:
'
15%
'
}
}
},
function
(
data
){
data
.
childTable
.
jtable
(
'
load
'
);
});
});
return
$imgSubOrg
;
}
},
id
:
{
title
:
'
id
'
,
width
:
'
15%
'
,
...
...
@@ -152,12 +100,12 @@ function organiationTable(){
},
family_id
:
{
title
:
'
Typ
'
,
options
:
'
/cmdb/api/v1/o
rganisa
tion/families/0
'
,
//family_type_id
options
:
'
/cmdb/api/v1/o
p
tion
s
/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/o
rganisa
tion/classes/0
'
,
//class_type_id
options
:
'
/cmdb/api/v1/o
p
tion
s
/classes/0
'
,
//class_type_id
width
:
'
15%
'
}
}
...
...
@@ -185,12 +133,12 @@ function organiationTable(){
},
family_id
:
{
title
:
'
Typ
'
,
options
:
'
/cmdb/api/v1/o
rganisa
tion/families/0
'
,
//family_type_id
options
:
'
/cmdb/api/v1/o
p
tion
s
/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/o
rganisa
tion/classes/0
'
,
//class_type_id
options
:
'
/cmdb/api/v1/o
p
tion
s
/classes/0
'
,
//class_type_id
width
:
'
15%
'
}
}
...
...
@@ -218,12 +166,12 @@ function organiationTable(){
},
family_id
:
{
title
:
'
Typ
'
,
options
:
'
/cmdb/api/v1/o
rganisa
tion/families/0
'
,
//family_type_id
options
:
'
/cmdb/api/v1/o
p
tion
s
/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/o
rganisa
tion/classes/0
'
,
//class_type_id
options
:
'
/cmdb/api/v1/o
p
tion
s
/classes/0
'
,
//class_type_id
width
:
'
15%
'
}
}
...
...
@@ -251,12 +199,12 @@ function organiationTable(){
},
family_id
:
{
title
:
'
Typ
'
,
options
:
'
/cmdb/api/v1/o
rganisa
tion/families/0
'
,
//family_type_id
options
:
'
/cmdb/api/v1/o
p
tion
s
/families/0
'
,
//family_type_id
width
:
'
15%
'
},
level_id
:
{
title
:
'
Nivå
'
,
options
:
'
/cmdb/api/v1/o
rganisa
tion/classes/0
'
,
//class_type_id
options
:
'
/cmdb/api/v1/o
p
tion
s
/classes/0
'
,
//class_type_id
width
:
'
15%
'
}
}
...
...
public/javascripts/dashlets/relation-table.js
View file @
2383e8b1
function
relationNodesTable
(){
$
(
'
#cmdb-table
'
).
jtable
({
title
:
"
Nodlista
"
,
title
:
"
Relationstyper
"
,
paging
:
false
,
//Enable paging
pageSize
:
10
,
//Set page size (default: 10)
pageList
:
'
minimal
'
,
...
...
public/javascripts/menu.js
deleted
100644 → 0
View file @
0ba8a266
/* jQuery ready function. Specify a function to execute when the DOM is fully loaded. */
$
(
document
).
ready
(
/* This is the function that will get executed after the DOM is fully loaded */
function
()
{
/* Next part of code handles hovering effect and submenu appearing */
$
(
'
.nav li
'
).
hover
(
function
()
{
//appearing on hover
$
(
'
ul
'
,
this
).
fadeIn
();
},
function
()
{
//disappearing on hover
$
(
'
ul
'
,
this
).
fadeOut
();
}
);
}
);
public/javascripts/
dashlets/
select.js
→
public/javascripts/select.js
View file @
2383e8b1
$
(
document
).
ready
(
function
()
{
var
ref
=
window
.
location
.
href
;
if
(
ref
.
endsWith
(
'
family-and-class
'
)){
structureTable
();
// structureGraph(0);
}
if
(
ref
.
endsWith
(
'
enterprise-service
'
)){
enterpriseServiceTable
();
}
if
(
ref
.
endsWith
(
'
organisation
'
)){
organiationTable
(
1
);
...
...
routes/enterprise_service.js
0 → 100644
View file @
2383e8b1
var
express
=
require
(
'
express
'
);
var
router
=
express
.
Router
();
const
pg
=
require
(
'
pg
'
);
const
jQuery
=
require
(
'
jquery
'
);
const
path
=
require
(
'
path
'
);
const
connectionString
=
process
.
env
.
DATABASE_URL
||
'
postgres://jasper.u:Me4sgyAp@postgresql-utv.smhi.se:5432/jasper
'
;
router
.
post
(
'
/list
'
,
(
req
,
res
,
next
)
=>
{
var
pool
=
new
pg
.
Pool
({
connectionString
:
connectionString
,
});
// Get a Postgres client from the connection pool
pool
.
connect
(
function
(
err
,
client
,
done
){
// Handle connection errors
if
(
err
)
{
done
();
console
.
log
(
err
);
return
res
.
status
(
500
).
json
({
success
:
false
,
data
:
err
});
}
// SQL Query > Select Data
var
sql
=
"
select * from cmdb.ci_family_enterprise_service order by display_name;
"
;
client
.
query
(
sql
,
[],
function
(
err
,
result
){
done
();
if
(
err
){
return
res
.
json
(
JSON
.
parse
(
'
{"Result":"ERROR", "Message":"/family_type"}
'
));
}
else
{
var
response
=
'
{"Result":"OK", "Records":
'
;
response
+=
JSON
.
stringify
(
result
.
rows
);
response
+=
'
,"TotalRecordCount":
'
+
result
.
rowCount
+
'
}
'
;
return
res
.
json
(
JSON
.
parse
(
response
));
}
});
});
});
router
.
post
(
'
/families/:family_type_id
'
,
(
req
,
res
,
next
)
=>
{
var
pool
=
new
pg
.
Pool
({
connectionString
:
connectionString
,
});
// Get a Postgres client from the connection pool
pool
.
connect
(
function
(
err
,
client
,
done
){
// Handle connection errors
if
(
err
)
{
done
();
return
res
.
status
(
500
).
json
({
success
:
false
,
data
:
err
});
}