mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 17:44:46 +00:00
feat: change metric graph with selectors
This commit is contained in:
parent
51a2ac8931
commit
57faac6ddc
@ -23,6 +23,7 @@ export const Services = {
|
|||||||
label: name
|
label: name
|
||||||
group
|
group
|
||||||
layers
|
layers
|
||||||
|
normal
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<div class="widget-config flex-v">
|
<div class="widget-config flex-v">
|
||||||
<div class="graph">
|
<div class="graph" v-loading="loading">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<span>{{ states.widget.title }}</span>
|
<span>{{ states.widget.title }}</span>
|
||||||
<div class="tips" v-show="states.widget.tips">
|
<div class="tips" v-show="states.widget.tips">
|
||||||
@ -43,6 +43,7 @@ limitations under the License. -->
|
|||||||
:graph="states.graph"
|
:graph="states.graph"
|
||||||
@update="getSource"
|
@update="getSource"
|
||||||
@apply="getMetricsConfig"
|
@apply="getMetricsConfig"
|
||||||
|
@loading="setLoading"
|
||||||
/>
|
/>
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
<el-collapse-item :title="t('selectVisualization')" name="2">
|
<el-collapse-item :title="t('selectVisualization')" name="2">
|
||||||
@ -89,7 +90,7 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { reactive, defineComponent } from "vue";
|
import { reactive, defineComponent, ref } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
@ -123,6 +124,7 @@ export default defineComponent({
|
|||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const appStoreWithOut = useAppStoreWithOut();
|
const appStoreWithOut = useAppStoreWithOut();
|
||||||
const { selectedGrid, entity } = dashboardStore;
|
const { selectedGrid, entity } = dashboardStore;
|
||||||
|
const loading = ref<boolean>(false);
|
||||||
const states = reactive<{
|
const states = reactive<{
|
||||||
activeNames: string;
|
activeNames: string;
|
||||||
source: any;
|
source: any;
|
||||||
@ -192,6 +194,7 @@ export default defineComponent({
|
|||||||
function getSource(source: unknown) {
|
function getSource(source: unknown) {
|
||||||
states.source = source;
|
states.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMetricsConfig(opts: {
|
function getMetricsConfig(opts: {
|
||||||
metrics?: string[];
|
metrics?: string[];
|
||||||
metricTypes?: string[];
|
metricTypes?: string[];
|
||||||
@ -204,6 +207,10 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setLoading(load: boolean) {
|
||||||
|
loading.value = load;
|
||||||
|
}
|
||||||
|
|
||||||
function applyConfig() {
|
function applyConfig() {
|
||||||
const opts = {
|
const opts = {
|
||||||
...dashboardStore.selectedGrid,
|
...dashboardStore.selectedGrid,
|
||||||
@ -229,6 +236,7 @@ export default defineComponent({
|
|||||||
applyConfig,
|
applyConfig,
|
||||||
getSource,
|
getSource,
|
||||||
getMetricsConfig,
|
getMetricsConfig,
|
||||||
|
setLoading,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -78,7 +78,7 @@ const props = defineProps({
|
|||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const emit = defineEmits(["update", "apply"]);
|
const emit = defineEmits(["update", "apply", "loading"]);
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const { selectedGrid, entity, metrics, metricTypes } = dashboardStore;
|
const { selectedGrid, entity, metrics, metricTypes } = dashboardStore;
|
||||||
const states = reactive<{
|
const states = reactive<{
|
||||||
@ -173,7 +173,9 @@ async function queryMetrics() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit("loading", true);
|
||||||
const json = await dashboardStore.fetchMetricValue(params);
|
const json = await dashboardStore.fetchMetricValue(params);
|
||||||
|
emit("loading", false);
|
||||||
if (json.errors) {
|
if (json.errors) {
|
||||||
ElMessage.error(json.errors);
|
ElMessage.error(json.errors);
|
||||||
return;
|
return;
|
||||||
|
@ -150,9 +150,12 @@ function clickTabGrid(e: Event, item: LayoutConfig) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
document.body.addEventListener("click", handleClick, false);
|
document.body.addEventListener("click", handleClick, false);
|
||||||
|
|
||||||
|
const children = ref(
|
||||||
|
dashboardStore.layout[props.data.i].children[activeTabIndex.value].children
|
||||||
|
);
|
||||||
watch(
|
watch(
|
||||||
() =>
|
() => children.value,
|
||||||
dashboardStore.layout[props.data.i].children[activeTabIndex.value].children,
|
|
||||||
(data) => {
|
(data) => {
|
||||||
state.layout = data;
|
state.layout = data;
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,8 @@ import { toRefs, reactive, defineComponent, ref, watch } from "vue";
|
|||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import { LayoutConfig } from "@/types/dashboard";
|
import { LayoutConfig } from "@/types/dashboard";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
|
||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import graphs from "../graphs";
|
import graphs from "../graphs";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useProcessor";
|
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useProcessor";
|
||||||
@ -87,9 +87,6 @@ export default defineComponent({
|
|||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
|
|
||||||
if (props.data.metrics && props.data.metrics[0]) {
|
|
||||||
queryMetrics();
|
|
||||||
}
|
|
||||||
async function queryMetrics() {
|
async function queryMetrics() {
|
||||||
const params = await useQueryProcessor(props.data);
|
const params = await useQueryProcessor(props.data);
|
||||||
if (!params) {
|
if (!params) {
|
||||||
@ -118,14 +115,19 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
watch(
|
watch(
|
||||||
() => [props.data.metricTypes, props.data.metrics],
|
() => [
|
||||||
|
props.data.metricTypes,
|
||||||
|
props.data.metrics,
|
||||||
|
selectorStore.currentService,
|
||||||
|
],
|
||||||
(data, old) => {
|
(data, old) => {
|
||||||
if (data[0] === old[0] && data[1] === old[1]) {
|
if (data[0] === old[0] && data[1] === old[1] && data[2] === old[2]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
queryMetrics();
|
queryMetrics();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
state,
|
state,
|
||||||
appStore,
|
appStore,
|
||||||
|
@ -69,7 +69,8 @@ import { InstanceListConfig } from "@/types/dashboard";
|
|||||||
/*global defineProps */
|
/*global defineProps */
|
||||||
defineProps({
|
defineProps({
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object as PropType<{ [key: string]: number[] }>,
|
||||||
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
config: {
|
config: {
|
||||||
type: Object as PropType<InstanceListConfig>,
|
type: Object as PropType<InstanceListConfig>,
|
||||||
|
Loading…
Reference in New Issue
Block a user