update endpoint

This commit is contained in:
Qiuxia Fan 2022-04-18 15:39:23 +08:00
parent fac72364f5
commit 91aeb45604
5 changed files with 39 additions and 41 deletions

View File

View File

@ -16,7 +16,7 @@
*/ */
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { Duration } from "@/types/app"; import { Duration } from "@/types/app";
import { Service } from "@/types/selector"; import { Endpoint } from "@/types/selector";
import { import {
TaskListItem, TaskListItem,
SegmentSpan, SegmentSpan,
@ -31,7 +31,7 @@ import { AxiosResponse } from "axios";
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
interface ProfileState { interface ProfileState {
services: Service[]; endpoints: Endpoint[];
durationTime: Duration; durationTime: Duration;
condition: { serviceId: string; endpointName: string }; condition: { serviceId: string; endpointName: string };
taskList: TaskListItem[]; taskList: TaskListItem[];
@ -47,7 +47,7 @@ interface ProfileState {
export const profileStore = defineStore({ export const profileStore = defineStore({
id: "profile", id: "profile",
state: (): ProfileState => ({ state: (): ProfileState => ({
services: [{ value: "0", label: "All" }], endpoints: [{ value: "", label: "All" }],
durationTime: useAppStoreWithOut().durationTime, durationTime: useAppStoreWithOut().durationTime,
condition: { serviceId: "", endpointName: "" }, condition: { serviceId: "", endpointName: "" },
taskList: [], taskList: [],
@ -75,14 +75,16 @@ export const profileStore = defineStore({
setHighlightTop() { setHighlightTop() {
this.highlightTop = !this.highlightTop; this.highlightTop = !this.highlightTop;
}, },
async getServices(layer: string) { async getEndpoints(serviceId: string, keyword?: string) {
const res: AxiosResponse = await graphql.query("queryServices").params({ const res: AxiosResponse = await graphql.query("queryEndpoints").params({
layer, serviceId,
duration: this.durationTime,
keyword: keyword || "",
}); });
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;
} }
this.services = res.data.data.services; this.endpoints = [{ value: "", label: "All" }, ...res.data.data.pods];
return res.data; return res.data;
}, },
async getTaskList() { async getTaskList() {

View File

@ -95,10 +95,7 @@ export const traceStore = defineStore({
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;
} }
this.instances = [ this.instances = [{ value: "0", label: "All" }, ...res.data.data.pods];
{ value: "0", label: "All" },
...res.data.data.pods,
] || [{ value: " 0", label: "All" }];
return res.data; return res.data;
}, },
async getEndpoints(id: string, keyword?: string) { async getEndpoints(id: string, keyword?: string) {
@ -113,10 +110,7 @@ export const traceStore = defineStore({
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;
} }
this.endpoints = [ this.endpoints = [{ value: "0", label: "All" }, ...res.data.data.pods];
{ value: "0", label: "All" },
...res.data.data.pods,
] || [{ value: "0", label: "All" }];
return res.data; return res.data;
}, },
async getTraces() { async getTraces() {

View File

@ -465,7 +465,7 @@ function setControls(id: string) {
dashboardStore.addControl("Profile"); dashboardStore.addControl("Profile");
break; break;
case "addEbpf": case "addEbpf":
dashboardStore.addTabControls("Ebpf"); dashboardStore.addControl("Ebpf");
break; break;
case "addLog": case "addLog":
dashboardStore.addControl("Log"); dashboardStore.addControl("Log");

View File

@ -14,19 +14,18 @@ See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="flex-h header"> <div class="flex-h header">
<!-- <div class="mr-10" v-if="dashboardStore.entity==='All'">
<span class="grey mr-5">{{ t("service") }}:</span>
<Selector
size="small"
:value="service.value"
:options="profileStore.services"
placeholder="Select a service"
@change="changeService"
/>
</div> -->
<div class="mr-10"> <div class="mr-10">
<span class="grey mr-5">{{ t("endpointName") }}:</span> <span class="grey mr-5">{{ t("endpointName") }}:</span>
<el-input v-model="endpointName" class="name" size="small" /> <Selector
class="name"
size="small"
:value="endpointName"
:options="profileStore.endpoints"
placeholder="Select a endpoint"
:isRemote="true"
@change="changeEndpoint"
@query="searchEndpoints"
/>
</div> </div>
<el-button <el-button
class="search-btn" class="search-btn"
@ -65,27 +64,30 @@ const appStore = useAppStoreWithOut();
const selectorStore = useSelectorStore(); const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const { t } = useI18n(); const { t } = useI18n();
// const service = ref<any>({});
const endpointName = ref<string>(""); const endpointName = ref<string>("");
const newTask = ref<boolean>(false); const newTask = ref<boolean>(false);
searchTasks(); searchTasks();
// getServices(); searchEndpoints("");
// async function getServices() { async function searchEndpoints(keyword: string) {
// const res = await profileStore.getServices(dashboardStore.layerId); if (!selectorStore.currentService) {
return;
}
const service = selectorStore.currentService.value;
const res = await profileStore.getEndpoints(service, keyword);
// if (res.errors) { if (res.errors) {
// ElMessage.error(res.errors); ElMessage.error(res.errors);
// return; return;
// } }
// service.value = profileStore.services[0]; endpointName.value = profileStore.endpoints[0].value;
// searchTasks(); }
// }
function changeEndpoint(opt: any[]) {
endpointName.value = opt[0].value;
}
// function changeService(opt: any[]) {
// service.value = opt[0];
// }
async function searchTasks() { async function searchTasks() {
profileStore.setConditions({ profileStore.setConditions({
serviceId: serviceId: