update list

This commit is contained in:
Qiuxia Fan 2022-03-24 15:17:16 +08:00
parent e64c75f257
commit 1a1494bab7
5 changed files with 23 additions and 21 deletions

View File

@ -203,6 +203,9 @@ async function importTemplates(event: any) {
dashboardFile.value = null; dashboardFile.value = null;
} }
function exportTemplates() { function exportTemplates() {
if (!multipleSelection.value.length) {
return;
}
const arr = multipleSelection.value.sort( const arr = multipleSelection.value.sort(
(a: DashboardItem, b: DashboardItem) => { (a: DashboardItem, b: DashboardItem) => {
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);

View File

@ -13,10 +13,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div v-if="states.isList && states.dashboardList.length" class="ds-name"> <div v-if="states.isList" class="ds-name">
<div>{{ t("dashboards") }}</div> <div>{{ t("dashboards") }}</div>
<Selector <Selector
:value="states.dashboardName" :value="states.dashboardName || ''"
:options="states.dashboardList" :options="states.dashboardList"
size="small" size="small"
placeholder="Please select a dashboard name" placeholder="Please select a dashboard name"

View File

@ -120,9 +120,8 @@ const pageSize = 5;
const total = 10; const total = 10;
const searchText = ref<string>(""); const searchText = ref<string>("");
if (props.needQuery) {
queryEndpoints(total); queryEndpoints(total);
}
async function queryEndpoints(limit?: number) { async function queryEndpoints(limit?: number) {
chartLoading.value = true; chartLoading.value = true;
const resp = await selectorStore.getEndpoints({ const resp = await selectorStore.getEndpoints({
@ -136,13 +135,13 @@ async function queryEndpoints(limit?: number) {
return; return;
} }
endpoints.value = selectorStore.pods.splice(0, pageSize); endpoints.value = selectorStore.pods.splice(0, pageSize);
if (props.config.isEdit || !endpoints.value.length) { if (!endpoints.value.length || props.config.isEdit) {
return; return;
} }
queryEndpointMetrics(endpoints.value); await queryEndpointMetrics(endpoints.value);
} }
async function queryEndpointMetrics(currentPods: Endpoint[]) { async function queryEndpointMetrics(currentPods: Endpoint[]) {
const { metrics } = props.config; const metrics = props.config.metrics.filter((d: string) => d);
if (metrics.length && metrics[0]) { if (metrics.length && metrics[0]) {
const params = await useQueryPodsMetrics( const params = await useQueryPodsMetrics(
@ -188,9 +187,10 @@ async function searchList() {
watch( watch(
() => [props.config.metricTypes, props.config.metrics], () => [props.config.metricTypes, props.config.metrics],
() => { () => {
if (dashboardStore.showConfig) { if (!endpoints.value.length) {
queryEndpointMetrics(endpoints.value); return;
} }
queryEndpointMetrics(endpoints.value);
} }
); );
watch( watch(

View File

@ -137,9 +137,7 @@ const searchInstances = ref<Instance[]>([]); // all instances
const pageSize = 5; const pageSize = 5;
const searchText = ref<string>(""); const searchText = ref<string>("");
if (props.needQuery) {
queryInstance(); queryInstance();
}
async function queryInstance() { async function queryInstance() {
chartLoading.value = true; chartLoading.value = true;
const resp = await selectorStore.getServiceInstances(); const resp = await selectorStore.getServiceInstances();
@ -153,7 +151,7 @@ async function queryInstance() {
} }
searchInstances.value = selectorStore.pods; searchInstances.value = selectorStore.pods;
instances.value = searchInstances.value.splice(0, pageSize); instances.value = searchInstances.value.splice(0, pageSize);
if (props.config.isEdit) { if (!instances.value.length || props.config.isEdit) {
return; return;
} }
queryInstanceMetrics(instances.value); queryInstanceMetrics(instances.value);
@ -211,9 +209,10 @@ function searchList() {
watch( watch(
() => [props.config.metricTypes, props.config.metrics], () => [props.config.metricTypes, props.config.metrics],
() => { () => {
if (dashboardStore.showConfig) { if (!instances.value.length) {
queryInstanceMetrics(instances.value); return;
} }
queryInstanceMetrics(instances.value);
} }
); );
watch( watch(

View File

@ -143,7 +143,7 @@ async function queryServices() {
ElMessage.error(resp.errors); ElMessage.error(resp.errors);
} }
setServices(selectorStore.services); setServices(selectorStore.services);
if (props.config.isEdit) { if (!services.value.length || props.config.isEdit) {
return; return;
} }
queryServiceMetrics(services.value); queryServiceMetrics(services.value);
@ -232,8 +232,7 @@ function objectSpanMethod(param: any): any {
colspan: 0, colspan: 0,
}; };
} }
console.log(groups.value); return { rowspan: groups.value[param.row.group], colspan: 1 };
return { rowspan: 5, colspan: 1 };
} }
function changePage(pageIndex: number) { function changePage(pageIndex: number) {
services.value = sortServices.value.filter((d: Service, index: number) => { services.value = sortServices.value.filter((d: Service, index: number) => {
@ -254,9 +253,10 @@ function searchList() {
watch( watch(
() => [props.config.metricTypes, props.config.metrics], () => [props.config.metricTypes, props.config.metrics],
() => { () => {
if (dashboardStore.showConfig) { if (!services.value.length) {
queryServiceMetrics(services.value); return;
} }
queryServiceMetrics(services.value);
} }
); );
</script> </script>