handle metrics

This commit is contained in:
Fine 2025-01-02 17:48:43 +08:00
parent af0af466ce
commit 77630ecb5d
3 changed files with 42 additions and 2 deletions

View File

@ -141,6 +141,7 @@ export async function useDashboardQueryProcessor(configList: Indexable[]) {
} }
} }
} }
console.log(source);
return { source, tips, typesOfMQE }; return { source, tips, typesOfMQE };
} }
async function fetchMetrics(configArr: any) { async function fetchMetrics(configArr: any) {

33
src/hooks/useSnapshot.ts Normal file
View File

@ -0,0 +1,33 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function useSnapshot(metrics: { name: string; results: any[] }[]) {
function processResults() {
const sources = metrics.map((metric: { name: string; results: any[] }) => {
const values = metric.results.map((r: { values: { value: string }[] }) =>
r.values.map((v: { value: string }) => v.value),
);
return { [metric.name]: values[0] };
});
return sources;
}
return {
processResults,
};
}

View File

@ -13,14 +13,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
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. -->
<template> <template>
<div class="snapshot flex-v"> Line Charts </div> <div class="snapshot flex-v">
<LineChart />
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import LineChart from "@/views/dashboard/graphs/Line.vue";
import { useSnapshot } from "@/hooks/useSnapshot";
/*global defineProps */ /*global defineProps */
const props = defineProps({ const props = defineProps({
snapshot: { type: Object, default: () => {} }, snapshot: { type: Object, default: () => {} },
}); });
console.log(props.snapshot); const { processResults } = useSnapshot(props.snapshot.metrics);
const data = processResults();
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>