mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 15:05:24 +00:00
fix: update filters
This commit is contained in:
parent
41a9e26f04
commit
87cac31d25
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { Duration } from "@/types/app";
|
import { Duration } from "@/types/app";
|
||||||
import { Instance, Endpoint } from "@/types/selector";
|
import { Instance, Endpoint, Service } from "@/types/selector";
|
||||||
import { Trace, Span } from "@/types/trace";
|
import { Trace, Span } from "@/types/trace";
|
||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
import graphql from "@/graphql";
|
import graphql from "@/graphql";
|
||||||
@ -25,6 +25,7 @@ import { useAppStoreWithOut } from "@/store/modules/app";
|
|||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
|
|
||||||
interface TraceState {
|
interface TraceState {
|
||||||
|
services: Service[];
|
||||||
instances: Instance[];
|
instances: Instance[];
|
||||||
endpoints: Endpoint[];
|
endpoints: Endpoint[];
|
||||||
traceList: Trace[];
|
traceList: Trace[];
|
||||||
@ -44,8 +45,9 @@ interface TraceState {
|
|||||||
export const traceStore = defineStore({
|
export const traceStore = defineStore({
|
||||||
id: "trace",
|
id: "trace",
|
||||||
state: (): TraceState => ({
|
state: (): TraceState => ({
|
||||||
instances: [],
|
services: [{ value: "0", label: "All" }],
|
||||||
endpoints: [],
|
instances: [{ value: "0", label: "All" }],
|
||||||
|
endpoints: [{ value: "0", label: "All" }],
|
||||||
traceList: [],
|
traceList: [],
|
||||||
traceSpans: [],
|
traceSpans: [],
|
||||||
traceTotal: 0,
|
traceTotal: 0,
|
||||||
@ -71,6 +73,19 @@ export const traceStore = defineStore({
|
|||||||
setTraceSpans(spans: Span) {
|
setTraceSpans(spans: Span) {
|
||||||
this.traceSpans = spans;
|
this.traceSpans = spans;
|
||||||
},
|
},
|
||||||
|
async getServices(layer: string) {
|
||||||
|
const res: AxiosResponse = await graphql.query("queryServices").params({
|
||||||
|
layer,
|
||||||
|
});
|
||||||
|
if (res.data.errors) {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
this.services = [
|
||||||
|
{ value: "0", label: "All" },
|
||||||
|
...res.data.data.services,
|
||||||
|
] || [{ value: "0", label: "All" }];
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
async getInstances() {
|
async getInstances() {
|
||||||
const res: AxiosResponse = await graphql.query("queryInstances").params({
|
const res: AxiosResponse = await graphql.query("queryInstances").params({
|
||||||
serviceId: this.selectorStore.currentService.id,
|
serviceId: this.selectorStore.currentService.id,
|
||||||
|
18
src/types/selector.d.ts
vendored
18
src/types/selector.d.ts
vendored
@ -15,25 +15,25 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
export type Service = {
|
export type Service = {
|
||||||
id: string;
|
id?: string;
|
||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
layers: string[];
|
layers?: string[];
|
||||||
normal: boolean;
|
normal?: boolean;
|
||||||
group: string;
|
group?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Instance = {
|
export type Instance = {
|
||||||
value: string;
|
value: string;
|
||||||
label: string;
|
label: string;
|
||||||
layer: string;
|
layer?: string;
|
||||||
language: string;
|
language?: string;
|
||||||
instanceUUID: string;
|
instanceUUID?: string;
|
||||||
attributes: { name: string; value: string }[];
|
attributes?: { name: string; value: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Endpoint = {
|
export type Endpoint = {
|
||||||
id: string;
|
id?: string;
|
||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
};
|
};
|
||||||
|
@ -14,7 +14,17 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<div class="flex-h row">
|
<div class="flex-h row">
|
||||||
<div class="mr-5" v-if="dashboardStore.entity === EntityType[0].value">
|
<div class="mr-5" v-if="dashboardStore.entity === EntityType[1].value">
|
||||||
|
<span class="grey mr-5">{{ t("service") }}:</span>
|
||||||
|
<Selector
|
||||||
|
size="small"
|
||||||
|
:value="state.service.value"
|
||||||
|
:options="traceStore.services"
|
||||||
|
placeholder="Select a service"
|
||||||
|
@change="changeField('service', $event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="mr-5" v-if="dashboardStore.entity !== EntityType[3].value">
|
||||||
<span class="grey mr-5">{{ t("instance") }}:</span>
|
<span class="grey mr-5">{{ t("instance") }}:</span>
|
||||||
<Selector
|
<Selector
|
||||||
size="small"
|
size="small"
|
||||||
@ -24,7 +34,7 @@ limitations under the License. -->
|
|||||||
@change="changeField('instance', $event)"
|
@change="changeField('instance', $event)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-5" v-if="dashboardStore.entity === EntityType[0].value">
|
<div class="mr-5" v-if="dashboardStore.entity !== EntityType[2].value">
|
||||||
<span class="grey mr-5">{{ t("endpoint") }}:</span>
|
<span class="grey mr-5">{{ t("endpoint") }}:</span>
|
||||||
<Selector
|
<Selector
|
||||||
size="small"
|
size="small"
|
||||||
@ -48,12 +58,6 @@ limitations under the License. -->
|
|||||||
<span class="grey mr-5">{{ t("traceID") }}:</span>
|
<span class="grey mr-5">{{ t("traceID") }}:</span>
|
||||||
<el-input v-model="traceId" class="traceId" />
|
<el-input v-model="traceId" class="traceId" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-5">
|
|
||||||
<span class="sm b grey mr-5">{{ t("duration") }}:</span>
|
|
||||||
<el-input class="inputs mr-5" v-model="minTraceDuration" />
|
|
||||||
<span class="grey mr-5">-</span>
|
|
||||||
<el-input class="inputs" v-model="maxTraceDuration" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-h">
|
<div class="flex-h">
|
||||||
<!-- <div class="mr-5">
|
<!-- <div class="mr-5">
|
||||||
@ -65,6 +69,12 @@ limitations under the License. -->
|
|||||||
@input="changeTimeRange"
|
@input="changeTimeRange"
|
||||||
/>
|
/>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
<div class="mr-5">
|
||||||
|
<span class="sm b grey mr-5">{{ t("duration") }}:</span>
|
||||||
|
<el-input class="inputs mr-5" v-model="minTraceDuration" />
|
||||||
|
<span class="grey mr-5">-</span>
|
||||||
|
<el-input class="inputs" v-model="maxTraceDuration" />
|
||||||
|
</div>
|
||||||
<ConditionTags :type="'TRACE'" @update="updateTags" />
|
<ConditionTags :type="'TRACE'" @update="updateTags" />
|
||||||
<el-button
|
<el-button
|
||||||
class="search-btn"
|
class="search-btn"
|
||||||
@ -101,8 +111,9 @@ const tagsList = ref<string[]>([]);
|
|||||||
const tagsMap = ref<Option[]>([]);
|
const tagsMap = ref<Option[]>([]);
|
||||||
const state = reactive<any>({
|
const state = reactive<any>({
|
||||||
status: { label: "All", value: "ALL" },
|
status: { label: "All", value: "ALL" },
|
||||||
instance: { label: "", value: "" },
|
instance: { value: "0", label: "All" },
|
||||||
endpoint: { label: "", value: "" },
|
endpoint: { value: "0", label: "All" },
|
||||||
|
service: { value: "0", label: "All" },
|
||||||
});
|
});
|
||||||
|
|
||||||
// const dateTime = computed(() => [
|
// const dateTime = computed(() => [
|
||||||
@ -111,11 +122,32 @@ const state = reactive<any>({
|
|||||||
// ]);
|
// ]);
|
||||||
init();
|
init();
|
||||||
function init() {
|
function init() {
|
||||||
if (dashboardStore.entity === EntityType[0].value) {
|
|
||||||
getEndpoints();
|
|
||||||
getInstances();
|
|
||||||
}
|
|
||||||
searchTraces();
|
searchTraces();
|
||||||
|
if (dashboardStore.entity === EntityType[1].value) {
|
||||||
|
getServices();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dashboardStore.entity === EntityType[2].value) {
|
||||||
|
getInstances();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dashboardStore.entity === EntityType[3].value) {
|
||||||
|
getEndpoints();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dashboardStore.entity === EntityType[0].value) {
|
||||||
|
getInstances();
|
||||||
|
getEndpoints();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getServices() {
|
||||||
|
const resp = await traceStore.getServices(dashboardStore.layerId);
|
||||||
|
if (resp.errors) {
|
||||||
|
ElMessage.error(resp.errors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.service = traceStore.services[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getEndpoints() {
|
async function getEndpoints() {
|
||||||
@ -135,13 +167,21 @@ async function getInstances() {
|
|||||||
state.instance = traceStore.instances[0];
|
state.instance = traceStore.instances[0];
|
||||||
}
|
}
|
||||||
function searchTraces() {
|
function searchTraces() {
|
||||||
|
let endpoint = "",
|
||||||
|
instance = "";
|
||||||
|
if (dashboardStore.entity === EntityType[2].value) {
|
||||||
|
endpoint = selectorStore.currentPod.id;
|
||||||
|
}
|
||||||
|
if (dashboardStore.entity === EntityType[3].value) {
|
||||||
|
instance = selectorStore.currentPod.id;
|
||||||
|
}
|
||||||
traceStore.setTraceCondition({
|
traceStore.setTraceCondition({
|
||||||
serviceId: selectorStore.currentService
|
serviceId: selectorStore.currentService
|
||||||
? selectorStore.currentService.id
|
? selectorStore.currentService.id
|
||||||
: "",
|
: state.service.id,
|
||||||
traceId: traceId.value || undefined,
|
traceId: traceId.value || undefined,
|
||||||
endpointId: state.endpoint.id || undefined,
|
endpointId: endpoint || state.endpoint.id || undefined,
|
||||||
serviceInstanceId: state.instance.id || undefined,
|
serviceInstanceId: instance || state.instance.id || undefined,
|
||||||
traceState: state.status.value || "ALL",
|
traceState: state.status.value || "ALL",
|
||||||
queryDuration: appStore.durationTime,
|
queryDuration: appStore.durationTime,
|
||||||
minTraceDuration: appStore.minTraceDuration || undefined,
|
minTraceDuration: appStore.minTraceDuration || undefined,
|
||||||
@ -160,6 +200,10 @@ async function queryTraces() {
|
|||||||
}
|
}
|
||||||
function changeField(type: string, opt: any[]) {
|
function changeField(type: string, opt: any[]) {
|
||||||
state[type] = opt[0];
|
state[type] = opt[0];
|
||||||
|
if (type === "service") {
|
||||||
|
getEndpoints();
|
||||||
|
getInstances();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function updateTags(data: { tagsMap: Array<Option>; tagsList: string[] }) {
|
function updateTags(data: { tagsMap: Array<Option>; tagsList: string[] }) {
|
||||||
tagsList.value = data.tagsList;
|
tagsList.value = data.tagsList;
|
||||||
@ -189,7 +233,7 @@ watch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
.search-btn {
|
.search-btn {
|
||||||
margin-left: 50px;
|
margin-left: 20px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user