1
1
import { ref , computed , onMounted , watch } from "vue"
2
- import { useClient } from "@servicestack/vue"
3
- import { QueryMediaModels , QueryMediaTypes , GetComfyModels } from "../dtos.mjs"
2
+ import { useClient , useFormatters } from "@servicestack/vue"
3
+ import { QueryMediaModels , QueryMediaTypes , GetComfyModels , CheckMediaProviderStatus } from "../dtos.mjs"
4
4
5
5
const SelectModels = {
6
6
template : `
@@ -255,12 +255,13 @@ export default {
255
255
SelectModels,
256
256
} ,
257
257
template : `
258
- <AutoQueryGrid ref="grid" :type="type" selectedColumns="id,enabled,name,type,mediaTypeId,apiKey,models"
259
- :visibleFrom="{ id:'never', enabled:'never', mediaTypeId:'never'}" modelTitle="Generation Provider" @nav="onNav">
260
- <template #name="{ id, name, enabled }">
258
+ <AutoQueryGrid ref="grid" :type="type" selectedColumns="id,enabled,offlineDate, name,type,mediaTypeId,apiKey,models"
259
+ :visibleFrom="{ id:'never', enabled:'never', offlineDate:'never', mediaTypeId:'never'}" modelTitle="Generation Provider" @nav="onNav">
260
+ <template #name="{ id, name, enabled, offlineDate }">
261
261
<div class="flex">
262
262
<svg v-if="enabled" class="w-6 h-6 text-green-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M17 7H7a5 5 0 0 0-5 5a5 5 0 0 0 5 5h10a5 5 0 0 0 5-5a5 5 0 0 0-5-5m0 8a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3a3 3 0 0 1-3 3"/></svg>
263
263
<svg v-else class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M17 6H7c-3.31 0-6 2.69-6 6s2.69 6 6 6h10c3.31 0 6-2.69 6-6s-2.69-6-6-6m0 10H7c-2.21 0-4-1.79-4-4s1.79-4 4-4h10c2.21 0 4 1.79 4 4s-1.79 4-4 4M7 9c-1.66 0-3 1.34-3 3s1.34 3 3 3s3-1.34 3-3s-1.34-3-3-3"/></svg>
264
+ <span :title="!enabled ? 'disabled' : offlineDate ? 'offline ' + relativeTime(offlineDate) : 'online'"><svg :class="['h-6 w-6', !enabled ? 'text-grey-500' : offlineDate ? 'text-red-500' : 'text-green-500']" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="8" fill="currentColor"/></svg></span>
264
265
<div class="ml-1">{{name}}</div>
265
266
</div>
266
267
</template>
@@ -298,6 +299,13 @@ export default {
298
299
</div>
299
300
</template>
300
301
<template #formfooter="{ form, formInstance, apis, model, editId, updateModel }">
302
+ <div v-if="form=='edit'" class="pl-6 mb-2 text-gray-500">
303
+ <div class="flex">
304
+ <svg :class="['h-6 w-6', !model.enabled ? 'text-grey-500' : model.offlineDate ? 'text-red-500' : 'text-green-500']" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="8" fill="currentColor"/></svg>
305
+ <span>{{!model.enabled ? 'disabled' : model.offlineDate ? 'offline ' + relativeTime(model.offlineDate) : 'online'}}</span>
306
+ <button type="button" @click="checkStatus(model.name)" class="ml-2 rounded-full bg-white px-2.5 py-1 text-xs font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50" :disabled="checking">{{checking ? 'checking...' : 'check status'}}</button>
307
+ </div>
308
+ </div>
301
309
<div class="pl-6">
302
310
<SelectModels
303
311
v-if="formModel"
@@ -324,6 +332,8 @@ export default {
324
332
const selectedModels = ref ( [ ] )
325
333
const providerTypes = ref ( { } )
326
334
const formModel = computed ( ( ) => ( grid . value ?. createForm ?? grid . value ?. editForm ) ?. model )
335
+ const checking = ref ( false )
336
+ const { formatDate, relativeTime } = useFormatters ( )
327
337
328
338
onMounted ( async ( ) => {
329
339
const api = await client . api ( new QueryMediaTypes ( ) )
@@ -353,6 +363,18 @@ export default {
353
363
}
354
364
}
355
365
366
+ async function checkStatus ( provider ) {
367
+ checking . value = true
368
+ const api = await client . api ( new CheckMediaProviderStatus ( { provider } ) )
369
+ if ( api . response ) {
370
+ grid . value ?. setEdit ( {
371
+ offlineDate : api . response . result ? null : new Date ( ) ,
372
+ } )
373
+ grid . value ?. update ( )
374
+ }
375
+ checking . value = false
376
+ }
377
+
356
378
watch ( ( ) => providerType . value , ( ) => {
357
379
if ( ! providerTypes . value [ providerType . value ] ) return
358
380
let providerTypeDefaults = providerTypes . value [ providerType . value ]
@@ -377,7 +399,8 @@ export default {
377
399
378
400
return {
379
401
grid, apiTypes, providerTypes, providerType, providerModels, formModel, selectedModels,
380
- allProviderModels, updateSelected, onNav
402
+ allProviderModels, updateSelected, onNav,
403
+ checkStatus, checking,
381
404
}
382
405
}
383
406
}
0 commit comments