Initial commit

This commit is contained in:
2025-10-22 22:06:16 +02:00
commit d8ca4e154f
141 changed files with 32231 additions and 0 deletions

62
frontend/views/dashboard/dist/utils.js vendored Normal file
View File

@@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createProgress = exports.setProgressState = exports.setStatusState = exports.lerp = void 0;
exports.capitalizeFirstLetter = capitalizeFirstLetter;
exports.formatUptime = formatUptime;
exports.delay = delay;
var morphux_1 = require("morphux");
/**
* A linear interpolation helper function.
* @param a The start value.
* @param b The end value.
* @param t The interpolation factor (0 to 1).
* @returns The interpolated value.
*/
var lerp = function (a, b, t) {
return a + (b - a) * t;
};
exports.lerp = lerp;
var setStatusState = function (statusElement, state) {
statusElement.classList.remove('ntsh_status-green', 'ntsh_status-yellow', 'ntsh_status-red', 'ntsh_status-gray');
statusElement.classList.add("ntsh_status-".concat(state));
};
exports.setStatusState = setStatusState;
var setProgressState = function (progressElement, percentage) {
var value = progressElement.querySelector('.ntsh_progress-value');
value.style.width = "".concat(percentage * 100, "%");
var label = progressElement.querySelector('.ntsh_progress-label');
label.innerText = "".concat(Math.round(percentage * 100), "%");
};
exports.setProgressState = setProgressState;
var createProgress = function (value) {
var progress = (0, morphux_1.ce)('div', 'ntsh_progress');
progress.appendChild((0, morphux_1.ce)('div', 'ntsh_progress-value'));
progress.appendChild((0, morphux_1.ce)('div', 'ntsh_progress-label'));
(0, exports.setProgressState)(progress, value);
return progress;
};
exports.createProgress = createProgress;
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function formatUptime(seconds) {
if (seconds < 0)
return '';
var days = Math.floor(seconds / 86400);
seconds %= 86400;
var hours = Math.floor(seconds / 3600);
seconds %= 3600;
var minutes = Math.floor(seconds / 60);
seconds = Math.floor(seconds % 60);
var parts = [];
if (days > 0)
parts.push("".concat(days, "d"));
parts.push("".concat(hours.toString().padStart(2, '0'), ":").concat(minutes
.toString()
.padStart(2, '0'), ":").concat(seconds.toString().padStart(2, '0')));
return parts.join(' ');
}
function delay(duration) {
return new Promise(function (resolve) { return setTimeout(resolve, duration); });
}
//# sourceMappingURL=utils.js.map