Initial commit
This commit is contained in:
74
frontend/views/dashboard/dist/dashboard.showcontrol.js
vendored
Normal file
74
frontend/views/dashboard/dist/dashboard.showcontrol.js
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DashboardShowControl = void 0;
|
||||
var utils_1 = require("./utils");
|
||||
var CELCIUS = 'ºC';
|
||||
var DashboardShowControl = /** @class */ (function () {
|
||||
function DashboardShowControl(Main) {
|
||||
this.container = document.querySelector('.ntsh_dashboard-showcontrol');
|
||||
this.runningStatus = this.container.querySelector('.ntsh_dashboard-showcontrol-runningstatus');
|
||||
this.runningInfo = this.container.querySelector('.ntsh_dashboard-showcontrol-runninginfo');
|
||||
this.errorContainer = this.container.querySelector('.ntsh_dashboard-showcontrol-error');
|
||||
this.errorText = this.container.querySelector('.ntsh_dashboard-showcontrol-errortext');
|
||||
this.startButton = this.container.querySelector('.ntsh_dashboard-showcontrol-start');
|
||||
this.stopButton = this.container.querySelector('.ntsh_dashboard-showcontrol-stop');
|
||||
this._Main = Main;
|
||||
this.registerListeners();
|
||||
}
|
||||
DashboardShowControl.prototype.updateState = function (state) {
|
||||
var _a;
|
||||
// ----------- Running -----------
|
||||
var runningStatus = {
|
||||
STOPPED: 'gray',
|
||||
STARTING: 'yellow',
|
||||
RUNNING: 'green',
|
||||
STOPPING: 'yellow',
|
||||
RETRYING: 'red',
|
||||
HALTED: 'red',
|
||||
}[state.status];
|
||||
(0, utils_1.setStatusState)(this.runningStatus, runningStatus);
|
||||
this.runningInfo.innerText = {
|
||||
STOPPED: 'Idle',
|
||||
STARTING: state.info,
|
||||
RUNNING: 'Running',
|
||||
STOPPING: 'Stopping...',
|
||||
RETRYING: 'Problem detected! Retrying...',
|
||||
HALTED: 'Halted due to problems!',
|
||||
}[state.status];
|
||||
// ----------- Buttons -----------
|
||||
this.startButton.style.display =
|
||||
state.status == 'STOPPED' ||
|
||||
state.status == 'HALTED' ||
|
||||
state.status == 'RETRYING'
|
||||
? 'flex'
|
||||
: 'none';
|
||||
this.stopButton.style.display =
|
||||
state.status == 'RUNNING' || state.status == 'RETRYING'
|
||||
? 'flex'
|
||||
: 'none';
|
||||
// ----------- Error -----------
|
||||
if (((_a = state === null || state === void 0 ? void 0 : state.error) !== null && _a !== void 0 ? _a : '').trim().length > 0) {
|
||||
this.errorText.innerText = state.error;
|
||||
this.errorContainer.style.display = 'block';
|
||||
}
|
||||
else {
|
||||
this.errorContainer.style.display = 'none';
|
||||
this.errorText.innerText = '';
|
||||
}
|
||||
};
|
||||
DashboardShowControl.prototype.registerListeners = function () {
|
||||
var _this = this;
|
||||
this._Main.socket.on('showControlState', function (state) {
|
||||
_this.updateState(state);
|
||||
});
|
||||
this.startButton.onclick = function () {
|
||||
fetch('/api/v1/start');
|
||||
};
|
||||
this.stopButton.onclick = function () {
|
||||
fetch('/api/v1/stop');
|
||||
};
|
||||
};
|
||||
return DashboardShowControl;
|
||||
}());
|
||||
exports.DashboardShowControl = DashboardShowControl;
|
||||
//# sourceMappingURL=dashboard.showcontrol.js.map
|
||||
Reference in New Issue
Block a user