mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Add simulation-model model and routes
This commit is contained in:
parent
f3fd704b91
commit
d9e1819645
30 changed files with 297 additions and 0 deletions
4
app/controllers/simulation-model/delete.js
Normal file
4
app/controllers/simulation-model/delete.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
});
|
4
app/controllers/simulation-model/edit.js
Normal file
4
app/controllers/simulation-model/edit.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
});
|
4
app/controllers/simulation-model/index.js
Normal file
4
app/controllers/simulation-model/index.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
});
|
39
app/controllers/simulation-model/new.js
Normal file
39
app/controllers/simulation-model/new.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* File: new.js
|
||||
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
|
||||
* Date: 20.07.2016
|
||||
* Copyright: 2016, Institute for Automation of Complex Power Systems, EONERC
|
||||
* This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
**********************************************************************************/
|
||||
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
sessionUser: Ember.inject.service('session-user'),
|
||||
|
||||
actions: {
|
||||
newModel() {
|
||||
// get current user
|
||||
var user = this.get('sessionUser.user');
|
||||
|
||||
// create new model from properties
|
||||
var properties = this.getProperties('name');
|
||||
properties['owner'] = user;
|
||||
|
||||
var simulationModel = this.store.createRecord('simulation-model', properties);
|
||||
var controller = this;
|
||||
|
||||
simulationModel.save().then(function() {
|
||||
Ember.debug('Saved new model');
|
||||
controller.transitionToRoute('/simulation-models');
|
||||
}, function() {
|
||||
Ember.debug('Error saving new model');
|
||||
});
|
||||
},
|
||||
|
||||
cancelNewModel() {
|
||||
this.transitionToRoute('/simulation-models');
|
||||
}
|
||||
}
|
||||
});
|
19
app/models/simulation-model.js
Normal file
19
app/models/simulation-model.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* File: simulation-model.js
|
||||
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
|
||||
* Date: 20.07.2016
|
||||
* Copyright: 2016, Institute for Automation of Complex Power Systems, EONERC
|
||||
* This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
**********************************************************************************/
|
||||
|
||||
import Model from 'ember-data/model';
|
||||
import attr from 'ember-data/attr';
|
||||
import { belongsTo, hasMany } from 'ember-data/relationships';
|
||||
|
||||
export default Model.extend({
|
||||
name: attr('string'),
|
||||
running: attr('boolean'),
|
||||
owner: belongsTo('user', { async: true }),
|
||||
projects: hasMany('project', { async: true })
|
||||
});
|
|
@ -16,5 +16,6 @@ export default Model.extend({
|
|||
password: attr('string'),
|
||||
adminLevel: attr('number'),
|
||||
projects: hasMany('project', { async: true }),
|
||||
simulationModels: hasMany('simulation-model', { async: true }),
|
||||
mail: attr('string')
|
||||
});
|
||||
|
|
|
@ -42,6 +42,14 @@ Router.map(function() {
|
|||
});
|
||||
|
||||
this.route('404', { path: '/*path' });
|
||||
|
||||
this.route('simulation-model', function() {
|
||||
this.route('index', { path: '/:modelid' });
|
||||
this.route('new');
|
||||
this.route('delete', { path: '/delete/:modelid' });
|
||||
this.route('edit', { path: '/edit/:modelid' });
|
||||
});
|
||||
this.route('simulation-models');
|
||||
});
|
||||
|
||||
export default Router;
|
||||
|
|
4
app/routes/simulation-model/delete.js
Normal file
4
app/routes/simulation-model/delete.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
});
|
4
app/routes/simulation-model/edit.js
Normal file
4
app/routes/simulation-model/edit.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
});
|
4
app/routes/simulation-model/index.js
Normal file
4
app/routes/simulation-model/index.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
});
|
14
app/routes/simulation-model/new.js
Normal file
14
app/routes/simulation-model/new.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* File: new.js
|
||||
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
|
||||
* Date: 20.07.2016
|
||||
* Copyright: 2016, Institute for Automation of Complex Power Systems, EONERC
|
||||
* This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
**********************************************************************************/
|
||||
|
||||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
});
|
21
app/routes/simulation-models.js
Normal file
21
app/routes/simulation-models.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* File: simulation-models.js
|
||||
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
|
||||
* Date: 20.07.2016
|
||||
* Copyright: 2016, Institute for Automation of Complex Power Systems, EONERC
|
||||
* This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
**********************************************************************************/
|
||||
|
||||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
sessionUser: Ember.inject.service('session-user'),
|
||||
|
||||
model() {
|
||||
// get models for current user
|
||||
var user = this.get('sessionUser.user');
|
||||
return user.get('simulationModels');
|
||||
}
|
||||
});
|
17
app/serializers/simulation-model.js
Normal file
17
app/serializers/simulation-model.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* File: simulation-model.js
|
||||
* Author: Markus Grigull <mgrigull@eonerc.rwth-aachen.de>
|
||||
* Date: 20.07.2016
|
||||
* Copyright: 2016, Institute for Automation of Complex Power Systems, EONERC
|
||||
* This file is part of VILLASweb. All Rights Reserved. Proprietary and confidential.
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
**********************************************************************************/
|
||||
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
attrs: {
|
||||
owner: { serialize: 'ids' },
|
||||
projects: { serialize: 'ids' }
|
||||
}
|
||||
});
|
|
@ -9,6 +9,7 @@
|
|||
<ul>
|
||||
<li>{{#link-to 'index'}}Home{{/link-to}}</li>
|
||||
<li>{{#link-to 'projects'}}Projects{{/link-to}}</li>
|
||||
<li>{{#link-to 'simulation-models'}}Models{{/link-to}}</li>
|
||||
<li>{{#link-to 'me'}}Account{{/link-to}}</li>
|
||||
<li>{{#link-to 'logout'}}Logout{{/link-to}}</li>
|
||||
</ul>
|
||||
|
|
1
app/templates/simulation-model/delete.hbs
Normal file
1
app/templates/simulation-model/delete.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
{{outlet}}
|
1
app/templates/simulation-model/edit.hbs
Normal file
1
app/templates/simulation-model/edit.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
{{outlet}}
|
1
app/templates/simulation-model/index.hbs
Normal file
1
app/templates/simulation-model/index.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
{{outlet}}
|
11
app/templates/simulation-model/new.hbs
Normal file
11
app/templates/simulation-model/new.hbs
Normal file
|
@ -0,0 +1,11 @@
|
|||
<h1>New model</h1>
|
||||
|
||||
<form {{action 'newModel' on='submit'}}>
|
||||
<p>
|
||||
<label for="name">Name</label>
|
||||
{{input id='name' placeholder='Enter model name' value=name}}
|
||||
</p>
|
||||
|
||||
<button {{action 'cancelNewModel'}}>Cancel</button>
|
||||
<button type="submit">Create</button>
|
||||
</form>
|
9
app/templates/simulation-models.hbs
Normal file
9
app/templates/simulation-models.hbs
Normal file
|
@ -0,0 +1,9 @@
|
|||
<h1>Models</h1>
|
||||
|
||||
<ul>
|
||||
{{#each model as |simulationModel|}}
|
||||
<li>{{#link-to "simulation-model.index" simulationModel.id}}{{simulationModel.name}}{{/link-to}}</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
{{#link-to "simulation-model.new"}}New model{{/link-to}}
|
12
tests/unit/controllers/simulation-model/delete-test.js
Normal file
12
tests/unit/controllers/simulation-model/delete-test.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('controller:simulation-model/delete', 'Unit | Controller | simulation-model/delete', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.subject();
|
||||
assert.ok(controller);
|
||||
});
|
12
tests/unit/controllers/simulation-model/edit-test.js
Normal file
12
tests/unit/controllers/simulation-model/edit-test.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('controller:simulation-model/edit', 'Unit | Controller | simulation-model/edit', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.subject();
|
||||
assert.ok(controller);
|
||||
});
|
12
tests/unit/controllers/simulation-model/index-test.js
Normal file
12
tests/unit/controllers/simulation-model/index-test.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('controller:simulation-model/index', 'Unit | Controller | simulation-model/index', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.subject();
|
||||
assert.ok(controller);
|
||||
});
|
12
tests/unit/controllers/simulation-model/new-test.js
Normal file
12
tests/unit/controllers/simulation-model/new-test.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('controller:simulation-model/new', 'Unit | Controller | simulation-model/new', {
|
||||
// Specify the other units that are required for this test.
|
||||
// needs: ['controller:foo']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it exists', function(assert) {
|
||||
let controller = this.subject();
|
||||
assert.ok(controller);
|
||||
});
|
12
tests/unit/models/simulation-model-test.js
Normal file
12
tests/unit/models/simulation-model-test.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { moduleForModel, test } from 'ember-qunit';
|
||||
|
||||
moduleForModel('simulation-model', 'Unit | Model | simulation-model', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: []
|
||||
});
|
||||
|
||||
test('it exists', function(assert) {
|
||||
let model = this.subject();
|
||||
// let store = this.store();
|
||||
assert.ok(!!model);
|
||||
});
|
11
tests/unit/routes/models-test.js
Normal file
11
tests/unit/routes/models-test.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:models', 'Unit | Route | models', {
|
||||
// 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);
|
||||
});
|
11
tests/unit/routes/simulation-model/delete-test.js
Normal file
11
tests/unit/routes/simulation-model/delete-test.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:simulation-model/delete', 'Unit | Route | simulation-model/delete', {
|
||||
// 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);
|
||||
});
|
11
tests/unit/routes/simulation-model/edit-test.js
Normal file
11
tests/unit/routes/simulation-model/edit-test.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:simulation-model/edit', 'Unit | Route | simulation-model/edit', {
|
||||
// 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);
|
||||
});
|
11
tests/unit/routes/simulation-model/index-test.js
Normal file
11
tests/unit/routes/simulation-model/index-test.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:simulation-model/index', 'Unit | Route | simulation-model/index', {
|
||||
// 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);
|
||||
});
|
11
tests/unit/routes/simulation-model/new-test.js
Normal file
11
tests/unit/routes/simulation-model/new-test.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { moduleFor, test } from 'ember-qunit';
|
||||
|
||||
moduleFor('route:simulation-model/new', 'Unit | Route | simulation-model/new', {
|
||||
// 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);
|
||||
});
|
15
tests/unit/serializers/simulation-model-test.js
Normal file
15
tests/unit/serializers/simulation-model-test.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { moduleForModel, test } from 'ember-qunit';
|
||||
|
||||
moduleForModel('simulation-model', 'Unit | Serializer | simulation-model', {
|
||||
// Specify the other units that are required for this test.
|
||||
needs: ['serializer:simulation-model']
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it serializes records', function(assert) {
|
||||
let record = this.subject();
|
||||
|
||||
let serializedRecord = record.serialize();
|
||||
|
||||
assert.ok(serializedRecord);
|
||||
});
|
Loading…
Add table
Reference in a new issue