mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-01 17:44:48 +00:00
feat: query layers
This commit is contained in:
parent
3e4f595c86
commit
3eef246d1d
@ -17,7 +17,7 @@
|
|||||||
import { Services, Layers, Endpoints, Instances } from "../fragments/selector";
|
import { Services, Layers, Endpoints, Instances } from "../fragments/selector";
|
||||||
|
|
||||||
export const queryServices = `query queryServices(${Services.variable}) {${Services.query}}`;
|
export const queryServices = `query queryServices(${Services.variable}) {${Services.query}}`;
|
||||||
export const queryLayers = `query ${Layers.query}`;
|
|
||||||
export const queryEndpoints = `query queryEndpoints(${Endpoints.variable}) {${Endpoints.query}}`;
|
export const queryEndpoints = `query queryEndpoints(${Endpoints.variable}) {${Endpoints.query}}`;
|
||||||
|
|
||||||
export const queryInstances = `query queryInstances(${Instances.variable}) {${Instances.query}}`;
|
export const queryInstances = `query queryInstances(${Instances.variable}) {${Instances.query}}`;
|
||||||
|
export const queryLayers = `query listLayer {${Layers.query}}`;
|
||||||
|
@ -33,7 +33,7 @@ export const selectorStore = defineStore({
|
|||||||
async fetchLayers(): Promise<AxiosResponse> {
|
async fetchLayers(): Promise<AxiosResponse> {
|
||||||
const res: AxiosResponse = await graph.query("queryLayers").params({});
|
const res: AxiosResponse = await graph.query("queryLayers").params({});
|
||||||
|
|
||||||
return res;
|
return res.data || {};
|
||||||
},
|
},
|
||||||
async fetchServices(layer: string): Promise<AxiosResponse> {
|
async fetchServices(layer: string): Promise<AxiosResponse> {
|
||||||
const res: AxiosResponse = await graph
|
const res: AxiosResponse = await graph
|
||||||
@ -43,7 +43,7 @@ export const selectorStore = defineStore({
|
|||||||
if (!res.data.errors) {
|
if (!res.data.errors) {
|
||||||
this.services = res.data.data.services;
|
this.services = res.data.data.services;
|
||||||
}
|
}
|
||||||
return res;
|
return res.data;
|
||||||
},
|
},
|
||||||
async getServiceInstances(params: {
|
async getServiceInstances(params: {
|
||||||
serviceId: string;
|
serviceId: string;
|
||||||
|
@ -26,8 +26,8 @@ limitations under the License. -->
|
|||||||
<div class="item">
|
<div class="item">
|
||||||
<div class="label">{{ t("layer") }}</div>
|
<div class="label">{{ t("layer") }}</div>
|
||||||
<Selector
|
<Selector
|
||||||
:value="states.layer"
|
v-model="states.selectedLayer"
|
||||||
:options="Options"
|
:options="states.layers"
|
||||||
size="small"
|
size="small"
|
||||||
placeholder="Select a layer"
|
placeholder="Select a layer"
|
||||||
@change="changeLayer"
|
@change="changeLayer"
|
||||||
@ -53,28 +53,40 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive } from "vue";
|
import { reactive, onBeforeMount } from "vue";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import { EntityType, Options } from "./data";
|
import { EntityType } from "./data";
|
||||||
import uuid from "@/utils/uuid";
|
import uuid from "@/utils/uuid";
|
||||||
|
import { ElMessage } from "element-plus";
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
const states = reactive({
|
const states = reactive({
|
||||||
name: "",
|
name: "",
|
||||||
layer: Options[0].value,
|
selectedLayer: "",
|
||||||
entity: EntityType[0].value,
|
entity: EntityType[0].value,
|
||||||
|
layers: [],
|
||||||
});
|
});
|
||||||
const onCreate = () => {
|
const onCreate = () => {
|
||||||
const id = uuid();
|
const id = uuid();
|
||||||
const path = `/dashboard/edit/${states.layer}/${states.entity}/${id}`;
|
const path = `/dashboard/edit/${states.selectedLayer}/${states.entity}/${id}`;
|
||||||
router.push(path);
|
router.push(path);
|
||||||
};
|
};
|
||||||
selectorStore.fetchServices("general");
|
onBeforeMount(async () => {
|
||||||
|
const resp = await selectorStore.fetchLayers();
|
||||||
|
if (resp.errors) {
|
||||||
|
ElMessage.error(resp.errors);
|
||||||
|
}
|
||||||
|
states.selectedLayer = resp.data.layers[0];
|
||||||
|
states.layers = resp.data.layers.map((d: string) => {
|
||||||
|
return { label: d, value: d };
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// selectorStore.fetchServices("general");
|
||||||
function changeLayer(opt: { label: string; value: string }[]) {
|
function changeLayer(opt: { label: string; value: string }[]) {
|
||||||
states.layer = opt[0].value;
|
states.selectedLayer = opt[0].value;
|
||||||
}
|
}
|
||||||
function changeEntity(opt: { label: string; value: string }[]) {
|
function changeEntity(opt: { label: string; value: string }[]) {
|
||||||
states.entity = opt[0].value;
|
states.entity = opt[0].value;
|
||||||
|
@ -245,7 +245,7 @@ export default defineComponent({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json.error) {
|
if (json.errors) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const metricVal = json.data.readMetricsValues.values.values.map(
|
const metricVal = json.data.readMetricsValues.values.values.map(
|
||||||
|
@ -40,10 +40,20 @@ module.exports = {
|
|||||||
chunks: "all",
|
chunks: "all",
|
||||||
cacheGroups: {
|
cacheGroups: {
|
||||||
echarts: {
|
echarts: {
|
||||||
name: "three",
|
name: "echarts",
|
||||||
test: /[\\/]node_modules[\\/]three[\\/]/,
|
test: /[\\/]node_modules[\\/]echarts[\\/]/,
|
||||||
|
priority: 1,
|
||||||
|
},
|
||||||
|
elementPlus: {
|
||||||
|
name: "element-plus",
|
||||||
|
test: /[\\/]node_modules[\\/]element-plus[\\/]/,
|
||||||
priority: 2,
|
priority: 2,
|
||||||
},
|
},
|
||||||
|
three: {
|
||||||
|
name: "three",
|
||||||
|
test: /[\\/]node_modules[\\/]three[\\/]/,
|
||||||
|
priority: 3,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user