OSDN Git Service

[Develop and Manual Test] show help with websocket v0.3.0p0052
authorhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Fri, 19 Feb 2016 10:02:47 +0000 (19:02 +0900)
committerhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Fri, 19 Feb 2016 10:02:47 +0000 (19:02 +0900)
front-end/app/index.html
front-end/app/scripts/directives/Command.ts
front-end/app/scripts/services/APIEndPoint.ts
front-end/app/style.scss
front-end/app/templates/command.html
front-end/dist/bundle.js
front-end/dist/css/style.css
front-end/dist/index.html
front-end/dist/templates/command.html
server/api/v1/help/index.js [new file with mode: 0644]
server/routes.js

index 83c4ccc..83490fb 100644 (file)
@@ -2,7 +2,8 @@
 <html>
   <head lang="en">
     <meta charset="UTF-8">
-    <title>Zephyrだよ</title>
+    <title>Zephyr</title>
+    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
     <link rel="stylesheet" href="./css/style.css">
   </head>
   <body ng-app="zephyr">
index 583f4a7..b37107b 100644 (file)
@@ -162,5 +162,13 @@ namespace app.directives {
             });
         }
         
+        public help() {
+            this.APIEndPoint
+            .help(this.name)
+            .then((result) => {
+                console.log(result);
+            });
+        }
+
     } 
 }
index bc5adce..bf36427 100644 (file)
@@ -73,5 +73,10 @@ namespace app.services {
             var endPoint = '/api/v1/debug';
             return this.$http.get(endPoint);
         }
+        public help(command:string): ng.IHttpPromise<string> {
+            var endPoint = '/api/v1/help/' + command;
+            return this.$http.get(endPoint);
+        }
+
     }
 }
index 2b0855c..c7a2b5d 100644 (file)
@@ -17,6 +17,9 @@ $panel-bg: #eee;
     height: 100%;
 }
 
+.console-body p {
+    font-family: 'Open Sans';
+}
 // Import libs
 // --------------------
 @import "../node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
index f27f787..545ea00 100644 (file)
         </div>
         <div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">
             <h4>Message from console</h4>
+            <button type="button" class="btn btn-default" ng-click="ctrl.help()">show help</button>
             <div class="panel-info">
                 <div class="panel-body console-body">
-                    <p ng-repeat="msg in ctrl.messages track by $index" class="lead">{{msg}}</p>
+                    <p ng-repeat="msg in ctrl.messages track by $index">{{msg}}</p>
                 </div>
             </div>
         </div>
index 380e311..94bf743 100644 (file)
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
                        var endPoint = '/api/v1/debug';
                        return this.$http.get(endPoint);
                    };
+                   APIEndPoint.prototype.help = function (command) {
+                       var endPoint = '/api/v1/help/' + command;
+                       return this.$http.get(endPoint);
+                   };
                    return APIEndPoint;
                })();
                services.APIEndPoint = APIEndPoint;
                            console.log(result);
                        });
                    };
+                   CommandController.prototype.help = function () {
+                       this.APIEndPoint
+                           .help(this.name)
+                           .then(function (result) {
+                           console.log(result);
+                       });
+                   };
                    CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
                    return CommandController;
                })();
index 3299080..5209198 100644 (file)
@@ -12,6 +12,9 @@
   background-color: white;
   height: 100%; }
 
+.console-body p {
+  font-family: 'Open Sans'; }
+
 /*!
  * Bootstrap v3.3.6 (http://getbootstrap.com)
  * Copyright 2011-2015 Twitter, Inc.
index 83c4ccc..83490fb 100644 (file)
@@ -2,7 +2,8 @@
 <html>
   <head lang="en">
     <meta charset="UTF-8">
-    <title>Zephyrだよ</title>
+    <title>Zephyr</title>
+    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
     <link rel="stylesheet" href="./css/style.css">
   </head>
   <body ng-app="zephyr">
index f27f787..545ea00 100644 (file)
         </div>
         <div class="col-xs-8 col-sm-8 col-md-8 col-lg-8">
             <h4>Message from console</h4>
+            <button type="button" class="btn btn-default" ng-click="ctrl.help()">show help</button>
             <div class="panel-info">
                 <div class="panel-body console-body">
-                    <p ng-repeat="msg in ctrl.messages track by $index" class="lead">{{msg}}</p>
+                    <p ng-repeat="msg in ctrl.messages track by $index">{{msg}}</p>
                 </div>
             </div>
         </div>
diff --git a/server/api/v1/help/index.js b/server/api/v1/help/index.js
new file mode 100644 (file)
index 0000000..d7d3f84
--- /dev/null
@@ -0,0 +1,27 @@
+'use strict';
+
+var express    = require('express');
+var router     = express.Router()
+var path       = require('path')
+var ws = require(__dirname + '/../../../../server/class/WebSocket').instance;
+var spawn = require('child_process').spawn;
+
+var config = {
+    cwd: ''
+};
+
+router.get('/:command', function(req, res) {
+    var command = req.params.command;
+    var runner = spawn(command,['-h'],config);
+
+    runner.stderr.on('data', (data) => {
+        ws.emit('console', data.toString());
+    });
+
+    runner.on('close', function() {
+        res.send('/api/v1/help/'+command+' success');
+    });
+
+});
+
+module.exports = router;
index ff2e788..4fc1f51 100644 (file)
@@ -25,6 +25,7 @@ module.exports = function(app) {
     app.use('/api/v1/tagList', require(__dirname + '/api/v1/tagList'));
     app.use('/api/v1/commandList', require(__dirname + '/api/v1/commandList'));
     app.use('/api/v1/debug', require(__dirname + '/api/v1/debug'));
+    app.use('/api/v1/help', require(__dirname + '/api/v1/help'));
 
     app.route('/*')
     .get(function(req, res) {