Lots of changes
- ✅ Feedback van dataSensor array - ✅ dataSliders min/max and unit - ✅ Camera before Unity - ✅ Restart knop buiten service mode - ✅ Operator phonenumber button - ✅ Gracefull shutdown - ✅ Out of service control
This commit is contained in:
187
frontend/views/dashboard/dist/dashboard.unity.js
vendored
187
frontend/views/dashboard/dist/dashboard.unity.js
vendored
@@ -48,6 +48,10 @@ var DashboardUnity = /** @class */ (function () {
|
||||
this.uptimeInfo = document.querySelector('.ntsh_dashboard-unity-uptime');
|
||||
this.webSocketStatus = document.querySelector('.ntsh_dashboard-unity-websocketstatus');
|
||||
this.webSocketInfo = document.querySelector('.ntsh_dashboard-unity-websocketinfo');
|
||||
this.outOfServiceStatus = document.querySelector('.ntsh_dashboard-unity-outofservicestatus');
|
||||
this.outOfServiceInfo = document.querySelector('.ntsh_dashboard-unity-outofserviceinfo');
|
||||
this.enableOutOfServiceButton = document.querySelector('.ntsh_dashboard-unity-enableoutofservice');
|
||||
this.disableOutOfServiceButton = document.querySelector('.ntsh_dashboard-unity-disableoutofservice');
|
||||
this.zedStreamStatus = document.querySelector('.ntsh_dashboard-unity-zedstreamstatus');
|
||||
this.zedStreamInfo = document.querySelector('.ntsh_dashboard-unity-zedstreaminfo');
|
||||
this.zedStreamFps = document.querySelector('.ntsh_dashboard-unity-zedstreamfps');
|
||||
@@ -56,6 +60,7 @@ var DashboardUnity = /** @class */ (function () {
|
||||
this.timelineStanding = document.querySelector('.ntsh_dashboard-unity-timeline-standing');
|
||||
this.timelineProgress = document.querySelector('.ntsh_dashboard-unity-timeline-progress');
|
||||
this.parametersTable = document.querySelector('.ntsh_dashboard-unity-parameters');
|
||||
this.sensorsTable = document.querySelector('.ntsh_dashboard-unity-sensors');
|
||||
this.errorContainer = document.querySelector('.ntsh_dashboard-unity-error');
|
||||
this.errorText = document.querySelector('.ntsh_dashboard-unity-errortext');
|
||||
this._Main = Main;
|
||||
@@ -73,7 +78,7 @@ var DashboardUnity = /** @class */ (function () {
|
||||
}
|
||||
(0, utils_1.setStatusState)(this.processStatus, {
|
||||
RUNNING: 'green',
|
||||
STOPPED: 'red',
|
||||
STOPPED: 'gray',
|
||||
STARTING: 'yellow',
|
||||
PROBLEM: 'red',
|
||||
}[state.state]);
|
||||
@@ -99,6 +104,28 @@ var DashboardUnity = /** @class */ (function () {
|
||||
FAILED: 'red',
|
||||
}[state.state]);
|
||||
this.webSocketInfo.innerText = (_a = state.message) !== null && _a !== void 0 ? _a : '';
|
||||
// ----------- Out of Service -----------
|
||||
(0, utils_1.setStatusState)(this.outOfServiceStatus, state.parameters.outOfService == null
|
||||
? 'gray'
|
||||
: state.parameters.outOfService
|
||||
? 'red'
|
||||
: 'green');
|
||||
this.outOfServiceInfo.innerText =
|
||||
state.parameters.outOfService == null
|
||||
? ''
|
||||
: state.parameters.outOfService
|
||||
? 'Out of Service'
|
||||
: 'Operational';
|
||||
this.enableOutOfServiceButton.style.display =
|
||||
state.parameters.outOfService == null ||
|
||||
state.parameters.outOfService
|
||||
? 'none'
|
||||
: 'flex';
|
||||
this.disableOutOfServiceButton.style.display =
|
||||
state.parameters.outOfService &&
|
||||
state.parameters.outOfService != null
|
||||
? 'flex'
|
||||
: 'none';
|
||||
// ----------- ZED Stream -----------
|
||||
(0, utils_1.setStatusState)(this.zedStreamStatus, state.parameters.zedReady ? 'green' : 'red');
|
||||
this.zedStreamInfo.innerText = state.parameters.zedReady
|
||||
@@ -113,9 +140,10 @@ var DashboardUnity = /** @class */ (function () {
|
||||
this.timelineStanding.innerText = state.parameters.timelineStanding
|
||||
? 'Yes'
|
||||
: 'No';
|
||||
(0, utils_1.setProgressState)(this.timelineProgress, state.parameters.timelineProgress);
|
||||
(0, utils_1.setProgressState)(this.timelineProgress, Math.round(state.parameters.timelineProgress * 100), 0, 100, '%');
|
||||
// ----------- Parameters -----------
|
||||
this.renderParameterSliders(state.parameters.parameters);
|
||||
this.renderParameterSliders(state.state == 'CONNECTED' ? state.parameters.sliders : []);
|
||||
this.renderParameterSensors(state.state == 'CONNECTED' ? state.parameters.sensors : []);
|
||||
// ----------- Error -----------
|
||||
if (((_b = state === null || state === void 0 ? void 0 : state.error) !== null && _b !== void 0 ? _b : '').trim().length > 0)
|
||||
this.webSocketError = state.error;
|
||||
@@ -123,55 +151,107 @@ var DashboardUnity = /** @class */ (function () {
|
||||
this.webSocketError = null;
|
||||
this.updateError();
|
||||
};
|
||||
DashboardUnity.prototype.renderParameterSliders = function (parameters) {
|
||||
DashboardUnity.prototype.renderParameterSliders = function (sliders) {
|
||||
var _this = this;
|
||||
if (parameters.length === 0)
|
||||
return;
|
||||
var existingSliders = this.parametersTable.querySelectorAll('.ntsh_dashboard-unity-parameter-row');
|
||||
if (existingSliders.length !== parameters.length) {
|
||||
if (existingSliders.length !== sliders.length) {
|
||||
this.parametersTable.innerHTML = '';
|
||||
parameters.forEach(function (param) {
|
||||
var row = (0, morphux_1.ce)('tr', 'ntsh_dashboard-unity-parameter-row');
|
||||
var nameCell = (0, morphux_1.ce)('td');
|
||||
nameCell.appendChild((0, morphux_1.ce)('div', 'mux_text', null, param.sliderName));
|
||||
row.appendChild(nameCell);
|
||||
var progressCell = (0, morphux_1.ce)('td', 'no-service');
|
||||
progressCell.appendChild((0, utils_1.createProgress)(param.outputValue));
|
||||
row.appendChild(progressCell);
|
||||
var sliderCell = (0, morphux_1.ce)('td', 'only-service');
|
||||
var sliderProgress = (0, utils_1.createProgress)(param.outputValue);
|
||||
var sliderValue = sliderProgress.querySelector('.ntsh_progress-value');
|
||||
sliderValue.classList.add('mux_resizer');
|
||||
sliderCell.appendChild(sliderProgress);
|
||||
var resizer = new morphux_1.MorphComponent.Resizer({
|
||||
existingContainer: sliderValue,
|
||||
direction: 'right',
|
||||
relative: true,
|
||||
min: 0,
|
||||
max: function () { return sliderProgress.clientWidth; },
|
||||
if (sliders.length === 0) {
|
||||
var row = (0, morphux_1.ce)('tr');
|
||||
var cell = (0, morphux_1.ce)('td');
|
||||
cell.appendChild((0, morphux_1.ce)('div', ['mux_text', 'ntsh_dashboard-unity-parameters-loading'], null, 'Waiting for Unity...'));
|
||||
row.appendChild(cell);
|
||||
this.parametersTable.appendChild(row);
|
||||
}
|
||||
else
|
||||
sliders.forEach(function (slider) {
|
||||
var _a, _b;
|
||||
var multiplierFactor = (_a = slider.visualMultiplier) !== null && _a !== void 0 ? _a : 1;
|
||||
var decimalPlacesFactor = Math.pow(10, ((_b = slider.decimalPlaces) !== null && _b !== void 0 ? _b : 0));
|
||||
var value = Math.round(slider.outputValue *
|
||||
multiplierFactor *
|
||||
decimalPlacesFactor) / decimalPlacesFactor;
|
||||
var row = (0, morphux_1.ce)('tr', 'ntsh_dashboard-unity-parameter-row');
|
||||
var nameCell = (0, morphux_1.ce)('td');
|
||||
nameCell.appendChild((0, morphux_1.ce)('div', 'mux_text', null, slider.sliderName));
|
||||
row.appendChild(nameCell);
|
||||
var progressCell = (0, morphux_1.ce)('td', 'no-service');
|
||||
progressCell.appendChild((0, utils_1.createProgress)(value, slider.min * multiplierFactor, slider.max * multiplierFactor, slider.unit));
|
||||
row.appendChild(progressCell);
|
||||
var sliderCell = (0, morphux_1.ce)('td', 'only-service');
|
||||
var sliderProgress = (0, utils_1.createProgress)(value, slider.min * multiplierFactor, slider.max * multiplierFactor, slider.unit);
|
||||
var sliderValue = sliderProgress.querySelector('.ntsh_progress-value');
|
||||
sliderValue.classList.add('mux_resizer');
|
||||
sliderCell.appendChild(sliderProgress);
|
||||
var resizer = new morphux_1.MorphComponent.Resizer({
|
||||
existingContainer: sliderValue,
|
||||
direction: 'right',
|
||||
relative: true,
|
||||
min: 0,
|
||||
max: function () { return sliderProgress.clientWidth; },
|
||||
});
|
||||
var lastValue = -1;
|
||||
resizer.on('resized', function (size) {
|
||||
var percentage = Math.round((size / sliderProgress.clientWidth) * 100) / 100;
|
||||
var actualValue = slider.min + percentage * (slider.max - slider.min);
|
||||
if (actualValue === lastValue)
|
||||
return;
|
||||
lastValue = actualValue;
|
||||
_this._Main.socket.emit('unityWebSocket', 'parameterValue', slider.sliderIndex, actualValue);
|
||||
(0, utils_1.setProgressState)(sliderProgress, Math.round(actualValue *
|
||||
multiplierFactor *
|
||||
decimalPlacesFactor) / decimalPlacesFactor, slider.min * multiplierFactor, slider.max * multiplierFactor, slider.unit);
|
||||
});
|
||||
row.appendChild(sliderCell);
|
||||
_this.parametersTable.appendChild(row);
|
||||
});
|
||||
var lastPercentage = -1;
|
||||
resizer.on('resized', function (size) {
|
||||
var percentage = Math.round((size / sliderProgress.clientWidth) * 100) /
|
||||
100;
|
||||
if (percentage === lastPercentage)
|
||||
return;
|
||||
lastPercentage = percentage;
|
||||
_this._Main.socket.emit('unityWebSocket', 'parameterValue', param.sliderIndex, percentage);
|
||||
(0, utils_1.setProgressState)(sliderProgress, percentage);
|
||||
});
|
||||
row.appendChild(sliderCell);
|
||||
_this.parametersTable.appendChild(row);
|
||||
});
|
||||
}
|
||||
else {
|
||||
existingSliders.forEach(function (row, index) {
|
||||
var value = parameters[index].outputValue;
|
||||
var _a, _b;
|
||||
var slider = sliders[index];
|
||||
var multiplierFactor = (_a = slider.visualMultiplier) !== null && _a !== void 0 ? _a : 1;
|
||||
var decimalPlacesFactor = Math.pow(10, ((_b = slider.decimalPlaces) !== null && _b !== void 0 ? _b : 0));
|
||||
var value = Math.round(slider.outputValue *
|
||||
multiplierFactor *
|
||||
decimalPlacesFactor) / decimalPlacesFactor;
|
||||
var progressElement = row.querySelector('.no-service .ntsh_progress');
|
||||
(0, utils_1.setProgressState)(progressElement, value);
|
||||
(0, utils_1.setProgressState)(progressElement, value, slider.min * multiplierFactor, slider.max * multiplierFactor, slider.unit);
|
||||
var sliderElement = row.querySelector('.only-service .ntsh_progress');
|
||||
if (sliderElement.querySelector('.mux_resizer-moving') == null)
|
||||
(0, utils_1.setProgressState)(sliderElement, value);
|
||||
(0, utils_1.setProgressState)(sliderElement, value, slider.min * multiplierFactor, slider.max * multiplierFactor, slider.unit);
|
||||
});
|
||||
}
|
||||
};
|
||||
DashboardUnity.prototype.renderParameterSensors = function (sensors) {
|
||||
var _this = this;
|
||||
var existingSensors = this.sensorsTable.querySelectorAll('.ntsh_dashboard-unity-sensor-row');
|
||||
if (existingSensors.length !== sensors.length) {
|
||||
this.sensorsTable.innerHTML = '';
|
||||
if (sensors.length === 0) {
|
||||
var row = (0, morphux_1.ce)('tr');
|
||||
var cell = (0, morphux_1.ce)('td');
|
||||
cell.appendChild((0, morphux_1.ce)('div', ['mux_text', 'ntsh_dashboard-unity-sensors-loading'], null, 'Waiting for Unity...'));
|
||||
row.appendChild(cell);
|
||||
this.sensorsTable.appendChild(row);
|
||||
}
|
||||
else
|
||||
sensors.forEach(function (sensor) {
|
||||
var row = (0, morphux_1.ce)('tr', 'ntsh_dashboard-unity-sensor-row');
|
||||
var nameCell = (0, morphux_1.ce)('td');
|
||||
nameCell.appendChild((0, morphux_1.ce)('div', 'mux_text', null, sensor.deviceName));
|
||||
row.appendChild(nameCell);
|
||||
var progressCell = (0, morphux_1.ce)('td');
|
||||
progressCell.appendChild((0, utils_1.createProgress)(Math.round(sensor.outputValue * 100), 0, 100, '%'));
|
||||
row.appendChild(progressCell);
|
||||
_this.sensorsTable.appendChild(row);
|
||||
});
|
||||
}
|
||||
else {
|
||||
existingSensors.forEach(function (row, index) {
|
||||
var value = sensors[index].outputValue;
|
||||
var progressElement = row.querySelector('.ntsh_progress');
|
||||
(0, utils_1.setProgressState)(progressElement, Math.round(value * 100), 0, 100, '%');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -202,10 +282,23 @@ var DashboardUnity = /** @class */ (function () {
|
||||
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');
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); });
|
||||
this.disableOutOfServiceButton.addEventListener('click', function () { return __awaiter(_this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
this.executeCommand('disableOutOfService', 'Are you sure you want to set the installation to "Operational"?', 'unityWebSocket');
|
||||
return [2 /*return*/];
|
||||
});
|
||||
}); });
|
||||
};
|
||||
DashboardUnity.prototype.executeCommand = function (command, message) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
DashboardUnity.prototype.executeCommand = function (command_1, message_1) {
|
||||
return __awaiter(this, arguments, void 0, function (command, message, type) {
|
||||
var confirmed;
|
||||
if (type === void 0) { type = 'unityRunner'; }
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, morphux_1.MorphFeature.Confirm({
|
||||
@@ -218,9 +311,9 @@ var DashboardUnity = /** @class */ (function () {
|
||||
return [2 /*return*/];
|
||||
morphux_1.MorphFeature.Loader({
|
||||
active: true,
|
||||
message: "Requesting Unity Runner ".concat(command, "..."),
|
||||
message: "Dispatching command...",
|
||||
});
|
||||
this._Main.socket.emit('unityRunner', command, function (response) {
|
||||
this._Main.socket.emit(type, command, function (response) {
|
||||
morphux_1.MorphFeature.Loader({ active: false });
|
||||
if (!response.succeed)
|
||||
return morphux_1.MorphFeature.Alert({
|
||||
@@ -229,7 +322,7 @@ var DashboardUnity = /** @class */ (function () {
|
||||
});
|
||||
morphux_1.MorphFeature.Notification({
|
||||
level: 'success',
|
||||
message: "Unity Runner is ".concat(command, "ing..."),
|
||||
message: "Dispatched command",
|
||||
});
|
||||
});
|
||||
return [2 /*return*/];
|
||||
|
||||
Reference in New Issue
Block a user