78
app/routes/Dashboards/System/components/CardSystem.js
Executable file
78
app/routes/Dashboards/System/components/CardSystem.js
Executable file
@@ -0,0 +1,78 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import {
|
||||
Card,
|
||||
CardBody,
|
||||
Badge
|
||||
} from './../../../../components';
|
||||
|
||||
import {
|
||||
TinyDonutChart
|
||||
} from "./TinyDonutChart"
|
||||
import {
|
||||
TinyBarChart
|
||||
} from "./TinyBarChart"
|
||||
|
||||
import { randomArray } from './../../../../utilities';
|
||||
|
||||
const percents = [
|
||||
"15",
|
||||
"25",
|
||||
"30",
|
||||
"35",
|
||||
"40",
|
||||
"45",
|
||||
"55",
|
||||
"60",
|
||||
"75",
|
||||
"80",
|
||||
"95"
|
||||
];
|
||||
|
||||
const caret = [
|
||||
"down",
|
||||
"up"
|
||||
];
|
||||
|
||||
const CardSystem = (props) => (
|
||||
<Card className="mb-3 mb-lg-0">
|
||||
<CardBody className="pb-0">
|
||||
<div className="d-flex">
|
||||
<span>
|
||||
<Badge pill className="mb-3" color={ props.badgeColor } >
|
||||
<i className={` fa fa-fw fa-caret-${ randomArray(caret) }`} />
|
||||
{ randomArray(percents) }%
|
||||
</Badge>
|
||||
<h6 className="mb-0">
|
||||
{ props.title }
|
||||
</h6>
|
||||
<h2 className="mb-3">
|
||||
{ randomArray(percents) } <small>{ props.unit }</small>
|
||||
</h2>
|
||||
</span>
|
||||
<span className="text-right ml-auto">
|
||||
<TinyDonutChart
|
||||
pieColor={props.pieColor}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
<TinyBarChart />
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
|
||||
CardSystem.propTypes = {
|
||||
title: PropTypes.node,
|
||||
badgeColor: PropTypes.string,
|
||||
unit: PropTypes.node,
|
||||
pieColor: PropTypes.string
|
||||
};
|
||||
CardSystem.defaultProps = {
|
||||
title: "Waiting...",
|
||||
badgeColor: "secondary",
|
||||
unit: "%",
|
||||
pieColor: "500"
|
||||
};
|
||||
|
||||
export { CardSystem };
|
32
app/routes/Dashboards/System/components/TinyAreaChart.js
Executable file
32
app/routes/Dashboards/System/components/TinyAreaChart.js
Executable file
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
ResponsiveContainer,
|
||||
AreaChart,
|
||||
Area
|
||||
} from './../../../../components/recharts';
|
||||
|
||||
import colors from './../../../../colors';
|
||||
|
||||
const TinyAreaChart = (props) => {
|
||||
const data = _.times(20, () => ({ pv: Math.random() * 100 }));
|
||||
return (
|
||||
<ResponsiveContainer width='100%' minWidth='150px' height={ 40 }>
|
||||
<AreaChart data={data}>
|
||||
<Area dataKey='pv' stroke={ colors[ props.strokeColor ] } fill={ colors[ props.fillColor ] } />
|
||||
</AreaChart>
|
||||
</ResponsiveContainer>
|
||||
)
|
||||
};
|
||||
|
||||
TinyAreaChart.propTypes = {
|
||||
strokeColor: PropTypes.string,
|
||||
fillColor: PropTypes.string
|
||||
};
|
||||
TinyAreaChart.defaultProps = {
|
||||
strokeColor: "600",
|
||||
fillColor: "200",
|
||||
};
|
||||
|
||||
export { TinyAreaChart };
|
31
app/routes/Dashboards/System/components/TinyBarChart.js
Executable file
31
app/routes/Dashboards/System/components/TinyBarChart.js
Executable file
@@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
ResponsiveContainer,
|
||||
BarChart,
|
||||
Bar
|
||||
} from './../../../../components/recharts';
|
||||
|
||||
import colors from './../../../../colors';
|
||||
|
||||
const TinyBarChart = (props) => {
|
||||
const data = _.times(40, () => ({ pv: 20+Math.random() * 100 }));
|
||||
return (
|
||||
<ResponsiveContainer width='100%' height={ 80 }>
|
||||
<BarChart data={data} margin={{ top: 0, bottom: 0, right: 0, left: 0 }}>
|
||||
<Bar dataKey='pv' fill={ colors[ props.barColor ] } />
|
||||
</BarChart>
|
||||
</ResponsiveContainer>
|
||||
)
|
||||
};
|
||||
|
||||
TinyBarChart.propTypes = {
|
||||
barColor: PropTypes.string
|
||||
};
|
||||
TinyBarChart.defaultProps = {
|
||||
barColor: "200"
|
||||
};
|
||||
|
||||
export { TinyBarChart };
|
43
app/routes/Dashboards/System/components/TinyDonutChart.js
Executable file
43
app/routes/Dashboards/System/components/TinyDonutChart.js
Executable file
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
PieChart,
|
||||
Pie,
|
||||
Cell
|
||||
} from './../../../../components/recharts';
|
||||
|
||||
import colors from './../../../../colors';
|
||||
|
||||
const TinyDonutChart = (props) => {
|
||||
const data = [
|
||||
{name: 'Group A', value: 40+Math.random()*100},
|
||||
{name: 'Group B', value: Math.random()*100}
|
||||
];
|
||||
return (
|
||||
<PieChart width={ 80 } height={ 80 }>
|
||||
<Pie
|
||||
data={data}
|
||||
dataKey="value"
|
||||
stroke={ colors[ props.strokeColor ] }
|
||||
innerRadius={ 28 }
|
||||
outerRadius={ 35 }
|
||||
fill={ colors[ props.pieBg ] }
|
||||
>
|
||||
<Cell fill={ colors[ props.pieColor ] } />
|
||||
</Pie>
|
||||
</PieChart>
|
||||
)
|
||||
};
|
||||
|
||||
TinyDonutChart.propTypes = {
|
||||
pieColor: PropTypes.string,
|
||||
strokeColor: PropTypes.string,
|
||||
pieBg: PropTypes.string
|
||||
};
|
||||
TinyDonutChart.defaultProps = {
|
||||
pieColor: "primary",
|
||||
strokeColor: "white",
|
||||
pieBg: "200"
|
||||
};
|
||||
|
||||
export { TinyDonutChart };
|
132
app/routes/Dashboards/System/components/trSystem.js
Executable file
132
app/routes/Dashboards/System/components/trSystem.js
Executable file
@@ -0,0 +1,132 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
Progress,
|
||||
Badge
|
||||
} from './../../../../components';
|
||||
|
||||
import {
|
||||
TinyAreaChart
|
||||
} from "./TinyAreaChart"
|
||||
|
||||
import { randomArray } from './../../../../utilities';
|
||||
|
||||
const percents = [
|
||||
"15",
|
||||
"25",
|
||||
"30",
|
||||
"35",
|
||||
"40",
|
||||
"45",
|
||||
"55",
|
||||
"60",
|
||||
"75",
|
||||
"80",
|
||||
"95"
|
||||
];
|
||||
|
||||
const versions = [
|
||||
"1.10",
|
||||
"1.34",
|
||||
"2.35",
|
||||
"0.23",
|
||||
"2.90",
|
||||
"9.05"
|
||||
];
|
||||
|
||||
const name = [
|
||||
"Apache",
|
||||
"Postfix",
|
||||
"Ruby R1",
|
||||
"MySQL",
|
||||
"Ruby R2"
|
||||
];
|
||||
|
||||
const gbLeft = [
|
||||
"2,234",
|
||||
"6,738",
|
||||
"982",
|
||||
"9,001",
|
||||
"1,329"
|
||||
];
|
||||
|
||||
const tdValue = [
|
||||
"783",
|
||||
"45",
|
||||
"4",
|
||||
"190",
|
||||
"65"
|
||||
];
|
||||
|
||||
const tdUnits = [
|
||||
"",
|
||||
"Mb",
|
||||
"%",
|
||||
"Kb/s"
|
||||
];
|
||||
|
||||
const TrSystem = (props) => (
|
||||
<tr>
|
||||
<td style={{ width: '20%' }}>
|
||||
<span className="d-flex mb-2">
|
||||
<h6 className="mb-0 mr-5">
|
||||
{ randomArray(name) }
|
||||
</h6>
|
||||
<Badge pill className="ml-auto align-self-center">
|
||||
v. { randomArray(versions) }
|
||||
</Badge>
|
||||
</span>
|
||||
<Progress value={ randomArray(percents) } style={{height: "4px"}} className="mb-2" />
|
||||
<span className="d-flex">
|
||||
<span className="text-inverse">
|
||||
{ randomArray(percents) }%
|
||||
</span>
|
||||
<span className="ml-auto text-right">
|
||||
{ randomArray(gbLeft) } GB Left
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
{
|
||||
_.map(props.colors, (color,index)=>(
|
||||
<td style={{ width: '20%' }} key={index}>
|
||||
<h6 className="mb-0">
|
||||
{ randomArray(tdValue) } {tdUnits[index]}
|
||||
</h6>
|
||||
<TinyAreaChart
|
||||
strokeColor={color.stroke}
|
||||
fillColor={color.fill}
|
||||
/>
|
||||
</td>
|
||||
))
|
||||
}
|
||||
</tr>
|
||||
);
|
||||
|
||||
TrSystem.propTypes = {
|
||||
title: PropTypes.node,
|
||||
|
||||
colors: PropTypes.array
|
||||
};
|
||||
TrSystem.defaultProps = {
|
||||
colors: [
|
||||
{
|
||||
fill: "400",
|
||||
stroke: "primary"
|
||||
},
|
||||
{
|
||||
fill: "yellow",
|
||||
stroke: "400"
|
||||
},
|
||||
{
|
||||
fill: "purple",
|
||||
stroke: "info"
|
||||
},
|
||||
{
|
||||
fill: "success",
|
||||
stroke: "500"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export { TrSystem };
|
Reference in New Issue
Block a user