From b0450c218e014623c454b4e5e7189528c5beb112 Mon Sep 17 00:00:00 2001 From: Mathis Neumann <mathis@simpletechs.net> Date: Wed, 1 Jun 2016 01:00:57 +0200 Subject: [PATCH] model structure and loading added yuidoc --- app/adapters/_baseAdapter.js | 8 ++ app/adapters/application.js | 21 ++- app/adapters/system.js | 3 + app/models/communication.js | 2 +- app/models/communicationInstance.js | 2 +- app/models/node.js | 2 +- app/models/nodeGroup.js | 2 +- app/models/service.js | 2 +- app/models/serviceInstance.js | 7 +- app/models/system.js | 6 +- app/router.js | 8 +- app/routes/.gitkeep | 0 app/routes/architecture.js | 173 ------------------------- app/routes/architectures/index.js | 12 ++ app/routes/architectures/single.js | 25 ++++ app/routes/cytoscape.js | 2 +- app/serializers/application.js | 5 + app/services/graphing-service.js | 11 ++ app/services/session.js | 10 ++ app/templates/application.hbs | 5 +- app/templates/architecture.hbs | 2 - app/templates/architectures.hbs | 1 + app/templates/architectures/index.hbs | 9 ++ app/templates/architectures/single.hbs | 1 + package.json | 3 + tests/unit/routes/systems-test.js | 11 ++ tests/unit/services/session-test.js | 12 ++ yuidoc.json | 16 +++ 28 files changed, 162 insertions(+), 199 deletions(-) create mode 100644 app/adapters/_baseAdapter.js create mode 100644 app/adapters/system.js delete mode 100644 app/routes/.gitkeep delete mode 100644 app/routes/architecture.js create mode 100644 app/routes/architectures/index.js create mode 100644 app/routes/architectures/single.js create mode 100644 app/serializers/application.js create mode 100644 app/services/graphing-service.js create mode 100644 app/services/session.js delete mode 100644 app/templates/architecture.hbs create mode 100644 app/templates/architectures.hbs create mode 100644 app/templates/architectures/index.hbs create mode 100644 app/templates/architectures/single.hbs create mode 100644 tests/unit/routes/systems-test.js create mode 100644 tests/unit/services/session-test.js create mode 100644 yuidoc.json diff --git a/app/adapters/_baseAdapter.js b/app/adapters/_baseAdapter.js new file mode 100644 index 0000000..8e9613e --- /dev/null +++ b/app/adapters/_baseAdapter.js @@ -0,0 +1,8 @@ +import Ember from 'ember'; +import RESTAdapter from 'ember-data/adapters/rest'; + +export default RESTAdapter.extend({ + host: 'http://localhost:3000', + namespace: 'v1', + session: Ember.inject.service() +}); \ No newline at end of file diff --git a/app/adapters/application.js b/app/adapters/application.js index e93e859..34b5f81 100644 --- a/app/adapters/application.js +++ b/app/adapters/application.js @@ -1,6 +1,19 @@ -import RESTAdapter from 'ember-data/adapters/rest'; +import Ember from 'ember'; +import BaseAdapter from './_baseAdapter'; +import UrlTemplates from "ember-data-url-templates"; -export default RESTAdapter.extend({ - host: 'http://localhost:3000', - namespace: 'v1' +/** + * @param {UrlTemplate} + * @param {Object} configuration for templates + * @return {Adapter} adapter that is used for all metamodel models + */ +export default BaseAdapter.extend(UrlTemplates, { + urlTemplate: '{+host}/{+namespace}/systems{/systemId}/{pathForType}/{/id}', + findAllUrlTemplate: '{+host}/{+namespace}/systems{/systemId}/{pathForType}/{?query*}', + + urlSegments: { + systemId() { + return this.get('session.systemId'); + } + } }); \ No newline at end of file diff --git a/app/adapters/system.js b/app/adapters/system.js new file mode 100644 index 0000000..4154b01 --- /dev/null +++ b/app/adapters/system.js @@ -0,0 +1,3 @@ +import BaseAdapter from './_baseAdapter'; + +export default BaseAdapter; // do not use URL Templates! \ No newline at end of file diff --git a/app/models/communication.js b/app/models/communication.js index 74f799d..859bfa0 100644 --- a/app/models/communication.js +++ b/app/models/communication.js @@ -1,4 +1,4 @@ -import BaseEntity from './baseentity.js'; +import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; export default BaseEntity.extend({ diff --git a/app/models/communicationInstance.js b/app/models/communicationInstance.js index 352267c..2ec2e3a 100644 --- a/app/models/communicationInstance.js +++ b/app/models/communicationInstance.js @@ -1,4 +1,4 @@ -import BaseEntity from './baseentity.js'; +import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; export default BaseEntity.extend({ diff --git a/app/models/node.js b/app/models/node.js index 0595317..a218acf 100644 --- a/app/models/node.js +++ b/app/models/node.js @@ -1,4 +1,4 @@ -import BaseEntity from './baseentity.js'; +import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; export default BaseEntity.extend({ diff --git a/app/models/nodeGroup.js b/app/models/nodeGroup.js index 23355b3..167a21f 100644 --- a/app/models/nodeGroup.js +++ b/app/models/nodeGroup.js @@ -1,4 +1,4 @@ -import BaseEntity from './baseentity.js'; +import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; export default BaseEntity.extend({ diff --git a/app/models/service.js b/app/models/service.js index 68e6a4b..f33a068 100644 --- a/app/models/service.js +++ b/app/models/service.js @@ -1,4 +1,4 @@ -import BaseEntity from './baseentity.js'; +import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; export default BaseEntity.extend({ diff --git a/app/models/serviceInstance.js b/app/models/serviceInstance.js index 8bb57a8..2899d22 100644 --- a/app/models/serviceInstance.js +++ b/app/models/serviceInstance.js @@ -1,8 +1,9 @@ -import BaseEntity from './baseentity.js'; +import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; +import DS from 'ember-data'; export default BaseEntity.extend({ name: attr('string'), - node: attr(), // FIXME relation - service: attr() // FIXME relation + node: DS.belongsTo('node', {async: true}), + service: DS.belongsTo('service', {async: true}) }); diff --git a/app/models/system.js b/app/models/system.js index dd31943..33c1efd 100644 --- a/app/models/system.js +++ b/app/models/system.js @@ -1,9 +1,7 @@ import BaseEntity from './baseentity'; import attr from 'ember-data/attr'; +import DS from 'ember-data'; export default BaseEntity.extend({ - name: attr('string'), - nodeGroups: attr('string'), // FIXME relation - communications: attr('string'), // FIXME relation - services: attr('string') // FIXME relation + name: attr('string') }); diff --git a/app/router.js b/app/router.js index fc46ed2..7b6ee52 100644 --- a/app/router.js +++ b/app/router.js @@ -6,10 +6,10 @@ const Router = Ember.Router.extend({ }); Router.map(function() { - this.route('home', {path: '/'}); - this.route('architecture', {path: '/architecture'}); - this.route('cola', {path: '/cola'}); - this.route('cytoscape'); + this.route('home', {path: '/'}); + this.route('architectures', function() { + this.route('single', {path: '/:systemId'}); + }); }); export default Router; diff --git a/app/routes/.gitkeep b/app/routes/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/app/routes/architecture.js b/app/routes/architecture.js deleted file mode 100644 index b3b46e5..0000000 --- a/app/routes/architecture.js +++ /dev/null @@ -1,173 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Route.extend({ - model() { - return { - id: 'root', - labels: [{text: 'My Architecture'}], - 'properties': { - 'direction': 'RIGHT', - 'spacing': 10, - 'de.cau.cs.kieler.aspectRatio': 1.7, - 'de.cau.cs.kieler.separateConnComp': true, - 'separateConnComp': true - }, - children: [{ - id: 'VM_Profile', - children: [{ - id: 'VM_Profile>Database', - labels: [{text: 'Profile DB'}], - width: 20, - height: 20 - }] - }, - { - id: 'VM_Big', - children: [{ - id: 'VM_Big>Auth', - width: 20, - height: 20 - }, { - id: 'VM_Big>User', - width: 20, - height: 20 - }, { - id: 'VM_Big>User2', - width: 20, - height: 20 - }, { - id: 'VM_Big>User3', - width: 20, - height: 20 - }, { - id: 'VM_Big>User4', - width: 20, - height: 20 - }], - edges: [{ - id: 'VM_Big>Auth->VM_Big>User', - labels: [ { text: 'e1' } ], - source: 'VM_Big>Auth', - target: 'VM_Big>User' - }] - }, - { - id: 'VM_1', - children: [{ - id: 'VM_1>Auth', - labels: [{text: 'Auth 1'}], - width: 20, - height: 20 - }] - }, - { - id: 'VM_2', - children: [{ - id: 'VM_2>Auth', - labels: [{text: 'Auth 2'}], - width: 20, - height: 20 - }] - }, - { - id: 'VM_3', - children: [{ - id: 'VM_3>User', - labels: [{text: 'User 1'}], - width: 20, - height: 20 - }] - }, - { - id: 'VM_4', - children: [{ - id: 'VM_4>User', - labels: [{text: 'User 2'}], - width: 20, - height: 20 - }] - }, - { - id: 'VM_5', - children: [{ - id: 'VM_5>User', - labels: [{text: 'User 2'}], - width: 20, - height: 20 - }] - }, - { - id: 'VM_6', - children: [{ - id: 'VM_6>User', - labels: [{text: 'User 2'}], - width: 20, - height: 20 - }] - }, - { - id: 'VM_7', - children: [{ - id: 'VM_7>User', - labels: [{text: 'User 2'}], - width: 20, - height: 20 - }] - }, - { - id: 'VM_8', - children: [{ - id: 'VM_8>User', - labels: [{text: 'User 2'}], - width: 20, - height: 20 - }] - }], - edges: [{ - id: 'VM_1>Auth->VM_3>User', - source: 'VM_1>Auth', - target: 'VM_3>User', - }, { - id: 'VM_2>Auth->VM_4>User', - source: 'VM_2>Auth', - target: 'VM_4>User', - } /*{ - id: 'VM_Big>User->VM_Profile>Database', - source: 'VM_Big>User', - target: 'VM_Profile>Database', - }, { - id: 'VM_2>Auth->VM_Profile>Database', - source: 'VM_2>Auth', - target: 'VM_Profile>Database', - }, { - id: 'VM_1>Auth->VM_Profile>Database', - source: 'VM_1>Auth', - target: 'VM_Profile>Database', - }, { - id: 'VM_3>User->VM_Profile>Database', - source: 'VM_3>User', - target: 'VM_Profile>Database', - }, { - id: 'VM_4>User->VM_Profile>Database', - source: 'VM_4>User', - target: 'VM_Profile>Database', - }, { - id: 'VM_5>User->VM_Profile>Database', - source: 'VM_5>User', - target: 'VM_Profile>Database', - }, { - id: 'VM_6>User->VM_Profile>Database', - source: 'VM_6>User', - target: 'VM_Profile>Database', - }, { - id: 'VM_7>User->VM_Profile>Database', - source: 'VM_7>User', - target: 'VM_Profile>Database', - }, { - id: 'VM_8>User->VM_Profile>Database', - source: 'VM_8>User', - target: 'VM_Profile>Database', - }*/] - }; - } -}); \ No newline at end of file diff --git a/app/routes/architectures/index.js b/app/routes/architectures/index.js new file mode 100644 index 0000000..96fbfbc --- /dev/null +++ b/app/routes/architectures/index.js @@ -0,0 +1,12 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + session: Ember.inject.service(), // loads services/session.js for systemId + model () { + this.set('session.systemId', null); // no system selected, remove from model requests + return this.store.findAll('system').then((systems) => { + this.debug(systems); + return systems; + }); + } +}); diff --git a/app/routes/architectures/single.js b/app/routes/architectures/single.js new file mode 100644 index 0000000..113eaab --- /dev/null +++ b/app/routes/architectures/single.js @@ -0,0 +1,25 @@ +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); + + 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; + }); + } +}); diff --git a/app/routes/cytoscape.js b/app/routes/cytoscape.js index 8490ad1..733b4cb 100644 --- a/app/routes/cytoscape.js +++ b/app/routes/cytoscape.js @@ -3,7 +3,7 @@ import Ember from 'ember'; export default Ember.Route.extend({ model() { return this.store.findAll('system').then((systems) => { - console.log('loaded systems', systems) + console.log('loaded systems', systems); return systems; }); } diff --git a/app/serializers/application.js b/app/serializers/application.js new file mode 100644 index 0000000..2e9a062 --- /dev/null +++ b/app/serializers/application.js @@ -0,0 +1,5 @@ +import JSONSerializer from 'ember-data/serializers/json'; + +export default JSONSerializer.extend({ + +}); \ No newline at end of file diff --git a/app/services/graphing-service.js b/app/services/graphing-service.js new file mode 100644 index 0000000..da002ef --- /dev/null +++ b/app/services/graphing-service.js @@ -0,0 +1,11 @@ +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; + } +}); diff --git a/app/services/session.js b/app/services/session.js new file mode 100644 index 0000000..8445138 --- /dev/null +++ b/app/services/session.js @@ -0,0 +1,10 @@ +import Ember from 'ember'; + +/** + * this service stores the global state of the system. + * @property {String} systemId store the id of the system which is currently used for + * loading metamodel components + */ +export default Ember.Service.extend({ + systemId: null +}); diff --git a/app/templates/application.hbs b/app/templates/application.hbs index 8231f96..afbc629 100644 --- a/app/templates/application.hbs +++ b/app/templates/application.hbs @@ -1,9 +1,8 @@ +{{loading-slider isLoading=loading duration=250}} <h2 id="title">Welcome to Ember</h2> <ul> <li>Go to {{#link-to 'home'}}Home{{/link-to}}</li> - <li>Go to {{#link-to 'architecture'}}Klay-based Architecture{{/link-to}}</li> - <li>Go to {{#link-to 'cola'}}Webcola Architecture{{/link-to}}</li> - <li>Go to {{#link-to 'cytoscape'}}Cytoscape Architecture{{/link-to}}</li> + <li>Go to {{#link-to 'architectures'}}Architekturen{{/link-to}}</li> </ul> {{outlet}} diff --git a/app/templates/architecture.hbs b/app/templates/architecture.hbs deleted file mode 100644 index a7234d6..0000000 --- a/app/templates/architecture.hbs +++ /dev/null @@ -1,2 +0,0 @@ -Visualisierung: -{{architecture-visualisation graph=model}} \ No newline at end of file diff --git a/app/templates/architectures.hbs b/app/templates/architectures.hbs new file mode 100644 index 0000000..c24cd68 --- /dev/null +++ b/app/templates/architectures.hbs @@ -0,0 +1 @@ +{{outlet}} diff --git a/app/templates/architectures/index.hbs b/app/templates/architectures/index.hbs new file mode 100644 index 0000000..dbc342d --- /dev/null +++ b/app/templates/architectures/index.hbs @@ -0,0 +1,9 @@ +{{model.length}} + +<ul> +{{#each model as |system| }} + <li>{{#link-to 'architectures.single' system.id}}{{system.name}}{{/link-to}}</li> +{{/each}} +</ul> + +{{outlet}} \ No newline at end of file diff --git a/app/templates/architectures/single.hbs b/app/templates/architectures/single.hbs new file mode 100644 index 0000000..63b43e9 --- /dev/null +++ b/app/templates/architectures/single.hbs @@ -0,0 +1 @@ +Hallo Visualisierung {{model}} \ No newline at end of file diff --git a/package.json b/package.json index 6c07f15..6966775 100644 --- a/package.json +++ b/package.json @@ -30,13 +30,16 @@ "ember-cli-htmlbars": "^1.0.1", "ember-cli-htmlbars-inline-precompile": "^0.3.1", "ember-cli-inject-live-reload": "^1.3.1", + "ember-cli-loading-slider": "1.3.0", "ember-cli-qunit": "^1.2.1", "ember-cli-release": "0.2.8", "ember-cli-sass": "5.3.1", "ember-cli-sri": "^2.1.0", "ember-cli-uglify": "^1.2.0", + "ember-cli-yuidoc": "0.8.3", "ember-d3": "0.1.0", "ember-data": "^2.4.0", + "ember-data-url-templates": "0.1.1", "ember-debug-logger": "0.2.0", "ember-disable-proxy-controllers": "^1.0.1", "ember-export-application-global": "^1.0.4", diff --git a/tests/unit/routes/systems-test.js b/tests/unit/routes/systems-test.js new file mode 100644 index 0000000..e29a8ee --- /dev/null +++ b/tests/unit/routes/systems-test.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:systems', 'Unit | Route | systems', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +test('it exists', function(assert) { + let route = this.subject(); + assert.ok(route); +}); diff --git a/tests/unit/services/session-test.js b/tests/unit/services/session-test.js new file mode 100644 index 0000000..a027c05 --- /dev/null +++ b/tests/unit/services/session-test.js @@ -0,0 +1,12 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('service:session', 'Unit | Service | session', { + // Specify the other units that are required for this test. + // needs: ['service:foo'] +}); + +// Replace this with your real tests. +test('it exists', function(assert) { + let service = this.subject(); + assert.ok(service); +}); diff --git a/yuidoc.json b/yuidoc.json new file mode 100644 index 0000000..11c63df --- /dev/null +++ b/yuidoc.json @@ -0,0 +1,16 @@ +{ + "name": "frontend-prototype", + "description": "Small description for frontend-prototype goes here", + "version": "0.0.0", + "options": { + "paths": [ + "app" + ], + "exclude": "vendor", + "outdir": "docs", + "linkNatives": true, + "quiet": true, + "parseOnly": false, + "lint": false + } +} \ No newline at end of file -- GitLab