feat: add switch to control dashboard mode (#31)

This commit is contained in:
Fine0830
2022-03-21 19:34:08 +08:00
committed by GitHub
parent 61f82c54df
commit f1e405fbb4
23 changed files with 250 additions and 82 deletions

View File

@@ -33,17 +33,13 @@ limitations under the License. -->
<el-table v-loading="chartLoading" :data="instances" style="width: 100%">
<el-table-column label="Service Instances">
<template #default="scope">
<router-link
<span
class="link"
:to="`/dashboard/${dashboardStore.layerId}/${
EntityType[3].value
}/${selectorStore.currentService.id}/${
scope.row.id
}/${config.dashboardName.split(' ').join('-')}`"
@click="clickInstance"
:style="{ fontSize: `${config.fontSize}px` }"
>
{{ scope.row.label }}
</router-link>
</span>
</template>
</el-table-column>
<el-table-column
@@ -94,6 +90,8 @@ import { InstanceListConfig } from "@/types/dashboard";
import { Instance } from "@/types/selector";
import { useQueryPodsMetrics, usePodsSource } from "@/hooks/useProcessor";
import { EntityType } from "../data";
import router from "@/router";
import getDashboard from "@/hooks/useDashboardsSession";
/*global defineProps */
const props = defineProps({
@@ -164,6 +162,21 @@ async function queryInstanceMetrics(currentInstances: Instance[]) {
instances.value = currentInstances;
}
function clickInstance(scope: any) {
const d = getDashboard({
name: props.config.dashboardName,
layer: dashboardStore.layerId,
entity: EntityType[3].value,
});
dashboardStore.setCurrentDashboard(d);
dashboardStore.setEntity(d.entity);
router.push(
`/dashboard/${d.layer}/${d.entity}/${selectorStore.currentService.id}/${
scope.row.id
}/${d.name.split(" ").join("-")}`
);
}
function changePage(pageIndex: number) {
instances.value = searchInstances.value.splice(pageIndex - 1, pageSize);
}