Added start/stop control to Unity process
This commit is contained in:
29
dist/Unity/UnityRunner.js
vendored
29
dist/Unity/UnityRunner.js
vendored
@@ -65,13 +65,16 @@ var UnityRunner = /** @class */ (function () {
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
args[_i - 1] = arguments[_i];
|
||||
}
|
||||
switch (command) {
|
||||
case 'restart':
|
||||
var callback = args[0];
|
||||
if (typeof callback !== 'function')
|
||||
return;
|
||||
callback(this.requestRestart());
|
||||
break;
|
||||
switch (command) {
|
||||
case 'restart':
|
||||
return callback(this.requestRestart());
|
||||
case 'stop':
|
||||
return callback(this.requestStop());
|
||||
case 'start':
|
||||
return callback(this.requestStart());
|
||||
}
|
||||
};
|
||||
UnityRunner.prototype.startStatusClock = function () {
|
||||
@@ -90,6 +93,24 @@ var UnityRunner = /** @class */ (function () {
|
||||
this.restart(true);
|
||||
return { succeed: true };
|
||||
};
|
||||
UnityRunner.prototype.requestStop = function () {
|
||||
if (this.state !== 'RUNNING')
|
||||
return {
|
||||
succeed: false,
|
||||
message: 'Cannot stop when process is not running. It is probably restarting already.',
|
||||
};
|
||||
this.stop();
|
||||
return { succeed: true };
|
||||
};
|
||||
UnityRunner.prototype.requestStart = function () {
|
||||
if (this.state !== 'STOPPED')
|
||||
return {
|
||||
succeed: false,
|
||||
message: 'Cannot start when process is already running.',
|
||||
};
|
||||
this.start();
|
||||
return { succeed: true };
|
||||
};
|
||||
UnityRunner.prototype.broadcastState = function () {
|
||||
this._Main.WebServer.socket.emit('unityRunnerState', this.getStatus());
|
||||
};
|
||||
|
||||
2
dist/Unity/UnityRunner.js.map
vendored
2
dist/Unity/UnityRunner.js.map
vendored
File diff suppressed because one or more lines are too long
18
frontend/views/dashboard/dist/dashboard.unity.js
vendored
18
frontend/views/dashboard/dist/dashboard.unity.js
vendored
@@ -45,6 +45,8 @@ var DashboardUnity = /** @class */ (function () {
|
||||
this.processStatus = document.querySelector('.ntsh_dashboard-unity-processstatus');
|
||||
this.processInfo = document.querySelector('.ntsh_dashboard-unity-processinfo');
|
||||
this.restartButton = document.querySelector('.ntsh_dashboard-unity-restart');
|
||||
this.startButton = document.querySelector('.ntsh_dashboard-unity-start');
|
||||
this.stopButton = document.querySelector('.ntsh_dashboard-unity-stop');
|
||||
this.uptimeInfo = document.querySelector('.ntsh_dashboard-unity-uptime');
|
||||
this.webSocketStatus = document.querySelector('.ntsh_dashboard-unity-websocketstatus');
|
||||
this.webSocketInfo = document.querySelector('.ntsh_dashboard-unity-websocketinfo');
|
||||
@@ -73,10 +75,14 @@ var DashboardUnity = /** @class */ (function () {
|
||||
if (state.state != 'RUNNING') {
|
||||
state.startTime = -1;
|
||||
this.restartButton.style.display = 'none';
|
||||
this.stopButton.style.display = 'none';
|
||||
}
|
||||
else {
|
||||
this.restartButton.style.display = 'flex';
|
||||
this.stopButton.style.display = 'flex';
|
||||
}
|
||||
this.startButton.style.display =
|
||||
state.state == 'STOPPED' ? 'flex' : 'none';
|
||||
(0, utils_1.setStatusState)(this.processStatus, {
|
||||
RUNNING: 'green',
|
||||
STOPPED: 'gray',
|
||||
@@ -356,6 +362,18 @@ var DashboardUnity = /** @class */ (function () {
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); });
|
||||
this.startButton.addEventListener('click', function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
this.executeCommand('start', 'Are you sure you want to start the Unity Runner process?');
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); });
|
||||
this.stopButton.addEventListener('click', function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
this.executeCommand('stop', 'Are you sure you want to stop the Unity Runner process?');
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); });
|
||||
this.enableOutOfServiceButton.addEventListener('click', function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
this.executeCommand('enableOutOfService', 'Are you sure you want to set the installation to "Out of Service"?', 'unityWebSocket');
|
||||
|
||||
File diff suppressed because one or more lines are too long
54
frontend/views/dashboard/dist/menubar.js
vendored
54
frontend/views/dashboard/dist/menubar.js
vendored
@@ -73,21 +73,18 @@ var MenuBar = /** @class */ (function () {
|
||||
});
|
||||
}); },
|
||||
},
|
||||
{
|
||||
type: 'icon',
|
||||
text: 'Shutdown',
|
||||
materialIcon: 'power_settings_new',
|
||||
uniqueIdentifier: 'shutdown_installation',
|
||||
click: function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var mobileMenu;
|
||||
return __generator(this, function (_a) {
|
||||
mobileMenu = document.querySelector('.mux_mobilemenu');
|
||||
mobileMenu === null || mobileMenu === void 0 ? void 0 : mobileMenu.click();
|
||||
this.shutdownInstallation();
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); },
|
||||
},
|
||||
// {
|
||||
// type: 'icon',
|
||||
// text: 'Shutdown',
|
||||
// materialIcon: 'power_settings_new',
|
||||
// uniqueIdentifier: 'shutdown_installation',
|
||||
// click: async () => {
|
||||
// const mobileMenu: HTMLDivElement =
|
||||
// document.querySelector('.mux_mobilemenu');
|
||||
// mobileMenu?.click();
|
||||
// this.shutdownInstallation();
|
||||
// },
|
||||
// },
|
||||
],
|
||||
right: [
|
||||
{
|
||||
@@ -115,21 +112,18 @@ var MenuBar = /** @class */ (function () {
|
||||
});
|
||||
}); },
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
text: 'Shutdown',
|
||||
materialIcon: 'power_settings_new',
|
||||
uniqueIdentifier: 'shutdown_installation',
|
||||
click: function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
var mobileMenu;
|
||||
return __generator(this, function (_a) {
|
||||
mobileMenu = document.querySelector('.mux_mobilemenu');
|
||||
mobileMenu === null || mobileMenu === void 0 ? void 0 : mobileMenu.click();
|
||||
this.shutdownInstallation();
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); },
|
||||
},
|
||||
// {
|
||||
// type: 'normal',
|
||||
// text: 'Shutdown',
|
||||
// materialIcon: 'power_settings_new',
|
||||
// uniqueIdentifier: 'shutdown_installation',
|
||||
// click: async () => {
|
||||
// const mobileMenu: HTMLDivElement =
|
||||
// document.querySelector('.mux_mobilemenu');
|
||||
// mobileMenu?.click();
|
||||
// this.shutdownInstallation();
|
||||
// },
|
||||
// },
|
||||
{
|
||||
type: 'normal',
|
||||
text: 'Dashboard',
|
||||
|
||||
2
frontend/views/dashboard/dist/menubar.js.map
vendored
2
frontend/views/dashboard/dist/menubar.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -105,8 +105,15 @@
|
||||
<td>
|
||||
<div class="ntsh_buttons">
|
||||
<div class="ntsh_button mux_text ntsh_dashboard-unity-restart">
|
||||
Restart Process
|
||||
Restart
|
||||
</div>
|
||||
<div class="ntsh_button mux_text ntsh_dashboard-unity-stop">
|
||||
Stop
|
||||
</div>
|
||||
<div class="ntsh_button mux_text ntsh_dashboard-unity-start">
|
||||
Start
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -14479,21 +14479,18 @@
|
||||
});
|
||||
}); },
|
||||
},
|
||||
{
|
||||
type: 'icon',
|
||||
text: 'Shutdown',
|
||||
materialIcon: 'power_settings_new',
|
||||
uniqueIdentifier: 'shutdown_installation',
|
||||
click: function () { return __awaiter$4(_this, void 0, void 0, function () {
|
||||
var mobileMenu;
|
||||
return __generator$4(this, function (_a) {
|
||||
mobileMenu = document.querySelector('.mux_mobilemenu');
|
||||
mobileMenu === null || mobileMenu === void 0 ? void 0 : mobileMenu.click();
|
||||
this.shutdownInstallation();
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); },
|
||||
},
|
||||
// {
|
||||
// type: 'icon',
|
||||
// text: 'Shutdown',
|
||||
// materialIcon: 'power_settings_new',
|
||||
// uniqueIdentifier: 'shutdown_installation',
|
||||
// click: async () => {
|
||||
// const mobileMenu: HTMLDivElement =
|
||||
// document.querySelector('.mux_mobilemenu');
|
||||
// mobileMenu?.click();
|
||||
// this.shutdownInstallation();
|
||||
// },
|
||||
// },
|
||||
],
|
||||
right: [
|
||||
{
|
||||
@@ -14521,21 +14518,18 @@
|
||||
});
|
||||
}); },
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
text: 'Shutdown',
|
||||
materialIcon: 'power_settings_new',
|
||||
uniqueIdentifier: 'shutdown_installation',
|
||||
click: function () { return __awaiter$4(_this, void 0, void 0, function () {
|
||||
var mobileMenu;
|
||||
return __generator$4(this, function (_a) {
|
||||
mobileMenu = document.querySelector('.mux_mobilemenu');
|
||||
mobileMenu === null || mobileMenu === void 0 ? void 0 : mobileMenu.click();
|
||||
this.shutdownInstallation();
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); },
|
||||
},
|
||||
// {
|
||||
// type: 'normal',
|
||||
// text: 'Shutdown',
|
||||
// materialIcon: 'power_settings_new',
|
||||
// uniqueIdentifier: 'shutdown_installation',
|
||||
// click: async () => {
|
||||
// const mobileMenu: HTMLDivElement =
|
||||
// document.querySelector('.mux_mobilemenu');
|
||||
// mobileMenu?.click();
|
||||
// this.shutdownInstallation();
|
||||
// },
|
||||
// },
|
||||
{
|
||||
type: 'normal',
|
||||
text: 'Dashboard',
|
||||
@@ -15732,6 +15726,8 @@
|
||||
this.processStatus = document.querySelector('.ntsh_dashboard-unity-processstatus');
|
||||
this.processInfo = document.querySelector('.ntsh_dashboard-unity-processinfo');
|
||||
this.restartButton = document.querySelector('.ntsh_dashboard-unity-restart');
|
||||
this.startButton = document.querySelector('.ntsh_dashboard-unity-start');
|
||||
this.stopButton = document.querySelector('.ntsh_dashboard-unity-stop');
|
||||
this.uptimeInfo = document.querySelector('.ntsh_dashboard-unity-uptime');
|
||||
this.webSocketStatus = document.querySelector('.ntsh_dashboard-unity-websocketstatus');
|
||||
this.webSocketInfo = document.querySelector('.ntsh_dashboard-unity-websocketinfo');
|
||||
@@ -15760,10 +15756,14 @@
|
||||
if (state.state != 'RUNNING') {
|
||||
state.startTime = -1;
|
||||
this.restartButton.style.display = 'none';
|
||||
this.stopButton.style.display = 'none';
|
||||
}
|
||||
else {
|
||||
this.restartButton.style.display = 'flex';
|
||||
this.stopButton.style.display = 'flex';
|
||||
}
|
||||
this.startButton.style.display =
|
||||
state.state == 'STOPPED' ? 'flex' : 'none';
|
||||
(0, utils_1.setStatusState)(this.processStatus, {
|
||||
RUNNING: 'green',
|
||||
STOPPED: 'gray',
|
||||
@@ -16043,6 +16043,18 @@
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); });
|
||||
this.startButton.addEventListener('click', function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
this.executeCommand('start', 'Are you sure you want to start the Unity Runner process?');
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); });
|
||||
this.stopButton.addEventListener('click', function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
this.executeCommand('stop', 'Are you sure you want to stop the Unity Runner process?');
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); });
|
||||
this.enableOutOfServiceButton.addEventListener('click', function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
this.executeCommand('enableOutOfService', 'Are you sure you want to set the installation to "Out of Service"?', 'unityWebSocket');
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -23,6 +23,12 @@ export class DashboardUnity {
|
||||
restartButton: HTMLDivElement = document.querySelector(
|
||||
'.ntsh_dashboard-unity-restart'
|
||||
);
|
||||
startButton: HTMLDivElement = document.querySelector(
|
||||
'.ntsh_dashboard-unity-start'
|
||||
);
|
||||
stopButton: HTMLDivElement = document.querySelector(
|
||||
'.ntsh_dashboard-unity-stop'
|
||||
);
|
||||
|
||||
uptimeInfo: HTMLDivElement = document.querySelector(
|
||||
'.ntsh_dashboard-unity-uptime'
|
||||
@@ -103,9 +109,13 @@ export class DashboardUnity {
|
||||
state.startTime = -1;
|
||||
|
||||
this.restartButton.style.display = 'none';
|
||||
this.stopButton.style.display = 'none';
|
||||
} else {
|
||||
this.restartButton.style.display = 'flex';
|
||||
this.stopButton.style.display = 'flex';
|
||||
}
|
||||
this.startButton.style.display =
|
||||
state.state == 'STOPPED' ? 'flex' : 'none';
|
||||
|
||||
setStatusState(
|
||||
this.processStatus,
|
||||
@@ -603,6 +613,18 @@ export class DashboardUnity {
|
||||
'Are you sure you want to restart the Unity Runner process?'
|
||||
);
|
||||
});
|
||||
this.startButton.addEventListener('click', async () => {
|
||||
this.executeCommand(
|
||||
'start',
|
||||
'Are you sure you want to start the Unity Runner process?'
|
||||
);
|
||||
});
|
||||
this.stopButton.addEventListener('click', async () => {
|
||||
this.executeCommand(
|
||||
'stop',
|
||||
'Are you sure you want to stop the Unity Runner process?'
|
||||
);
|
||||
});
|
||||
|
||||
this.enableOutOfServiceButton.addEventListener('click', async () => {
|
||||
this.executeCommand(
|
||||
|
||||
@@ -44,20 +44,20 @@ export class MenuBar {
|
||||
this.restartInstallation();
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'icon',
|
||||
text: 'Shutdown',
|
||||
materialIcon: 'power_settings_new',
|
||||
uniqueIdentifier: 'shutdown_installation',
|
||||
// {
|
||||
// type: 'icon',
|
||||
// text: 'Shutdown',
|
||||
// materialIcon: 'power_settings_new',
|
||||
// uniqueIdentifier: 'shutdown_installation',
|
||||
|
||||
click: async () => {
|
||||
const mobileMenu: HTMLDivElement =
|
||||
document.querySelector('.mux_mobilemenu');
|
||||
mobileMenu?.click();
|
||||
// click: async () => {
|
||||
// const mobileMenu: HTMLDivElement =
|
||||
// document.querySelector('.mux_mobilemenu');
|
||||
// mobileMenu?.click();
|
||||
|
||||
this.shutdownInstallation();
|
||||
},
|
||||
},
|
||||
// this.shutdownInstallation();
|
||||
// },
|
||||
// },
|
||||
],
|
||||
right: [
|
||||
{
|
||||
@@ -84,20 +84,20 @@ export class MenuBar {
|
||||
this.restartInstallation();
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
text: 'Shutdown',
|
||||
materialIcon: 'power_settings_new',
|
||||
uniqueIdentifier: 'shutdown_installation',
|
||||
// {
|
||||
// type: 'normal',
|
||||
// text: 'Shutdown',
|
||||
// materialIcon: 'power_settings_new',
|
||||
// uniqueIdentifier: 'shutdown_installation',
|
||||
|
||||
click: async () => {
|
||||
const mobileMenu: HTMLDivElement =
|
||||
document.querySelector('.mux_mobilemenu');
|
||||
mobileMenu?.click();
|
||||
// click: async () => {
|
||||
// const mobileMenu: HTMLDivElement =
|
||||
// document.querySelector('.mux_mobilemenu');
|
||||
// mobileMenu?.click();
|
||||
|
||||
this.shutdownInstallation();
|
||||
},
|
||||
},
|
||||
// this.shutdownInstallation();
|
||||
// },
|
||||
// },
|
||||
{
|
||||
type: 'normal',
|
||||
text: 'Dashboard',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ntshcontrol",
|
||||
"version": "2025.11.1",
|
||||
"version": "2025.11.2",
|
||||
"main": "dist/Entry.js",
|
||||
"scripts": {
|
||||
"start": "node ."
|
||||
|
||||
@@ -26,16 +26,19 @@ export class UnityRunner {
|
||||
}
|
||||
|
||||
handle(command: string, ...args: any[]) {
|
||||
switch (command) {
|
||||
case 'restart':
|
||||
const callback: (response: {
|
||||
succeed: boolean;
|
||||
message?: string;
|
||||
}) => void = args[0];
|
||||
if (typeof callback !== 'function') return;
|
||||
|
||||
callback(this.requestRestart());
|
||||
break;
|
||||
switch (command) {
|
||||
case 'restart':
|
||||
return callback(this.requestRestart());
|
||||
case 'stop':
|
||||
return callback(this.requestStop());
|
||||
case 'start':
|
||||
return callback(this.requestStart());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +62,29 @@ export class UnityRunner {
|
||||
return { succeed: true };
|
||||
}
|
||||
|
||||
requestStop(): { succeed: boolean; message?: string } {
|
||||
if (this.state !== 'RUNNING')
|
||||
return {
|
||||
succeed: false,
|
||||
message:
|
||||
'Cannot stop when process is not running. It is probably restarting already.',
|
||||
};
|
||||
|
||||
this.stop();
|
||||
return { succeed: true };
|
||||
}
|
||||
|
||||
requestStart(): { succeed: boolean; message?: string } {
|
||||
if (this.state !== 'STOPPED')
|
||||
return {
|
||||
succeed: false,
|
||||
message: 'Cannot start when process is already running.',
|
||||
};
|
||||
|
||||
this.start();
|
||||
return { succeed: true };
|
||||
}
|
||||
|
||||
broadcastState() {
|
||||
this._Main.WebServer.socket.emit('unityRunnerState', this.getStatus());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user