diff --git a/app/components/plot-abstract.js b/app/components/plot-abstract.js index 9b6377d..eded6a2 100644 --- a/app/components/plot-abstract.js +++ b/app/components/plot-abstract.js @@ -21,8 +21,6 @@ export default Ember.Component.extend(Resizable, Draggable, { grid: false, data: null, - simulator: 0, - disabled_resize: false, autoHide_resize: false, grid_resize: [ 10, 10 ], @@ -32,43 +30,14 @@ export default Ember.Component.extend(Resizable, Draggable, { grid_drag: [ 10, 10 ], scroll_drag: true, - _popoverDisplayed: false, - - didInsertElement() { - this._super(); - - if (this.get('editing') === true) { - // create popover - var self = this; - - this.$().popover({ - html: true, - placement: 'auto right', - content: function () { - return self.$('.popover-content').html(); - }, - viewport: { selector: '.plots', padding: 10 } - }); - - // register popover events - this.$().on('show.bs.popover', function() { - - }); - - this.$().on('shown.bs.popover', function() { - self._popoverDisplayed = true; - }); - - this.$().on('hide.bs.popover', function() { - self._popoverDisplayed = false; - }); - } - }, - style: function() { return Ember.String.htmlSafe('width: ' + this.get('plot.width') + 'px; height: ' + this.get('plot.height') + 'px; left: ' + this.get('plot.x') + 'px; top: ' + this.get('plot.y') + 'px;'); }.property('plot'), + name: function() { + return this.get('plot.name'); + }.property('plot'), + stop_resize(event, ui) { var width = ui.size.width; var height = ui.size.height; @@ -77,10 +46,8 @@ export default Ember.Component.extend(Resizable, Draggable, { this.set('plot.height', height); }, - resize_resize(event, ui) { - if (this._popoverDisplayed === true) { - this.$().popover('show'); - } + resize_resize(/* event, ui */) { + }, stop_drag(event, ui) { @@ -88,10 +55,8 @@ export default Ember.Component.extend(Resizable, Draggable, { this.set('plot.y', ui.position.top); }, - drag_drag(event, ui) { - if (this._popoverDisplayed === true) { - this.$().popover('show'); - } + drag_drag(/* event, ui */) { + }, _updateUI: function() { @@ -114,9 +79,9 @@ export default Ember.Component.extend(Resizable, Draggable, { } }.observes('editing', 'grid').on('init'), - actions: { - savePlot() { - this.$().popover('hide'); + doubleClick() { + if (this.get('editing')) { + this.sendAction('showPlotDialog', this.get('plot')); } } }); diff --git a/app/components/plot-container.js b/app/components/plot-container.js index df4d908..5f758c3 100644 --- a/app/components/plot-container.js +++ b/app/components/plot-container.js @@ -47,5 +47,11 @@ export default Ember.Component.extend({ maxHeight += 40; return maxHeight; + }, + + actions: { + showPlotDialog(plot) { + this.sendAction('showPlotDialog', plot); + } } }); diff --git a/app/components/plot-value.js b/app/components/plot-value.js index 09bb9d1..338d900 100644 --- a/app/components/plot-value.js +++ b/app/components/plot-value.js @@ -15,19 +15,16 @@ export default PlotAbstract.extend({ minWidth_resize: 50, minHeight_resize: 20, - simulator: 2, - signal: 1, - value: function() { // get all values for the choosen simulator - let values = this.get('data.' + this.get('simulator') + '.values'); + let values = this.get('data.' + this.get('plot.simulator') + '.values'); if (values) { - return values[this.get('signal')]; + return values[this.get('plot.signal')]; } // values is null, try to reload later Ember.run.later(this, function() { - this.notifyPropertyChange('data.' + this.get('simulator') + '.values'); + this.notifyPropertyChange('data.' + this.get('plot.simulator') + '.values'); }, 1000); - }.property('data.2.values') + }.property('data.2.values', 'plot.simulator', 'plot.signal') }); diff --git a/app/controllers/visualization/edit.js b/app/controllers/visualization/edit.js index f9eaae7..c864a5a 100644 --- a/app/controllers/visualization/edit.js +++ b/app/controllers/visualization/edit.js @@ -11,17 +11,26 @@ import Ember from 'ember'; import FetchLiveDataMixin from '../../mixins/fetch-live-data'; export default Ember.Controller.extend(FetchLiveDataMixin, { + isShowingPlotValueModal: false, + + errorMessage: null, + + plot: null, + name: null, + simulator: null, + signal: null, + actions: { addPlot(name) { var plot = null; if (name === 'chart') { // create new chart plot - plot = this.store.createRecord('plot', { name: 'Chart 1', signal: 'Signal 1', type: 'plot-chart' }); + plot = this.store.createRecord('plot', { name: 'Chart 1', type: 'plot-chart' }); } else if (name === 'table') { - plot = this.store.createRecord('plot', { name: 'Table 1', signal: 'Signal 1', type: 'plot-table', width: 500, height: 200, title: 'Table 1' }); + plot = this.store.createRecord('plot', { name: 'Table 1', type: 'plot-table', width: 500, height: 200, title: 'Table 1' }); } else if (name === 'value') { - plot = this.store.createRecord('plot', { name: 'Value 1', signal: 'Signal 1', type: 'plot-value' }); + plot = this.store.createRecord('plot', { name: 'Value 1', type: 'plot-value' }); } else { // DEBUG console.log('Add plot: ' + name); @@ -62,6 +71,47 @@ export default Ember.Controller.extend(FetchLiveDataMixin, { let id = this.get('model.id'); this.transitionToRoute('/visualization/' + id); + }, + + showPlotDialog(plot) { + // show dialog by plot type + let plotType = plot.get('type'); + if (plotType === 'plot-value') { + // set properties + this.set('plot', plot); + this.set('name', plot.get('name')); + this.set('simulator', plot.get('simulator')); + this.set('signal', plot.get('signal')); + + this.set('isShowingPlotValueModal', true); + } + }, + + submitValuePlot() { + // verify properties + let properties = this.getProperties('name', 'simulator', 'signal'); + if (properties['name'] === null || properties['name'] === "") { + this.set('errorMessage', 'Plot name is missing'); + return; + } + + properties['simulator'] = Number(properties['simulator']); + properties['signal'] = Number(properties['signal']); + + // save properties + this.get('plot').setProperties(properties); + + let self = this; + + this.get('plot').save().then(function() { + self.set('isShowingPlotValueModal', false); + }, function() { + Ember.debug('Error saving value plot'); + }); + }, + + cancelValuePlot() { + this.set('isShowingPlotValueModal', false); } } }); diff --git a/app/models/plot.js b/app/models/plot.js index 17ab769..ab6cf46 100644 --- a/app/models/plot.js +++ b/app/models/plot.js @@ -13,7 +13,7 @@ import { belongsTo } from 'ember-data/relationships'; export default Model.extend({ name: attr('string'), - signal: attr('string'), + signal: attr('number', { defaultValue: 1 }), simulator: attr('number', { defaultValue: 1 }), width: attr('number', { defaultValue: 100 }), height: attr('number', { defaultValue: 100 }), diff --git a/app/router.js b/app/router.js index 4f52379..5e95c68 100644 --- a/app/router.js +++ b/app/router.js @@ -51,6 +51,10 @@ Router.map(function() { this.route('simulators'); this.route('simulator'); + + this.route('dialog', function() { + this.route('plot', function() {}); + }); }); export default Router; diff --git a/app/templates/components/plot-container.hbs b/app/templates/components/plot-container.hbs index 110a95e..008dfad 100644 --- a/app/templates/components/plot-container.hbs +++ b/app/templates/components/plot-container.hbs @@ -1,3 +1,3 @@ {{#each plots as |plot|}} - {{component plot.type plot=plot editing=editing grid=grid data=data}} + {{component plot.type plot=plot editing=editing grid=grid data=data showPlotDialog=showPlotDialog}} {{/each}} diff --git a/app/templates/components/plot-value.hbs b/app/templates/components/plot-value.hbs index 9ad31d4..b824785 100644 --- a/app/templates/components/plot-value.hbs +++ b/app/templates/components/plot-value.hbs @@ -1 +1 @@ -Value: {{value}} +{{name}}: {{value}} diff --git a/app/templates/dialog/plot/value.hbs b/app/templates/dialog/plot/value.hbs new file mode 100644 index 0000000..971e9ec --- /dev/null +++ b/app/templates/dialog/plot/value.hbs @@ -0,0 +1,44 @@ +{{#if isShowingPlotValueModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

Value

+ +
+ + + + + + + + + + + + + + + + +
+ + + {{input id='name' placeholder='Enter plot name' value=name}} +
+ + + {{input id='simulator' type='number' value=simulator min='1' max='255'}} +
+ + + {{input id='signal' type='number' value=signal min='1'}} +
+ + +
+
+ + {{#if errorMessage}} +

Error: {{errorMessage}}

+ {{/if}} + {{/modal-dialog}} +{{/if}} diff --git a/app/templates/dialog/project.hbs b/app/templates/dialog/project.hbs new file mode 100644 index 0000000..5d45882 --- /dev/null +++ b/app/templates/dialog/project.hbs @@ -0,0 +1,68 @@ +{{#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/dialog/projects.hbs b/app/templates/dialog/projects.hbs new file mode 100644 index 0000000..83dae43 --- /dev/null +++ b/app/templates/dialog/projects.hbs @@ -0,0 +1,92 @@ +{{#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/dialog/simulation.hbs b/app/templates/dialog/simulation.hbs new file mode 100644 index 0000000..aaa09a0 --- /dev/null +++ b/app/templates/dialog/simulation.hbs @@ -0,0 +1,92 @@ +{{#if isShowingNewModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

New model

+ +
+ + + + + + + + + + + + +
+ + + {{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/dialog/simulations.hbs b/app/templates/dialog/simulations.hbs new file mode 100644 index 0000000..96f847d --- /dev/null +++ b/app/templates/dialog/simulations.hbs @@ -0,0 +1,86 @@ +{{#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}} + +{{#if isShowingRunningModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

Simulation running

+ + {{simulation.name}}: + + + +
+ + + + {{/modal-dialog}} +{{/if}} diff --git a/app/templates/dialog/simulators.hbs b/app/templates/dialog/simulators.hbs new file mode 100644 index 0000000..ff43682 --- /dev/null +++ b/app/templates/dialog/simulators.hbs @@ -0,0 +1,118 @@ +{{#if isShowingNewModal}} + {{#modal-dialog attachment="middle center" translucentOverlay=true}} +

New simulator

+ +
+ + + + + + + + + + + + + + + + +
+ + + {{input id='name' placeholder='Enter simulator name' value=name}} +
+ + + {{input id='simulatorid' type='number' value=simulatorid min='1' max='255'}} +
+ + + {{input id='endpoint' placeholder='Enter endpoint' value=endpoint}} +
+ + +
+
+ + {{#if errorMessage}} +

Error: {{errorMessage}}

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

Delete simulator

+ +

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

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

New simulator

+ +
+ + + + + + + + + + + + + + + + +
+ + + {{input id='name' placeholder='Enter simulator name' value=simulatorName}} +
+ + + {{input id='simulatorid' type='number' value=simulatorid min='1' max='255'}} +
+ + + {{input id='endpoint' placeholder='Enter endpoint' value=simulatorEndpoint}} +
+ + +
+
+ + {{#if errorMessage}} +

Error: {{errorMessage}}

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

Simulator running

+ + {{simulator.name}}: + + + +
+ + + + {{/modal-dialog}} +{{/if}} diff --git a/app/templates/project/index.hbs b/app/templates/project/index.hbs index b94ec9d..ce4c826 100644 --- a/app/templates/project/index.hbs +++ b/app/templates/project/index.hbs @@ -28,71 +28,4 @@ -{{#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}} +{{partial "dialog/project"}} diff --git a/app/templates/projects.hbs b/app/templates/projects.hbs index f544a78..ff264cd 100644 --- a/app/templates/projects.hbs +++ b/app/templates/projects.hbs @@ -30,95 +30,4 @@ -{{#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}} +{{partial "dialog/projects"}} diff --git a/app/templates/simulation/index.hbs b/app/templates/simulation/index.hbs index 3804575..a938a9b 100644 --- a/app/templates/simulation/index.hbs +++ b/app/templates/simulation/index.hbs @@ -32,95 +32,4 @@ -{{#if isShowingNewModal}} - {{#modal-dialog attachment="middle center" translucentOverlay=true}} -

New model

- -
- - - - - - - - - - - - -
- - - {{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}} +{{partial "dialog/simulation"}} diff --git a/app/templates/simulations.hbs b/app/templates/simulations.hbs index fee2ede..70b16d1 100644 --- a/app/templates/simulations.hbs +++ b/app/templates/simulations.hbs @@ -31,89 +31,4 @@ -{{#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}} - -{{#if isShowingRunningModal}} - {{#modal-dialog attachment="middle center" translucentOverlay=true}} -

Simulation running

- - {{simulation.name}}: - - - -
- - - - {{/modal-dialog}} -{{/if}} +{{partial "dialog/simulations"}} diff --git a/app/templates/simulators.hbs b/app/templates/simulators.hbs index d610d92..d70e298 100644 --- a/app/templates/simulators.hbs +++ b/app/templates/simulators.hbs @@ -40,121 +40,4 @@ -{{#if isShowingNewModal}} - {{#modal-dialog attachment="middle center" translucentOverlay=true}} -

New simulator

- -
- - - - - - - - - - - - - - - - -
- - - {{input id='name' placeholder='Enter simulator name' value=name}} -
- - - {{input id='simulatorid' type='number' value=simulatorid min='1' max='255'}} -
- - - {{input id='endpoint' placeholder='Enter endpoint' value=endpoint}} -
- - -
-
- - {{#if errorMessage}} -

Error: {{errorMessage}}

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

Delete simulator

- -

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

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

New simulator

- -
- - - - - - - - - - - - - - - - -
- - - {{input id='name' placeholder='Enter simulator name' value=simulatorName}} -
- - - {{input id='simulatorid' type='number' value=simulatorid min='1' max='255'}} -
- - - {{input id='endpoint' placeholder='Enter endpoint' value=simulatorEndpoint}} -
- - -
-
- - {{#if errorMessage}} -

Error: {{errorMessage}}

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

Simulator running

- - {{simulator.name}}: - - - -
- - - - {{/modal-dialog}} -{{/if}} +{{partial "dialog/simulators"}} diff --git a/app/templates/visualization/edit.hbs b/app/templates/visualization/edit.hbs index 80e78f3..46c89e7 100644 --- a/app/templates/visualization/edit.hbs +++ b/app/templates/visualization/edit.hbs @@ -16,10 +16,12 @@ {{#draggable-dropzone dropped='addPlot'}} - {{plot-container plots=model.plots editing=true data=data}} + {{plot-container plots=model.plots editing=true data=data showPlotDialog='showPlotDialog'}} {{/draggable-dropzone}}

+ +{{partial "dialog/plot/value"}}