1
0
Fork 0
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:
Markus Grigull 2016-07-20 16:54:20 +02:00
parent f3fd704b91
commit d9e1819645
30 changed files with 297 additions and 0 deletions

View file

@ -0,0 +1,4 @@
import Ember from 'ember';
export default Ember.Controller.extend({
});

View file

@ -0,0 +1,4 @@
import Ember from 'ember';
export default Ember.Controller.extend({
});

View file

@ -0,0 +1,4 @@
import Ember from 'ember';
export default Ember.Controller.extend({
});

View 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');
}
}
});

View 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 })
});

View file

@ -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')
});

View file

@ -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;

View file

@ -0,0 +1,4 @@
import Ember from 'ember';
export default Ember.Route.extend({
});

View file

@ -0,0 +1,4 @@
import Ember from 'ember';
export default Ember.Route.extend({
});

View file

@ -0,0 +1,4 @@
import Ember from 'ember';
export default Ember.Route.extend({
});

View 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, {
});

View 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');
}
});

View 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' }
}
});

View file

@ -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>

View file

@ -0,0 +1 @@
{{outlet}}

View file

@ -0,0 +1 @@
{{outlet}}

View file

@ -0,0 +1 @@
{{outlet}}

View 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>

View 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}}

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});

View 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);
});