• R/O
  • HTTP
  • SSH
  • HTTPS

zephyr: Commit

This repository is for zephyr, which is implemented for a GUI of Eos.


Commit MetaInfo

Revisionafac53c58743329dbcc41e6f804fdaf001b0cce6 (tree)
Time2016-02-18 22:04:29
Authorhimetani_cafe <fumifumi@yasu...>
Commiterhimetani_cafe

Log Message

[Develop] /api/v1/debug for debugging websocket messaging

Change Summary

Incremental Difference

--- a/front-end/app/scripts/directives/Command.ts
+++ b/front-end/app/scripts/directives/Command.ts
@@ -89,11 +89,8 @@ namespace app.directives {
8989 controller.isOpen = false;
9090 });
9191
92- this.WebSocket.on('connect', function(msg) {
93- console.log(msg);
94- });
95-
96- this.WebSocket.on('test', function(msg) {
92+ this.WebSocket.on('console', function(msg) {
93+ console.log('CONSOLE!!!');
9794 console.log(msg);
9895 });
9996
@@ -157,9 +154,12 @@ namespace app.directives {
157154 }
158155
159156 public debug() {
160- this.MyModal.preview();
157+ this.APIEndPoint
158+ .debug()
159+ .then((result) => {
160+ console.log(result);
161+ });
161162 }
162-
163163
164164 }
165165 }
--- a/front-end/app/scripts/services/APIEndPoint.ts
+++ b/front-end/app/scripts/services/APIEndPoint.ts
@@ -57,7 +57,6 @@ namespace app.services {
5757 return this.resource(endPoint, {}).get();
5858 }
5959
60-
6160 public execute(data: any): ng.IHttpPromise<{}> {
6261 var endPoint = '/api/v1/execution';
6362 var fd = new FormData()
@@ -69,5 +68,10 @@ namespace app.services {
6968 transformRequest: angular.identity
7069 });
7170 }
71+
72+ public debug(): ng.IHttpPromise<string> {
73+ var endPoint = '/api/v1/debug';
74+ return this.$http.get(endPoint);
75+ }
7276 }
7377 }
--- a/front-end/dist/bundle.js
+++ b/front-end/dist/bundle.js
@@ -41066,6 +41066,10 @@
4106641066 transformRequest: angular.identity
4106741067 });
4106841068 };
41069+ APIEndPoint.prototype.debug = function () {
41070+ var endPoint = '/api/v1/debug';
41071+ return this.$http.get(endPoint);
41072+ };
4106941073 return APIEndPoint;
4107041074 })();
4107141075 services.APIEndPoint = APIEndPoint;
@@ -41200,10 +41204,8 @@
4120041204 this.$scope.$on('close', function () {
4120141205 controller.isOpen = false;
4120241206 });
41203- this.WebSocket.on('connect', function (msg) {
41204- console.log(msg);
41205- });
41206- this.WebSocket.on('test', function (msg) {
41207+ this.WebSocket.on('console', function (msg) {
41208+ console.log('CONSOLE!!!');
4120741209 console.log(msg);
4120841210 });
4120941211 }
@@ -41259,7 +41261,11 @@
4125941261 });
4126041262 };
4126141263 CommandController.prototype.debug = function () {
41262- this.MyModal.preview();
41264+ this.APIEndPoint
41265+ .debug()
41266+ .then(function (result) {
41267+ console.log(result);
41268+ });
4126341269 };
4126441270 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4126541271 return CommandController;
@@ -41669,6 +41675,10 @@
4166941675 transformRequest: angular.identity
4167041676 });
4167141677 };
41678+ APIEndPoint.prototype.debug = function () {
41679+ var endPoint = '/api/v1/debug';
41680+ return this.$http.get(endPoint);
41681+ };
4167241682 return APIEndPoint;
4167341683 })();
4167441684 services.APIEndPoint = APIEndPoint;
@@ -41803,10 +41813,8 @@
4180341813 this.$scope.$on('close', function () {
4180441814 controller.isOpen = false;
4180541815 });
41806- this.WebSocket.on('connect', function (msg) {
41807- console.log(msg);
41808- });
41809- this.WebSocket.on('test', function (msg) {
41816+ this.WebSocket.on('console', function (msg) {
41817+ console.log('CONSOLE!!!');
4181041818 console.log(msg);
4181141819 });
4181241820 }
@@ -41862,7 +41870,11 @@
4186241870 });
4186341871 };
4186441872 CommandController.prototype.debug = function () {
41865- this.MyModal.preview();
41873+ this.APIEndPoint
41874+ .debug()
41875+ .then(function (result) {
41876+ console.log(result);
41877+ });
4186641878 };
4186741879 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4186841880 return CommandController;
@@ -42272,6 +42284,10 @@
4227242284 transformRequest: angular.identity
4227342285 });
4227442286 };
42287+ APIEndPoint.prototype.debug = function () {
42288+ var endPoint = '/api/v1/debug';
42289+ return this.$http.get(endPoint);
42290+ };
4227542291 return APIEndPoint;
4227642292 })();
4227742293 services.APIEndPoint = APIEndPoint;
@@ -42406,10 +42422,8 @@
4240642422 this.$scope.$on('close', function () {
4240742423 controller.isOpen = false;
4240842424 });
42409- this.WebSocket.on('connect', function (msg) {
42410- console.log(msg);
42411- });
42412- this.WebSocket.on('test', function (msg) {
42425+ this.WebSocket.on('console', function (msg) {
42426+ console.log('CONSOLE!!!');
4241342427 console.log(msg);
4241442428 });
4241542429 }
@@ -42465,7 +42479,11 @@
4246542479 });
4246642480 };
4246742481 CommandController.prototype.debug = function () {
42468- this.MyModal.preview();
42482+ this.APIEndPoint
42483+ .debug()
42484+ .then(function (result) {
42485+ console.log(result);
42486+ });
4246942487 };
4247042488 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4247142489 return CommandController;
@@ -42875,6 +42893,10 @@
4287542893 transformRequest: angular.identity
4287642894 });
4287742895 };
42896+ APIEndPoint.prototype.debug = function () {
42897+ var endPoint = '/api/v1/debug';
42898+ return this.$http.get(endPoint);
42899+ };
4287842900 return APIEndPoint;
4287942901 })();
4288042902 services.APIEndPoint = APIEndPoint;
@@ -43009,10 +43031,8 @@
4300943031 this.$scope.$on('close', function () {
4301043032 controller.isOpen = false;
4301143033 });
43012- this.WebSocket.on('connect', function (msg) {
43013- console.log(msg);
43014- });
43015- this.WebSocket.on('test', function (msg) {
43034+ this.WebSocket.on('console', function (msg) {
43035+ console.log('CONSOLE!!!');
4301643036 console.log(msg);
4301743037 });
4301843038 }
@@ -43068,7 +43088,11 @@
4306843088 });
4306943089 };
4307043090 CommandController.prototype.debug = function () {
43071- this.MyModal.preview();
43091+ this.APIEndPoint
43092+ .debug()
43093+ .then(function (result) {
43094+ console.log(result);
43095+ });
4307243096 };
4307343097 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4307443098 return CommandController;
@@ -43478,6 +43502,10 @@
4347843502 transformRequest: angular.identity
4347943503 });
4348043504 };
43505+ APIEndPoint.prototype.debug = function () {
43506+ var endPoint = '/api/v1/debug';
43507+ return this.$http.get(endPoint);
43508+ };
4348143509 return APIEndPoint;
4348243510 })();
4348343511 services.APIEndPoint = APIEndPoint;
@@ -43612,10 +43640,8 @@
4361243640 this.$scope.$on('close', function () {
4361343641 controller.isOpen = false;
4361443642 });
43615- this.WebSocket.on('connect', function (msg) {
43616- console.log(msg);
43617- });
43618- this.WebSocket.on('test', function (msg) {
43643+ this.WebSocket.on('console', function (msg) {
43644+ console.log('CONSOLE!!!');
4361943645 console.log(msg);
4362043646 });
4362143647 }
@@ -43671,7 +43697,11 @@
4367143697 });
4367243698 };
4367343699 CommandController.prototype.debug = function () {
43674- this.MyModal.preview();
43700+ this.APIEndPoint
43701+ .debug()
43702+ .then(function (result) {
43703+ console.log(result);
43704+ });
4367543705 };
4367643706 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4367743707 return CommandController;
@@ -44081,6 +44111,10 @@
4408144111 transformRequest: angular.identity
4408244112 });
4408344113 };
44114+ APIEndPoint.prototype.debug = function () {
44115+ var endPoint = '/api/v1/debug';
44116+ return this.$http.get(endPoint);
44117+ };
4408444118 return APIEndPoint;
4408544119 })();
4408644120 services.APIEndPoint = APIEndPoint;
@@ -44215,10 +44249,8 @@
4421544249 this.$scope.$on('close', function () {
4421644250 controller.isOpen = false;
4421744251 });
44218- this.WebSocket.on('connect', function (msg) {
44219- console.log(msg);
44220- });
44221- this.WebSocket.on('test', function (msg) {
44252+ this.WebSocket.on('console', function (msg) {
44253+ console.log('CONSOLE!!!');
4422244254 console.log(msg);
4422344255 });
4422444256 }
@@ -44274,7 +44306,11 @@
4427444306 });
4427544307 };
4427644308 CommandController.prototype.debug = function () {
44277- this.MyModal.preview();
44309+ this.APIEndPoint
44310+ .debug()
44311+ .then(function (result) {
44312+ console.log(result);
44313+ });
4427844314 };
4427944315 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4428044316 return CommandController;
@@ -44684,6 +44720,10 @@
4468444720 transformRequest: angular.identity
4468544721 });
4468644722 };
44723+ APIEndPoint.prototype.debug = function () {
44724+ var endPoint = '/api/v1/debug';
44725+ return this.$http.get(endPoint);
44726+ };
4468744727 return APIEndPoint;
4468844728 })();
4468944729 services.APIEndPoint = APIEndPoint;
@@ -44818,10 +44858,8 @@
4481844858 this.$scope.$on('close', function () {
4481944859 controller.isOpen = false;
4482044860 });
44821- this.WebSocket.on('connect', function (msg) {
44822- console.log(msg);
44823- });
44824- this.WebSocket.on('test', function (msg) {
44861+ this.WebSocket.on('console', function (msg) {
44862+ console.log('CONSOLE!!!');
4482544863 console.log(msg);
4482644864 });
4482744865 }
@@ -44877,7 +44915,11 @@
4487744915 });
4487844916 };
4487944917 CommandController.prototype.debug = function () {
44880- this.MyModal.preview();
44918+ this.APIEndPoint
44919+ .debug()
44920+ .then(function (result) {
44921+ console.log(result);
44922+ });
4488144923 };
4488244924 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4488344925 return CommandController;
@@ -45287,6 +45329,10 @@
4528745329 transformRequest: angular.identity
4528845330 });
4528945331 };
45332+ APIEndPoint.prototype.debug = function () {
45333+ var endPoint = '/api/v1/debug';
45334+ return this.$http.get(endPoint);
45335+ };
4529045336 return APIEndPoint;
4529145337 })();
4529245338 services.APIEndPoint = APIEndPoint;
@@ -45421,10 +45467,8 @@
4542145467 this.$scope.$on('close', function () {
4542245468 controller.isOpen = false;
4542345469 });
45424- this.WebSocket.on('connect', function (msg) {
45425- console.log(msg);
45426- });
45427- this.WebSocket.on('test', function (msg) {
45470+ this.WebSocket.on('console', function (msg) {
45471+ console.log('CONSOLE!!!');
4542845472 console.log(msg);
4542945473 });
4543045474 }
@@ -45480,7 +45524,11 @@
4548045524 });
4548145525 };
4548245526 CommandController.prototype.debug = function () {
45483- this.MyModal.preview();
45527+ this.APIEndPoint
45528+ .debug()
45529+ .then(function (result) {
45530+ console.log(result);
45531+ });
4548445532 };
4548545533 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4548645534 return CommandController;
@@ -45890,6 +45938,10 @@
4589045938 transformRequest: angular.identity
4589145939 });
4589245940 };
45941+ APIEndPoint.prototype.debug = function () {
45942+ var endPoint = '/api/v1/debug';
45943+ return this.$http.get(endPoint);
45944+ };
4589345945 return APIEndPoint;
4589445946 })();
4589545947 services.APIEndPoint = APIEndPoint;
@@ -46024,10 +46076,8 @@
4602446076 this.$scope.$on('close', function () {
4602546077 controller.isOpen = false;
4602646078 });
46027- this.WebSocket.on('connect', function (msg) {
46028- console.log(msg);
46029- });
46030- this.WebSocket.on('test', function (msg) {
46079+ this.WebSocket.on('console', function (msg) {
46080+ console.log('CONSOLE!!!');
4603146081 console.log(msg);
4603246082 });
4603346083 }
@@ -46083,7 +46133,11 @@
4608346133 });
4608446134 };
4608546135 CommandController.prototype.debug = function () {
46086- this.MyModal.preview();
46136+ this.APIEndPoint
46137+ .debug()
46138+ .then(function (result) {
46139+ console.log(result);
46140+ });
4608746141 };
4608846142 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4608946143 return CommandController;
@@ -46493,6 +46547,10 @@
4649346547 transformRequest: angular.identity
4649446548 });
4649546549 };
46550+ APIEndPoint.prototype.debug = function () {
46551+ var endPoint = '/api/v1/debug';
46552+ return this.$http.get(endPoint);
46553+ };
4649646554 return APIEndPoint;
4649746555 })();
4649846556 services.APIEndPoint = APIEndPoint;
@@ -46627,10 +46685,8 @@
4662746685 this.$scope.$on('close', function () {
4662846686 controller.isOpen = false;
4662946687 });
46630- this.WebSocket.on('connect', function (msg) {
46631- console.log(msg);
46632- });
46633- this.WebSocket.on('test', function (msg) {
46688+ this.WebSocket.on('console', function (msg) {
46689+ console.log('CONSOLE!!!');
4663446690 console.log(msg);
4663546691 });
4663646692 }
@@ -46686,7 +46742,11 @@
4668646742 });
4668746743 };
4668846744 CommandController.prototype.debug = function () {
46689- this.MyModal.preview();
46745+ this.APIEndPoint
46746+ .debug()
46747+ .then(function (result) {
46748+ console.log(result);
46749+ });
4669046750 };
4669146751 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4669246752 return CommandController;
@@ -47096,6 +47156,10 @@
4709647156 transformRequest: angular.identity
4709747157 });
4709847158 };
47159+ APIEndPoint.prototype.debug = function () {
47160+ var endPoint = '/api/v1/debug';
47161+ return this.$http.get(endPoint);
47162+ };
4709947163 return APIEndPoint;
4710047164 })();
4710147165 services.APIEndPoint = APIEndPoint;
@@ -47230,10 +47294,8 @@
4723047294 this.$scope.$on('close', function () {
4723147295 controller.isOpen = false;
4723247296 });
47233- this.WebSocket.on('connect', function (msg) {
47234- console.log(msg);
47235- });
47236- this.WebSocket.on('test', function (msg) {
47297+ this.WebSocket.on('console', function (msg) {
47298+ console.log('CONSOLE!!!');
4723747299 console.log(msg);
4723847300 });
4723947301 }
@@ -47289,7 +47351,11 @@
4728947351 });
4729047352 };
4729147353 CommandController.prototype.debug = function () {
47292- this.MyModal.preview();
47354+ this.APIEndPoint
47355+ .debug()
47356+ .then(function (result) {
47357+ console.log(result);
47358+ });
4729347359 };
4729447360 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4729547361 return CommandController;
@@ -47699,6 +47765,10 @@
4769947765 transformRequest: angular.identity
4770047766 });
4770147767 };
47768+ APIEndPoint.prototype.debug = function () {
47769+ var endPoint = '/api/v1/debug';
47770+ return this.$http.get(endPoint);
47771+ };
4770247772 return APIEndPoint;
4770347773 })();
4770447774 services.APIEndPoint = APIEndPoint;
@@ -47833,10 +47903,8 @@
4783347903 this.$scope.$on('close', function () {
4783447904 controller.isOpen = false;
4783547905 });
47836- this.WebSocket.on('connect', function (msg) {
47837- console.log(msg);
47838- });
47839- this.WebSocket.on('test', function (msg) {
47906+ this.WebSocket.on('console', function (msg) {
47907+ console.log('CONSOLE!!!');
4784047908 console.log(msg);
4784147909 });
4784247910 }
@@ -47892,7 +47960,11 @@
4789247960 });
4789347961 };
4789447962 CommandController.prototype.debug = function () {
47895- this.MyModal.preview();
47963+ this.APIEndPoint
47964+ .debug()
47965+ .then(function (result) {
47966+ console.log(result);
47967+ });
4789647968 };
4789747969 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4789847970 return CommandController;
@@ -48302,6 +48374,10 @@
4830248374 transformRequest: angular.identity
4830348375 });
4830448376 };
48377+ APIEndPoint.prototype.debug = function () {
48378+ var endPoint = '/api/v1/debug';
48379+ return this.$http.get(endPoint);
48380+ };
4830548381 return APIEndPoint;
4830648382 })();
4830748383 services.APIEndPoint = APIEndPoint;
@@ -48436,10 +48512,8 @@
4843648512 this.$scope.$on('close', function () {
4843748513 controller.isOpen = false;
4843848514 });
48439- this.WebSocket.on('connect', function (msg) {
48440- console.log(msg);
48441- });
48442- this.WebSocket.on('test', function (msg) {
48515+ this.WebSocket.on('console', function (msg) {
48516+ console.log('CONSOLE!!!');
4844348517 console.log(msg);
4844448518 });
4844548519 }
@@ -48495,7 +48569,11 @@
4849548569 });
4849648570 };
4849748571 CommandController.prototype.debug = function () {
48498- this.MyModal.preview();
48572+ this.APIEndPoint
48573+ .debug()
48574+ .then(function (result) {
48575+ console.log(result);
48576+ });
4849948577 };
4850048578 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4850148579 return CommandController;
@@ -48905,6 +48983,10 @@
4890548983 transformRequest: angular.identity
4890648984 });
4890748985 };
48986+ APIEndPoint.prototype.debug = function () {
48987+ var endPoint = '/api/v1/debug';
48988+ return this.$http.get(endPoint);
48989+ };
4890848990 return APIEndPoint;
4890948991 })();
4891048992 services.APIEndPoint = APIEndPoint;
@@ -49039,10 +49121,8 @@
4903949121 this.$scope.$on('close', function () {
4904049122 controller.isOpen = false;
4904149123 });
49042- this.WebSocket.on('connect', function (msg) {
49043- console.log(msg);
49044- });
49045- this.WebSocket.on('test', function (msg) {
49124+ this.WebSocket.on('console', function (msg) {
49125+ console.log('CONSOLE!!!');
4904649126 console.log(msg);
4904749127 });
4904849128 }
@@ -49098,7 +49178,11 @@
4909849178 });
4909949179 };
4910049180 CommandController.prototype.debug = function () {
49101- this.MyModal.preview();
49181+ this.APIEndPoint
49182+ .debug()
49183+ .then(function (result) {
49184+ console.log(result);
49185+ });
4910249186 };
4910349187 CommandController.$inject = ['APIEndPoint', '$scope', 'MyModal', 'WebSocket'];
4910449188 return CommandController;
--- /dev/null
+++ b/server/api/v1/debug/index.js
@@ -0,0 +1,28 @@
1+'use strict';
2+
3+var express = require('express');
4+var router = express.Router()
5+var path = require('path')
6+var ws = require(__dirname + '/../../../../server/class/WebSocket').instance;
7+var spawn = require('child_process').spawn;
8+
9+var config = {
10+ cwd: ''
11+};
12+
13+router.get('/', function(req, res) {
14+
15+
16+ var runner = spawn('tree',['-L', 2],config);
17+
18+ runner.stdout.on('data', (data) => {
19+ ws.emit('console', data.toString());
20+ });
21+
22+ runner.on('close', function() {
23+ res.send('success');
24+ });
25+
26+});
27+
28+module.exports = router;
--- a/server/api/v1/execution/index.js
+++ b/server/api/v1/execution/index.js
@@ -6,7 +6,7 @@ var path = require('path')
66 var formidable = require('formidable')
77 var db = require(__dirname + '/../../../../server/class/DB').instance;
88 var eos = require(__dirname + '/../../../../server/class/Eos').instance;
9-var ws = require(__dirname + '/../../../../server/ws').instance;
9+var ws = require(__dirname + '/../../../../server/class/WebSocket').instance;
1010
1111 router.post('/', function(req, res) {
1212
--- a/server/app.js
+++ b/server/app.js
@@ -9,7 +9,7 @@ var EventEmitter = require('events').EventEmitter;
99 var emitter = new EventEmitter;
1010 var server = require('http').Server(app)
1111 var ioServer = require('socket.io');
12-var ws = require('./ws').instance;
12+var ws = require('./class/WebSocket').instance;
1313
1414 require('./express')(app);
1515 require('./routes')(app);
--- a/server/ws/index.js
+++ b/server/class/WebSocket.js
@@ -11,8 +11,8 @@ var instance = {
1111 socket.emit('connect', 'connected');
1212 });
1313 },
14- emit: function() {
15- socket.emit('test','outer test');
14+ emit: function(event, data) {
15+ socket.emit(event, data);
1616 }
1717 /*
1818 array include obj
--- a/server/routes.js
+++ b/server/routes.js
@@ -24,6 +24,7 @@ module.exports = function(app) {
2424 app.use('/api/v1/optionControlFile', require(__dirname + '/api/v1/optionControlFile'));
2525 app.use('/api/v1/tagList', require(__dirname + '/api/v1/tagList'));
2626 app.use('/api/v1/commandList', require(__dirname + '/api/v1/commandList'));
27+ app.use('/api/v1/debug', require(__dirname + '/api/v1/debug'));
2728
2829 app.route('/*')
2930 .get(function(req, res) {
Show on old repository browser