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({
// this.renderGraph();
}
});
......@@ -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({
});
}
});
......@@ -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
`;
......@@ -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')
});
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')
});
......@@ -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')
});
......@@ -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')
});
......@@ -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')
});
......@@ -3,6 +3,5 @@ import attr from 'ember-data/attr';
export default BaseEntity.extend({
name: attr('string'),
system: attr(), // FIXME relation
description: attr('string')
});
......@@ -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')
});
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;
});
}
});
......@@ -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;
}
});
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