X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=front-end%2Fapp%2Fscripts%2Fdirectives%2FCommand.ts;h=edfca2bb246a38e61e47a3c5271bf89989e95be9;hb=af181c0a4516761e4c0822b911b489eb21ace0bd;hp=8c2cc3327a52643bdd73fedfec68322fdfe27f1c;hpb=a582bc3c8d2fb484f7038b800b8646f2486ce57e;p=eos%2Fzephyr.git diff --git a/front-end/app/scripts/directives/Command.ts b/front-end/app/scripts/directives/Command.ts index 8c2cc33..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']; + public static $inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket', '$window', '$rootScope', 'Console']; // From parent directive bindToController property private index: string; @@ -62,104 +62,158 @@ namespace app.directives { private files: any; private options: declares.IOption[]; 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 Console: services.Console + ) { + var controller = this; + + // Get OptionControlFile and bind it to $scope.options + this.APIEndPoint + //.getOptionControlFile('mrcImageNoiseAdd') + .getOptionControlFile(this.name) + .$promise + .then(function(result) { + controller.options = result.info; + }); + + this.APIEndPoint + .getDirectories() + .$promise + .then(function(result) { + controller.dirs = result.info; + }); + + this.heading = "[" + this.index + "]: dcdFilePrint"; + this.isOpen = true; + + // When call add button at executeController, all accordion close. + this.$scope.$on('close', () => { + controller.isOpen = false; + }); + + function guid() { + function s4() { + return Math.floor((1 + Math.random()) * 0x10000) + .toString(16) + .substring(1); + } + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + + s4() + '-' + s4() + s4() + s4(); + } + + this.uuid = guid(); + + this.Console.addDirective(this.uuid); + this.Console.showIDs(); + /* + this.$rootScope.on(uuid, function(msg) { + console.log(msg); + }); + */ + } + + public submit() { + var opt = []; + angular.forEach(this.options, (option) => { + + var obj = { + name: option.option, + arguments: [] + }; + + angular.forEach(option.arg, (arg) => { + if(arg.input) { + if(typeof arg.input === 'object') { + obj.arguments.push(arg.input.name); + } else { + obj.arguments.push(arg.input); + } + } + }); + + if(obj.arguments.length > 0) { + opt.push(obj); + } + }); + + var execObj = { + command: this.name, + workspace: this.workspace.fileId, + options: opt + }; + + //console.log(JSON.stringify(execObj,null,'\t')); + this.APIEndPoint + .execute(JSON.stringify(execObj)) + .then((result) => { + console.log(result); + }) + } + + public removeMySelf(index:number) { + this.$scope.$destroy(); + this.Console.removeDirective(this.uuid); + this.remove()(index,this.list); + this.Console.showIDs(); + } + + private reloadFiles() { + var fileId = this.workspace.fileId; + this.APIEndPoint + .getFiles(fileId) + .$promise + .then((result) => { + var status = result.status; + if(status === 'success') { + this.files = result.info; + } else { + console.log(result.message); + } + }); + } + + public debug() { + /* Create console area + * + */ + + var div = angular.element(this.$window.document).find("div"); + var consoleTag; + var parametersTag; + angular.forEach(div,function(v) { + if(v.className === "panel-body console") { + consoleTag = v; + } else if(v.className === "row parameters-console") { + parametersTag = v; + } + }); + + // Adjust console area from CSS styling positoning information + var consoleHeight = parseInt(parametersTag.clientHeight.toString().replace('px','')) - 150 + 'px'; + var consoleWidth = parseInt(parametersTag.clientWidth.toString().replace('px','')) / 3 * 2 - 150 + 'px'; + consoleTag.style.height = consoleHeight; + consoleTag.style.width = consoleWidth; + /* Create console area + * + */ + } + + public help() { + this.APIEndPoint + .help(this.name) + .then((result) => { + console.log(result); + }); + } - constructor(private APIEndPoint: services.APIEndPoint, private $scope: ng.IScope, private MyModal: services.MyModal, private WebSocket: services.WebSocket) { - var controller = this; - - // Get OptionControlFile and bind it to $scope.options - this.APIEndPoint - .getOptionControlFile('mrcImageNoiseAdd') - .$promise - .then(function(result) { - controller.options = result.info; - }); - - this.APIEndPoint - .getDirectories() - .$promise - .then(function(result) { - controller.dirs = result.info; - }); - - this.heading = "[" + this.index + "]: dcdFilePring"; - this.isOpen = true; - - // When call add button at executeController, all accordion close. - this.$scope.$on('close', () => { - controller.isOpen = false; - }); - - this.WebSocket.on('connect', function(msg) { - console.log(msg); - }); - - this.WebSocket.on('test', function(msg) { - console.log(msg); - }); - - } - - public submit() { - var opt = []; - angular.forEach(this.options, (option) => { - - var obj = { - name: option.option, - arguments: [] - }; - - angular.forEach(option.arg, (arg) => { - if(arg.input) { - if(typeof arg.input === 'object') { - obj.arguments.push(arg.input.name); - } else { - obj.arguments.push(arg.input); - } - } - }); - - if(obj.arguments.length > 0) { - opt.push(obj); - } - }); - - var execObj = { - command: this.name, - workspace: this.workspace.fileId, - options: opt - }; - - //console.log(JSON.stringify(execObj,null,'\t')); - this.APIEndPoint - .execute(JSON.stringify(execObj)) - .then((result) => { - console.log(result); - }) - } - - public removeMySelf(index:number) { - this.remove()(index,this.list); - } - - private reloadFiles() { - var fileId = this.workspace.fileId; - this.APIEndPoint - .getFiles(fileId) - .$promise - .then((result) => { - var status = result.status; - if(status === 'success') { - this.files = result.info; - } else { - console.log(result.message); - } - }); - } - - public debug() { - this.MyModal.preview(); - } - - } }