mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-12 07:36:14 +00:00
add type
This commit is contained in:
parent
b2627de8c2
commit
4e47242053
@ -14,10 +14,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import type { MetricsResults } from "@/types/dashboard";
|
||||
|
||||
export function useSnapshot(metrics: { name: string; results: any[] }[]) {
|
||||
export function useSnapshot(metrics: { name: string; results: MetricsResults[] }[]) {
|
||||
function processResults() {
|
||||
const sources = metrics.map((metric: { name: string; results: any[] }) => {
|
||||
const sources = metrics.map((metric: { name: string; results: MetricsResults[] }) => {
|
||||
const values = metric.results.map(
|
||||
(r: { values: { value: string }[]; metric: { labels: { key: string; value: string }[] } }) => {
|
||||
const arr = r.values.map((v: { value: string }) => Number(v.value));
|
||||
|
14
src/types/dashboard.d.ts
vendored
14
src/types/dashboard.d.ts
vendored
@ -198,3 +198,17 @@ export type LegendOptions = {
|
||||
toTheRight: boolean;
|
||||
width: number;
|
||||
};
|
||||
export type MetricsResults = {
|
||||
metric: { labels: MetricLabel[] };
|
||||
values: MetricValue[];
|
||||
};
|
||||
type MetricLabel = {
|
||||
key: string;
|
||||
value: string;
|
||||
};
|
||||
type MetricValue = {
|
||||
name: string;
|
||||
value: string;
|
||||
owner: null | string;
|
||||
refId: null | string;
|
||||
};
|
||||
|
@ -139,6 +139,7 @@ limitations under the License. -->
|
||||
import { useSnapshot } from "@/hooks/useSnapshot";
|
||||
import Snapshot from "./components/Snapshot.vue";
|
||||
import Line from "@/views/dashboard/graphs/Line.vue";
|
||||
import type { MetricsResults } from "@/types/dashboard";
|
||||
|
||||
const { t } = useI18n();
|
||||
const alarmStore = useAlarmStore();
|
||||
@ -164,7 +165,7 @@ limitations under the License. -->
|
||||
showEventDetails.value = true;
|
||||
}
|
||||
|
||||
function handleMetrics(snapshot: any) {
|
||||
function handleMetrics(snapshot: { metrics: { name: string; results: MetricsResults[] }[] }) {
|
||||
const { getMetricsMap } = useSnapshot(snapshot.metrics);
|
||||
|
||||
return getMetricsMap();
|
||||
|
Loading…
Reference in New Issue
Block a user