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('test', function(data) {
93 console.log("HOGEHOGEHOGEHOHGOEHGOH");
99 angular.forEach(this.options, (option) => {
106 angular.forEach(option.arg, (arg) => {
108 if(typeof arg.input === 'object') {
109 obj.arguments.push(arg.input.name);
111 obj.arguments.push(arg.input);
116 if(obj.arguments.length > 0) {
123 workspace: this.workspace.fileId,
127 //console.log(JSON.stringify(execObj,null,'\t'));
129 .execute(JSON.stringify(execObj))
135 public removeMySelf(index:number) {
136 this.remove()(index,this.list);
139 private reloadFiles() {
140 var fileId = this.workspace.fileId;
145 var status = result.status;
146 if(status === 'success') {
147 this.files = result.info;
149 console.log(result.message);
155 this.MyModal.preview();