mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-28 10:01:11 +02:00
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
Demo.DemoCrudController = Ember.ObjectController.extend({
|
|
needs: ['demo', 'application'],
|
|
isLoading: Ember.computed.alias('controllers.demo.isLoading'),
|
|
currentText: Ember.computed.alias('controllers.demo.currentText'),
|
|
logs: Ember.computed.alias('controllers.demo.logs'),
|
|
logPrefix: Ember.computed.alias('controllers.demo.logPrefix'),
|
|
currentMarker: Ember.computed.alias('controllers.demo.currentMarker'),
|
|
notCleared: Ember.computed.alias('controllers.demo.notCleared'),
|
|
socket: Ember.computed.alias('controllers.application.socket'),
|
|
|
|
sendCommand: function() {
|
|
this.set('isLoading', true);
|
|
|
|
var demoController = this.get('controllers.demo');
|
|
var command = this.getWithDefault('currentText', '');
|
|
var log = this.get('log');
|
|
|
|
this.set('currentText', '');
|
|
demoController.logCommand(command);
|
|
demoController.appendLog(command, true);
|
|
|
|
switch(command) {
|
|
case "clear":
|
|
this.set('logs', "");
|
|
this.set('notCleared', false);
|
|
break;
|
|
default:
|
|
var data = JSON.stringify({type: "cli", data: {command: command}});
|
|
console.log("Sending: ", data);
|
|
this.get('socket').send(data);
|
|
}
|
|
},
|
|
|
|
actions: {
|
|
submitText: function() {
|
|
this.set('controllers.demo.isLoading', true);
|
|
|
|
// Send the actual request (fake for now)
|
|
this.sendCommand();
|
|
}
|
|
}
|
|
});
|