update: bump 'common' version to 0.1.18
This commit is contained in:
+10
-17
@@ -130,12 +130,10 @@
|
||||
|
||||
<script type="module">
|
||||
import { default as $, Rpc2, LogRecord } from '/';
|
||||
if (performance.getEntriesByType('navigation')[0].type === 'reload') await Rpc2.invoke('exit');
|
||||
if (performance.getEntriesByType('navigation')[0].type === 'reload') await Rpc2.notify('exit');
|
||||
|
||||
let error = null;
|
||||
let status = null;
|
||||
let { profiles, parameters } = await Rpc2.invoke('context');
|
||||
|
||||
let status = null;
|
||||
let date = new Date();
|
||||
let day = date.getDay() || 7;
|
||||
$('#datefrom').valueAsNumber = date.setHours(-24 * (day - 1)) - date.getTimezoneOffset() * 60 * 1000;
|
||||
@@ -160,7 +158,7 @@ $.set('#begin', 'click', async () => {
|
||||
parameters[element.id] = element.valueAsNumber;
|
||||
}
|
||||
|
||||
await Rpc2.invoke('begin', options, parameters);
|
||||
await Rpc2.invoke('begin', { params: [options, parameters] });
|
||||
break;
|
||||
case 'RUNNING':
|
||||
await Rpc2.invoke('pause');
|
||||
@@ -180,12 +178,12 @@ $.set('#begin', 'click', () => {
|
||||
|
||||
$.set('#cancel', 'click', async () => {
|
||||
$('#cancel').disabled = true;
|
||||
await Rpc2.invoke('cancel');
|
||||
await Rpc2.notify('cancel');
|
||||
});
|
||||
|
||||
$.set('#skip', 'click', async () => {
|
||||
$('#skip').disabled = true;
|
||||
await Rpcs.invoke('skip');
|
||||
await Rpc2.notify('skip');
|
||||
});
|
||||
|
||||
$.set('#logs', 'change', (e) => {
|
||||
@@ -219,12 +217,12 @@ for (let item of $.all("input[type='number']")) {
|
||||
}
|
||||
|
||||
while (await new Promise(o => setTimeout(o, 1000, true))) {
|
||||
let history = await Rpc2.invoke('history').catch(() => []);
|
||||
let history = await Rpc2.invoke('logs').catch(() => []);
|
||||
let logs = Array.from(history);
|
||||
|
||||
for (let record of logs) {
|
||||
if ($('#messages').childNodes.length >= 500) $('#messages').childNodes.item(0)?.remove();
|
||||
if (record.levelno >= 40) error = record;
|
||||
if (record.levelno >= 40) alert(`(${record.levelname}) ` + [record.msg, record.exc_text].filter(Boolean).join('\n'));
|
||||
let message = LogRecord.format(record);
|
||||
let node = document.createTextNode(new String(message).concat('\n'));
|
||||
$('#messages').appendChild(node);
|
||||
@@ -247,22 +245,17 @@ while (await new Promise(o => setTimeout(o, 1000, true))) {
|
||||
$('#begin > span.text').innerText = 'Pause';
|
||||
$('#begin').classList.add('pulse');
|
||||
|
||||
let progress = await Rpc2.invoke('progress').catch(() => new Object());
|
||||
let { task, number, index, limit } = progress;
|
||||
let { task, number, index, limit } = await Rpc2.invoke('progress').catch(() => new Object());
|
||||
$('#numberLabel').innerText = number ?? '';
|
||||
$('#progressLabel').innerText = limit ? `${task}, ${parseFloat((index / limit * 100).toFixed(2))}% (${index}/${limit})` : task;
|
||||
$('#progressLabel').innerText = limit ? `${task} — ${parseFloat((index / limit * 100).toFixed(2))}% (${index}/${limit})` : task;
|
||||
|
||||
let [t1, t2] = await Rpc2.invoke('uptime').catch(() => []);
|
||||
$('#uptimeLabel').innerText = Temporal.Duration.from({ seconds: t1 ?? 0 }).round({ largestUnit: 'hours' }).toLocaleString('en', { style: 'digital' });
|
||||
|
||||
let remaining = index && limit && t2 ? Math.floor((limit - index) / (index / t2)) : 0;
|
||||
$('#remainingLabel').innerHTML = remaining ? Temporal.Duration.from({ seconds: remaining }).round({ largestUnit: 'hours' }).toLocaleString('en') : '';
|
||||
$('#remainingLabel').innerText = remaining > 0 ? Temporal.Duration.from({ seconds: remaining }).round({ largestUnit: 'hours' }).toLocaleString('en') : '';
|
||||
break;
|
||||
case 'STANDBY':
|
||||
if (error !== null) {
|
||||
alert(`(${error.levelname}) ${error.msg}\n${error.exc_text ?? ''}`);
|
||||
error = null;
|
||||
}
|
||||
$('#begin > span.text').innerText = 'Resume';
|
||||
$('#begin').classList.remove('pulse');
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user