Skip to content
Snippets Groups Projects
Commit 68815626 authored by Christoph Dornieden's avatar Christoph Dornieden
Browse files

added graphing service

parent e590fb2a
No related branches found
No related tags found
No related merge requests found
...@@ -141,5 +141,3 @@ export default Ember.Component.extend({ ...@@ -141,5 +141,3 @@ export default Ember.Component.extend({
// this.renderGraph(); // this.renderGraph();
} }
}); });
...@@ -63,7 +63,7 @@ export default Ember.Component.extend({ ...@@ -63,7 +63,7 @@ export default Ember.Component.extend({
style: cytoscapeStyle, style: cytoscapeStyle,
elements: this.get('dummyGraph'), // TODO! elements: this.get('graph'), // TODO!
layout: { layout: {
name: 'cola', name: 'cola',
...@@ -72,5 +72,3 @@ export default Ember.Component.extend({ ...@@ -72,5 +72,3 @@ export default Ember.Component.extend({
}); });
} }
}); });
...@@ -3,7 +3,7 @@ export default ` ...@@ -3,7 +3,7 @@ export default `
node { node {
content: data(name); content: data(label);
text-valign: center; text-valign: center;
text-halign: center; text-halign: center;
} }
......
...@@ -3,4 +3,5 @@ import attr from 'ember-data/attr'; ...@@ -3,4 +3,5 @@ import attr from 'ember-data/attr';
export default Model.extend({ export default Model.extend({
// id: attr('string') - not allowed to be listed by ember // id: attr('string') - not allowed to be listed by ember
systemId: attr('string')
}); });
...@@ -2,9 +2,7 @@ import BaseEntity from './baseentity'; ...@@ -2,9 +2,7 @@ import BaseEntity from './baseentity';
import attr from 'ember-data/attr'; import attr from 'ember-data/attr';
export default BaseEntity.extend({ export default BaseEntity.extend({
system: attr('string'), // TODO: relation?
technology: attr('string'), technology: attr('string'),
source: attr(), // FIXME relation sourceId: attr('string'),
target: attr(), // FIXME relation targetId: attr('string')
instances: attr(), // FIXME relation
}); });
...@@ -2,7 +2,7 @@ import BaseEntity from './baseentity'; ...@@ -2,7 +2,7 @@ import BaseEntity from './baseentity';
import attr from 'ember-data/attr'; import attr from 'ember-data/attr';
export default BaseEntity.extend({ export default BaseEntity.extend({
source: attr(), // FIXME relation sourceId: attr('string'),
target: attr(), // FIXME relation targetId: attr('string'),
communication: attr(), // FIXME relation communicationId: attr('string')
}); });
...@@ -2,9 +2,8 @@ import BaseEntity from './baseentity'; ...@@ -2,9 +2,8 @@ import BaseEntity from './baseentity';
import attr from 'ember-data/attr'; import attr from 'ember-data/attr';
export default BaseEntity.extend({ export default BaseEntity.extend({
name: attr(), // FIXME relation name: attr('string'),
services: attr(), // FIXME relation
ip: attr('string'), ip: attr('string'),
hostname: attr('string'), hostname: attr('string'),
group: attr('string'), // TODO: relation? nodeGroupId: attr('string')
}); });
...@@ -2,7 +2,6 @@ import BaseEntity from './baseentity'; ...@@ -2,7 +2,6 @@ import BaseEntity from './baseentity';
import attr from 'ember-data/attr'; import attr from 'ember-data/attr';
export default BaseEntity.extend({ export default BaseEntity.extend({
name: attr('string'), name: attr('string')
system: attr(), // FIXME relation
nodes: attr() // FIXME relation
}); });
...@@ -3,6 +3,5 @@ import attr from 'ember-data/attr'; ...@@ -3,6 +3,5 @@ import attr from 'ember-data/attr';
export default BaseEntity.extend({ export default BaseEntity.extend({
name: attr('string'), name: attr('string'),
system: attr(), // FIXME relation
description: attr('string') description: attr('string')
}); });
...@@ -4,6 +4,6 @@ import DS from 'ember-data'; ...@@ -4,6 +4,6 @@ import DS from 'ember-data';
export default BaseEntity.extend({ export default BaseEntity.extend({
name: attr('string'), name: attr('string'),
node: DS.belongsTo('node', {async: true}), nodeId: attr('string'),
service: DS.belongsTo('service', {async: true}) serviceId: attr('string')
}); });
...@@ -9,7 +9,6 @@ export default Ember.Route.extend({ ...@@ -9,7 +9,6 @@ export default Ember.Route.extend({
const createGraph = graphingService.createGraph.bind(graphingService); const createGraph = graphingService.createGraph.bind(graphingService);
this.set('loading', true); this.set('loading', true);
return Ember.RSVP.Promise.all([ return Ember.RSVP.Promise.all([
this.store.findAll('node'), this.store.findAll('node'),
this.store.findAll('nodegroup'), this.store.findAll('nodegroup'),
...@@ -17,7 +16,15 @@ export default Ember.Route.extend({ ...@@ -17,7 +16,15 @@ export default Ember.Route.extend({
this.store.findAll('serviceinstance'), this.store.findAll('serviceinstance'),
this.store.findAll('communication'), this.store.findAll('communication'),
this.store.findAll('communicationinstance') this.store.findAll('communicationinstance')
]).then(createGraph).finally((graph) => { ]).then(responses => {
return {
nodes: responses.get(0),
nodeGroups: responses.get(1),
services: responses.get(2),
serviceInstances: responses.get(3),
communications: responses.get(4),
communicationInstances: responses.get(5)
};}).then(createGraph).then((graph) => {
this.set('loading', false); this.set('loading', false);
return graph; return graph;
}); });
......
...@@ -6,6 +6,54 @@ import Ember from 'ember'; ...@@ -6,6 +6,54 @@ import Ember from 'ember';
export default Ember.Service.extend({ export default Ember.Service.extend({
createGraph(models) { createGraph(models) {
this.debug('loaded models', models); this.debug('loaded models', models);
return models; const serviceInstances = models.serviceInstances;
const communicationInstances = models.communicationInstances;
const nodeGroups = models.nodeGroups;
const nodes = models.nodes;
var network = {
nodes: [],
edges: []
};
this.debug('loaded instances', serviceInstances);
nodeGroups.forEach(instance => {
const data = instance.toJSON({includeId: true});
data.label = data.name;
network.nodes.push({
data: data
});});
nodes.forEach(instance => {
const data = instance.toJSON({includeId: true});
data.label = data.name;
data.parent = data.nodeGroupId
network.nodes.push({
data: data
});});
serviceInstances.forEach(instance => {
const data = instance.toJSON({includeId: true});
data.label = data.name;
data.parent = data.nodeId;
network.nodes.push({
data: data
});});
communicationInstances.forEach(instance => {
const data = instance.toJSON({includeId: true});
data.label = data.name;
data.source = data.sourceId;
data.target = data.targetId;
network.edges.push({
data: data
});});
return network;
} }
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment