luci-app-dockerman: correctness fixes

follow-up to baa0f16bb3

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald
2026-05-22 15:46:41 +03:00
parent adf5f6d492
commit 4a63b98525
4 changed files with 7 additions and 6 deletions
@@ -488,7 +488,7 @@ const dv = view.extend({
parseMemory(value) {
if (!value) return 0;
const rex = /^([0-9.]+) *([bkmgt])?i? *[Bb]?/i;
const rex = /^([0-9.]+) *([bkmgtp])?i? *[Bb]?/i;
let [, amount, unit] = rex.exec(value.toLowerCase());
amount = amount ? Number.parseFloat(amount) : 0;
switch (unit) {
@@ -1086,7 +1086,7 @@ return dm2.dv.extend({
o = s.taboption('wsconsole', form.DummyValue, 'wsconsole_controls', _('WebSocket Console'));
o.render = L.bind(function() {
const status = this.getContainerStatus();
const status = this.getContainerStatus(this_container);
const isRunning = status === 'running';
if (!isRunning) {
@@ -1327,6 +1327,7 @@ return dm2.dv.extend({
.then(() => {
const this_container = map.data.get('json', 'cont');
const id = this_container?.Id;
const nc = gethc('NanoCpus');
/* In the container edit context, there are not many items we
can change - duplicate the container */
const createBody = {
@@ -1335,11 +1336,11 @@ return dm2.dv.extend({
Memory: toInt(gethc('Memory')),
MemorySwap: toInt(gethc('MemorySwap')),
MemoryReservation: toInt(gethc('MemoryReservation')),
BlkioWeight: toInt(gethc('blkio_weight')),
BlkioWeight: toInt(gethc('BlkioWeight')),
CpuPeriod: toInt(gethc('CpuPeriod')),
CpuQuota: toInt(gethc('CpuQuota')),
NanoCPUs: toInt(gethc('NanoCpus') * (10 ** 9)), // unit: 10^-9, input: float
NanoCPUs: nc ? Math.round(nc * 1e9) : undefined, // unit: 10^-9, input: float
OomKillDisable: toBool(gethc('OomKillDisable')),
RestartPolicy: { Name: get('restart_policy') || this_container.HostConfig?.RestartPolicy?.Name },
@@ -22,7 +22,7 @@ return dm2.dv.extend({
render([volumes, containers]) {
if (volumes?.code !== 200) {
return E('div', {}, [ volumes.body.message ]);
return E('div', {}, [ volumes?.body?.message ?? _('Failed to load volumes') ]);
}
// this.volumes = volumes || {};
@@ -290,7 +290,7 @@ function run_ttyd(request) {
const id = request.args.id || '';
const cmd = request.args.cmd || '/bin/sh';
const port = request.args.port || 7682;
const port = int(request.args.port) || 7682;
const uid = request.args.uid || '';
if (!id) {