|
|
@@ -1,5 +1,5 @@
|
|
|
import * as React from "react";
|
|
|
-import { Modal, Paper, Typography } from "@material-ui/core";
|
|
|
+import { Box, Modal, Paper, Typography } from "@material-ui/core";
|
|
|
import Warnings from "../components/Warnings";
|
|
|
import CircularProgress from "@material-ui/core/CircularProgress";
|
|
|
|
|
|
@@ -47,8 +47,8 @@ const CloudCostDetails = ({
|
|
|
costMetric,
|
|
|
nextFilters
|
|
|
);
|
|
|
- console.log(resp);
|
|
|
- if (resp) {
|
|
|
+
|
|
|
+ if (resp.data) {
|
|
|
setData(resp.data);
|
|
|
} else {
|
|
|
if (resp.message && resp.message.indexOf("boundary error") >= 0) {
|
|
|
@@ -67,6 +67,7 @@ const CloudCostDetails = ({
|
|
|
setData([]);
|
|
|
}
|
|
|
} catch (err) {
|
|
|
+ console.log(err);
|
|
|
if (err.message.indexOf("404") === 0) {
|
|
|
setErrors([
|
|
|
{
|
|
|
@@ -113,66 +114,64 @@ const CloudCostDetails = ({
|
|
|
return dataPoint;
|
|
|
});
|
|
|
|
|
|
- console.log(drilldownData);
|
|
|
-
|
|
|
return (
|
|
|
- <Modal
|
|
|
- open={true}
|
|
|
- onClose={onClose}
|
|
|
- title={`Costs over the last ${window}`}
|
|
|
- >
|
|
|
- <Paper>
|
|
|
- <Typography style={{ marginTop: "1rem" }} variant="body1">
|
|
|
- {selectedItem}
|
|
|
- </Typography>
|
|
|
+ <div>
|
|
|
+ <Modal
|
|
|
+ open={true}
|
|
|
+ onClose={onClose}
|
|
|
+ title={`Costs over the last ${window}`}
|
|
|
+ style={{ margin: "10%" }}
|
|
|
+ >
|
|
|
+ <Paper>
|
|
|
+ <Typography style={{ marginTop: "1rem" }} variant="body1">
|
|
|
+ {selectedItem}
|
|
|
+ </Typography>
|
|
|
|
|
|
- {loading && (
|
|
|
- <div style={{ display: "flex", justifyContent: "center" }}>
|
|
|
- <div style={{ paddingTop: 100, paddingBottom: 100 }}>
|
|
|
- <CircularProgress />
|
|
|
+ {loading && (
|
|
|
+ <div style={{ display: "flex", justifyContent: "center" }}>
|
|
|
+ <div style={{ paddingTop: 100, paddingBottom: 100 }}>
|
|
|
+ <CircularProgress />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- )}
|
|
|
- {!loading && errors.length > 0 && (
|
|
|
- <div style={{ marginBottom: 20 }}>
|
|
|
- <Warnings warnings={errors} />
|
|
|
- </div>
|
|
|
- )}
|
|
|
- {data && (
|
|
|
- <div style={{ display: "flex", marginTop: "2.5rem" }}>
|
|
|
- <ResponsiveContainer
|
|
|
- height={250}
|
|
|
- id={"cloud-cost-drilldown"}
|
|
|
- width={"100%"}
|
|
|
- >
|
|
|
- <BarChart
|
|
|
- data={itemData}
|
|
|
- margin={{
|
|
|
- top: 0,
|
|
|
- bottom: 10,
|
|
|
- left: 20,
|
|
|
- right: 0,
|
|
|
- }}
|
|
|
+ )}
|
|
|
+ {!loading && errors.length > 0 && (
|
|
|
+ <div style={{ marginBottom: 20 }}>
|
|
|
+ <Warnings warnings={errors} />
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ {data && (
|
|
|
+ <div style={{ display: "flex", marginTop: "2.5rem" }}>
|
|
|
+ <ResponsiveContainer
|
|
|
+ height={250}
|
|
|
+ id={"cloud-cost-drilldown"}
|
|
|
+ width={"100%"}
|
|
|
>
|
|
|
- <CartesianGrid vertical={false} />
|
|
|
- <Legend verticalAlign={"bottom"} />
|
|
|
- <XAxis
|
|
|
- dataKey={"time"}
|
|
|
- tickFormatter={(date) => format(date, "MM/dd/yyy")}
|
|
|
- />
|
|
|
- <YAxis tickFormatter={(tick) => `${toCurrency(tick)}`} />
|
|
|
- <Bar dataKey={"cost"} fill={"#2196f3"} name={"Item Cost"} />
|
|
|
- <Tooltip
|
|
|
- formatter={(value) =>
|
|
|
- `${toCurrency(value ?? 0, currency, 4, true)}`
|
|
|
- }
|
|
|
- />
|
|
|
- </BarChart>
|
|
|
- </ResponsiveContainer>
|
|
|
- </div>
|
|
|
- )}
|
|
|
- </Paper>
|
|
|
- </Modal>
|
|
|
+ <BarChart
|
|
|
+ data={itemData}
|
|
|
+ margin={{
|
|
|
+ top: 0,
|
|
|
+ bottom: 10,
|
|
|
+ left: 20,
|
|
|
+ right: 0,
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <CartesianGrid vertical={false} />
|
|
|
+ <Legend verticalAlign={"bottom"} />
|
|
|
+ <XAxis dataKey={"time"} />
|
|
|
+ <YAxis tickFormatter={(tick) => `${toCurrency(tick)}`} />
|
|
|
+ <Bar dataKey={"cost"} fill={"#2196f3"} name={"Item Cost"} />
|
|
|
+ <Tooltip
|
|
|
+ formatter={(value) =>
|
|
|
+ `${toCurrency(value ?? 0, currency, 4, true)}`
|
|
|
+ }
|
|
|
+ />
|
|
|
+ </BarChart>
|
|
|
+ </ResponsiveContainer>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ </Paper>
|
|
|
+ </Modal>
|
|
|
+ </div>
|
|
|
);
|
|
|
};
|
|
|
|