search endpoints

This commit is contained in:
Qiuxia Fan 2022-03-28 17:32:18 +08:00
parent 10fbf33d5d
commit d53fe5ed73
5 changed files with 29 additions and 9 deletions

View File

@ -86,14 +86,14 @@ export const logStore = defineStore({
] || [{ value: " 0", label: "All" }]; ] || [{ value: " 0", label: "All" }];
return res.data; return res.data;
}, },
async getEndpoints(id: string) { async getEndpoints(id: string, keyword?: string) {
const serviceId = this.selectorStore.currentService const serviceId = this.selectorStore.currentService
? this.selectorStore.currentService.id ? this.selectorStore.currentService.id
: id; : id;
const res: AxiosResponse = await graphql.query("queryEndpoints").params({ const res: AxiosResponse = await graphql.query("queryEndpoints").params({
serviceId, serviceId,
duration: this.durationTime, duration: this.durationTime,
keyword: "", keyword: keyword || "",
}); });
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;

View File

@ -101,14 +101,14 @@ export const traceStore = defineStore({
] || [{ value: " 0", label: "All" }]; ] || [{ value: " 0", label: "All" }];
return res.data; return res.data;
}, },
async getEndpoints(id: string) { async getEndpoints(id: string, keyword?: string) {
const serviceId = this.selectorStore.currentService const serviceId = this.selectorStore.currentService
? this.selectorStore.currentService.id ? this.selectorStore.currentService.id
: id; : id;
const res: AxiosResponse = await graphql.query("queryEndpoints").params({ const res: AxiosResponse = await graphql.query("queryEndpoints").params({
serviceId, serviceId,
duration: this.durationTime, duration: this.durationTime,
keyword: "", keyword: keyword || "",
}); });
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;

View File

@ -42,7 +42,9 @@ limitations under the License. -->
@change="changePods" @change="changePods"
@query="searchPods" @query="searchPods"
class="selectorPod" class="selectorPod"
:isRemote="true" :isRemote="
['EndpointRelation', 'Endpoint'].includes(dashboardStore.entity)
"
/> />
</div> </div>
<div class="selectors-item" v-if="states.key === 2 || states.key === 4"> <div class="selectors-item" v-if="states.key === 2 || states.key === 4">
@ -62,8 +64,8 @@ limitations under the License. -->
dashboardStore.entity === "EndpointRelation" dashboardStore.entity === "EndpointRelation"
? "$DestinationEndpoint" ? "$DestinationEndpoint"
: "$DestinationServiceInstance" : "$DestinationServiceInstance"
}}</span }}
> </span>
<Selector <Selector
v-model="states.currentDestPod" v-model="states.currentDestPod"
:options="selectorStore.destPods" :options="selectorStore.destPods"
@ -71,6 +73,8 @@ limitations under the License. -->
placeholder="Select a data" placeholder="Select a data"
@change="changePods" @change="changePods"
class="selectorPod" class="selectorPod"
@query="searchPods"
:isRemote="dashboardStore.entity === 'EndpointRelation'"
/> />
</div> </div>
</div> </div>

View File

@ -46,6 +46,8 @@ limitations under the License. -->
:options="logStore.endpoints" :options="logStore.endpoints"
placeholder="Select a endpoint" placeholder="Select a endpoint"
@change="changeField('endpoint', $event)" @change="changeField('endpoint', $event)"
:isRemote="true"
@query="searchEndpoints"
/> />
</div> </div>
</div> </div>
@ -243,6 +245,12 @@ function changeField(type: string, opt: any) {
getInstances(state.service.id); getInstances(state.service.id);
} }
} }
async function searchEndpoints(keyword: string) {
const resp = await logStore.getEndpoints(state.service.id, keyword);
if (resp.errors) {
ElMessage.error(resp.errors);
}
}
function updateTags(data: { tagsMap: Array<Option>; tagsList: string[] }) { function updateTags(data: { tagsMap: Array<Option>; tagsList: string[] }) {
tagsList.value = data.tagsList; tagsList.value = data.tagsList;
tagsMap.value = data.tagsMap; tagsMap.value = data.tagsMap;

View File

@ -41,7 +41,9 @@ limitations under the License. -->
:value="state.endpoint.value" :value="state.endpoint.value"
:options="traceStore.endpoints" :options="traceStore.endpoints"
placeholder="Select a endpoint" placeholder="Select a endpoint"
:isRemote="true"
@change="changeField('endpoint', $event)" @change="changeField('endpoint', $event)"
@query="searchEndpoints"
/> />
</div> </div>
<div class="mr-5"> <div class="mr-5">
@ -149,8 +151,8 @@ async function getServices() {
getInstances(state.service.id); getInstances(state.service.id);
} }
async function getEndpoints(id?: string) { async function getEndpoints(id?: string, keyword?: string) {
const resp = await traceStore.getEndpoints(id); const resp = await traceStore.getEndpoints(id, keyword);
if (resp.errors) { if (resp.errors) {
ElMessage.error(resp.errors); ElMessage.error(resp.errors);
return; return;
@ -208,6 +210,12 @@ function updateTags(data: { tagsMap: Array<Option>; tagsList: string[] }) {
tagsList.value = data.tagsList; tagsList.value = data.tagsList;
tagsMap.value = data.tagsMap; tagsMap.value = data.tagsMap;
} }
async function searchEndpoints(keyword: string) {
const resp = await traceStore.getEndpoints(state.service.id, keyword);
if (resp.errors) {
ElMessage.error(resp.errors);
}
}
watch( watch(
() => [selectorStore.currentPod], () => [selectorStore.currentPod],
() => { () => {