mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-17 16:15:25 +00:00
update list
This commit is contained in:
parent
9c34ac0c3b
commit
b84b5f9338
@ -257,7 +257,11 @@ export function useQueryPodsMetrics(
|
||||
export function usePodsSource(
|
||||
pods: Array<Instance | Endpoint>,
|
||||
resp: { errors: string; data: { [key: string]: any } },
|
||||
config: { metrics: string[]; metricTypes: string[] }
|
||||
config: {
|
||||
metrics: string[];
|
||||
metricTypes: string[];
|
||||
metricConfig: MetricConfigOpt[];
|
||||
}
|
||||
): any {
|
||||
if (resp.errors) {
|
||||
ElMessage.error(resp.errors);
|
||||
@ -265,13 +269,14 @@ export function usePodsSource(
|
||||
}
|
||||
const data = pods.map((d: Instance | any, idx: number) => {
|
||||
config.metrics.map((name: string, index: number) => {
|
||||
const c = (config.metricConfig && config.metricConfig[index]) || {};
|
||||
const key = name + idx + index;
|
||||
if (config.metricTypes[index] === MetricQueryTypes.ReadMetricsValue) {
|
||||
d[name] = resp.data[key];
|
||||
d[name] = aggregation(resp.data[key], c);
|
||||
}
|
||||
if (config.metricTypes[index] === MetricQueryTypes.ReadMetricsValues) {
|
||||
d[name] = resp.data[key].values.values.map(
|
||||
(d: { value: number }) => d.value
|
||||
d[name] = resp.data[key].values.values.map((d: { value: number }) =>
|
||||
aggregation(d.value, c)
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -307,7 +312,7 @@ export function useQueryTopologyMetrics(metrics: string[], ids: string[]) {
|
||||
}
|
||||
|
||||
function aggregation(val: number, config: any): number | string {
|
||||
let data: number | string = val;
|
||||
let data: number | string = Number(val);
|
||||
|
||||
switch (config.calculation) {
|
||||
case Calculations.Percentage:
|
||||
@ -329,5 +334,7 @@ function aggregation(val: number, config: any): number | string {
|
||||
data;
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
return data;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ import { Option } from "@/types/app";
|
||||
import graphs from "../graphs";
|
||||
import configs from "./widget/graph-styles";
|
||||
import WidgetOptions from "./widget/WidgetOptions.vue";
|
||||
import MetricOptions from "./widget/metric/MetricOptions.vue";
|
||||
import MetricOptions from "./widget/metric/Options.vue";
|
||||
|
||||
export default defineComponent({
|
||||
name: "WidgetEdit",
|
||||
|
@ -55,7 +55,7 @@ limitations under the License. -->
|
||||
<Icon class="cp mr-5" iconName="mode_edit" size="middle" />
|
||||
</span>
|
||||
</template>
|
||||
<StandardOptions @update="queryMetrics" @close="showConfig = false" />
|
||||
<Standard @update="queryMetrics" @close="showConfig = false" />
|
||||
</el-popover>
|
||||
<span
|
||||
v-show="states.isList || states.metricTypes[0] === 'readMetricsValues'"
|
||||
@ -110,7 +110,7 @@ import Icon from "@/components/Icon.vue";
|
||||
import { useQueryProcessor, useSourceProcessor } from "@/hooks/useProcessor";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { DashboardItem, MetricConfigOpt } from "@/types/dashboard";
|
||||
import StandardOptions from "./StandardOptions.vue";
|
||||
import Standard from "./Standard.vue";
|
||||
|
||||
/*global defineEmits */
|
||||
const { t } = useI18n();
|
@ -105,7 +105,6 @@ function changeConfigs(index: number, param: { [key: string]: string }) {
|
||||
...dashboardStore.selectedGrid,
|
||||
metricConfig,
|
||||
});
|
||||
console.log(dashboardStore.selectedGrid);
|
||||
emit("update");
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ limitations under the License. -->
|
||||
metricTypes: data.metricTypes,
|
||||
i: data.i,
|
||||
}"
|
||||
:standard="data.standard"
|
||||
:standard="data.metricConfig"
|
||||
:needQuery="needQuery"
|
||||
/>
|
||||
</div>
|
||||
|
@ -31,7 +31,7 @@ limitations under the License. -->
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { computed, PropType } from "vue";
|
||||
import { CardConfig, StandardConfig } from "@/types/dashboard";
|
||||
import { CardConfig, MetricConfigOpt } from "@/types/dashboard";
|
||||
|
||||
/*global defineProps */
|
||||
const props = defineProps({
|
||||
@ -44,7 +44,7 @@ const props = defineProps({
|
||||
default: () => ({ fontSize: 12, showUint: true, textAlign: "center" }),
|
||||
},
|
||||
standard: {
|
||||
type: Object as PropType<StandardConfig>,
|
||||
type: Object as PropType<MetricConfigOpt>,
|
||||
default: () => ({ unit: "" }),
|
||||
},
|
||||
});
|
||||
|
@ -104,6 +104,7 @@ import { useQueryPodsMetrics, usePodsSource } from "@/hooks/useProcessor";
|
||||
import { EntityType } from "../data";
|
||||
import router from "@/router";
|
||||
import getDashboard from "@/hooks/useDashboardsSession";
|
||||
import { MetricConfigOpt } from "@/types/dashboard";
|
||||
|
||||
/*global defineProps */
|
||||
const props = defineProps({
|
||||
@ -123,6 +124,10 @@ const props = defineProps({
|
||||
},
|
||||
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
|
||||
isEdit: { type: Boolean, default: false },
|
||||
standard: {
|
||||
type: Object as PropType<MetricConfigOpt[]>,
|
||||
default: () => ({ unit: "" }),
|
||||
},
|
||||
});
|
||||
const selectorStore = useSelectorStore();
|
||||
const dashboardStore = useDashboardStore();
|
||||
@ -201,7 +206,7 @@ async function queryServiceMetrics(currentServices: Service[]) {
|
||||
return;
|
||||
}
|
||||
const { metrics } = props.config;
|
||||
|
||||
console.log(props.config);
|
||||
if (metrics.length && metrics[0]) {
|
||||
const params = await useQueryPodsMetrics(
|
||||
currentServices,
|
||||
@ -214,7 +219,10 @@ async function queryServiceMetrics(currentServices: Service[]) {
|
||||
ElMessage.error(json.errors);
|
||||
return;
|
||||
}
|
||||
services.value = usePodsSource(currentServices, json, props.config);
|
||||
services.value = usePodsSource(currentServices, json, {
|
||||
...props.config,
|
||||
metricConfig: props.standard || [],
|
||||
});
|
||||
return;
|
||||
}
|
||||
services.value = currentServices;
|
||||
|
Loading…
Reference in New Issue
Block a user