Added basic control panel
This commit is contained in:
27
dist/WebServer/WebServer.js
vendored
27
dist/WebServer/WebServer.js
vendored
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
||||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
@@ -53,12 +53,14 @@ var DashboardRouter_1 = require("./DashboardRouter");
|
||||
var path_1 = require("path");
|
||||
var CalibrationRouter_1 = require("./CalibrationRouter");
|
||||
var Utils_1 = require("../Utils");
|
||||
var ControlRouter_1 = require("./ControlRouter");
|
||||
var PREFIX = '[WebServer]';
|
||||
var WebServer = /** @class */ (function () {
|
||||
function WebServer(Main) {
|
||||
this._Main = Main;
|
||||
this.Dashboard = new DashboardRouter_1.DashboardRouter(this._Main);
|
||||
this.Calibration = new CalibrationRouter_1.CalibrationRouter(this._Main);
|
||||
this.Control = new ControlRouter_1.ControlRouter(this._Main);
|
||||
this.prepare();
|
||||
}
|
||||
WebServer.prototype.prepare = function () {
|
||||
@@ -68,8 +70,11 @@ var WebServer = /** @class */ (function () {
|
||||
this.socket = new socket_io_1.Server(this.httpServer);
|
||||
this.app.use(express.static((0, path_1.join)(__filename, '..', '..', '..', 'frontend', 'static')));
|
||||
this.app.use(this.Dashboard.Router);
|
||||
this.app.use(this.Control.Router);
|
||||
this.app.use(this.Calibration.Router);
|
||||
this.socket.on('connection', function (socket) {
|
||||
socket.emit('status', _this._Main.Status.getState());
|
||||
socket.emit('timer', _this._Main.Timer.getState());
|
||||
socket.emit('cameraRunnerState', _this._Main.CameraRunner.getState());
|
||||
socket.emit('unityRunnerState', _this._Main.UnityRunner.getStatus());
|
||||
socket.emit('unityWebSocketState', _this._Main.UnityWebSocket.getState());
|
||||
@@ -119,6 +124,24 @@ var WebServer = /** @class */ (function () {
|
||||
}
|
||||
return (_a = _this._Main.UnityWebSocket).handle.apply(_a, __spreadArray([command], args, false));
|
||||
});
|
||||
socket.on('status', function (action, type) {
|
||||
switch (action) {
|
||||
case 'fullreboot':
|
||||
return _this._Main.restart();
|
||||
case 'reboot':
|
||||
return _this._Main.Status.reboot(type);
|
||||
case 'start':
|
||||
return _this._Main.Status.start(type);
|
||||
case 'stop':
|
||||
return _this._Main.Status.stop(type);
|
||||
}
|
||||
});
|
||||
socket.on('setTimerStart', function (data) {
|
||||
_this._Main.Timer.setStart(data);
|
||||
});
|
||||
socket.on('setTimerEnd', function (data) {
|
||||
_this._Main.Timer.setEnd(data);
|
||||
});
|
||||
});
|
||||
};
|
||||
WebServer.prototype.listen = function () {
|
||||
|
||||
Reference in New Issue
Block a user