mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 00:45:26 +00:00
update list graph
This commit is contained in:
parent
1a1494bab7
commit
ae09693c15
@ -38,7 +38,7 @@ const props = defineProps({
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await setOptions(props.option);
|
await setOptions(props.option);
|
||||||
addResizeListener(unref(chartRef), resize);
|
chartRef.value && addResizeListener(unref(chartRef), resize);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const instance = getInstance();
|
const instance = getInstance();
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ limitations under the License. -->
|
|||||||
:multiple="multiple"
|
:multiple="multiple"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:style="{ borderRadius }"
|
:style="{ borderRadius }"
|
||||||
|
:clearable="clearable"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in options"
|
v-for="item in options"
|
||||||
@ -60,6 +61,7 @@ const props = defineProps({
|
|||||||
borderRadius: { type: Number, default: 3 },
|
borderRadius: { type: Number, default: 3 },
|
||||||
multiple: { type: Boolean, default: false },
|
multiple: { type: Boolean, default: false },
|
||||||
disabled: { type: Boolean, default: false },
|
disabled: { type: Boolean, default: false },
|
||||||
|
clearable: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const selected = ref<string[] | string>(props.value);
|
const selected = ref<string[] | string>(props.value);
|
||||||
|
@ -96,6 +96,7 @@ export function useECharts(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setOptions(options: ECOption, clear = true) {
|
function setOptions(options: ECOption, clear = true) {
|
||||||
|
console.log(options);
|
||||||
cacheOptions.value = options;
|
cacheOptions.value = options;
|
||||||
if (unref(elRef)?.offsetHeight === 0) {
|
if (unref(elRef)?.offsetHeight === 0) {
|
||||||
useTimeoutFn(() => {
|
useTimeoutFn(() => {
|
||||||
|
@ -37,8 +37,9 @@ limitations under the License. -->
|
|||||||
metrics: dashboardStore.selectedGrid.metrics,
|
metrics: dashboardStore.selectedGrid.metrics,
|
||||||
metricTypes: dashboardStore.selectedGrid.metricTypes,
|
metricTypes: dashboardStore.selectedGrid.metricTypes,
|
||||||
standard: dashboardStore.selectedGrid.standard,
|
standard: dashboardStore.selectedGrid.standard,
|
||||||
isEdit: true,
|
|
||||||
}"
|
}"
|
||||||
|
:isEdit="isEdit"
|
||||||
|
@changeOpt="setStatus"
|
||||||
/>
|
/>
|
||||||
<div v-show="!dashboardStore.selectedGrid.graph.type" class="no-data">
|
<div v-show="!dashboardStore.selectedGrid.graph.type" class="no-data">
|
||||||
{{ t("noData") }}
|
{{ t("noData") }}
|
||||||
@ -51,7 +52,11 @@ limitations under the License. -->
|
|||||||
:style="{ '--el-collapse-header-font-size': '15px' }"
|
:style="{ '--el-collapse-header-font-size': '15px' }"
|
||||||
>
|
>
|
||||||
<el-collapse-item :title="t('selectVisualization')" name="1">
|
<el-collapse-item :title="t('selectVisualization')" name="1">
|
||||||
<MetricOptions @update="getSource" @loading="setLoading" />
|
<MetricOptions
|
||||||
|
@update="getSource"
|
||||||
|
@changeOpt="setStatus"
|
||||||
|
@loading="setLoading"
|
||||||
|
/>
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
<el-collapse-item :title="t('graphStyles')" name="2">
|
<el-collapse-item :title="t('graphStyles')" name="2">
|
||||||
<component :is="`${dashboardStore.selectedGrid.graph.type}Config`" />
|
<component :is="`${dashboardStore.selectedGrid.graph.type}Config`" />
|
||||||
@ -85,6 +90,7 @@ import configs from "./widget/graph-styles";
|
|||||||
import WidgetOptions from "./widget/WidgetOptions.vue";
|
import WidgetOptions from "./widget/WidgetOptions.vue";
|
||||||
import StandardOptions from "./widget/StandardOptions.vue";
|
import StandardOptions from "./widget/StandardOptions.vue";
|
||||||
import MetricOptions from "./widget/MetricOptions.vue";
|
import MetricOptions from "./widget/MetricOptions.vue";
|
||||||
|
import { ListChartTypes } from "../data";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "ConfigEdit",
|
name: "ConfigEdit",
|
||||||
@ -101,6 +107,7 @@ export default defineComponent({
|
|||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const appStoreWithOut = useAppStoreWithOut();
|
const appStoreWithOut = useAppStoreWithOut();
|
||||||
const loading = ref<boolean>(false);
|
const loading = ref<boolean>(false);
|
||||||
|
const isEdit = ref<boolean>(false);
|
||||||
const states = reactive<{
|
const states = reactive<{
|
||||||
activeNames: string;
|
activeNames: string;
|
||||||
source: unknown;
|
source: unknown;
|
||||||
@ -123,8 +130,13 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applyConfig() {
|
function applyConfig() {
|
||||||
dashboardStore.setConfigs(dashboardStore.selectedGrid);
|
|
||||||
dashboardStore.setConfigPanel(false);
|
dashboardStore.setConfigPanel(false);
|
||||||
|
setStatus(true);
|
||||||
|
dashboardStore.setConfigs(dashboardStore.selectedGrid);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setStatus(p: boolean) {
|
||||||
|
isEdit.value = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelConfig() {
|
function cancelConfig() {
|
||||||
@ -143,6 +155,8 @@ export default defineComponent({
|
|||||||
cancelConfig,
|
cancelConfig,
|
||||||
getSource,
|
getSource,
|
||||||
setLoading,
|
setLoading,
|
||||||
|
setStatus,
|
||||||
|
isEdit,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -22,6 +22,7 @@ limitations under the License. -->
|
|||||||
placeholder="Please select a dashboard name"
|
placeholder="Please select a dashboard name"
|
||||||
@change="changeDashboard"
|
@change="changeDashboard"
|
||||||
class="selectors"
|
class="selectors"
|
||||||
|
:clearable="true"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>{{ t("metrics") }}</div>
|
<div>{{ t("metrics") }}</div>
|
||||||
@ -63,7 +64,6 @@ limitations under the License. -->
|
|||||||
/>
|
/>
|
||||||
<Icon
|
<Icon
|
||||||
class="cp"
|
class="cp"
|
||||||
v-show="states.metrics.length > 1"
|
|
||||||
iconName="remove_circle_outline"
|
iconName="remove_circle_outline"
|
||||||
size="middle"
|
size="middle"
|
||||||
@click="deleteMetric(index)"
|
@click="deleteMetric(index)"
|
||||||
@ -105,7 +105,7 @@ import { DashboardItem } from "@/types/dashboard";
|
|||||||
|
|
||||||
/*global defineEmits */
|
/*global defineEmits */
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const emit = defineEmits(["update", "loading"]);
|
const emit = defineEmits(["update", "loading", "changeOpt"]);
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const { metrics, metricTypes, graph } = dashboardStore.selectedGrid;
|
const { metrics, metricTypes, graph } = dashboardStore.selectedGrid;
|
||||||
const states = reactive<{
|
const states = reactive<{
|
||||||
@ -116,7 +116,7 @@ const states = reactive<{
|
|||||||
isList: boolean;
|
isList: boolean;
|
||||||
metricList: (Option & { type: string })[];
|
metricList: (Option & { type: string })[];
|
||||||
dashboardName: string;
|
dashboardName: string;
|
||||||
dashboardList: (DashboardItem & { label: string; value: string })[];
|
dashboardList: ((DashboardItem & { label: string; value: string }) | any)[];
|
||||||
}>({
|
}>({
|
||||||
metrics: metrics && metrics.length ? metrics : [""],
|
metrics: metrics && metrics.length ? metrics : [""],
|
||||||
metricTypes: metricTypes && metricTypes.length ? metricTypes : [""],
|
metricTypes: metricTypes && metricTypes.length ? metricTypes : [""],
|
||||||
@ -125,11 +125,11 @@ const states = reactive<{
|
|||||||
isList: false,
|
isList: false,
|
||||||
metricList: [],
|
metricList: [],
|
||||||
dashboardName: graph.dashboardName,
|
dashboardName: graph.dashboardName,
|
||||||
dashboardList: [],
|
dashboardList: [{ label: "", value: "" }],
|
||||||
});
|
});
|
||||||
|
|
||||||
states.isList = ListChartTypes.includes(graph.type);
|
states.isList = ListChartTypes.includes(graph.type);
|
||||||
const defaultLen = ref<number>(states.isList ? 5 : 10);
|
const defaultLen = ref<number>(states.isList ? 5 : 20);
|
||||||
states.visTypes = setVisTypes();
|
states.visTypes = setVisTypes();
|
||||||
|
|
||||||
setDashboards();
|
setDashboards();
|
||||||
@ -197,7 +197,7 @@ async function setMetricType() {
|
|||||||
function setDashboards() {
|
function setDashboards() {
|
||||||
const { graph } = dashboardStore.selectedGrid;
|
const { graph } = dashboardStore.selectedGrid;
|
||||||
const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
|
const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
|
||||||
states.dashboardList = list.reduce(
|
const arr = list.reduce(
|
||||||
(
|
(
|
||||||
prev: (DashboardItem & { label: string; value: string })[],
|
prev: (DashboardItem & { label: string; value: string })[],
|
||||||
d: DashboardItem
|
d: DashboardItem
|
||||||
@ -219,6 +219,8 @@ function setDashboards() {
|
|||||||
},
|
},
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
states.dashboardList = arr.length ? arr : [{ label: "", value: "" }];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVisTypes() {
|
function setVisTypes() {
|
||||||
@ -281,6 +283,7 @@ function changeMetrics(
|
|||||||
...{ metricTypes: states.metricTypes, metrics: states.metrics },
|
...{ metricTypes: states.metricTypes, metrics: states.metrics },
|
||||||
});
|
});
|
||||||
if (states.isList) {
|
if (states.isList) {
|
||||||
|
emit("changeOpt", true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
queryMetrics();
|
queryMetrics();
|
||||||
@ -311,6 +314,7 @@ function changeMetricType(index: number, opt: Option[] | any) {
|
|||||||
...{ metricTypes: states.metricTypes },
|
...{ metricTypes: states.metricTypes },
|
||||||
});
|
});
|
||||||
if (states.isList) {
|
if (states.isList) {
|
||||||
|
emit("changeOpt", true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
queryMetrics();
|
queryMetrics();
|
||||||
@ -338,7 +342,11 @@ async function queryMetrics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function changeDashboard(opt: any) {
|
function changeDashboard(opt: any) {
|
||||||
|
if (!opt[0]) {
|
||||||
|
states.dashboardName = "";
|
||||||
|
} else {
|
||||||
states.dashboardName = opt[0].value;
|
states.dashboardName = opt[0].value;
|
||||||
|
}
|
||||||
const graph = {
|
const graph = {
|
||||||
...dashboardStore.selectedGrid.graph,
|
...dashboardStore.selectedGrid.graph,
|
||||||
dashboardName: states.dashboardName,
|
dashboardName: states.dashboardName,
|
||||||
@ -358,6 +366,11 @@ function addMetric() {
|
|||||||
states.metricTypes.push("");
|
states.metricTypes.push("");
|
||||||
}
|
}
|
||||||
function deleteMetric(index: number) {
|
function deleteMetric(index: number) {
|
||||||
|
if (states.metrics.length === 1) {
|
||||||
|
states.metrics = [""];
|
||||||
|
states.metricTypes = [""];
|
||||||
|
return;
|
||||||
|
}
|
||||||
states.metrics.splice(index, 1);
|
states.metrics.splice(index, 1);
|
||||||
states.metricTypes.splice(index, 1);
|
states.metricTypes.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ import { EntityType } from "../data";
|
|||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import getDashboard from "@/hooks/useDashboardsSession";
|
import getDashboard from "@/hooks/useDashboardsSession";
|
||||||
|
|
||||||
/*global defineProps */
|
/*global defineProps, defineEmits */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@ -104,14 +104,14 @@ const props = defineProps({
|
|||||||
i: string;
|
i: string;
|
||||||
metrics: string[];
|
metrics: string[];
|
||||||
metricTypes: string[];
|
metricTypes: string[];
|
||||||
isEdit: boolean;
|
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
default: () => ({ dashboardName: "", fontSize: 12, i: "" }),
|
default: () => ({ dashboardName: "", fontSize: 12, i: "" }),
|
||||||
},
|
},
|
||||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||||
needQuery: { type: Boolean, default: false },
|
isEdit: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
const emit = defineEmits(["changeOpt"]);
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const chartLoading = ref<boolean>(false);
|
const chartLoading = ref<boolean>(false);
|
||||||
@ -135,12 +135,12 @@ async function queryEndpoints(limit?: number) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
endpoints.value = selectorStore.pods.splice(0, pageSize);
|
endpoints.value = selectorStore.pods.splice(0, pageSize);
|
||||||
if (!endpoints.value.length || props.config.isEdit) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await queryEndpointMetrics(endpoints.value);
|
await queryEndpointMetrics(endpoints.value);
|
||||||
}
|
}
|
||||||
async function queryEndpointMetrics(currentPods: Endpoint[]) {
|
async function queryEndpointMetrics(currentPods: Endpoint[]) {
|
||||||
|
if (!currentPods.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const metrics = props.config.metrics.filter((d: string) => d);
|
const metrics = props.config.metrics.filter((d: string) => d);
|
||||||
|
|
||||||
if (metrics.length && metrics[0]) {
|
if (metrics.length && metrics[0]) {
|
||||||
@ -186,11 +186,9 @@ async function searchList() {
|
|||||||
}
|
}
|
||||||
watch(
|
watch(
|
||||||
() => [props.config.metricTypes, props.config.metrics],
|
() => [props.config.metricTypes, props.config.metrics],
|
||||||
() => {
|
async () => {
|
||||||
if (!endpoints.value.length) {
|
await queryEndpointMetrics(endpoints.value);
|
||||||
return;
|
emit("changeOpt", false);
|
||||||
}
|
|
||||||
queryEndpointMetrics(endpoints.value);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
watch(
|
watch(
|
||||||
|
@ -158,6 +158,9 @@ async function queryInstance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function queryInstanceMetrics(currentInstances: Instance[]) {
|
async function queryInstanceMetrics(currentInstances: Instance[]) {
|
||||||
|
if (!instances.value.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { metrics } = props.config;
|
const { metrics } = props.config;
|
||||||
|
|
||||||
if (metrics.length && metrics[0]) {
|
if (metrics.length && metrics[0]) {
|
||||||
@ -209,9 +212,6 @@ function searchList() {
|
|||||||
watch(
|
watch(
|
||||||
() => [props.config.metricTypes, props.config.metrics],
|
() => [props.config.metricTypes, props.config.metrics],
|
||||||
() => {
|
() => {
|
||||||
if (!instances.value.length) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
queryInstanceMetrics(instances.value);
|
queryInstanceMetrics(instances.value);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user