Skip to content

Commit c580514

Browse files
committed
update
Signed-off-by: Demis Bellot <demis.bellot@gmail.com>
1 parent 9480c34 commit c580514

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

AiServer/wwwroot/tailwind/BackgroundJobs.mjs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ref, computed, watch, onMounted, onUnmounted, provide, inject, nextTick } from "vue"
2-
import { humanize, queryString, setQueryString, toDate, leftPart, rightPart, pick, omit, EventBus } from "@servicestack/client"
2+
import { humanize, toDate, timeFmt12, leftPart, rightPart, pick, omit, EventBus } from "@servicestack/client"
33
import { useClient, useUtils, useFormatters } from "@servicestack/vue"
44
import { AdminJobInfo, AdminGetJob, AdminGetJobProgress, AdminCancelJobs, AdminRequeueFailedJobs, AdminJobDashboard } from "dtos"
55
import { Chart, registerables } from 'chart.js'
@@ -26,7 +26,8 @@ async function updateStats() {
2626
console.debug('updateStats', !!window.client)
2727
if (window.client) {
2828
const prefs = getPrefs()
29-
swrApi(window.client, new AdminJobInfo({ month:prefs.monthDb }), r => {
29+
const request = new AdminJobInfo({ month:prefs.monthDb }) //var needed by safari
30+
swrApi(window.client, request, r => {
3031
if (lastStats?.pageStats == null ||
3132
lastStats.pageStats.find(x => x.label === 'JobSummary').total !==
3233
r.response.pageStats.find(x => x.label === 'JobSummary').total) {
@@ -333,14 +334,15 @@ const JobDialog = {
333334
const duration = ref(formatMs(props.job.durationMs))
334335
const errorStatus = ref()
335336
const loading = ref(false)
336-
const isRunning = state => state === 'Queued' || state === 'Started'
337+
const isRunning = state => state === 'Queued' || state === 'Started' || state === 'Executed'
337338
const logs = ref(props.job.logs || '')
338339
const state = ref(props.job.state)
339340
const { formatDate, time } = useFormatters()
340341
function formatArgs(args) {
341342
Object.keys(args).forEach(key => {
343+
const val = args[key]
342344
if (key.endsWith('Date')) {
343-
args[key] = formatDate(args[key]) + ' ' + time(args[key])
345+
args[key] = formatDate(val) + ' ' + timeFmt12(toDate(val))
344346
} else if (key === 'durationMs') {
345347
args['duration'] = duration.value
346348
}
@@ -373,7 +375,7 @@ const JobDialog = {
373375
const r = apiRefresh.response
374376
const job = r.completed ?? r.failed ?? r.queued ?? r.result
375377
console.debug('requeue', job?.state, r.result.state)
376-
if (job?.state === 'Queued' || job?.state === 'Started') {
378+
if (job?.state === 'Queued' || job?.state === 'Started' || job?.state === 'Executed') {
377379
updated(job)
378380
clearTimeout(updateTimer)
379381
refresh()
@@ -433,12 +435,13 @@ const JobDialog = {
433435
// console.log('apiRefresh',job)
434436
if (job) {
435437
updated(job)
436-
scrollToBottom()
438+
if (api.response.logs) {
439+
scrollToBottom()
440+
}
437441
return
438442
}
439443
}
440444
}
441-
scrollToBottom()
442445
}
443446
updateTimer = setTimeout(refresh, 500)
444447
}
@@ -467,14 +470,14 @@ const Queue = {
467470
components,
468471
props:['info'],
469472
template: `
470-
<AutoQueryGrid ref="grid" type="BackgroundJob" hide="downloadCsv,copyApiUrl"
473+
<AutoQueryGrid ref="grid" type="BackgroundJob" hide="downloadCsv,copyApiUrl,forms"
471474
selectedColumns="progress,durationMs,worker,id,parentId,refId,tag,requestType,request,requestBody,command,userId,dependsOn,batchId,callback,replyTo,createdDate,state,status,lastActivityDate,attempts"
472475
:headerTitles="{parentId:'Parent',batchId:'Batch',requestType:'Type',createdDate:'Created',startedDate:'Started',completedDate:'Completed',notifiedDate:'Notified',lastActivityDate:'Last Activity',timeoutSecs:'Timeout'}"
473476
:visibleFrom="{durationMs:'never',requestBody:'never'}"
474477
@rowSelected="routes.edit = routes.edit == $event.id ? null : $event.id" :isSelected="(row) => routes.edit == row.id">
475478
<template #progress="job"><JobProgress :job="job" /></template>
476479
<template #id="{id}">{{id}}</template>
477-
<template #parentId="{parentId}"><EditLink :id="parentId" @selected="editId = $event" /></template>
480+
<template #parentId="{parentId}"><EditLink :id="parentId" @selected="routes.edit=$event" /></template>
478481
<template #refId="{ refId }"><Truncate class="w-16" :value="refId" /></template>
479482
<template #tag="{tag}">{{tag}}</template>
480483
<template #request="job"><Request :job="job" /></template>
@@ -510,8 +513,11 @@ const Queue = {
510513
let updateTimer = null
511514
async function updateGrid(){
512515
if (grid.value) {
513-
const take = grid.value.apiPrefs?.take ?? 25
514-
await grid.value.search({ include:'total', take })
516+
const searchArgs = grid.value.createRequestArgs()
517+
searchArgs.take = grid.value.apiPrefs?.take ?? 25
518+
searchArgs.include = 'total'
519+
delete searchArgs.fields
520+
await grid.value.search(searchArgs)
515521
}
516522
updateTimer = setTimeout(updateGrid, 1000)
517523
}
@@ -526,7 +532,7 @@ const Queue = {
526532
const Summary = {
527533
components,
528534
template: `
529-
<AutoQueryGrid ref="grid" type="JobSummary" hide="copyApiUrl"
535+
<AutoQueryGrid ref="grid" type="JobSummary" hide="copyApiUrl,forms"
530536
selectedColumns="id,parentId,refId,tag,requestType,request,command,response,callback,createdDate,worker,state,durationMs,completedDate,attempts,errorCode,errorMessage"
531537
:visibleFrom="{requestType:'never',callback:'never',errorMessage:'never'}"
532538
:headerTitles="{parentId:'Parent',createdDate:'Created',completedDate:'Completed',durationMs:'Duration',errorCode:'Error'}"
@@ -580,12 +586,12 @@ const Completed = {
580586
components,
581587
props:['info','month'],
582588
template: `
583-
<AutoQueryGrid ref="grid" type="CompletedJob" hide="copyApiUrl"
589+
<AutoQueryGrid ref="grid" type="CompletedJob" hide="copyApiUrl,forms"
584590
selectedColumns="id,parentId,refId,tag,requestType,request,command,userId,dependsOn,batchId,response,callback,replyTo,createdDate,worker,startedDate,state,status,durationMs,completedDate,notifiedDate,attempts,lastActivityDate"
585591
:headerTitles="{parentId:'Parent',batchId:'Batch',requestType:'Type',createdDate:'Created',startedDate:'Started',completedDate:'Completed',notifiedDate:'Notified',lastActivityDate:'Last Activity',timeoutSecs:'Timeout'}"
586592
@rowSelected="routes.edit = routes.edit == $event.id ? null : $event.id" :isSelected="(row) => routes.edit == row.id"
587593
:filters="{month}">
588-
<template #parentId="{parentId}"><EditLink :id="parentId" @selected="editId = $event" /></template>
594+
<template #parentId="{parentId}"><EditLink :id="parentId" @selected="routes.edit = $event" /></template>
589595
<template #refId="{ refId }"><Truncate class="w-16" :value="refId" /></template>
590596
<template #tag="{tag}">{{tag}}</template>
591597
<template #request="job"><Request :job="job" /></template>
@@ -631,7 +637,7 @@ const Failed = {
631637
components,
632638
props:['info','month'],
633639
template: `
634-
<AutoQueryGrid ref="grid" type="FailedJob" hide="copyApiUrl"
640+
<AutoQueryGrid ref="grid" type="FailedJob" hide="copyApiUrl,forms"
635641
selectedColumns="id,parentId,refId,tag,dependsOn,batchId,requestType,request,command,userId,response,callback,replyTo,createdDate,worker,startedDate,state,status,durationMs,completedDate,notifiedDate,lastActivityDate,attempts,retryLimit,timeoutSecs,errorCode,error"
636642
:visibleFrom="{error:'never'}"
637643
:headerTitles="{parentId:'Parent',batchId:'Batch',requestType:'Type',createdDate:'Created',startedDate:'Started',completedDate:'Completed',notifiedDate:'Notified',lastActivityDate:'Last Activity',timeoutSecs:'Timeout'}"
@@ -717,7 +723,7 @@ const History = {
717723
const ScheduledTasks = {
718724
components,
719725
template: `
720-
<AutoQueryGrid ref="grid" type="ScheduledTask" hide="copyApiUrl"
726+
<AutoQueryGrid ref="grid" type="ScheduledTask" hide="copyApiUrl,forms"
721727
selectedColumns="id,name,lastJobId,lastRun,interval,cronExpression,requestType,command,request,requestBody,options"
722728
:headerTitles="{lastJobId:'Last Job'}"
723729
@rowSelected="routes.edit = routes.edit === $event.id ? null : $event.id" :isSelected="(row) => routes.edit === row.id">
@@ -774,7 +780,7 @@ const Dashboard = {
774780
<div v-if="isToday && results.today.length" class="mb-8">
775781
<h4 class="mt-4 font-semibold text-gray-500">24 hour activity</h4>
776782
<div style="max-width:1024px;max-height:512px">
777-
<canvas ref="elChart"></canvas>
783+
<canvas ref="elChart"></canvas>
778784
</div>
779785
</div>
780786
<div v-if="results.commands.length">

0 commit comments

Comments
 (0)