From 4affb69f890ca0e09cbe4789f6f466e26366e473 Mon Sep 17 00:00:00 2001 From: himetani_cafe Date: Fri, 19 Feb 2016 19:02:47 +0900 Subject: [PATCH] [Develop and Manual Test] show help with websocket --- front-end/app/index.html | 3 +- front-end/app/scripts/directives/Command.ts | 8 ++ front-end/app/scripts/services/APIEndPoint.ts | 5 + front-end/app/style.scss | 3 + front-end/app/templates/command.html | 3 +- front-end/dist/bundle.js | 154 ++++++++++++++++++++++++++ front-end/dist/css/style.css | 3 + front-end/dist/index.html | 3 +- front-end/dist/templates/command.html | 3 +- server/api/v1/help/index.js | 27 +++++ server/routes.js | 1 + 11 files changed, 209 insertions(+), 4 deletions(-) create mode 100644 server/api/v1/help/index.js diff --git a/front-end/app/index.html b/front-end/app/index.html index 83c4ccc..83490fb 100644 --- a/front-end/app/index.html +++ b/front-end/app/index.html @@ -2,7 +2,8 @@ - Zephyrだよ + Zephyr + diff --git a/front-end/app/scripts/directives/Command.ts b/front-end/app/scripts/directives/Command.ts index 583f4a7..b37107b 100644 --- a/front-end/app/scripts/directives/Command.ts +++ b/front-end/app/scripts/directives/Command.ts @@ -162,5 +162,13 @@ namespace app.directives { }); } + public help() { + this.APIEndPoint + .help(this.name) + .then((result) => { + console.log(result); + }); + } + } } diff --git a/front-end/app/scripts/services/APIEndPoint.ts b/front-end/app/scripts/services/APIEndPoint.ts index bc5adce..bf36427 100644 --- a/front-end/app/scripts/services/APIEndPoint.ts +++ b/front-end/app/scripts/services/APIEndPoint.ts @@ -73,5 +73,10 @@ namespace app.services { var endPoint = '/api/v1/debug'; return this.$http.get(endPoint); } + public help(command:string): ng.IHttpPromise { + var endPoint = '/api/v1/help/' + command; + return this.$http.get(endPoint); + } + } } diff --git a/front-end/app/style.scss b/front-end/app/style.scss index 2b0855c..c7a2b5d 100644 --- a/front-end/app/style.scss +++ b/front-end/app/style.scss @@ -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"; diff --git a/front-end/app/templates/command.html b/front-end/app/templates/command.html index f27f787..545ea00 100644 --- a/front-end/app/templates/command.html +++ b/front-end/app/templates/command.html @@ -42,9 +42,10 @@

Message from console

+
-

{{msg}}

+

{{msg}}

diff --git a/front-end/dist/bundle.js b/front-end/dist/bundle.js index 380e311..94bf743 100644 --- a/front-end/dist/bundle.js +++ b/front-end/dist/bundle.js @@ -41070,6 +41070,10 @@ 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; @@ -41266,6 +41270,13 @@ 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; })(); @@ -41678,6 +41689,10 @@ 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; @@ -41874,6 +41889,13 @@ 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; })(); @@ -42286,6 +42308,10 @@ 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; @@ -42482,6 +42508,13 @@ 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; })(); @@ -42894,6 +42927,10 @@ 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; @@ -43090,6 +43127,13 @@ 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; })(); @@ -43502,6 +43546,10 @@ 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; @@ -43698,6 +43746,13 @@ 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; })(); @@ -44110,6 +44165,10 @@ 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; @@ -44306,6 +44365,13 @@ 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; })(); @@ -44718,6 +44784,10 @@ 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; @@ -44914,6 +44984,13 @@ 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; })(); @@ -45326,6 +45403,10 @@ 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; @@ -45522,6 +45603,13 @@ 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; })(); @@ -45934,6 +46022,10 @@ 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; @@ -46130,6 +46222,13 @@ 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; })(); @@ -46542,6 +46641,10 @@ 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; @@ -46738,6 +46841,13 @@ 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; })(); @@ -47150,6 +47260,10 @@ 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; @@ -47346,6 +47460,13 @@ 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; })(); @@ -47758,6 +47879,10 @@ 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; @@ -47954,6 +48079,13 @@ 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; })(); @@ -48366,6 +48498,10 @@ 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; @@ -48562,6 +48698,13 @@ 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; })(); @@ -48974,6 +49117,10 @@ 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; @@ -49170,6 +49317,13 @@ 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; })(); diff --git a/front-end/dist/css/style.css b/front-end/dist/css/style.css index 3299080..5209198 100644 --- a/front-end/dist/css/style.css +++ b/front-end/dist/css/style.css @@ -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. diff --git a/front-end/dist/index.html b/front-end/dist/index.html index 83c4ccc..83490fb 100644 --- a/front-end/dist/index.html +++ b/front-end/dist/index.html @@ -2,7 +2,8 @@ - Zephyrだよ + Zephyr + diff --git a/front-end/dist/templates/command.html b/front-end/dist/templates/command.html index f27f787..545ea00 100644 --- a/front-end/dist/templates/command.html +++ b/front-end/dist/templates/command.html @@ -42,9 +42,10 @@

Message from console

+
-

{{msg}}

+

{{msg}}

diff --git a/server/api/v1/help/index.js b/server/api/v1/help/index.js new file mode 100644 index 0000000..d7d3f84 --- /dev/null +++ b/server/api/v1/help/index.js @@ -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; diff --git a/server/routes.js b/server/routes.js index ff2e788..4fc1f51 100644 --- a/server/routes.js +++ b/server/routes.js @@ -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) { -- 2.11.0