feat(ui): refresh Vue Bootstrap dashboard and network diagrams
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<script setup>
|
||||
defineProps({ name: { type: String, default: "grid" } });
|
||||
const paths = {
|
||||
shield: "M12 2 3 6v6c0 5 9 10 9 10s9-5 9-10V6Z M8 12l3 3 5-6",
|
||||
location: "M20 10c0 6-8 12-8 12S4 16 4 10a8 8 0 1 1 16 0 M15 10a3 3 0 1 1-6 0 3 3 0 0 1 6 0",
|
||||
home: "m3 10 9-7 9 7v10H3Z M9 20v-7h6v7",
|
||||
journal: "M5 3h14v18H5Z M8 7h8 M8 11h8 M8 15h5",
|
||||
grid: "M3 3h7v7H3Z M14 3h7v7h-7Z M3 14h7v7H3Z M14 14h7v7h-7Z",
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { snapshot, bridge, accessLabel } from "../composables/bridge.js";
|
||||
import AppIcon from "./AppIcon.vue";
|
||||
import HomeInsights from "./HomeInsights.vue";
|
||||
const draft = ref({
|
||||
revision: 0,
|
||||
columns: 2,
|
||||
@@ -14,6 +15,7 @@ const draft = ref({
|
||||
page = ref(0),
|
||||
arrange = ref(false),
|
||||
mode = ref("cards"),
|
||||
layoutOptions = ref(false),
|
||||
drag = ref(""),
|
||||
message = ref("");
|
||||
let owner = "";
|
||||
@@ -28,6 +30,7 @@ watch(
|
||||
page.value = 0;
|
||||
arrange.value = false;
|
||||
mode.value = "cards";
|
||||
layoutOptions.value = false;
|
||||
drag.value = "";
|
||||
message.value = "";
|
||||
}
|
||||
@@ -144,7 +147,8 @@ async function enter(h, network = false) {
|
||||
+ 新建家庭或场所
|
||||
</button>
|
||||
</div>
|
||||
<div class="home-toolbar">
|
||||
<HomeInsights />
|
||||
<div class="home-toolbar" :class="{ 'home-options-open': layoutOptions }">
|
||||
<div class="btn-group" role="group" aria-label="场所显示方式">
|
||||
<button
|
||||
id="home-card-view"
|
||||
@@ -164,7 +168,8 @@ async function enter(h, network = false) {
|
||||
<AppIcon name="network" /> 整体拓扑
|
||||
</button>
|
||||
</div>
|
||||
<div v-show="mode === 'cards'" class="home-layout-controls">
|
||||
<button v-show="mode === 'cards'" class="btn btn-outline-secondary home-layout-toggle" :aria-expanded="layoutOptions" aria-controls="home-layout-options" @click="layoutOptions = !layoutOptions">{{ layoutOptions ? '收起设置' : '布局设置' }}</button>
|
||||
<div id="home-layout-options" v-show="mode === 'cards'" class="home-layout-controls">
|
||||
<label
|
||||
>每页
|
||||
<select
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { snapshot } from '../composables/bridge.js';
|
||||
import { summarizeHomes } from '../composables/insights.mjs';
|
||||
import AppIcon from './AppIcon.vue';
|
||||
const summary = computed(() => summarizeHomes(snapshot.value.state.households));
|
||||
</script>
|
||||
<template>
|
||||
<section class="home-insights" aria-label="已授权场所概览">
|
||||
<article class="insight-welcome">
|
||||
<span class="insight-kicker">一处相连 · 各有归属</span>
|
||||
<h2>家与日常,尽在掌握</h2>
|
||||
<p>从一个空间出发,照看设备,也珍藏生活。</p>
|
||||
<div class="insight-scope"><AppIcon name="shield" /> 仅汇总你有权访问的家庭与场所</div>
|
||||
</article>
|
||||
<article class="insight-number">
|
||||
<span class="insight-icon"><AppIcon name="devices" /></span>
|
||||
<span class="insight-label">已登记设备</span>
|
||||
<strong>{{ summary.devices }}<small>台</small></strong>
|
||||
<span class="insight-foot">分布在 {{ summary.areas }} 处区域</span>
|
||||
</article>
|
||||
<article class="insight-distribution">
|
||||
<div class="insight-donut">
|
||||
<svg viewBox="0 0 120 120" role="img" :aria-label="'场所分布:' + (summary.kinds.map(k => k.label + k.count + '个').join(',') || '暂无场所')">
|
||||
<circle class="donut-track" cx="60" cy="60" r="48" fill="none" stroke-width="10" />
|
||||
<circle v-for="kind in summary.kinds" :key="kind.key" cx="60" cy="60" r="48" fill="none" stroke-width="10" pathLength="100" :stroke="kind.color" :stroke-dasharray="`${kind.share} ${100 - kind.share}`" :stroke-dashoffset="-kind.offset" transform="rotate(-90 60 60)" />
|
||||
</svg>
|
||||
<div aria-hidden="true"><strong>{{ summary.total }}</strong><small>家庭与场所</small></div>
|
||||
</div>
|
||||
<div class="insight-legend"><h3>空间分布</h3><span v-for="kind in summary.kinds" :key="kind.key"><i :style="{ background: kind.color }"></i>{{ kind.label }}<b>{{ kind.count }}</b></span><span v-if="!summary.total">等待添加空间</span></div>
|
||||
</article>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,31 @@
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { deviceView, snapshot, bridge, accessLabel } from '../composables/bridge.js';
|
||||
import { layoutNetwork } from '../composables/insights.mjs';
|
||||
const zoom = ref(1);
|
||||
const graph = computed(() => layoutNetwork(deviceView.value.rows));
|
||||
watch(() => snapshot.value.session + ':' + snapshot.value.state.familyId, () => { zoom.value = 1; });
|
||||
const open = node => bridge().enterDevice(node.device.source, node.device.id, 'device');
|
||||
</script>
|
||||
<template>
|
||||
<div v-if="graph.nodes.length" class="network-diagram">
|
||||
<div class="diagram-toolbar">
|
||||
<div><span class="diagram-dot"></span><strong>设备连接图</strong><span class="small text-secondary">{{ graph.nodes.length }} 台设备 · {{ graph.edges.length }} 条已登记连接</span></div>
|
||||
<label>缩放<select v-model.number="zoom" class="form-select form-select-sm" aria-label="网络图缩放"><option :value="0.75">75%</option><option :value="1">100%</option><option :value="1.25">125%</option></select></label>
|
||||
</div>
|
||||
<div class="diagram-scroll" tabindex="0" role="region" aria-label="设备连接图,可滚动查看;点击设备打开档案">
|
||||
<svg :width="graph.width * zoom" :height="graph.height * zoom" :viewBox="`0 0 ${graph.width} ${graph.height}`" class="network-svg" role="group" aria-label="已登记的网络连接">
|
||||
<path v-for="edge in graph.edges" :key="edge.id" :d="edge.path" class="network-edge" fill="none" />
|
||||
<g v-for="node in graph.nodes" :key="node.device.id" :transform="`translate(${node.x},${node.y})`" class="diagram-node" role="button" tabindex="0" :aria-label="node.device.name + ',打开设备档案'" @click="open(node)" @keydown.enter.prevent="open(node)" @keydown.space.prevent="open(node)">
|
||||
<title>{{ node.device.name }} · {{ node.device.deviceType }} · {{ (node.device.networkHosts || []).join(' / ') || 'IP 待填写' }}</title>
|
||||
<rect width="244" height="88" rx="12" class="diagram-node-bg" />
|
||||
<rect x="12" y="16" width="4" height="54" rx="2" :fill="node.device.source === 'camera' ? '#5c83cb' : '#258b76'" />
|
||||
<text x="28" y="26" class="diagram-node-type">{{ node.device.deviceType }} · {{ accessLabel(node.device.networkAccess) }}</text>
|
||||
<text x="28" y="48" class="diagram-node-title">{{ node.device.name.length > 14 ? node.device.name.slice(0, 14) + '…' : node.device.name }}</text>
|
||||
<text x="28" y="70" class="diagram-node-ip">{{ (node.device.networkHosts || [])[0] || 'IP 待填写' }}</text>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
<p class="diagram-note">点击节点查看名称、位置与网络详情。未登记上级的设备独立显示。</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from "../composables/bridge.js";
|
||||
import AppIcon from "./AppIcon.vue";
|
||||
import NetworkStatus from "./NetworkStatus.vue";
|
||||
import NetworkDiagram from "./NetworkDiagram.vue";
|
||||
const home = computed(() =>
|
||||
(snapshot.value.state.households || []).find(
|
||||
(h) => h.id === snapshot.value.state.familyId,
|
||||
@@ -27,6 +28,8 @@ const home = computed(() =>
|
||||
<p class="description">
|
||||
连线来自已确认的上级设备关系。上级未填写时单独列出;不代表已自动发现所有交换机或布线。
|
||||
</p>
|
||||
<NetworkDiagram />
|
||||
<h3 class="network-details-heading">设备与连接详情</h3>
|
||||
<div class="topology-nodes">
|
||||
<article
|
||||
v-for="row in deviceView.rows"
|
||||
|
||||
Reference in New Issue
Block a user