feat: set default depth

This commit is contained in:
Qiuxia Fan 2022-02-19 22:38:20 +08:00
parent 1ebf0ba261
commit 46099781c9
9 changed files with 33 additions and 25 deletions

View File

@ -239,6 +239,7 @@ const msg = {
defaultOrder: "Default Order", defaultOrder: "Default Order",
chartType: "Chart Type", chartType: "Chart Type",
currentDepth: "Current Depth", currentDepth: "Current Depth",
defaultDepth: "Default Depth",
traceTagsTip: `Only tags defined in the core/default/searchableTracesTags are searchable. traceTagsTip: `Only tags defined in the core/default/searchableTracesTags are searchable.
Check more details on the Configuration Vocabulary page`, Check more details on the Configuration Vocabulary page`,
tagsLink: "Configuration Vocabulary page", tagsLink: "Configuration Vocabulary page",

View File

@ -240,6 +240,7 @@ const msg = {
defaultOrder: "默认顺序", defaultOrder: "默认顺序",
chartType: "图表类型", chartType: "图表类型",
currentDepth: "当前深度", currentDepth: "当前深度",
defaultDepth: "默认深度",
traceTagsTip: traceTagsTip:
"只有core/default/searchableTracesTags中定义的标记才可搜索。查看配置词汇表页面上的更多详细信息。", "只有core/default/searchableTracesTags中定义的标记才可搜索。查看配置词汇表页面上的更多详细信息。",
tagsLink: "配置词汇页", tagsLink: "配置词汇页",

View File

@ -105,25 +105,6 @@ export const ConfigData3: any = [
{ {
x: 0, x: 0,
y: 0, y: 0,
w: 4,
h: 6,
i: "1",
type: "Topology",
widget: {
title: "Topology",
tips: "Topology",
},
graph: {
fontColor: "white",
backgroundColor: "green",
iconTheme: true,
content: "Topology",
fontSize: 18,
},
},
{
x: 4,
y: 0,
w: 8, w: 8,
h: 12, h: 12,
i: "0", i: "0",

View File

@ -35,6 +35,7 @@ interface TopologyState {
nodeMetrics: MetricVal; nodeMetrics: MetricVal;
linkServerMetrics: MetricVal; linkServerMetrics: MetricVal;
linkClientMetrics: MetricVal; linkClientMetrics: MetricVal;
defaultDepth: string;
} }
export const topologyStore = defineStore({ export const topologyStore = defineStore({
@ -47,6 +48,7 @@ export const topologyStore = defineStore({
nodeMetrics: {}, nodeMetrics: {},
linkServerMetrics: {}, linkServerMetrics: {},
linkClientMetrics: {}, linkClientMetrics: {},
defaultDepth: "2",
}), }),
actions: { actions: {
setNode(node: Node) { setNode(node: Node) {
@ -112,6 +114,9 @@ export const topologyStore = defineStore({
setLinkClientMetrics(m: { id: string; value: unknown }[]) { setLinkClientMetrics(m: { id: string; value: unknown }[]) {
this.linkClientMetrics = m; this.linkClientMetrics = m;
}, },
setDefaultDepth(val: number) {
this.defaultDepth = val;
},
async getDepthServiceTopology(serviceIds: string[], depth: number) { async getDepthServiceTopology(serviceIds: string[], depth: number) {
const res = await this.getServicesTopology(serviceIds); const res = await this.getServicesTopology(serviceIds);
if (depth > 1) { if (depth > 1) {

View File

@ -119,4 +119,5 @@ export interface TopologyConfig {
iconTheme?: boolean; iconTheme?: boolean;
content?: string; content?: string;
fontSize?: number; fontSize?: number;
depth?: string;
} }

View File

@ -66,20 +66,34 @@ limitations under the License. -->
@change="changeConfig({ content })" @change="changeConfig({ content })"
/> />
</div> </div>
<div class="item">
<span class="label">{{ t("defaultDepth") }}</span>
<Selector
class="inputs"
:value="depth"
:options="DepthList"
@change="changeDepth($event)"
/>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { ref } from "vue"; import { ref } from "vue";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import { DepthList } from "../../data";
import { Option } from "@/types/app";
import { useTopologyStore } from "@/store/modules/topology";
const { t } = useI18n(); const { t } = useI18n();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const topologyStore = useTopologyStore();
const { selectedGrid } = dashboardStore; const { selectedGrid } = dashboardStore;
const iconTheme = ref(selectedGrid.graph.iconTheme || true); const iconTheme = ref(selectedGrid.graph.iconTheme || true);
const backgroundColor = ref(selectedGrid.graph.backgroundColor || "green"); const backgroundColor = ref(selectedGrid.graph.backgroundColor || "green");
const fontColor = ref(selectedGrid.graph.fontColor || "white"); const fontColor = ref(selectedGrid.graph.fontColor || "white");
const content = ref<string>(selectedGrid.graph.content); const content = ref<string>(selectedGrid.graph.content);
const fontSize = ref<number>(selectedGrid.graph.fontSize); const fontSize = ref<number>(selectedGrid.graph.fontSize);
const depth = ref<string>(selectedGrid.graph.depth);
const colors = [ const colors = [
{ {
label: "Green", label: "Green",
@ -92,7 +106,7 @@ const colors = [
{ label: "Black", value: "black" }, { label: "Black", value: "black" },
{ label: "Orange", value: "orange" }, { label: "Orange", value: "orange" },
]; ];
topologyStore.setDefaultDepth(depth.value);
function changeConfig(param: { [key: string]: unknown }) { function changeConfig(param: { [key: string]: unknown }) {
const { selectedGrid } = dashboardStore; const { selectedGrid } = dashboardStore;
const graph = { const graph = {
@ -101,6 +115,11 @@ function changeConfig(param: { [key: string]: unknown }) {
}; };
dashboardStore.selectWidget({ ...selectedGrid, graph }); dashboardStore.selectWidget({ ...selectedGrid, graph });
} }
function changeDepth(opt: Option[]) {
const val = opt[0].value;
topologyStore.setDefaultDepth(val);
changeConfig({ depth: val });
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.slider { .slider {

View File

@ -108,7 +108,7 @@ const items = ref<
{ id: "inspect", title: "Inspect", func: handleInspect }, { id: "inspect", title: "Inspect", func: handleInspect },
{ id: "alarm", title: "Alarm", func: handleGoAlarm }, { id: "alarm", title: "Alarm", func: handleGoAlarm },
]); ]);
const depth = ref<string>("2"); const depth = ref<string>(topologyStore.defaultDepth);
onMounted(async () => { onMounted(async () => {
loading.value = true; loading.value = true;
@ -468,7 +468,7 @@ onBeforeUnmount(() => {
position: absolute; position: absolute;
top: 70px; top: 70px;
right: 0; right: 0;
width: 380px; width: 400px;
height: 700px; height: 700px;
background-color: #2b3037; background-color: #2b3037;
overflow: auto; overflow: auto;

View File

@ -209,7 +209,7 @@ function handleClick(event: any) {
position: absolute; position: absolute;
top: 40px; top: 40px;
right: 0; right: 0;
width: 380px; width: 400px;
height: 700px; height: 700px;
background-color: #2b3037; background-color: #2b3037;
overflow: auto; overflow: auto;

View File

@ -369,7 +369,7 @@ function addMetric() {
.inputs { .inputs {
margin-top: 8px; margin-top: 8px;
width: 350px; width: 370px;
} }
.item { .item {
@ -397,6 +397,6 @@ function addMetric() {
} }
.delete { .delete {
margin: 0 1px; margin: 0 3px;
} }
</style> </style>