fix(ui): full-row host click, agent version label on host card
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<p v-else-if="loading">Загрузка…</p>
|
||||
<template v-else>
|
||||
<p>Всего: {{ data?.total ?? 0 }}</p>
|
||||
<table>
|
||||
<table class="hosts-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><button type="button" class="th-sort" @click="setSort('id')">ID {{ sortMark('id') }}</button></th>
|
||||
@@ -29,24 +29,24 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="h in sortedItems" :key="h.id">
|
||||
<tr
|
||||
v-for="h in sortedItems"
|
||||
:key="h.id"
|
||||
class="sac-host-row"
|
||||
tabindex="0"
|
||||
:title="`Карточка хоста ${h.hostname}`"
|
||||
@click="openHost(h.id)"
|
||||
@keydown.enter="openHost(h.id)"
|
||||
>
|
||||
<td>{{ h.id }}</td>
|
||||
<td>
|
||||
<RouterLink
|
||||
:to="`/hosts/${h.id}`"
|
||||
class="sac-host-nav-link"
|
||||
:title="`Карточка хоста ${h.hostname}`"
|
||||
>
|
||||
{{ h.display_name || h.hostname }}
|
||||
</RouterLink>
|
||||
</td>
|
||||
<td>{{ h.display_name || h.hostname }}</td>
|
||||
<td>{{ h.hostname }}</td>
|
||||
<td>{{ h.product_version || "—" }}</td>
|
||||
<td>{{ h.os_family }}</td>
|
||||
<td>{{ h.ipv4 || "—" }}</td>
|
||||
<td :class="'agent-' + h.agent_status">{{ agentLabel(h.agent_status) }}</td>
|
||||
<td>{{ h.last_heartbeat_at ? formatDt(h.last_heartbeat_at) : "—" }}</td>
|
||||
<td>
|
||||
<td @click.stop>
|
||||
<RouterLink
|
||||
v-if="h.last_daily_report_at"
|
||||
:to="{ path: '/reports', query: { hostname: h.hostname } }"
|
||||
@@ -57,7 +57,7 @@
|
||||
</td>
|
||||
<td>{{ formatDt(h.last_seen_at) }}</td>
|
||||
<td>{{ h.event_count ?? 0 }}</td>
|
||||
<td class="actions">
|
||||
<td class="actions" @click.stop>
|
||||
<button
|
||||
type="button"
|
||||
class="danger"
|
||||
@@ -76,8 +76,11 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { apiFetch, type HostListResponse, type HostSummary } from "../api";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const data = ref<HostListResponse | null>(null);
|
||||
const loading = ref(false);
|
||||
const error = ref("");
|
||||
@@ -147,6 +150,10 @@ function agentLabel(status: string) {
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
function openHost(id: number) {
|
||||
router.push(`/hosts/${id}`);
|
||||
}
|
||||
|
||||
function agentStatusOrder(status: string) {
|
||||
if (status === "online") return 0;
|
||||
if (status === "stale") return 1;
|
||||
|
||||
Reference in New Issue
Block a user