export class CommandController {
- public static $inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket', '$window', '$rootScope'];
+ public static $inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket', '$window', '$rootScope', 'Console'];
// From parent directive bindToController property
private index: string;
private dirs: any;
private messages: any;
+ private uuid: string; // uuid of Instance of Command directive
+
constructor(private APIEndPoint: services.APIEndPoint,
private $scope: ng.IScope,
private MyModal: services.MyModal,
private WebSocket: services.WebSocket,
private $window: ng.IWindowService,
- private $rootScope: ng.IRootScopeService
+ private $rootScope: ng.IRootScopeService,
+ private Console: services.Console
) {
var controller = this;
controller.isOpen = false;
});
- /** Add EventHandler
- * ここではCommandディレクティブが受け取る可能性のあるイベントを登録する。
- * 例えば、コマンドのヘルプやEosコマンドの実行時のCLIの出力はWebSocketサービスで受け取るので、
- WebSocketサービスからこのCommandディレクティブに対してemitされたメッセージをこのイベントハンドラで受け取る。
-
- イベントネームは生成されたCommandディレクティブにユニークなidをディレクティブが生成されるたびに生成し、
- Commandディレクティブが削除されるたびにそのイベントハンドラを破棄することとする。
- */
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
s4() + '-' + s4() + s4() + s4();
}
- var uuid = guid();
+ this.uuid = guid();
+ this.Console.addDirective(this.uuid);
+ this.Console.showIDs();
/*
- this.WebSocket.add(uuid);
this.$rootScope.on(uuid, function(msg) {
console.log(msg);
- /*
- var messages = msg.split('\n');
- if(messages[0].substr(0,6) === 'Usage:') {
- controller.messages = msg.split('\n');
- }
});
- */
+ */
}
public submit() {
public removeMySelf(index:number) {
this.$scope.$destroy();
+ this.Console.removeDirective(this.uuid);
this.remove()(index,this.list);
+ this.Console.showIDs();
}
private reloadFiles() {
}
public debug() {
- console.log(this.$rootScope);
-
/* Create console area
*
*/