1 namespace app.directives {
2 export class Command implements ng.IDirective {
4 public restrict: string;
5 public replace: boolean;
6 public templateUrl: string;
8 public controller: string;
9 public controllerAs: string;
10 public bindToController: Object;
21 this.controller = 'commandController';
22 this.controllerAs = 'ctrl';
23 this.bindToController = {
29 this.templateUrl = 'templates/command.html';
34 * @returns {function(): HeaderMenu}
37 public static Factory(): ng.IDirectiveFactory {
38 var directive = () => {
41 directive.$inject = [];
46 export class CommandController {
48 public static $inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
50 // From parent directive bindToController property
51 private index: string;
53 private remove: Function;
54 private list: declares.CommandInfo[];
55 private workspace: declares.IFileInfo;
57 // property of ui.bootstrap uib-accordion directive
58 private isOpen: boolean;
59 private heading: string;
61 // property about Option directive
63 private options: declares.IOption[];
66 constructor(private APIEndPoint: services.APIEndPoint, private $scope: ng.IScope, private MyModal: services.MyModal, private WebSocket: services.WebSocket) {
67 var controller = this;
69 // Get OptionControlFile and bind it to $scope.options
71 .getOptionControlFile('mrcImageNoiseAdd')
73 .then(function(result) {
74 controller.options = result.info;
80 .then(function(result) {
81 controller.dirs = result.info;
84 this.heading = "[" + this.index + "]: dcdFilePring";
87 // When call add button at executeController, all accordion close.
88 this.$scope.$on('close', () => {
89 controller.isOpen = false;
92 this.WebSocket.on('console', function(msg) {
93 console.log('CONSOLE!!!');
101 angular.forEach(this.options, (option) => {
108 angular.forEach(option.arg, (arg) => {
110 if(typeof arg.input === 'object') {
111 obj.arguments.push(arg.input.name);
113 obj.arguments.push(arg.input);
118 if(obj.arguments.length > 0) {
125 workspace: this.workspace.fileId,
129 //console.log(JSON.stringify(execObj,null,'\t'));
131 .execute(JSON.stringify(execObj))
137 public removeMySelf(index:number) {
138 this.remove()(index,this.list);
141 private reloadFiles() {
142 var fileId = this.workspace.fileId;
147 var status = result.status;
148 if(status === 'success') {
149 this.files = result.info;
151 console.log(result.message);