Feature: Boton para reiniciar conexion de instancia
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 51s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 51s
This commit is contained in:
@@ -99,6 +99,17 @@ export const useInstances = () => {
|
||||
return await $fetch(`/api/instances/${id}/status`)
|
||||
}
|
||||
|
||||
const resetInstance = async (id: string) => {
|
||||
await $fetch(`/api/instances/${id}/reset`, { method: 'POST' })
|
||||
|
||||
// Update local state
|
||||
const idx = instances.value.findIndex(i => i.id === id)
|
||||
if (idx !== -1) {
|
||||
instances.value[idx].status = 'disconnected'
|
||||
instances.value[idx].qrCode = null
|
||||
}
|
||||
}
|
||||
|
||||
// Computed helpers
|
||||
const connectedCount = computed(() =>
|
||||
instances.value.filter(i => i.status === 'connected').length
|
||||
@@ -115,6 +126,7 @@ export const useInstances = () => {
|
||||
deleteInstance,
|
||||
connectInstance,
|
||||
disconnectInstance,
|
||||
resetInstance,
|
||||
getQRCode,
|
||||
requestPairingCode,
|
||||
getInstanceStatus,
|
||||
|
||||
@@ -128,6 +128,16 @@
|
||||
>
|
||||
Ver QR
|
||||
</UButton>
|
||||
|
||||
<UButton
|
||||
v-if="instance.status !== 'disconnected'"
|
||||
size="sm"
|
||||
color="neutral"
|
||||
variant="soft"
|
||||
@click="resetInstanceHandler(instance.id)"
|
||||
>
|
||||
Reiniciar
|
||||
</UButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -179,7 +189,7 @@ definePageMeta({
|
||||
title: 'Dashboard',
|
||||
})
|
||||
|
||||
const { instances, loading, fetchInstances, createInstance: apiCreateInstance, connectInstance: apiConnect } = useInstances()
|
||||
const { instances, loading, fetchInstances, createInstance: apiCreateInstance, connectInstance: apiConnect, resetInstance: apiReset } = useInstances()
|
||||
|
||||
const showCreateModal = ref(false)
|
||||
const showQRModal = ref(false)
|
||||
@@ -216,6 +226,12 @@ const createInstance = async () => {
|
||||
|
||||
const connectInstance = async (id: string) => {
|
||||
await apiConnect(id)
|
||||
// Refresh to get updated status/QR
|
||||
await fetchInstances()
|
||||
}
|
||||
|
||||
const resetInstanceHandler = async (id: string) => {
|
||||
await apiReset(id)
|
||||
}
|
||||
|
||||
const showQR = (instance: any) => {
|
||||
|
||||
Reference in New Issue
Block a user