diff --git a/app/components/architecture-visualisation-cola.js b/app/components/architecture-visualisation-cola.js index 14a538d5d32e88391b73b8f395d890cab5442237..4c9af7ce6c11d30c22fd4a4ba6bcb99939af6f6b 100644 --- a/app/components/architecture-visualisation-cola.js +++ b/app/components/architecture-visualisation-cola.js @@ -141,5 +141,3 @@ export default Ember.Component.extend({ // this.renderGraph(); } }); - - diff --git a/app/components/architecture-visualisation-cytoscape/component.js b/app/components/architecture-visualisation-cytoscape/component.js index 5858d31b5b7c89d49466dd1790f6ef3facc28475..13f1216af7108022cd7d238c7ef87c40126707da 100644 --- a/app/components/architecture-visualisation-cytoscape/component.js +++ b/app/components/architecture-visualisation-cytoscape/component.js @@ -63,7 +63,7 @@ export default Ember.Component.extend({ style: cytoscapeStyle, - elements: this.get('dummyGraph'), // TODO! + elements: this.get('graph'), // TODO! layout: { name: 'cola', @@ -72,5 +72,3 @@ export default Ember.Component.extend({ }); } }); - - diff --git a/app/components/architecture-visualisation-cytoscape/style.js b/app/components/architecture-visualisation-cytoscape/style.js index 5cfcb8bbcadb5badd79e6831446a807963cc46d8..32526168528edfd03604c5dc9f8f4cd223917147 100644 --- a/app/components/architecture-visualisation-cytoscape/style.js +++ b/app/components/architecture-visualisation-cytoscape/style.js @@ -3,7 +3,7 @@ export default ` node { - content: data(name); + content: data(label); text-valign: center; text-halign: center; } @@ -30,4 +30,4 @@ edge { } -`; \ No newline at end of file +`; diff --git a/app/models/baseentity.js b/app/models/baseentity.js index dc29a6284be5a351ccfe64c1e704c59048871134..23c9d13b55741a2e50e2a09eaecf8b2ecb5c0d28 100644 --- a/app/models/baseentity.js +++ b/app/models/baseentity.js @@ -3,4 +3,5 @@ import attr from 'ember-data/attr'; export default Model.extend({ // id: attr('string') - not allowed to be listed by ember + systemId: attr('string') }); diff --git a/app/models/communication.js b/app/models/communication.js index 859bfa056b0f65912bb47cf239554d5d30425f81..711f3fc8027c330cfe23f2bf5a0fa006187cd0e9 100644 --- a/app/models/communication.js +++ b/app/models/communication.js @@ -1,10 +1,8 @@ import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; -export default BaseEntity.extend({ - system: attr('string'), // TODO: relation? +export default BaseEntity.extend({ technology: attr('string'), - source: attr(), // FIXME relation - target: attr(), // FIXME relation - instances: attr(), // FIXME relation + sourceId: attr('string'), + targetId: attr('string') }); diff --git a/app/models/communicationinstance.js b/app/models/communicationinstance.js index 2ec2e3ab73da37dbf08908936395f9b8636e579e..bcd718d280ee80a3b100a11e60eb8c07f06793a0 100644 --- a/app/models/communicationinstance.js +++ b/app/models/communicationinstance.js @@ -2,7 +2,7 @@ import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; export default BaseEntity.extend({ - source: attr(), // FIXME relation - target: attr(), // FIXME relation - communication: attr(), // FIXME relation + sourceId: attr('string'), + targetId: attr('string'), + communicationId: attr('string') }); diff --git a/app/models/node.js b/app/models/node.js index a218acfb53fec4d63536c60499056220abdcfe6f..8d50dbc3708129a8e04fb500085a67a2f96bd0f4 100644 --- a/app/models/node.js +++ b/app/models/node.js @@ -2,9 +2,8 @@ import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; export default BaseEntity.extend({ - name: attr(), // FIXME relation - services: attr(), // FIXME relation + name: attr('string'), ip: attr('string'), hostname: attr('string'), - group: attr('string'), // TODO: relation? + nodeGroupId: attr('string') }); diff --git a/app/models/nodegroup.js b/app/models/nodegroup.js index 167a21f8bd9e940c2aa6e40ddc209efc477d47f8..eb8d434155be05df8481dd8eb96ca39b6837f480 100644 --- a/app/models/nodegroup.js +++ b/app/models/nodegroup.js @@ -2,7 +2,6 @@ import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; export default BaseEntity.extend({ - name: attr('string'), - system: attr(), // FIXME relation - nodes: attr() // FIXME relation + name: attr('string') + }); diff --git a/app/models/service.js b/app/models/service.js index f33a068691de03bb182e9e4501d0a31c5692364c..572f4e32a4d6340550852944de33e2c7ddb82b05 100644 --- a/app/models/service.js +++ b/app/models/service.js @@ -3,6 +3,5 @@ import attr from 'ember-data/attr'; export default BaseEntity.extend({ name: attr('string'), - system: attr(), // FIXME relation description: attr('string') }); diff --git a/app/models/serviceinstance.js b/app/models/serviceinstance.js index 2899d227178c076fc7559fea44638a8069e3a633..e41e5a6746f433e66779abf32e8d8e2666d94ea6 100644 --- a/app/models/serviceinstance.js +++ b/app/models/serviceinstance.js @@ -4,6 +4,6 @@ import DS from 'ember-data'; export default BaseEntity.extend({ name: attr('string'), - node: DS.belongsTo('node', {async: true}), - service: DS.belongsTo('service', {async: true}) + nodeId: attr('string'), + serviceId: attr('string') }); diff --git a/app/routes/architectures/single.js b/app/routes/architectures/single.js index 113eaab197749b338c6234af6d9ea05ff314ee36..606496cde55c7d37286c767af1485bc81ef8af40 100644 --- a/app/routes/architectures/single.js +++ b/app/routes/architectures/single.js @@ -1,25 +1,32 @@ import Ember from 'ember'; export default Ember.Route.extend({ - session: Ember.inject.service(), // loads services/session.js - graphingService: Ember.inject.service(), - model(params) { - this.set('session.systemId', params.systemId); // add the system to all requests - const graphingService = this.get('graphingService'); - const createGraph = graphingService.createGraph.bind(graphingService); + session: Ember.inject.service(), // loads services/session.js + graphingService: Ember.inject.service(), + model(params) { + this.set('session.systemId', params.systemId); // add the system to all requests + const graphingService = this.get('graphingService'); + const createGraph = graphingService.createGraph.bind(graphingService); - this.set('loading', true); - - return Ember.RSVP.Promise.all([ - this.store.findAll('node'), - this.store.findAll('nodegroup'), - this.store.findAll('service'), - this.store.findAll('serviceinstance'), - this.store.findAll('communication'), - this.store.findAll('communicationinstance') - ]).then(createGraph).finally((graph) => { - this.set('loading', false); - return graph; - }); - } + this.set('loading', true); + return Ember.RSVP.Promise.all([ + this.store.findAll('node'), + this.store.findAll('nodegroup'), + this.store.findAll('service'), + this.store.findAll('serviceinstance'), + this.store.findAll('communication'), + this.store.findAll('communicationinstance') + ]).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); + return graph; + }); + } }); diff --git a/app/services/graphing-service.js b/app/services/graphing-service.js index da002efe6b8396551e3cba15d0c4aa5393b6a6fb..a99db22bbe0f2d7a59e72fc97e958a15536fc0bf 100644 --- a/app/services/graphing-service.js +++ b/app/services/graphing-service.js @@ -4,8 +4,56 @@ import Ember from 'ember'; * parses a list of models and creates stores them */ export default Ember.Service.extend({ - createGraph(models) { - this.debug('loaded models', models); - return models; - } + createGraph(models) { + this.debug('loaded models', 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; + } });