feat: update instanceList and endpointList

This commit is contained in:
Qiuxia Fan 2022-01-17 17:58:23 +08:00
parent 9531e74f56
commit 652b3f2bbc
7 changed files with 55 additions and 18 deletions

View File

@ -83,10 +83,13 @@ export const selectorStore = defineStore({
} }
return res.data; return res.data;
}, },
async getEndpoints(params: { async getEndpoints(params?: {
keyword: string; keyword?: string;
serviceId?: string; serviceId?: string;
}): Promise<AxiosResponse> { }): Promise<AxiosResponse> {
if (!params) {
params = {};
}
if (!params.keyword) { if (!params.keyword) {
params.keyword = ""; params.keyword = "";
} }

View File

@ -169,12 +169,12 @@ export default defineComponent({
queryMetricType(states.metrics[0]); queryMetricType(states.metrics[0]);
} }
if (PodsChartTypes.includes(String(params.entity))) { if (params.entity === "service") {
states.visType = ChartTypes;
} else {
states.visType = ChartTypes.filter( states.visType = ChartTypes.filter(
(d: Option) => !PodsChartTypes.includes(d.value) (d: Option) => !PodsChartTypes.includes(d.value)
); );
} else {
states.visType = ChartTypes;
} }
async function changeMetrics(arr: Option[]) { async function changeMetrics(arr: Option[]) {

View File

@ -49,14 +49,19 @@ export const DefaultGraphConfig: { [key: string]: any } = {
showUint: true, showUint: true,
}, },
Table: { Table: {
type: "Card", type: "Table",
showTableValues: true, showTableValues: true,
tableHeaderCol1: "", tableHeaderCol1: "",
tableHeaderCol2: "", tableHeaderCol2: "",
}, },
TopList: { TopList: {
type: "TopList", type: "TopList",
topN: 10, },
InstanceList: {
type: "InstanceList",
},
EndpointList: {
type: "EndpointList",
}, },
}; };

View File

@ -13,22 +13,34 @@ 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>
<el-table :data="data" style="width: 100%"> <el-table
:data="selectorStore.endpoints"
style="width: 100%; height: 100%; overflow: auto"
>
<el-table-column prop="label" label="Endpoints" /> <el-table-column prop="label" label="Endpoints" />
</el-table> </el-table>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { defineProps } from "vue"; import { defineProps, onBeforeMount } from "vue";
import type { PropType } from "vue"; import { useSelectorStore } from "@/store/modules/selectors";
import { ElMessage } from "element-plus";
defineProps({ defineProps({
data: { data: {
type: Array as PropType<{ label: string; value: string }[]>, type: Object,
default: () => [],
}, },
config: { config: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
}); });
const selectorStore = useSelectorStore();
onBeforeMount(async () => {
const resp = await selectorStore.getEndpoints();
if (resp.errors) {
ElMessage.error(resp.errors);
}
});
</script> </script>

View File

@ -13,22 +13,34 @@ 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>
<el-table :data="data" style="width: 100%"> <el-table
:data="selectorStore.instances"
style="width: 100%; height: 100%; overflow: auto"
>
<el-table-column prop="label" label="Service Instances" /> <el-table-column prop="label" label="Service Instances" />
</el-table> </el-table>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { defineProps } from "vue"; import { defineProps, onBeforeMount } from "vue";
import type { PropType } from "vue"; import { useSelectorStore } from "@/store/modules/selectors";
import { ElMessage } from "element-plus";
defineProps({ defineProps({
data: { data: {
type: Array as PropType<{ label: string; value: string }[]>, type: Object,
default: () => [],
}, },
config: { config: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
}); });
const selectorStore = useSelectorStore();
onBeforeMount(async () => {
const resp = await selectorStore.getServiceInstances();
if (resp.errors) {
ElMessage.error(resp.errors);
}
});
</script> </script>

View File

@ -23,6 +23,8 @@ import TopList from "./TopList.vue";
import Table from "./Table.vue"; import Table from "./Table.vue";
import Pie from "./Pie.vue"; import Pie from "./Pie.vue";
import Card from "./Card.vue"; import Card from "./Card.vue";
import InstanceList from "./InstanceList.vue";
import EndpointList from "./EndpointList.vue";
export default { export default {
Line, Line,
@ -33,4 +35,6 @@ export default {
Table, Table,
Pie, Pie,
Card, Card,
EndpointList,
InstanceList,
}; };

View File

@ -165,10 +165,11 @@ async function fetchPods(type: string) {
case "serviceInstance": case "serviceInstance":
resp = await selectorStore.getServiceInstances(); resp = await selectorStore.getServiceInstances();
break; break;
default:
resp = {};
} }
if (resp.errors) { if (resp.errors) {
ElMessage.error(resp.errors); ElMessage.error(resp.errors);
return [];
} }
} }
</script> </script>