1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-10 20:26:48 +00:00

feat(operations): the job panel and job pages speak the page's language

The job panel on VM and storage pages wrote its buttons and notes in
English (Cancel, Open, Refresh, Dismiss, Finishing..., Files not
removed, Worker unavailable, Cancel failed) and its state badge as the
state's code, and the jobs API gave the phase untranslated. The panel
now takes its texts and the state labels from the page's settings, and
the API gives the phase in the viewer's language, as it gives the
label; the job pages show that phase.

A job that cannot be cancelled and ran past its time limit had
"(over its time limit)" written into its phase, which then matched no
translation. The phase stays as the job sets it, and the pages say the
job is past its limit.
This commit is contained in:
catborise 2026-11-02 23:33:34 +03:00
parent 9d57adc097
commit 0eab09e19d
13 changed files with 178 additions and 42 deletions

View file

@ -229,10 +229,9 @@ class Worker:
now = timezone.now()
for op in Operation.objects.filter(pk__in=list(self.jobs), time_limit__isnull=False):
if op.started_at and now - op.started_at > timedelta(seconds=op.time_limit):
# one that cannot be cancelled runs on; its page says it is over its limit
if jobs.get_kind(op.kind).cancellable and not op.cancel_requested:
self._fenced_update([op.pk], state=Operation.CANCELLING, cancel_requested=True)
elif "(over its time limit)" not in op.phase:
self._fenced_update([op.pk], phase=f"{op.phase} (over its time limit)"[:255])
def _progress(self):
"""At most one query per job and none waiting for a thread, so queries