X-Git-Url: http://git.osdn.net/view?p=eos%2Fzephyr.git;a=blobdiff_plain;f=front-end%2Fapp%2Fscripts%2Fdirectives%2FCommand.ts;h=edfca2bb246a38e61e47a3c5271bf89989e95be9;hp=150e3ad66153b72a17d1de9d8ce7a3bce7867add;hb=af181c0a4516761e4c0822b911b489eb21ace0bd;hpb=1b3154cb9ab48958f8fea50e39ac64b88ed1e4b6 diff --git a/front-end/app/scripts/directives/Command.ts b/front-end/app/scripts/directives/Command.ts index 150e3ad..edfca2b 100644 --- a/front-end/app/scripts/directives/Command.ts +++ b/front-end/app/scripts/directives/Command.ts @@ -45,7 +45,7 @@ namespace app.directives { 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; @@ -64,12 +64,15 @@ namespace app.directives { 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; @@ -97,14 +100,6 @@ namespace app.directives { 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) @@ -115,19 +110,15 @@ namespace app.directives { 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() { @@ -170,7 +161,9 @@ namespace app.directives { public removeMySelf(index:number) { this.$scope.$destroy(); + this.Console.removeDirective(this.uuid); this.remove()(index,this.list); + this.Console.showIDs(); } private reloadFiles() { @@ -189,8 +182,6 @@ namespace app.directives { } public debug() { - console.log(this.$rootScope); - /* Create console area * */