OSDN Git Service

[Develop and Manual test] /api/v1/execution
authorhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Mon, 8 Feb 2016 06:48:19 +0000 (15:48 +0900)
committerhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Mon, 8 Feb 2016 06:48:19 +0000 (15:48 +0900)
    modified:   front-end/app/scripts/controllers/Execution.ts
modified:   front-end/app/scripts/directives/Command.ts
modified:   front-end/dist/bundle.js
modified:   server/api/v1/execution/index.js
modified:   server/class/Eos.js

front-end/app/scripts/controllers/Execution.ts
front-end/app/scripts/directives/Command.ts
front-end/dist/bundle.js
server/api/v1/execution/index.js
server/class/Eos.js

index fc931f7..b1ae23d 100644 (file)
@@ -16,7 +16,7 @@ namespace app.controllers {
             this.$scope.$broadcast('close');
             
             // add <command> directive
-            this.commandInfoList.push(new declares.CommandInfo('dcdFilePrint'));
+            this.commandInfoList.push(new declares.CommandInfo('mrcImageNoiseAdd'));
         }
 
         public open() {
index b7812e6..93c9155 100644 (file)
@@ -68,7 +68,7 @@ namespace app.directives {
 
             // Get OptionControlFile and bind it to $scope.options
             this.APIEndPoint
-                .getOptionControlFile('dcdFilePrint')
+                .getOptionControlFile('mrcImageNoiseAdd')
                 .$promise
                 .then(function(result) {
                     controller.options = result.info;
index d8b6cd9..de98ad7 100644 (file)
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
                        this.$scope = $scope;
                        var controller = this;
                        this.APIEndPoint
-                           .getOptionControlFile('dcdFilePrint')
+                           .getOptionControlFile('mrcImageNoiseAdd')
                            .$promise
                            .then(function (result) {
                            controller.options = result.info;
                    ;
                    Execution.prototype.add = function () {
                        this.$scope.$broadcast('close');
-                       this.commandInfoList.push(new app.declares.CommandInfo('dcdFilePrint'));
+                       this.commandInfoList.push(new app.declares.CommandInfo('mrcImageNoiseAdd'));
                    };
                    Execution.prototype.open = function () {
                        var result = this.MyModal.open('SelectCommand');
index 4f041a6..f02a1ee 100644 (file)
@@ -10,19 +10,30 @@ var eos = require(__dirname + '/../../../../server/class/Eos').instance;
 router.post('/', function(req, res) {
     var form = new formidable.IncomingForm();
     var root; 
+    var result;
+
+    var command;
+    var options;
+    var workspace;
+
+    var optionsArray;
+
     if(process.env.NODE_ENV === 'debug') {
         root = __dirname + '/../../../../user-specific-files/workspace.debug/';
     } else {
         root = __dirname + '/../../../../user-specific-files/workspace/';
     }
+
     form.parse(req, function(err, fields, files) {
         var data = JSON.parse(fields.data);
-        var command = data.command;
-        var options = data.options;
-        var workspace = data.workspace;
+        command = data.command;
+        options = data.options;
+        workspace = data.workspace;
+    });
 
-        eos.validate(command,options, workspace)
-                .catch(function(r) {
+    form.on('end', function() {
+        Promise.all([eos.validate(command,options, workspace), eos.toExecArray(command, options, workspace)])
+        .catch(function(r) {
             var info = {
                 status: 'error',
                 message: r.message
@@ -30,15 +41,15 @@ router.post('/', function(req, res) {
             console.log(r.message);
             res.send(info);
         })
-        .then(function() {
-            return eos.execute(command, options, workspace);
-        .then(function(result) {
-            console.log(execStr);
+        .then(function(r) {
+            var optionsArray = r[1];
+            return eos.execute(command, optionsArray);
+        }).then(function(r) {
             var info = {
                 status: 'success',
             };
-            res.send(info);
-        })
+            res.send(r);
+        });
     });
 });
 
index 03519b2..c3cc07b 100644 (file)
@@ -298,10 +298,23 @@ function toExecArray(command, options, workspaceId) {
  * @param params
  * @returns {object}
  */
-function execute(str) {
+function execute(command, optionsArray) {
     return new Promise(function(resolve, reject) {
-        exec(str);
+        var workspace; 
+        if(process.env.NODE_ENV === 'debug') {
+            workspace = __dirname + '/../../user-specific-files/workspace.debug';
+        } else {
+            workspace = _dirname + '/../../user-specific-files/workspace';
+        }
+        
+        var config = {
+            cwd: workspace
+        };
+        var runner = spawn(command,optionsArray,config);
         
+        runner.on('close', function() {
+            resolve();
+        });
     });
 }