{{ t("noData") }}
@@ -51,7 +52,11 @@ limitations under the License. -->
:style="{ '--el-collapse-header-font-size': '15px' }"
>
-
+
@@ -85,6 +90,7 @@ import configs from "./widget/graph-styles";
import WidgetOptions from "./widget/WidgetOptions.vue";
import StandardOptions from "./widget/StandardOptions.vue";
import MetricOptions from "./widget/MetricOptions.vue";
+import { ListChartTypes } from "../data";
export default defineComponent({
name: "ConfigEdit",
@@ -101,6 +107,7 @@ export default defineComponent({
const dashboardStore = useDashboardStore();
const appStoreWithOut = useAppStoreWithOut();
const loading = ref(false);
+ const isEdit = ref(false);
const states = reactive<{
activeNames: string;
source: unknown;
@@ -123,8 +130,13 @@ export default defineComponent({
}
function applyConfig() {
- dashboardStore.setConfigs(dashboardStore.selectedGrid);
dashboardStore.setConfigPanel(false);
+ setStatus();
+ dashboardStore.setConfigs(dashboardStore.selectedGrid);
+ }
+
+ function setStatus() {
+ isEdit.value = true;
}
function cancelConfig() {
@@ -143,6 +155,8 @@ export default defineComponent({
cancelConfig,
getSource,
setLoading,
+ setStatus,
+ isEdit,
};
},
});
diff --git a/src/views/dashboard/configuration/widget/MetricOptions.vue b/src/views/dashboard/configuration/widget/MetricOptions.vue
index 7e6bc992..0e399f33 100644
--- a/src/views/dashboard/configuration/widget/MetricOptions.vue
+++ b/src/views/dashboard/configuration/widget/MetricOptions.vue
@@ -13,15 +13,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. -->
-
+
{{ t("metrics") }}
@@ -63,7 +64,6 @@ limitations under the License. -->
/>
({
metrics: metrics && metrics.length ? metrics : [""],
metricTypes: metricTypes && metricTypes.length ? metricTypes : [""],
@@ -125,11 +125,11 @@ const states = reactive<{
isList: false,
metricList: [],
dashboardName: graph.dashboardName,
- dashboardList: [],
+ dashboardList: [{ label: "", value: "" }],
});
states.isList = ListChartTypes.includes(graph.type);
-const defaultLen = ref(states.isList ? 5 : 10);
+const defaultLen = ref(states.isList ? 5 : 20);
states.visTypes = setVisTypes();
setDashboards();
@@ -197,7 +197,7 @@ async function setMetricType() {
function setDashboards() {
const { graph } = dashboardStore.selectedGrid;
const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
- states.dashboardList = list.reduce(
+ const arr = list.reduce(
(
prev: (DashboardItem & { label: string; value: string })[],
d: DashboardItem
@@ -219,6 +219,8 @@ function setDashboards() {
},
[]
);
+
+ states.dashboardList = arr.length ? arr : [{ label: "", value: "" }];
}
function setVisTypes() {
@@ -281,6 +283,7 @@ function changeMetrics(
...{ metricTypes: states.metricTypes, metrics: states.metrics },
});
if (states.isList) {
+ emit("changeOpt");
return;
}
queryMetrics();
@@ -311,6 +314,7 @@ function changeMetricType(index: number, opt: Option[] | any) {
...{ metricTypes: states.metricTypes },
});
if (states.isList) {
+ emit("changeOpt");
return;
}
queryMetrics();
@@ -338,7 +342,11 @@ async function queryMetrics() {
}
function changeDashboard(opt: any) {
- states.dashboardName = opt[0].value;
+ if (!opt[0]) {
+ states.dashboardName = "";
+ } else {
+ states.dashboardName = opt[0].value;
+ }
const graph = {
...dashboardStore.selectedGrid.graph,
dashboardName: states.dashboardName,
@@ -358,6 +366,15 @@ function addMetric() {
states.metricTypes.push("");
}
function deleteMetric(index: number) {
+ if (states.metrics.length === 1) {
+ states.metrics = [""];
+ states.metricTypes = [""];
+ dashboardStore.selectWidget({
+ ...dashboardStore.selectedGrid,
+ ...{ metricTypes: states.metricTypes, metrics: states.metrics },
+ });
+ return;
+ }
states.metrics.splice(index, 1);
states.metricTypes.splice(index, 1);
}
diff --git a/src/views/dashboard/graphs/EndpointList.vue b/src/views/dashboard/graphs/EndpointList.vue
index 21a4173b..a8d4c35b 100644
--- a/src/views/dashboard/graphs/EndpointList.vue
+++ b/src/views/dashboard/graphs/EndpointList.vue
@@ -104,26 +104,24 @@ const props = defineProps({
i: string;
metrics: string[];
metricTypes: string[];
- isEdit: boolean;
}
>,
default: () => ({ dashboardName: "", fontSize: 12, i: "" }),
},
intervalTime: { type: Array as PropType, default: () => [] },
- needQuery: { type: Boolean, default: false },
+ isEdit: { type: Boolean, default: false },
});
+// const emit = defineEmits(["changeOpt"]);
const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore();
const chartLoading = ref(false);
const endpoints = ref([]);
-const searchEndpoints = ref([]);
const pageSize = 5;
const total = 10;
const searchText = ref("");
-if (props.needQuery) {
- queryEndpoints(total);
-}
+queryEndpoints(total);
+
async function queryEndpoints(limit?: number) {
chartLoading.value = true;
const resp = await selectorStore.getEndpoints({
@@ -136,15 +134,14 @@ async function queryEndpoints(limit?: number) {
ElMessage.error(resp.errors);
return;
}
- searchEndpoints.value = selectorStore.pods;
endpoints.value = selectorStore.pods.splice(0, pageSize);
- if (props.config.isEdit || !endpoints.value.length) {
- return;
- }
- queryEndpointMetrics(endpoints.value);
+ await queryEndpointMetrics(endpoints.value);
}
async function queryEndpointMetrics(currentPods: Endpoint[]) {
- const { metrics } = props.config;
+ if (!currentPods.length) {
+ return;
+ }
+ const metrics = props.config.metrics.filter((d: string) => d);
if (metrics.length && metrics[0]) {
const params = await useQueryPodsMetrics(
@@ -178,7 +175,7 @@ function clickEndpoint(scope: any) {
);
}
function changePage(pageIndex: number) {
- endpoints.value = searchEndpoints.value.splice(
+ endpoints.value = selectorStore.pods.splice(
(pageIndex - 1 || 0) * pageSize,
pageSize * (pageIndex || 1)
);
@@ -189,10 +186,11 @@ async function searchList() {
}
watch(
() => [props.config.metricTypes, props.config.metrics],
- () => {
- if (dashboardStore.showConfig) {
+ async () => {
+ if (props.isEdit) {
queryEndpointMetrics(endpoints.value);
}
+ // emit("changeOpt", false);
}
);
watch(
diff --git a/src/views/dashboard/graphs/InstanceList.vue b/src/views/dashboard/graphs/InstanceList.vue
index d2280ccf..b2c7aa7d 100644
--- a/src/views/dashboard/graphs/InstanceList.vue
+++ b/src/views/dashboard/graphs/InstanceList.vue
@@ -42,20 +42,6 @@ limitations under the License. -->
-
-
-
-
- {{ attr.name }}: {{ attr.value || null }}
-
-
- No Data
-
-
+
+
+
+
+ {{ t("viewAttributes") }}
+
+
+
+ {{ attr.name }}: {{ attr.value || null }}
+
+
+
+
+