mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-19 15:37:36 +00:00
update unit
This commit is contained in:
parent
169047c59e
commit
4ace3c682f
@ -27,6 +27,7 @@ export enum Calculations {
|
|||||||
Percentage = "percentage",
|
Percentage = "percentage",
|
||||||
ByteToKB = "byteToKB",
|
ByteToKB = "byteToKB",
|
||||||
Apdex = "apdex",
|
Apdex = "apdex",
|
||||||
|
Precision = "precision",
|
||||||
ConvertSeconds = "convertSeconds",
|
ConvertSeconds = "convertSeconds",
|
||||||
ConvertMilliseconds = "convertMilliseconds",
|
ConvertMilliseconds = "convertMilliseconds",
|
||||||
}
|
}
|
||||||
|
@ -330,6 +330,9 @@ export function aggregation(val: number, config: any): number | string {
|
|||||||
case Calculations.ConvertMilliseconds:
|
case Calculations.ConvertMilliseconds:
|
||||||
data = dayjs.unix(val).format("YYYY-MM-DD HH:mm:ss");
|
data = dayjs.unix(val).format("YYYY-MM-DD HH:mm:ss");
|
||||||
break;
|
break;
|
||||||
|
case Calculations.Precision:
|
||||||
|
data = data.toFixed(2);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
data;
|
data;
|
||||||
break;
|
break;
|
||||||
|
@ -128,6 +128,7 @@ const msg = {
|
|||||||
textUrl: "Text Hyperlink",
|
textUrl: "Text Hyperlink",
|
||||||
textAlign: "Text Align",
|
textAlign: "Text Align",
|
||||||
metricLabel: "Metric Label",
|
metricLabel: "Metric Label",
|
||||||
|
showUnit: "Show Unit",
|
||||||
hourTip: "Select Hour",
|
hourTip: "Select Hour",
|
||||||
minuteTip: "Select Minute",
|
minuteTip: "Select Minute",
|
||||||
secondTip: "Select Second",
|
secondTip: "Select Second",
|
||||||
|
@ -128,6 +128,7 @@ const msg = {
|
|||||||
textUrl: "文本超链接",
|
textUrl: "文本超链接",
|
||||||
textAlign: "文本对齐",
|
textAlign: "文本对齐",
|
||||||
metricLabel: "指标标签",
|
metricLabel: "指标标签",
|
||||||
|
showUnit: "显示单位",
|
||||||
hourTip: "选择小时",
|
hourTip: "选择小时",
|
||||||
minuteTip: "选择分钟",
|
minuteTip: "选择分钟",
|
||||||
secondTip: "选择秒数",
|
secondTip: "选择秒数",
|
||||||
|
@ -96,7 +96,7 @@ export interface AreaConfig {
|
|||||||
export interface CardConfig {
|
export interface CardConfig {
|
||||||
type?: string;
|
type?: string;
|
||||||
fontSize?: number;
|
fontSize?: number;
|
||||||
showUint?: boolean;
|
showUnit?: boolean;
|
||||||
textAlign?: "center" | "right" | "left";
|
textAlign?: "center" | "right" | "left";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,15 @@ limitations under the License. -->
|
|||||||
@change="updateConfig({ fontSize })"
|
@change="updateConfig({ fontSize })"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="item">
|
||||||
|
<span class="label">{{ t("showUnit") }}</span>
|
||||||
|
<el-switch
|
||||||
|
v-model="showUnit"
|
||||||
|
active-text="Yes"
|
||||||
|
inactive-text="No"
|
||||||
|
@change="updateConfig({ showUnit })"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
@ -36,13 +45,14 @@ const { t } = useI18n();
|
|||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const { selectedGrid } = dashboardStore;
|
const { selectedGrid } = dashboardStore;
|
||||||
const fontSize = ref(selectedGrid.graph.fontSize);
|
const fontSize = ref(selectedGrid.graph.fontSize);
|
||||||
|
const showUnit = ref<boolean>(selectedGrid.graph.showUnit);
|
||||||
|
|
||||||
function updateConfig(param: { [key: string]: unknown }) {
|
function updateConfig(param: { [key: string]: unknown }) {
|
||||||
const graph = {
|
const graph = {
|
||||||
...selectedGrid.graph,
|
...dashboardStore.selectedGrid.graph,
|
||||||
...param,
|
...param,
|
||||||
};
|
};
|
||||||
dashboardStore.selectWidget({ ...selectedGrid, graph });
|
dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, graph });
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -95,7 +95,6 @@ const metricType = ref<string>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
function changeConfigs(index: number, param: { [key: string]: string }) {
|
function changeConfigs(index: number, param: { [key: string]: string }) {
|
||||||
console.log(param);
|
|
||||||
const metricConfig = dashboardStore.selectedGrid.metricConfig || [];
|
const metricConfig = dashboardStore.selectedGrid.metricConfig || [];
|
||||||
metricConfig[index] = { ...metricConfig[index], ...param };
|
metricConfig[index] = { ...metricConfig[index], ...param };
|
||||||
|
|
||||||
|
@ -274,4 +274,5 @@ export const CalculationOpts = [
|
|||||||
value: "convertMilliseconds",
|
value: "convertMilliseconds",
|
||||||
},
|
},
|
||||||
{ label: "Convert seconds to YYYY-MM-DD HH:mm:ss", value: "convertSeconds" },
|
{ label: "Convert seconds to YYYY-MM-DD HH:mm:ss", value: "convertSeconds" },
|
||||||
|
{ label: "Precision is 2", value: "precision" },
|
||||||
];
|
];
|
||||||
|
@ -26,13 +26,13 @@ limitations under the License. -->
|
|||||||
? null
|
? null
|
||||||
: singleVal.toFixed(2)
|
: singleVal.toFixed(2)
|
||||||
}}
|
}}
|
||||||
<span v-show="config.showUint">
|
<span v-show="config.showUnit">
|
||||||
<i v-for="(m, index) in metricConfig" :key="index">{{ m.unit }}</i>
|
{{ metricConfig[0]?.unit }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, PropType, ref } from "vue";
|
import { computed, PropType } from "vue";
|
||||||
import { CardConfig, MetricConfigOpt } from "@/types/dashboard";
|
import { CardConfig, MetricConfigOpt } from "@/types/dashboard";
|
||||||
|
|
||||||
/*global defineProps */
|
/*global defineProps */
|
||||||
@ -43,10 +43,15 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
type: Object as PropType<CardConfig & { metricConfig?: MetricConfigOpt[] }>,
|
type: Object as PropType<CardConfig & { metricConfig?: MetricConfigOpt[] }>,
|
||||||
default: () => ({ fontSize: 12, showUint: true, textAlign: "center" }),
|
default: () => ({
|
||||||
|
fontSize: 12,
|
||||||
|
showUnit: true,
|
||||||
|
textAlign: "center",
|
||||||
|
metricConfig: [],
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const metricConfig = ref<MetricConfigOpt[]>(props.config.metricConfig || []);
|
const metricConfig = computed(() => props.config.metricConfig || []);
|
||||||
const key = computed(() => Object.keys(props.data)[0]);
|
const key = computed(() => Object.keys(props.data)[0]);
|
||||||
const singleVal = computed(() => props.data[key.value]);
|
const singleVal = computed(() => props.data[key.value]);
|
||||||
</script>
|
</script>
|
||||||
|
@ -44,7 +44,7 @@ limitations under the License. -->
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-for="(metric, index) in config.metrics"
|
v-for="(metric, index) in config.metrics"
|
||||||
:label="metric"
|
:label="`${metric} ${getUnit(index)}`"
|
||||||
:key="metric + index"
|
:key="metric + index"
|
||||||
>
|
>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@ -190,6 +190,17 @@ async function searchList() {
|
|||||||
const limit = searchText.value ? undefined : total;
|
const limit = searchText.value ? undefined : total;
|
||||||
await queryEndpoints(limit);
|
await queryEndpoints(limit);
|
||||||
}
|
}
|
||||||
|
function getUnit(index: number) {
|
||||||
|
const u =
|
||||||
|
(props.config.metricConfig &&
|
||||||
|
props.config.metricConfig[index] &&
|
||||||
|
props.config.metricConfig[index].unit) ||
|
||||||
|
"";
|
||||||
|
if (u) {
|
||||||
|
return `(${u})`;
|
||||||
|
}
|
||||||
|
return u;
|
||||||
|
}
|
||||||
watch(
|
watch(
|
||||||
() => [props.config.metricTypes, props.config.metrics],
|
() => [props.config.metricTypes, props.config.metrics],
|
||||||
async () => {
|
async () => {
|
||||||
|
@ -44,7 +44,7 @@ limitations under the License. -->
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-for="(metric, index) in config.metrics"
|
v-for="(metric, index) in config.metrics"
|
||||||
:label="metric"
|
:label="`${metric} ${getUnit(index)}`"
|
||||||
:key="metric + index"
|
:key="metric + index"
|
||||||
>
|
>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@ -219,6 +219,18 @@ function searchList() {
|
|||||||
instances.value = searchInstances.value.splice(0, pageSize);
|
instances.value = searchInstances.value.splice(0, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUnit(index: number) {
|
||||||
|
const u =
|
||||||
|
(props.config.metricConfig &&
|
||||||
|
props.config.metricConfig[index] &&
|
||||||
|
props.config.metricConfig[index].unit) ||
|
||||||
|
"";
|
||||||
|
if (u) {
|
||||||
|
return `(${u})`;
|
||||||
|
}
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [props.config.metricTypes, props.config.metrics],
|
() => [props.config.metricTypes, props.config.metrics],
|
||||||
() => {
|
() => {
|
||||||
|
@ -56,7 +56,7 @@ limitations under the License. -->
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-for="(metric, index) in config.metrics"
|
v-for="(metric, index) in config.metrics"
|
||||||
:label="metric"
|
:label="`${metric} ${getUnit(index)}`"
|
||||||
:key="metric + index"
|
:key="metric + index"
|
||||||
>
|
>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
@ -255,6 +255,17 @@ function searchList() {
|
|||||||
);
|
);
|
||||||
services.value = searchServices.splice(0, pageSize);
|
services.value = searchServices.splice(0, pageSize);
|
||||||
}
|
}
|
||||||
|
function getUnit(index: number) {
|
||||||
|
const u =
|
||||||
|
(props.config.metricConfig &&
|
||||||
|
props.config.metricConfig[index] &&
|
||||||
|
props.config.metricConfig[index].unit) ||
|
||||||
|
"";
|
||||||
|
if (u) {
|
||||||
|
return `(${u})`;
|
||||||
|
}
|
||||||
|
return u;
|
||||||
|
}
|
||||||
watch(
|
watch(
|
||||||
() => [props.config.metricTypes, props.config.metrics],
|
() => [props.config.metricTypes, props.config.metrics],
|
||||||
() => {
|
() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user