1
1
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"
3
3
import { useClient , useUtils , useFormatters } from "@servicestack/vue"
4
4
import { AdminJobInfo , AdminGetJob , AdminGetJobProgress , AdminCancelJobs , AdminRequeueFailedJobs , AdminJobDashboard } from "dtos"
5
5
import { Chart , registerables } from 'chart.js'
@@ -26,7 +26,8 @@ async function updateStats() {
26
26
console . debug ( 'updateStats' , ! ! window . client )
27
27
if ( window . client ) {
28
28
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 => {
30
31
if ( lastStats ?. pageStats == null ||
31
32
lastStats . pageStats . find ( x => x . label === 'JobSummary' ) . total !==
32
33
r . response . pageStats . find ( x => x . label === 'JobSummary' ) . total ) {
@@ -333,14 +334,15 @@ const JobDialog = {
333
334
const duration = ref ( formatMs ( props . job . durationMs ) )
334
335
const errorStatus = ref ( )
335
336
const loading = ref ( false )
336
- const isRunning = state => state === 'Queued' || state === 'Started'
337
+ const isRunning = state => state === 'Queued' || state === 'Started' || state === 'Executed'
337
338
const logs = ref ( props . job . logs || '' )
338
339
const state = ref ( props . job . state )
339
340
const { formatDate, time } = useFormatters ( )
340
341
function formatArgs ( args ) {
341
342
Object . keys ( args ) . forEach ( key => {
343
+ const val = args [ key ]
342
344
if ( key . endsWith ( 'Date' ) ) {
343
- args [ key ] = formatDate ( args [ key ] ) + ' ' + time ( args [ key ] )
345
+ args [ key ] = formatDate ( val ) + ' ' + timeFmt12 ( toDate ( val ) )
344
346
} else if ( key === 'durationMs' ) {
345
347
args [ 'duration' ] = duration . value
346
348
}
@@ -373,7 +375,7 @@ const JobDialog = {
373
375
const r = apiRefresh . response
374
376
const job = r . completed ?? r . failed ?? r . queued ?? r . result
375
377
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' ) {
377
379
updated ( job )
378
380
clearTimeout ( updateTimer )
379
381
refresh ( )
@@ -433,12 +435,13 @@ const JobDialog = {
433
435
// console.log('apiRefresh',job)
434
436
if ( job ) {
435
437
updated ( job )
436
- scrollToBottom ( )
438
+ if ( api . response . logs ) {
439
+ scrollToBottom ( )
440
+ }
437
441
return
438
442
}
439
443
}
440
444
}
441
- scrollToBottom ( )
442
445
}
443
446
updateTimer = setTimeout ( refresh , 500 )
444
447
}
@@ -467,14 +470,14 @@ const Queue = {
467
470
components,
468
471
props :[ 'info' ] ,
469
472
template : `
470
- <AutoQueryGrid ref="grid" type="BackgroundJob" hide="downloadCsv,copyApiUrl"
473
+ <AutoQueryGrid ref="grid" type="BackgroundJob" hide="downloadCsv,copyApiUrl,forms "
471
474
selectedColumns="progress,durationMs,worker,id,parentId,refId,tag,requestType,request,requestBody,command,userId,dependsOn,batchId,callback,replyTo,createdDate,state,status,lastActivityDate,attempts"
472
475
:headerTitles="{parentId:'Parent',batchId:'Batch',requestType:'Type',createdDate:'Created',startedDate:'Started',completedDate:'Completed',notifiedDate:'Notified',lastActivityDate:'Last Activity',timeoutSecs:'Timeout'}"
473
476
:visibleFrom="{durationMs:'never',requestBody:'never'}"
474
477
@rowSelected="routes.edit = routes.edit == $event.id ? null : $event.id" :isSelected="(row) => routes.edit == row.id">
475
478
<template #progress="job"><JobProgress :job="job" /></template>
476
479
<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>
478
481
<template #refId="{ refId }"><Truncate class="w-16" :value="refId" /></template>
479
482
<template #tag="{tag}">{{tag}}</template>
480
483
<template #request="job"><Request :job="job" /></template>
@@ -510,8 +513,11 @@ const Queue = {
510
513
let updateTimer = null
511
514
async function updateGrid ( ) {
512
515
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 )
515
521
}
516
522
updateTimer = setTimeout ( updateGrid , 1000 )
517
523
}
@@ -526,7 +532,7 @@ const Queue = {
526
532
const Summary = {
527
533
components,
528
534
template : `
529
- <AutoQueryGrid ref="grid" type="JobSummary" hide="copyApiUrl"
535
+ <AutoQueryGrid ref="grid" type="JobSummary" hide="copyApiUrl,forms "
530
536
selectedColumns="id,parentId,refId,tag,requestType,request,command,response,callback,createdDate,worker,state,durationMs,completedDate,attempts,errorCode,errorMessage"
531
537
:visibleFrom="{requestType:'never',callback:'never',errorMessage:'never'}"
532
538
:headerTitles="{parentId:'Parent',createdDate:'Created',completedDate:'Completed',durationMs:'Duration',errorCode:'Error'}"
@@ -580,12 +586,12 @@ const Completed = {
580
586
components,
581
587
props :[ 'info' , 'month' ] ,
582
588
template : `
583
- <AutoQueryGrid ref="grid" type="CompletedJob" hide="copyApiUrl"
589
+ <AutoQueryGrid ref="grid" type="CompletedJob" hide="copyApiUrl,forms "
584
590
selectedColumns="id,parentId,refId,tag,requestType,request,command,userId,dependsOn,batchId,response,callback,replyTo,createdDate,worker,startedDate,state,status,durationMs,completedDate,notifiedDate,attempts,lastActivityDate"
585
591
:headerTitles="{parentId:'Parent',batchId:'Batch',requestType:'Type',createdDate:'Created',startedDate:'Started',completedDate:'Completed',notifiedDate:'Notified',lastActivityDate:'Last Activity',timeoutSecs:'Timeout'}"
586
592
@rowSelected="routes.edit = routes.edit == $event.id ? null : $event.id" :isSelected="(row) => routes.edit == row.id"
587
593
: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>
589
595
<template #refId="{ refId }"><Truncate class="w-16" :value="refId" /></template>
590
596
<template #tag="{tag}">{{tag}}</template>
591
597
<template #request="job"><Request :job="job" /></template>
@@ -631,7 +637,7 @@ const Failed = {
631
637
components,
632
638
props :[ 'info' , 'month' ] ,
633
639
template : `
634
- <AutoQueryGrid ref="grid" type="FailedJob" hide="copyApiUrl"
640
+ <AutoQueryGrid ref="grid" type="FailedJob" hide="copyApiUrl,forms "
635
641
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"
636
642
:visibleFrom="{error:'never'}"
637
643
: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 = {
717
723
const ScheduledTasks = {
718
724
components,
719
725
template : `
720
- <AutoQueryGrid ref="grid" type="ScheduledTask" hide="copyApiUrl"
726
+ <AutoQueryGrid ref="grid" type="ScheduledTask" hide="copyApiUrl,forms "
721
727
selectedColumns="id,name,lastJobId,lastRun,interval,cronExpression,requestType,command,request,requestBody,options"
722
728
:headerTitles="{lastJobId:'Last Job'}"
723
729
@rowSelected="routes.edit = routes.edit === $event.id ? null : $event.id" :isSelected="(row) => routes.edit === row.id">
@@ -774,7 +780,7 @@ const Dashboard = {
774
780
<div v-if="isToday && results.today.length" class="mb-8">
775
781
<h4 class="mt-4 font-semibold text-gray-500">24 hour activity</h4>
776
782
<div style="max-width:1024px;max-height:512px">
777
- <canvas ref="elChart"></canvas>
783
+ <canvas ref="elChart"></canvas>
778
784
</div>
779
785
</div>
780
786
<div v-if="results.commands.length">
0 commit comments