diff --git a/app/controllers/project/delete.js b/app/controllers/project/delete.js deleted file mode 100644 index b9b6c96..0000000 --- a/app/controllers/project/delete.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * File: delete.js - * Author: Markus Grigull - * Date: 26.06.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: { - cancelDelete() { - // go back to project view - let projectId = this.get('model.id'); - this.transitionToRoute('/project/' + projectId); - }, - - confirmDelete() { - // delete the project - var project = this.get('model'); - project.destroyRecord(); - - this.transitionToRoute('/projects'); - } - } -}); diff --git a/app/controllers/project/edit.js b/app/controllers/project/edit.js deleted file mode 100644 index 574a5ff..0000000 --- a/app/controllers/project/edit.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * File: edit.js - * Author: Markus Grigull - * Date: 11.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({ - name: function() { - return this.get('model.name'); - }.property('model.name'), - - actions: { - saveEdit() { - // apply the changes - var project = this.get('model'); - project.set('name', this.get('name')); - - // save the changes - let projectId = project.get('id'); - var controller = this; - - project.save().then(function() { - controller.transitionToRoute('/project/' + projectId); - }); - }, - - cancelEdit() { - let projectId = this.get('model.id'); - this.transitionToRoute('/project/' + projectId); - } - } -}); diff --git a/app/controllers/project/index.js b/app/controllers/project/index.js index 1437734..4f457cd 100644 --- a/app/controllers/project/index.js +++ b/app/controllers/project/index.js @@ -10,19 +10,107 @@ import Ember from 'ember'; export default Ember.Controller.extend({ - actions: { - newVisualization() { - // get the project - var project = this.get('model'); - var projectId = this.get('model.id'); + isShowingNewModal: false, + isShowingEditModal: false, + isShowingDeleteModal: false, - // create the visualization - var visualization = this.store.createRecord('visualization', { name: 'Visualization', project: projectId }); + errorMessage: null, + + visualization: null, + + actions: { + showNewModal() { + // reset properties + this.set('errorMessage', null); + this.set('name', null); + + // show the dialog + this.set('isShowingNewModal', true); + }, + + showEditModal(visualization) { + // set properties + this.set('errorMessage', null); + this.set('visualization', visualization); + this.set('name', visualization.get('name')); + + // show the dialog + this.set('isShowingEditModal', true); + }, + + showDeleteModal(visualization) { + // set properties + this.set('visualization', visualization); + + // show the dialog + this.set('isShowingDeleteModal', true); + }, + + submitNew() { + // verify properties + var properties = this.getProperties('name'); + if (properties['name'] == null || properties['name'] == "") { + this.set('errorMessage', 'Visualization name is missing'); + return; + } + + // set project property + properties['project'] = this.get('model.id'); + + // create new project + var visualization = this.store.createRecord('visualization', properties); + var controller = this; // this change will not be saved, but it is nessecary otherwise ember will omit the project's id in the post request + var project = this.get('model'); project.get('visualizations').pushObject(visualization); - visualization.save(); + visualization.save().then(function() { + controller.set('isShowingNewModal', false); + }, function() { + Ember.debug('Error saving new visualization'); + }); + }, + + cancelNew() { + this.set('isShowingNewModal', false); + }, + + submitEdit() { + // verify properties + var properties = this.getProperties('name'); + if (properties['name'] == null || properties['name'] == "") { + this.set('errorMessage', 'Visualization name is missing'); + return; + } + + // save properties + this.get('visualization').setProperties(properties); + + var controller = this; + + this.get('visualization').save().then(function() { + controller.set('isShowingEditModal', false); + }, function() { + Ember.debug('Error saving edit visualization'); + }); + }, + + cancelEdit() { + this.set('isShowingEditModal', false); + }, + + confirmDelete() { + // delete the visualization + var visualization = this.get('visualization'); + visualization.destroyRecord(); + + // hide the dialog + this.set('isShowingDeleteModal', false); + }, + + cancelDelete() { + this.set('isShowingDeleteModal', false); } } }); diff --git a/app/controllers/project/new.js b/app/controllers/project/new.js deleted file mode 100644 index 500e75e..0000000 --- a/app/controllers/project/new.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * File: new.js - * Author: Markus Grigull - * Date: 26.06.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: { - newProject() { - // get current user - var user = this.get('sessionUser.user'); - - // create new project from properties - var properties = this.getProperties('name'); - properties['owner'] = user; - - var project = this.store.createRecord('project', properties); - var controller = this; - - project.save().then(function() { - controller.transitionToRoute('/projects'); - }); - }, - - cancelNewProject() { - this.transitionToRoute('/projects'); - } - } -}); diff --git a/app/controllers/projects.js b/app/controllers/projects.js new file mode 100644 index 0000000..1a5dcfd --- /dev/null +++ b/app/controllers/projects.js @@ -0,0 +1,115 @@ +/** + * File: projects.js + * Author: Markus Grigull + * Date: 01.10.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'), + + isShowingNewModal: false, + isShowingEditModal: false, + isShowingDeleteModal: false, + + errorMessage: null, + + project: null, + + actions: { + showNewModal() { + // reset properties + this.set('errorMessage', null); + this.set('name', null); + + // show the dialog + this.set('isShowingNewModal', true); + }, + + showEditModal(project) { + // set properties + this.set('errorMessage', null); + this.set('project', project); + this.set('name', project.get('name')); + + // show the dialog + this.set('isShowingEditModal', true); + }, + + showDeleteModal(project) { + // set properties + this.set('project', project); + + // show the dialog + this.set('isShowingDeleteModal', true); + }, + + submitNew() { + // verify properties + var properties = this.getProperties('name'); + if (properties['name'] == null || properties['name'] == "") { + this.set('errorMessage', 'Project name is missing'); + return; + } + + // set owner properties + var user = this.get('sessionUser.user'); + properties['owner'] = user; + + // create new project + var project = this.store.createRecord('project', properties); + var controller = this; + + project.save().then(function() { + controller.set('isShowingNewModal', false); + }, function() { + Ember.debug('Error saving new project'); + }); + }, + + cancelNew() { + this.set('isShowingNewModal', false); + }, + + submitEdit() { + // verify properties + var properties = this.getProperties('name'); + if (properties['name'] == null || properties['name'] == "") { + this.set('errorMessage', 'Project name is missing'); + return; + } + + // save properties + this.get('project').setProperties(properties); + + var controller = this; + + this.get('project').save().then(function() { + controller.set('isShowingEditModal', false); + }, function() { + Ember.debug('Error saving edit project'); + }); + }, + + cancelEdit() { + this.set('isShowingEditModal', false); + }, + + confirmDelete() { + // delete the project + var project = this.get('project'); + project.destroyRecord(); + + // hide the dialog + this.set('isShowingDeleteModal', false); + }, + + cancelDelete() { + this.set('isShowingDeleteModal', false); + } + } +}); diff --git a/app/controllers/simulation-model/delete.js b/app/controllers/simulation-model/delete.js deleted file mode 100644 index 55ff9aa..0000000 --- a/app/controllers/simulation-model/delete.js +++ /dev/null @@ -1,4 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Controller.extend({ -}); diff --git a/app/controllers/simulation-model/edit.js b/app/controllers/simulation-model/edit.js deleted file mode 100644 index e38e81d..0000000 --- a/app/controllers/simulation-model/edit.js +++ /dev/null @@ -1,21 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Controller.extend({ - sequence: function() { - return this.get('model.sequence'); - }.property('model.sequence'), - - values: function() { - return this.get('model.values'); - }.property('model.values.@each'), - - _updateModel: function() { - if (this.get('model') === null) { - Ember.run.later(this, function() { - var simulationData = this.store.peekRecord('simulation-data', 1); - this.set('model', simulationData); - this.notifyPropertyChange('model'); - }, 500); - } - }.observes('model').on('init') -}); diff --git a/app/controllers/simulation-model/new.js b/app/controllers/simulation-model/new.js deleted file mode 100644 index b72bc7f..0000000 --- a/app/controllers/simulation-model/new.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * File: new.js - * Author: Markus Grigull - * 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({ - simulator: null, - - actions: { - newModel() { - // get the simulation - var simulation = this.get('model.simulation'); - var simulationId = this.get('model.simulation.id'); - - // create new model from properties - var properties = this.getProperties('name'); - properties['simulation'] = simulationId; - - // get the simulator id by simulator name - if (this.get('simulator') == null) { - this.set('simulator', this.get('model.simulators')[0]); - } - - console.log(this.get('model.simulators')[0]); - - /*var simulationModel = this.store.createRecord('simulation-model', properties); - - // this change will not be saved, but it is nessecary otherwise ember will omit the simulation's id in the post request - simulation.get('models').pushObject(simulationModel); - - var controller = this; - - simulationModel.save().then(function() { - controller.transitionToRoute('/simulation/' + simulationId); - }, function() { - Ember.debug('Error saving new model'); - });*/ - }, - - cancelNewModel() { - var simulationId = this.get('model.simulation.id'); - this.transitionToRoute('/simulation/' + simulationId); - }, - - selectSimulator(simulator) { - this.set('simulator', simulator); - } - } -}); diff --git a/app/controllers/simulation/delete.js b/app/controllers/simulation/delete.js deleted file mode 100644 index 55ff9aa..0000000 --- a/app/controllers/simulation/delete.js +++ /dev/null @@ -1,4 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Controller.extend({ -}); diff --git a/app/controllers/simulation/edit.js b/app/controllers/simulation/edit.js deleted file mode 100644 index 55ff9aa..0000000 --- a/app/controllers/simulation/edit.js +++ /dev/null @@ -1,4 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Controller.extend({ -}); diff --git a/app/controllers/simulation/index.js b/app/controllers/simulation/index.js index 55ff9aa..2208780 100644 --- a/app/controllers/simulation/index.js +++ b/app/controllers/simulation/index.js @@ -1,4 +1,181 @@ +/** + * File: index.js + * Author: Markus Grigull + * Date: 30.09.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({ + isShowingNewModal: false, + isShowingEditModal: false, + isShowingDeleteModal: false, + + errorMessage: null, + + simulationModel: null, + simulatorName: null, + + _updateSimulators: function() { + if (this.get('model.simulators') != null && this.get('model.simulators.length') > 0) { + var simulators = this.get('model.simulators'); + this.set('simulatorName', simulators.toArray()[0].get('name')); + } + }.observes('model'), + + actions: { + showNewModal() { + // reset properties + this.set('errorMessage', null); + this.set('name', null); + + // show the dialog + this.set('isShowingNewModal', true); + }, + + showEditModal(simulationModel) { + // set properties + this.set('errorMessage', null); + this.set('simulationModel', simulationModel); + this.set('name', simulationModel.get('name')); + + var simulators = this.get('model.simulators'); + var simulatorId = simulationModel.get('simulator'); + var simulatorName = null; + + simulators.forEach(function(simulator) { + if (simulator.get('simulatorid') == simulatorId) { + simulatorName = simulator.get('name'); + } + }); + + this.set('simulatorName', simulatorName); + + // show the dialog + this.set('isShowingEditModal', true); + }, + + showDeleteModal(simulationModel) { + // set properties + this.set('simulationModel', simulationModel); + + // show the dialog + this.set('isShowingDeleteModal', true); + }, + + submitNew() { + // verify properties + var properties = this.getProperties('name'); + if (properties['name'] == null || properties['name'] == "") { + this.set('errorMessage', 'Simulation model name is missing'); + return; + } + + // set simuatlion properties + var simulation = this.get('model.simulation'); + properties['simulation'] = simulation.get('id');; + + // get the simulator id by simulator name + var simulators = this.get('model.simulators'); + var simulatorId = null; + var simulatorName = this.get('simulatorName'); + + simulators.forEach(function(simulator) { + if (simulator.get('name') === simulatorName) { + simulatorId = simulator.get('simulatorid'); + } + }); + + if (simulatorId == null) { + Ember.debug('Unable to find simulator by name'); + return; + } + + properties['simulator'] = simulatorId; + + // create new model + var simulationModel = this.store.createRecord('simulation-model', properties); + + // this change will not be saved, but it is nessecary otherwise ember will omit the simulation's id in the post request + simulation.get('models').pushObject(simulationModel); + + var controller = this; + + simulationModel.save().then(function() { + controller.set('isShowingNewModal', false); + }, function() { + Ember.debug('Error saving new model'); + }); + }, + + cancelNew() { + this.set('isShowingNewModal', false); + }, + + submitEdit() { + // verify properties + var properties = this.getProperties('name'); + if (properties['name'] == null || properties['name'] == "") { + this.set('errorMessage', 'Simulation model name is missing'); + return; + } + + // set simuatlion properties + var simulation = this.get('model.simulation'); + properties['simulation'] = simulation.get('id');; + + // get the simulator id by simulator name + var simulators = this.get('model.simulators'); + var simulatorId = null; + var simulatorName = this.get('simulatorName'); + + simulators.forEach(function(simulator) { + if (simulator.get('name') === simulatorName) { + simulatorId = simulator.get('simulatorid'); + } + }); + + if (simulatorId == null) { + Ember.debug('Unable to find simulator by name'); + return; + } + + properties['simulator'] = simulatorId; + + // save properties + var controller = this; + + this.get('simulationModel').setProperties(properties); + + this.get('simulationModel').save().then(function() { + controller.set('isShowingEditModal', false); + }, function() { + Ember.debug('Error saving edit simulation model'); + }); + }, + + cancelEdit() { + this.set('isShowingEditModal', false); + }, + + confirmDelete() { + // delete the model + var simulationModel = this.get('simulationModel'); + simulationModel.destroyRecord(); + + // hide the dialog + this.set('isShowingDeleteModal', false); + }, + + cancelDelete() { + this.set('isShowingDeleteModal', false); + }, + + selectSimulator(simulator) { + this.set('simulatorName', simulator); + } + } }); diff --git a/app/controllers/simulation/new.js b/app/controllers/simulation/new.js deleted file mode 100644 index bf6255d..0000000 --- a/app/controllers/simulation/new.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * File: new.js - * Author: Markus Grigull - * Date: 26.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: { - newSimulation() { - // get current user - var user = this.get('sessionUser.user'); - - // create new simulation from properties - var properties = this.getProperties('name'); - properties['owner'] = user; - - var simulation = this.store.createRecord('simulation', properties); - var controller = this; - - simulation.save().then(function() { - controller.transitionToRoute('/simulations'); - }, function() { - Ember.debug('Error saving new simulation'); - }); - }, - - cancelNewSimulation() { - this.transitionToRoute('/simulations'); - } - } -}); diff --git a/app/controllers/simulations.js b/app/controllers/simulations.js new file mode 100644 index 0000000..9eaea92 --- /dev/null +++ b/app/controllers/simulations.js @@ -0,0 +1,115 @@ +/** + * File: simulation.js + * Author: Markus Grigull + * Date: 30.09.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'), + + isShowingNewModal: false, + isShowingEditModal: false, + isShowingEditModal: false, + + errorMessage: null, + + simulation: null, + + actions: { + showNewModal() { + // reset properties + this.set('errorMessage', null); + this.set('name', null); + + // show the dialog + this.set('isShowingNewModal', true); + }, + + showEditModal(simulation) { + // set properties + this.set('errorMessage', null); + this.set('simulation', simulation); + this.set('name', simulation.get('name')); + + // show the dialog + this.set('isShowingEditModal', true); + }, + + showDeleteModal(simulation) { + // set properties + this.set('simulation', simulation); + + // show the dialog + this.set('isShowingDeleteModal', true); + }, + + submitNew() { + // verify properties + var properties = this.getProperties('name'); + if (properties['name'] == null || properties['name'] == "") { + this.set('errorMessage', 'Simulation name is missing'); + return; + } + + // set owner properties + var user = this.get('sessionUser.user'); + properties['owner'] = user; + + // create new simulation + var simulation = this.store.createRecord('simulation', properties); + var controller = this; + + simulation.save().then(function() { + controller.set('isShowingNewModal', false); + }, function() { + Ember.debug('Error saving new simulation'); + }); + }, + + cancelNew() { + this.set('isShowingNewModal', false); + }, + + submitEdit() { + // verify properties + var properties = this.getProperties('name'); + if (properties['name'] == null || properties['name'] == "") { + this.set('errorMessage', 'Simulation name is missing'); + return; + } + + // save properties + this.get('simulation').set('name', properties['name']); + + var controller = this; + + this.get('simulation').save().then(function() { + controller.set('isShowingEditModal', false); + }, function() { + Ember.debug('Error saving edit simulation'); + }); + }, + + cancelEdit() { + this.set('isShowingEditModal', false); + }, + + confirmDelete() { + // delete the simulation + var simulation = this.get('simulation'); + simulation.destroyRecord(); + + // hide the dialog + this.set('isShowingDeleteModal', false); + }, + + cancelDelete() { + this.set('isShowingDeleteModal', false); + } + } +}); diff --git a/app/router.js b/app/router.js index 513436f..4f52379 100644 --- a/app/router.js +++ b/app/router.js @@ -21,9 +21,6 @@ Router.map(function() { this.route('projects'); this.route('project', function() { this.route('index', { path: '/:projectid' }); - this.route('new'); - this.route('edit', { path: '/edit/:projectid' }); - this.route('delete', { path: '/delete/:projectid' }); }); this.route('me'); @@ -45,18 +42,11 @@ Router.map(function() { this.route('simulation-model', function() { this.route('index', { path: '/:modelid' }); - this.route('new', { path: '/new/:simulationid' }); - this.route('delete', { path: '/delete/:modelid' }); - this.route('edit', { path: '/edit/:modelid' }); }); - this.route('simulation-models'); this.route('simulations'); this.route('simulation', function() { this.route('index', { path: '/:simulationid' }); - this.route('delete', { path: '/delete/:simulationid' }); - this.route('new'); - this.route('edit', { path: '/edit/:simulationid' }); }); this.route('simulators'); diff --git a/app/routes/project/delete.js b/app/routes/project/delete.js deleted file mode 100644 index ec3a964..0000000 --- a/app/routes/project/delete.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * File: delete.js - * Author: Markus Grigull - * Date: 26.06.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, { - model(params) { - return this.store.findRecord('project', params.projectid); - } -}); diff --git a/app/routes/project/edit.js b/app/routes/project/edit.js deleted file mode 100644 index 6e52fe9..0000000 --- a/app/routes/project/edit.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * File: edit.js - * Author: Markus Grigull - * Date: 05.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, { - model(params) { - return this.store.findRecord('project', params.projectid); - } -}); diff --git a/app/routes/project/new.js b/app/routes/project/new.js deleted file mode 100644 index 38e760a..0000000 --- a/app/routes/project/new.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * File: new.js - * Author: Markus Grigull - * Date: 26.06.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, { -}); diff --git a/app/routes/projects.js b/app/routes/projects.js index 2908aa4..cf7f030 100644 --- a/app/routes/projects.js +++ b/app/routes/projects.js @@ -14,10 +14,8 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { sessionUser: Ember.inject.service('session-user'), model() { - // get session user - var userId = this.get('sessionUser.user.id'); - let user = this.store.peekRecord('user', userId); - + // get projects for current user + var user = this.get('sessionUser.user'); return user.get('projects'); } }); diff --git a/app/routes/simulation-model/delete.js b/app/routes/simulation-model/delete.js deleted file mode 100644 index 26d9f31..0000000 --- a/app/routes/simulation-model/delete.js +++ /dev/null @@ -1,4 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Route.extend({ -}); diff --git a/app/routes/simulation-model/edit.js b/app/routes/simulation-model/edit.js deleted file mode 100644 index 992b1b1..0000000 --- a/app/routes/simulation-model/edit.js +++ /dev/null @@ -1,7 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Route.extend({ - model() { - return this.store.peekRecord('simulation-data', 1); - } -}); diff --git a/app/routes/simulation-model/new.js b/app/routes/simulation-model/new.js deleted file mode 100644 index fc60ffc..0000000 --- a/app/routes/simulation-model/new.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * File: new.js - * Author: Markus Grigull - * 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, { - model(params) { - return Ember.RSVP.hash({ - simulation: this.store.findRecord('simulation', params.simulationid), - simulators: this.store.findAll('simulator') - }); - } -}); diff --git a/app/routes/simulation-models.js b/app/routes/simulation-models.js deleted file mode 100644 index e80ebbb..0000000 --- a/app/routes/simulation-models.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * File: simulation-models.js - * Author: Markus Grigull - * 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, { -}); diff --git a/app/routes/simulation/delete.js b/app/routes/simulation/delete.js deleted file mode 100644 index 26d9f31..0000000 --- a/app/routes/simulation/delete.js +++ /dev/null @@ -1,4 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Route.extend({ -}); diff --git a/app/routes/simulation/edit.js b/app/routes/simulation/edit.js deleted file mode 100644 index 26d9f31..0000000 --- a/app/routes/simulation/edit.js +++ /dev/null @@ -1,4 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Route.extend({ -}); diff --git a/app/routes/simulation/index.js b/app/routes/simulation/index.js index 05b1b84..567b7e3 100644 --- a/app/routes/simulation/index.js +++ b/app/routes/simulation/index.js @@ -12,6 +12,9 @@ import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-rout export default Ember.Route.extend(AuthenticatedRouteMixin, { model(params) { - return this.store.findRecord('simulation', params.simulationid); + return Ember.RSVP.hash({ + simulation: this.store.findRecord('simulation', params.simulationid), + simulators: this.store.findAll('simulator') + }); } }); diff --git a/app/routes/simulation/new.js b/app/routes/simulation/new.js deleted file mode 100644 index 8f8de75..0000000 --- a/app/routes/simulation/new.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * File: new.js - * Author: Markus Grigull - * Date: 26.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, { -}); diff --git a/app/services/running-simulation.js b/app/services/running-simulation.js index 40aa46b..2d97597 100644 --- a/app/services/running-simulation.js +++ b/app/services/running-simulation.js @@ -21,6 +21,7 @@ export default Ember.Service.extend({ var self = this; // check every second for running simulation + /* setInterval(function() { // check if running simulation did changed self.get('store').findAll('simulation').then(function(simulations) { @@ -36,6 +37,6 @@ export default Ember.Service.extend({ self.set('simulation', newSimulation); } }); - }, 1000); + }, 1000);*/ } }); diff --git a/app/templates/project/delete.hbs b/app/templates/project/delete.hbs deleted file mode 100644 index 2aa92ae..0000000 --- a/app/templates/project/delete.hbs +++ /dev/null @@ -1,6 +0,0 @@ -

Delete Project

- -

Are you sure you want to delete the project?

- - - diff --git a/app/templates/project/edit.hbs b/app/templates/project/edit.hbs deleted file mode 100644 index 1c42a97..0000000 --- a/app/templates/project/edit.hbs +++ /dev/null @@ -1,15 +0,0 @@ -

Edit project

- -
-

- - {{input id='name' placeholder='Enter project name' value=name}} -

- - - - - {{#if errorMessage}} -

{{errorMessage.message}}

- {{/if}} -
diff --git a/app/templates/project/index.hbs b/app/templates/project/index.hbs index 93dcedb..b94ec9d 100644 --- a/app/templates/project/index.hbs +++ b/app/templates/project/index.hbs @@ -1,3 +1,5 @@ +{{#link-to 'projects'}}Back to projects{{/link-to}} +

{{model.name}}

@@ -13,8 +15,8 @@
- {{#link-to "visualization.edit" visualization.id}}Edit{{/link-to}} - {{#link-to "visualization.delete" visualization.id}}Delete{{/link-to}} + Edit + Delete
@@ -23,5 +25,74 @@
- New visualization +
+ +{{#if isShowingNewModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

New visualization

+ +
+ + + + + + + + +
+ + + {{input id='name' placeholder='Enter visualization name' value=name}} +
+ + +
+
+ + {{#if errorMessage}} +

Error: {{errorMessage}}

+ {{/if}} + {{/modal-dialog}} +{{/if}} + +{{#if isShowingEditModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

Edit visualization

+ +
+ + + + + + + + +
+ + + {{input id='name' placeholder='Enter visualization name' value=name}} +
+ + +
+
+ + {{#if errorMessage}} +

Error: {{errorMessage}}

+ {{/if}} + {{/modal-dialog}} +{{/if}} + +{{#if isShowingDeleteModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

Delete visualization

+ +

Are you sure you want to delete the visualization {{visualization.name}}?

+ + + + {{/modal-dialog}} +{{/if}} diff --git a/app/templates/project/new.hbs b/app/templates/project/new.hbs deleted file mode 100644 index a2d56d2..0000000 --- a/app/templates/project/new.hbs +++ /dev/null @@ -1,24 +0,0 @@ -

New project

- -
- - - - - - - - -
- - - {{input id='name' placeholder='Enter project name' value=name}} -
- - -
- - {{#if errorMessage}} -

{{errorMessage.message}}

- {{/if}} -
diff --git a/app/templates/projects.hbs b/app/templates/projects.hbs index c99113a..b4346fd 100644 --- a/app/templates/projects.hbs +++ b/app/templates/projects.hbs @@ -13,8 +13,8 @@
- {{#link-to "project.edit" project.id}}Edit{{/link-to}} - {{#link-to "project.delete" project.id}}Delete{{/link-to}} + Edit + Delete
@@ -23,5 +23,74 @@
- {{#link-to "project.new"}}New project{{/link-to}} +
+ +{{#if isShowingNewModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

New project

+ +
+ + + + + + + + +
+ + + {{input id='name' placeholder='Enter project name' value=name}} +
+ + +
+
+ + {{#if errorMessage}} +

Error: {{errorMessage}}

+ {{/if}} + {{/modal-dialog}} +{{/if}} + +{{#if isShowingEditModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

Edit project

+ +
+ + + + + + + + +
+ + + {{input id='name' placeholder='Enter project name' value=name}} +
+ + +
+
+ + {{#if errorMessage}} +

Error: {{errorMessage}}

+ {{/if}} + {{/modal-dialog}} +{{/if}} + +{{#if isShowingDeleteModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

Delete project

+ +

Are you sure you want to delete the project {{project.name}}?

+ + + + {{/modal-dialog}} +{{/if}} diff --git a/app/templates/simulation-model/delete.hbs b/app/templates/simulation-model/delete.hbs deleted file mode 100644 index c24cd68..0000000 --- a/app/templates/simulation-model/delete.hbs +++ /dev/null @@ -1 +0,0 @@ -{{outlet}} diff --git a/app/templates/simulation-model/edit.hbs b/app/templates/simulation-model/edit.hbs deleted file mode 100644 index 5db3453..0000000 --- a/app/templates/simulation-model/edit.hbs +++ /dev/null @@ -1,8 +0,0 @@ -{{sequence}} - -
- -{{#each values as |value|}} - {{value}} -
-{{/each}} diff --git a/app/templates/simulation-model/new.hbs b/app/templates/simulation-model/new.hbs deleted file mode 100644 index 5fa523d..0000000 --- a/app/templates/simulation-model/new.hbs +++ /dev/null @@ -1,32 +0,0 @@ -

New model

- -
- - - - - - - - - - - - -
- - - {{input id='name' placeholder='Enter model name' value=name}} -
- - - -
- - -
-
diff --git a/app/templates/simulation-models.hbs b/app/templates/simulation-models.hbs deleted file mode 100644 index ca7dd24..0000000 --- a/app/templates/simulation-models.hbs +++ /dev/null @@ -1,24 +0,0 @@ -

Models

- -
- - - - - {{#each model as |simulationModel|}} - - - - {{/each}} -
Name
- {{#link-to "simulation-model.index" simulationModel.id}}{{simulationModel.name}}{{/link-to}} -
- {{#link-to "simulation-model.edit" simulationModel.id}}Edit{{/link-to}} - {{#link-to "simulation-model.delete" simulationModel.id}}Delete{{/link-to}} -
-
-
- -
- {{#link-to "simulation-model.new"}}New model{{/link-to}} -
diff --git a/app/templates/simulation/delete.hbs b/app/templates/simulation/delete.hbs deleted file mode 100644 index c24cd68..0000000 --- a/app/templates/simulation/delete.hbs +++ /dev/null @@ -1 +0,0 @@ -{{outlet}} diff --git a/app/templates/simulation/edit.hbs b/app/templates/simulation/edit.hbs deleted file mode 100644 index c24cd68..0000000 --- a/app/templates/simulation/edit.hbs +++ /dev/null @@ -1 +0,0 @@ -{{outlet}} diff --git a/app/templates/simulation/index.hbs b/app/templates/simulation/index.hbs index 738ae2c..6a2efd5 100644 --- a/app/templates/simulation/index.hbs +++ b/app/templates/simulation/index.hbs @@ -1,4 +1,6 @@ -

{{model.name}}

+{{#link-to 'simulations'}}Back to simulations{{/link-to}} + +

{{model.simulation.name}}

@@ -7,7 +9,7 @@ - {{#each model.models as |simulationModel|}} + {{#each model.simulation.models as |simulationModel|}} @@ -27,5 +29,98 @@
- {{#link-to "simulation-model.new" model.id}}New model{{/link-to}} +
+ +{{#if isShowingNewModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

New model

+ + +
Simulator
{{#link-to "simulation-model.index" simulationModel.id}}{{simulationModel.name}}{{/link-to}} @@ -17,8 +19,8 @@
- {{#link-to "simulation-model.edit" simulationModel.id}}Edit{{/link-to}} - {{#link-to "simulation-model.delete" simulationModel.id}}Delete{{/link-to}} + Edit + Delete
+ + + + + + + + + + + +
+ + + {{input id='name' placeholder='Enter model name' value=name}} +
+ + + +
+ + +
+ + + {{#if errorMessage}} +

Error: {{errorMessage}}

+ {{/if}} + {{/modal-dialog}} +{{/if}} + +{{#if isShowingEditModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

Edit model

+ +
+ + + + + + + + + + + + +
+ + + {{input id='name' placeholder='Enter model name' value=name}} +
+ + + +
+ + +
+
+ + {{#if errorMessage}} +

Error: {{errorMessage}}

+ {{/if}} + {{/modal-dialog}} +{{/if}} + +{{#if isShowingDeleteModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

Delete simulation-model

+ +

Are you sure you want to delete the simulation-model {{simulationModel.name}}?

+ + + + {{/modal-dialog}} +{{/if}} diff --git a/app/templates/simulation/new.hbs b/app/templates/simulation/new.hbs deleted file mode 100644 index 211149f..0000000 --- a/app/templates/simulation/new.hbs +++ /dev/null @@ -1,20 +0,0 @@ -

New simulation

- -
- - - - - - - - -
- - - {{input id='name' placeholder='Enter simulation name' value=name}} -
- - -
-
diff --git a/app/templates/simulations.hbs b/app/templates/simulations.hbs index 40fa4a6..d94b085 100644 --- a/app/templates/simulations.hbs +++ b/app/templates/simulations.hbs @@ -17,8 +17,10 @@
- {{#link-to "simulation.edit" simulation.id}}Edit{{/link-to}} - {{#link-to "simulation.delete" simulation.id}}Delete{{/link-to}} + + + Edit + Delete
@@ -27,5 +29,74 @@
- {{#link-to "simulation.new"}}New simulation{{/link-to}} +
+ +{{#if isShowingNewModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

New simulation

+ +
+ + + + + + + + +
+ + + {{input id='name' placeholder='Enter simulation name' value=name}} +
+ + +
+
+ + {{#if errorMessage}} +

Error: {{errorMessage}}

+ {{/if}} + {{/modal-dialog}} +{{/if}} + +{{#if isShowingEditModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

Edit simulator

+ +
+ + + + + + + + +
+ + + {{input id='name' placeholder='Enter simulation name' value=name}} +
+ + +
+
+ + {{#if errorMessage}} +

Error: {{errorMessage}}

+ {{/if}} + {{/modal-dialog}} +{{/if}} + +{{#if isShowingDeleteModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

Delete simulation

+ +

Are you sure you want to delete the simulation {{simulation.name}}?

+ + + + {{/modal-dialog}} +{{/if}} diff --git a/app/templates/simulators.hbs b/app/templates/simulators.hbs index e860e7b..ed099fd 100644 --- a/app/templates/simulators.hbs +++ b/app/templates/simulators.hbs @@ -130,7 +130,7 @@ - + diff --git a/package.json b/package.json index bea92e8..45b186e 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "ember-resolver": "^2.0.3", "ember-simple-auth": "^1.1.0", "ember-tether": "0.3.1", + "ember-truth-helpers": "1.2.0", "loader.js": "^4.0.1" }, "dependencies": {} diff --git a/tests/unit/controllers/project/delete-test.js b/tests/unit/controllers/project/delete-test.js deleted file mode 100644 index 8b10820..0000000 --- a/tests/unit/controllers/project/delete-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('controller:project/delete', 'Unit | Controller | project/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); -}); diff --git a/tests/unit/controllers/project/edit-test.js b/tests/unit/controllers/projects-test.js similarity index 79% rename from tests/unit/controllers/project/edit-test.js rename to tests/unit/controllers/projects-test.js index 9100007..174083b 100644 --- a/tests/unit/controllers/project/edit-test.js +++ b/tests/unit/controllers/projects-test.js @@ -1,6 +1,6 @@ import { moduleFor, test } from 'ember-qunit'; -moduleFor('controller:project/edit', 'Unit | Controller | project/edit', { +moduleFor('controller:projects', 'Unit | Controller | projects', { // Specify the other units that are required for this test. // needs: ['controller:foo'] }); diff --git a/tests/unit/controllers/simulation-model/delete-test.js b/tests/unit/controllers/simulation-model/delete-test.js deleted file mode 100644 index b8ccc6b..0000000 --- a/tests/unit/controllers/simulation-model/delete-test.js +++ /dev/null @@ -1,12 +0,0 @@ -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); -}); diff --git a/tests/unit/controllers/simulation-model/edit-test.js b/tests/unit/controllers/simulation-model/edit-test.js deleted file mode 100644 index 252b107..0000000 --- a/tests/unit/controllers/simulation-model/edit-test.js +++ /dev/null @@ -1,12 +0,0 @@ -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); -}); diff --git a/tests/unit/controllers/simulation-model/new-test.js b/tests/unit/controllers/simulation-model/new-test.js deleted file mode 100644 index ae144f9..0000000 --- a/tests/unit/controllers/simulation-model/new-test.js +++ /dev/null @@ -1,12 +0,0 @@ -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); -}); diff --git a/tests/unit/controllers/simulation/delete-test.js b/tests/unit/controllers/simulation/delete-test.js deleted file mode 100644 index 97437e5..0000000 --- a/tests/unit/controllers/simulation/delete-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('controller:simulation/delete', 'Unit | Controller | simulation/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); -}); diff --git a/tests/unit/controllers/simulation/edit-test.js b/tests/unit/controllers/simulation/edit-test.js deleted file mode 100644 index 814e36a..0000000 --- a/tests/unit/controllers/simulation/edit-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('controller:simulation/edit', 'Unit | Controller | simulation/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); -}); diff --git a/tests/unit/controllers/simulation/new-test.js b/tests/unit/controllers/simulations-test.js similarity index 78% rename from tests/unit/controllers/simulation/new-test.js rename to tests/unit/controllers/simulations-test.js index 1f75ab8..9b64642 100644 --- a/tests/unit/controllers/simulation/new-test.js +++ b/tests/unit/controllers/simulations-test.js @@ -1,6 +1,6 @@ import { moduleFor, test } from 'ember-qunit'; -moduleFor('controller:simulation/new', 'Unit | Controller | simulation/new', { +moduleFor('controller:simulations', 'Unit | Controller | simulations', { // Specify the other units that are required for this test. // needs: ['controller:foo'] }); diff --git a/tests/unit/routes/simulation-model/delete-test.js b/tests/unit/routes/simulation-model/delete-test.js deleted file mode 100644 index b333a4a..0000000 --- a/tests/unit/routes/simulation-model/delete-test.js +++ /dev/null @@ -1,11 +0,0 @@ -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); -}); diff --git a/tests/unit/routes/simulation-model/edit-test.js b/tests/unit/routes/simulation-model/edit-test.js deleted file mode 100644 index 8da4968..0000000 --- a/tests/unit/routes/simulation-model/edit-test.js +++ /dev/null @@ -1,11 +0,0 @@ -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); -}); diff --git a/tests/unit/routes/simulation-model/new-test.js b/tests/unit/routes/simulation-model/new-test.js deleted file mode 100644 index 67f77f4..0000000 --- a/tests/unit/routes/simulation-model/new-test.js +++ /dev/null @@ -1,11 +0,0 @@ -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); -}); diff --git a/tests/unit/routes/simulation/delete-test.js b/tests/unit/routes/simulation/delete-test.js deleted file mode 100644 index 582dca0..0000000 --- a/tests/unit/routes/simulation/delete-test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('route:simulation/delete', 'Unit | Route | simulation/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); -}); diff --git a/tests/unit/routes/simulation/edit-test.js b/tests/unit/routes/simulation/edit-test.js deleted file mode 100644 index 9cb2ae5..0000000 --- a/tests/unit/routes/simulation/edit-test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('route:simulation/edit', 'Unit | Route | simulation/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); -}); diff --git a/tests/unit/routes/simulation/new-test.js b/tests/unit/routes/simulation/new-test.js deleted file mode 100644 index 340a6bd..0000000 --- a/tests/unit/routes/simulation/new-test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('route:simulation/new', 'Unit | Route | simulation/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); -});