OSDN Git Service

[TMP] Before implement websocket at front-end
[eos/zephyr.git] / front-end / app / scripts / controllers / Execution.ts
1 namespace app.controllers {
2     export class Execution {
3
4         public static $inject = ['MyModal', '$scope'];
5
6         public commandInfoList: declares.CommandInfo[];
7
8         public page: string;
9
10         constructor(private MyModal: services.MyModal, private $scope: ng.IScope) {
11             this.commandInfoList = [];
12         };
13
14         public add() {
15             // close all <uib-accordion> tag
16             this.$scope.$broadcast('close');
17             var commandInfoList = this.commandInfoList;
18             
19             // add <command> directive
20             var commandInstance = this.MyModal.selectCommand();
21             commandInstance
22                 .result
23                 .then(function(command) {
24                     commandInfoList.push(new declares.CommandInfo(command));
25                 });
26         }
27
28         public open() {
29             var result = this.MyModal.open('SelectCommand');
30             console.log(result);
31         }
32
33         public remove(index: number, list: declares.CommandInfo[]) {
34             list.splice(index, 1);
35
36             /**
37              * Commandディレクティブから実行する際にはExecution.commandInfoListの参照を取得できない。
38              * ディレクティブ経由でExecution.commandInfoListの参照を取得。
39              * this.commandInfoList.splice(index, 1);
40              * 上記のコードは実行できない。
41              * thisがremoveの呼び出し元となるため。
42              */
43         }
44
45         public close() {
46             console.log("close");
47         }
48
49     }
50 }