mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 11:24:06 +00:00
feat: update metric config
This commit is contained in:
parent
809fcff859
commit
4b9d1dd362
@ -17,6 +17,8 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
import { LayoutConfig } from "@/types/dashboard";
|
import { LayoutConfig } from "@/types/dashboard";
|
||||||
|
import graph from "@/graph";
|
||||||
|
import { AxiosResponse } from "axios";
|
||||||
|
|
||||||
interface DashboardState {
|
interface DashboardState {
|
||||||
showConfig: boolean;
|
showConfig: boolean;
|
||||||
@ -53,6 +55,13 @@ export const dashboardStore = defineStore({
|
|||||||
setConfigPanel(show: boolean) {
|
setConfigPanel(show: boolean) {
|
||||||
this.showConfig = show;
|
this.showConfig = show;
|
||||||
},
|
},
|
||||||
|
async fetchMetricType(item: string) {
|
||||||
|
const res: AxiosResponse = await graph
|
||||||
|
.query("queryTypeOfMetrics")
|
||||||
|
.params({ name: item });
|
||||||
|
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
2
src/types/app.d.ts
vendored
2
src/types/app.d.ts
vendored
@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
export interface Option {
|
export interface Option {
|
||||||
key: string | number;
|
value: string | number;
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
export interface Duration {
|
export interface Duration {
|
||||||
|
@ -15,9 +15,9 @@ limitations under the License. -->
|
|||||||
<template>
|
<template>
|
||||||
<div class="graph">No Data</div>
|
<div class="graph">No Data</div>
|
||||||
<div class="config">
|
<div class="config">
|
||||||
<div class="metric-config item">
|
<div class="metrics item">
|
||||||
<label>Graph your metric</label>
|
<label>Graph your metric</label>
|
||||||
<div class="name">Metrics</div>
|
<div class="name">Metrics Name</div>
|
||||||
<Selector
|
<Selector
|
||||||
:value="states.metrics"
|
:value="states.metrics"
|
||||||
:options="metricOpts"
|
:options="metricOpts"
|
||||||
@ -28,12 +28,12 @@ limitations under the License. -->
|
|||||||
class="selectors"
|
class="selectors"
|
||||||
/>
|
/>
|
||||||
<Selector
|
<Selector
|
||||||
:value="states.metrics"
|
v-show="states.valueType"
|
||||||
:options="metricOpts"
|
:value="states.valueType"
|
||||||
:multiple="true"
|
:options="states.valueTypes"
|
||||||
size="mini"
|
size="mini"
|
||||||
placeholder="Select a metric"
|
placeholder="Select a metric"
|
||||||
@change="changeMetrics"
|
@change="changeValueType"
|
||||||
class="selectors"
|
class="selectors"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -53,12 +53,36 @@ limitations under the License. -->
|
|||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
|
import { ElMessage } from "element-plus";
|
||||||
|
import { ValuesTypes, MetricQueryTypes } from "../data";
|
||||||
|
import { Option } from "@/types/app";
|
||||||
|
|
||||||
const states = reactive<any>({
|
const states = reactive<{
|
||||||
|
metrics: string;
|
||||||
|
valueTypes: Option[];
|
||||||
|
valueType: string;
|
||||||
|
metricQueryType: string;
|
||||||
|
}>({
|
||||||
metrics: "",
|
metrics: "",
|
||||||
|
valueTypes: [],
|
||||||
|
valueType: "",
|
||||||
|
metricQueryType: "",
|
||||||
});
|
});
|
||||||
function changeMetrics(val: string[]) {
|
const dashboardStore = useDashboardStore();
|
||||||
console.log(val);
|
async function changeMetrics(val: Option[]) {
|
||||||
|
const resp = await dashboardStore.fetchMetricType(val[0].value);
|
||||||
|
if (resp.error) {
|
||||||
|
ElMessage.error(resp.data.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { typeOfMetrics } = resp.data;
|
||||||
|
states.valueTypes = ValuesTypes[typeOfMetrics];
|
||||||
|
states.valueType = ValuesTypes[typeOfMetrics][0].value;
|
||||||
|
}
|
||||||
|
function changeValueType(val: Option[]) {
|
||||||
|
states.valueType = String(val[0].value);
|
||||||
|
states.metricQueryType = (MetricQueryTypes as any)[states.valueType];
|
||||||
}
|
}
|
||||||
const metricOpts = [
|
const metricOpts = [
|
||||||
{ value: "service_apdex", label: "service_apdex" },
|
{ value: "service_apdex", label: "service_apdex" },
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
export enum QueryTypes {
|
export enum MetricQueryTypes {
|
||||||
ReadMetricsValue = "readMetricsValue",
|
ReadMetricsValue = "readMetricsValue",
|
||||||
ReadMetricsValues = "readMetricsValues",
|
ReadMetricsValues = "readMetricsValues",
|
||||||
SortMetrics = "sortMetrics",
|
SortMetrics = "sortMetrics",
|
||||||
@ -29,7 +29,7 @@ export enum MetricsType {
|
|||||||
HEATMAP = "HEATMAP",
|
HEATMAP = "HEATMAP",
|
||||||
SAMPLED_RECORD = "SAMPLED_RECORD",
|
SAMPLED_RECORD = "SAMPLED_RECORD",
|
||||||
}
|
}
|
||||||
export const QueryMetricTypes: {
|
export const ValuesTypes: {
|
||||||
[key: string]: Array<{ label: string; value: string }>;
|
[key: string]: Array<{ label: string; value: string }>;
|
||||||
} = {
|
} = {
|
||||||
REGULAR_VALUE: [
|
REGULAR_VALUE: [
|
||||||
|
Loading…
Reference in New Issue
Block a user