Skip to content
Snippets Groups Projects
Commit d7883a8d authored by Mathis Neumann's avatar Mathis Neumann
Browse files

support node coloring if status property is set

parent c1e10857
No related branches found
No related tags found
No related merge requests found
...@@ -90,7 +90,13 @@ edge { ...@@ -90,7 +90,13 @@ edge {
font-weight: bold; font-weight: bold;
target-arrow-shape: triangle-backcurve; target-arrow-shape: triangle-backcurve;
curve-style: bezier; /* supports arrows */ curve-style: bezier; /* supports arrows */
}
.warning {
background-color: yellow;
}
.fail {
background-color: red;
} }
:selected { :selected {
......
...@@ -3,7 +3,8 @@ import attr from 'ember-data/attr'; ...@@ -3,7 +3,8 @@ import attr from 'ember-data/attr';
const Model = BaseEntity.extend({ const Model = BaseEntity.extend({
timeSeries: attr(), timeSeries: attr(),
statusInformations: attr() statusInformations: attr(),
status: attr('string')
}); });
export default Model; export default Model;
...@@ -17,6 +17,7 @@ Model.reopenClass({ ...@@ -17,6 +17,7 @@ Model.reopenClass({
"revisionNumber":0, "revisionNumber":0,
"systemId":"system123", "systemId":"system123",
"name":"Inventory", "name":"Inventory",
"status": "warning",
"nodeId":"test-system123-node-2", "nodeId":"test-system123-node-2",
"serviceId":"test-system123-service-4" "serviceId":"test-system123-service-4"
}, },
......
...@@ -4,53 +4,68 @@ import Ember from 'ember'; ...@@ -4,53 +4,68 @@ import Ember from 'ember';
* parses a list of models and creates stores them * parses a list of models and creates stores them
*/ */
export default Ember.Service.extend({ export default Ember.Service.extend({
store: Ember.inject.service(),
createGraph(models) { createGraph(models) {
this.debug('loaded models', models); this.debug('loaded models', models);
const serviceInstances = models.serviceInstances;
// const services = models.services; // not used in current view // prepare models by serializing them
const communicationInstances = models.communicationInstances; const prepared = {};
const nodeGroups = models.nodeGroups; [
const nodes = models.nodes; 'serviceInstances',
'communicationInstances',
'nodeGroups',
'nodes'
].forEach((key) => {
const records = models[key];
prepared[key] = records.map(record => record.serialize());
});
// services not used in current view
const {serviceInstances, communicationInstances, nodeGroups, nodes} = prepared;
var network = { var network = {
nodes: [], nodes: [],
edges: [] edges: []
}; };
nodeGroups.forEach(instance => { nodeGroups.forEach(data => {
const data = instance.serialize();
data.label = data.name; data.label = data.name;
network.nodes.push({ network.nodes.push({
data: data data: data
});}); });
});
nodes.forEach(instance => { nodes.forEach(data => {
const data = instance.serialize();
data.label = data.name; data.label = data.name;
data.parent = data.nodeGroupId; data.parent = data.nodeGroupId;
network.nodes.push({ network.nodes.push({
data: data data: data,
});}); classes: data.status || ''
});
});
serviceInstances.forEach(instance => { serviceInstances.forEach(data => {
const data = instance.serialize();
data.label = data.name; data.label = data.name;
data.parent = data.nodeId; data.parent = data.nodeId;
network.nodes.push({ network.nodes.push({
data: data data: data,
});}); classes: data.status || ''
});
});
communicationInstances.forEach(instance => { communicationInstances.forEach(data => {
const data = instance.serialize();
data.source = data.sourceId; data.source = data.sourceId;
data.target = data.targetId; data.target = data.targetId;
data.technology = instance.store.peekRecord('communication', data.communicationId).get('technology'); data.technology = this.get('store').peekRecord('communication', data.communicationId).get('technology');
data.label = data.technology; data.label = data.technology;
network.edges.push({ data }); network.edges.push({
data,
classes: data.status || ''
});
}); });
return network; return network;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment