Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: View data value related dashboards in TopList widgets #425

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/hooks/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ export const RespFields: Indexable = {
name: id
value
refId: traceID
owner {
scope
serviceID
serviceName
normal
serviceInstanceID
serviceInstanceName
endpointID
endpointName
}
}
}
error
Expand Down
2 changes: 1 addition & 1 deletion src/layout/components/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ limitations under the License. -->
<Icon iconName="retry" :loading="appStore.autoRefresh" class="middle" />
</span>
<span class="version ml-5 cp">
<el-popover trigger="hover" width="250" placement="bottom" :content="appStore.version">
<el-popover trigger="hover" :width="250" placement="bottom" :content="appStore.version">
<template #reference>
<span>
<Icon iconName="info_outline" size="middle" />
Expand Down
2 changes: 2 additions & 0 deletions src/locales/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@ const msg = {
hierarchyNodeDashboard: "As dashboard for Hierarchy Graph Node",
valueMappings: "Value Mappings",
mappingTip: "Notice: The mapping key is a Regex string, e.g. ^([0-9])$",
valueDashboard: "Data Value Related Dashboard",
viewValueDashboard: "View Dashboard",
};
export default msg;
2 changes: 2 additions & 0 deletions src/locales/lang/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,7 @@ const msg = {
hierarchyNodeDashboard: "As dashboard for Hierarchy Graph Node",
valueMappings: "Value Mappings",
mappingTip: "Aviso: La clave de mapeo es una cadena Regex, p. ej. ^([0-9])$",
valueDashboard: "Data Value Related Dashboard",
viewValueDashboard: "View Dashboard",
};
export default msg;
2 changes: 2 additions & 0 deletions src/locales/lang/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,5 +386,7 @@ const msg = {
hierarchyNodeDashboard: "作为层次图节点的dashboard",
valueMappings: "值映射",
mappingTip: "注意: 映射键是一个正则表达式字符串,比如 ^([0-9])$",
valueDashboard: "数据值相关的仪表板",
viewValueDashboard: "查看仪表板",
};
export default msg;
1 change: 1 addition & 0 deletions src/types/dashboard.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface LayoutConfig {
relatedTrace?: RelatedTrace;
subExpressions?: string[];
subTypesOfMQE?: string[];
valueRelatedDashboard?: string;
}
export type RelatedTrace = {
duration: DurationTime;
Expand Down
1 change: 1 addition & 0 deletions src/views/dashboard/Widget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ limitations under the License. -->
typesOfMQE: typesOfMQE || [],
subExpressions: config.subExpressions || [],
subTypesOfMQE: config.subTypesOfMQE || [],
valueRelatedDashboard: config.valueRelatedDashboard,
}"
:needQuery="true"
/>
Expand Down
1 change: 1 addition & 0 deletions src/views/dashboard/configuration/Widget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ limitations under the License. -->
typesOfMQE: dashboardStore.selectedGrid.typesOfMQE || [],
subExpressions: dashboardStore.selectedGrid.subExpressions || [],
subTypesOfMQE: dashboardStore.selectedGrid.subTypesOfMQE || [],
valueRelatedDashboard: dashboardStore.selectedGrid.valueRelatedDashboard,
}"
:needQuery="true"
@expressionTips="getErrors"
Expand Down
47 changes: 43 additions & 4 deletions src/views/dashboard/configuration/widget/metric/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ limitations under the License. -->
{{ type.label }}
</span>
</div>
<div v-if="states.isTopList" class="mt-10">
<div>{{ t("valueDashboard") }}</div>
<div>
<Selector
:value="states.valueRelatedDashboard || ''"
:options="states.dashboardList"
size="small"
placeholder="Please select a dashboard name"
@change="changeValueDashboard"
class="selectors"
:clearable="true"
/>
</div>
</div>
</template>
<script lang="ts" setup>
import { reactive, ref, computed } from "vue";
Expand Down Expand Up @@ -140,21 +154,25 @@ limitations under the License. -->
metricTypes: string[];
metricTypeList: Option[][];
isList: boolean;
isTopList: boolean;
dashboardName: string;
dashboardList: ((DashboardItem & { label: string; value: string }) | any)[];
tips: string[];
subTips: string[];
valueRelatedDashboard: string;
}>({
metrics: metrics.value.length ? metrics.value : [""],
metricTypes: typesOfMQE.value.length ? typesOfMQE.value : [""],
metricTypeList: [],
isList: false,
isTopList: false,
dashboardName: graph.value.dashboardName,
dashboardList: [{ label: "", value: "" }],
tips: [],
subTips: [],
subMetrics: subMetrics.value.length ? subMetrics.value : [""],
subMetricTypes: subMetricTypes.value.length ? subMetricTypes.value : [""],
valueRelatedDashboard: dashboardStore.selectedGrid.valueRelatedDashboard,
});
const currentMetricConfig = ref<MetricConfigOpt>({
unit: "",
Expand All @@ -163,6 +181,7 @@ limitations under the License. -->
sortOrder: "DES",
});

states.isTopList = graph.value.type === ChartTypes[4].value;
states.isList = ListChartTypes.includes(graph.value.type);
const defaultLen = ref<number>(states.isList ? 5 : 20);

Expand All @@ -187,9 +206,10 @@ limitations under the License. -->
const arr = list.reduce((prev: (DashboardItem & { label: string; value: string })[], d: DashboardItem) => {
if (d.layer === dashboardStore.layerId) {
if (
(d.entity === EntityType[0].value && chart === "ServiceList") ||
(d.entity === EntityType[2].value && chart === "EndpointList") ||
(d.entity === EntityType[3].value && chart === "InstanceList")
(d.entity === EntityType[0].value && chart === ChartTypes[8].value) ||
(d.entity === EntityType[2].value && chart === ChartTypes[9].value) ||
(d.entity === EntityType[3].value && chart === ChartTypes[10].value) ||
states.isTopList
) {
prev.push({
...d,
Expand Down Expand Up @@ -254,9 +274,28 @@ limitations under the License. -->
typesOfMQE: states.metricTypes,
});
emit("update", params.source || {});
if (states.isTopList) {
const values: any = Object.values(params.source)[0];
if (!values) {
return;
}
states.dashboardList = states.dashboardList.filter((d) => d.entity === values[0].owner.scope);
}
}

function changeValueDashboard(opt: { value: string }[]) {
if (!opt[0]) {
states.valueRelatedDashboard = "";
} else {
states.valueRelatedDashboard = opt[0].value;
}
dashboardStore.selectWidget({
...dashboardStore.selectedGrid,
valueRelatedDashboard: states.valueRelatedDashboard,
});
}

function changeDashboard(opt: any) {
function changeDashboard(opt: { value: string }[]) {
if (!opt[0]) {
states.dashboardName = "";
} else {
Expand Down
1 change: 1 addition & 0 deletions src/views/dashboard/controls/Widget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ limitations under the License. -->
typesOfMQE: typesOfMQE || [],
subExpressions: data.subExpressions || [],
subTypesOfMQE: data.subTypesOfMQE || [],
valueRelatedDashboard: data.valueRelatedDashboard,
}"
:needQuery="needQuery"
@click="clickHandle"
Expand Down
31 changes: 27 additions & 4 deletions src/views/dashboard/graphs/TopList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ limitations under the License. -->
<div class="operation" @click="viewTrace(i)" v-show="refIdType === RefIdTypes[0].value">
<span>{{ t("viewTrace") }}</span>
</div>
<div class="operation" @click="viewDashboard(i)">
<span>{{ t("viewValueDashboard") }}</span>
</div>
</el-popover>
</div>
<el-progress
Expand All @@ -61,12 +64,14 @@ limitations under the License. -->
import type { PropType } from "vue";
import { useI18n } from "vue-i18n";
import { computed, ref } from "vue";
import router from "@/router";
import { useDashboardStore } from "@/store/modules/dashboard";
import copy from "@/utils/copy";
import { TextColors } from "@/views/dashboard/data";
import { TextColors, MetricCatalog } from "@/views/dashboard/data";
import Trace from "@/views/dashboard/related/trace/Index.vue";
import { WidgetType, QueryOrders, Status, RefIdTypes, ExpressionResultType } from "@/views/dashboard/data";

/*global defineProps */
/*global defineProps, Recordable*/
const props = defineProps({
data: {
type: Object as PropType<{
Expand All @@ -80,12 +85,14 @@ limitations under the License. -->
expressions: string[];
typesOfMQE: string[];
relatedTrace: any;
valueRelatedDashboard: string;
}>,
default: () => ({ color: "purple" }),
},
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
});
const { t } = useI18n();
const dashboardStore = useDashboardStore();
const showTrace = ref<boolean>(false);
const traceOptions = ref<{ type: string; filters?: unknown }>({
type: WidgetType.Trace,
Expand Down Expand Up @@ -122,6 +129,23 @@ limitations under the License. -->
};
showTrace.value = true;
}
function viewDashboard(item: Recordable) {
const { owner } = item;
let path;
if (owner.scope === MetricCatalog.SERVICE) {
path = `/dashboard/${dashboardStore.layerId}/${owner.scope}/${owner.serviceID}/${props.config.valueRelatedDashboard}`;
}
if (owner.scope === MetricCatalog.SERVICE_INSTANCE) {
path = `/dashboard/${dashboardStore.layerId}/${owner.scope}/${owner.serviceID}/${owner.serviceInstanceID}/${props.config.valueRelatedDashboard}`;
}
if (owner.scope === MetricCatalog.ENDPOINT) {
path = `/dashboard/${dashboardStore.layerId}/${owner.scope}/${owner.serviceID}/${owner.endpointID}/${props.config.valueRelatedDashboard}`;
}
if (!path) {
return;
}
router.push(path);
}
</script>
<style lang="scss" scoped>
.top-list {
Expand Down Expand Up @@ -187,11 +211,10 @@ limitations under the License. -->
}

.operation {
padding: 5px 0;
padding: 5px;
color: $font-color;
cursor: pointer;
position: relative;
text-align: center;
font-size: $font-size-smaller;

&:hover {
Expand Down
Loading