chore: dashboard api

This commit is contained in:
jialin
2024-06-26 19:01:38 +08:00
parent 0fa4e21fa5
commit 1293f71bce
21 changed files with 430 additions and 188 deletions
+6 -19
View File
@@ -1,6 +1,8 @@
import { Card, Col, Row, Space } from 'antd';
import React from 'react';
import _ from 'lodash';
import React, { useContext } from 'react';
import { overviewConfigs } from '../config';
import { DashboardContext } from '../config/dashboard-context';
import '../styles/index.less';
import styles from './over-view.less';
@@ -23,23 +25,8 @@ const renderCardItem = (data: {
</Card>
);
};
const Overview: React.FC = (props) => {
// const { data = {} } = props;
const data = {
workers: 8,
models: {
healthy: 10,
warning: 2,
error: 1
},
gpus: 30,
allocatedGpus: 12,
instances: {
healthy: 32,
warning: 3,
error: 2
}
};
const Overview: React.FC = () => {
const data = useContext(DashboardContext).resource_counts || {};
const renderValue = (
value:
@@ -75,7 +62,7 @@ const Overview: React.FC = (props) => {
>
{renderCardItem({
label: config.label,
value: renderValue(data[config.key] || 0),
value: renderValue(_.get(data, config.key, 0)),
bgColor: config.backgroundColor
})}
</Col>