website: refactor send command for demo

This commit is contained in:
Jack Pearkes
2015-03-17 12:47:16 -07:00
parent 492ea9cec1
commit 05daec0905
2 changed files with 17 additions and 3 deletions

View File

@@ -1,13 +1,15 @@
Demo.DemoCrudController = Ember.ObjectController.extend({ Demo.DemoCrudController = Ember.ObjectController.extend({
needs: ['demo'], needs: ['demo'],
isLoading: Ember.computed.alias('controllers.demo.isLoading'),
currentText: Ember.computed.alias('controllers.demo.currentText'), currentText: Ember.computed.alias('controllers.demo.currentText'),
currentLog: Ember.computed.alias('controllers.demo.currentLog'), currentLog: Ember.computed.alias('controllers.demo.currentLog'),
logPrefix: Ember.computed.alias('controllers.demo.logPrefix'), logPrefix: Ember.computed.alias('controllers.demo.logPrefix'),
currentMarker: Ember.computed.alias('controllers.demo.currentMarker'), currentMarker: Ember.computed.alias('controllers.demo.currentMarker'),
notCleared: Ember.computed.alias('controllers.demo.notCleared'), notCleared: Ember.computed.alias('controllers.demo.notCleared'),
actions: { sendCommand: function() {
submitText: function() { // Request
Ember.run.later(this, function() {
var command = this.getWithDefault('currentText', ''); var command = this.getWithDefault('currentText', '');
var currentLogs = this.get('currentLog').toArray(); var currentLogs = this.get('currentLog').toArray();
@@ -28,6 +30,17 @@ Demo.DemoCrudController = Ember.ObjectController.extend({
default: default:
console.log("Submitting: ", command); console.log("Submitting: ", command);
} }
this.set('isLoading', false);
}, 1000);
},
actions: {
submitText: function() {
this.set('isLoading', true);
// Send the actual request (fake for now)
this.sendCommand();
} }
} }
}); });

View File

@@ -4,6 +4,7 @@ Demo.DemoController = Ember.ObjectController.extend({
logPrefix: "$ ", logPrefix: "$ ",
cursor: 0, cursor: 0,
notCleared: true, notCleared: true,
isLoading: false,
setFromHistory: function() { setFromHistory: function() {
var index = this.get('currentLog.length') + this.get('cursor'); var index = this.get('currentLog.length') + this.get('cursor');
@@ -14,6 +15,6 @@ Demo.DemoController = Ember.ObjectController.extend({
actions: { actions: {
close: function() { close: function() {
this.transitionTo('index'); this.transitionTo('index');
} },
} }
}); });