-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from wolfeaustin/austin/opencost-ui-external-c…
…osts adds external costs page, reorganizes for longevity
- Loading branch information
Showing
24 changed files
with
5,364 additions
and
4,159 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Modal, Paper } from "@material-ui/core"; | ||
import { | ||
TableContainer, | ||
TableCell, | ||
TableRow, | ||
Table, | ||
TableBody, | ||
} from "@material-ui/core"; | ||
|
||
// for now, we can assume that the "Name" is resourceType | ||
export const ExternalCostDetails = ({ row, onClose }) => ( | ||
<div> | ||
<Modal | ||
open={true} | ||
onClose={onClose} | ||
title={row.resource_type} | ||
style={{ margin: "10%" }} | ||
> | ||
<Paper style={{ padding: 20 }}> | ||
<TableContainer> | ||
<Table> | ||
<TableBody> | ||
<TableRow> | ||
<TableCell>account_name</TableCell> | ||
<TableCell>{row.account_name}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>aggregate</TableCell> | ||
<TableCell>{row.aggregate}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>charge_category</TableCell> | ||
<TableCell>{row.charge_category}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>cost</TableCell> | ||
<TableCell>{row.cost}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>cost_source</TableCell> | ||
<TableCell>{row.cost_source}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>cost_type</TableCell> | ||
<TableCell>{row.cost_type}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>description</TableCell> | ||
<TableCell>{row.description}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>domain</TableCell> | ||
<TableCell>{row.domain}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>id</TableCell> | ||
<TableCell>{row.id}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>list_unit_price</TableCell> | ||
<TableCell>{row.list_unit_price}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>provider_id</TableCell> | ||
<TableCell>{row.provider_id}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>resource_name</TableCell> | ||
<TableCell>{row.resource_name}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>resource_type</TableCell> | ||
<TableCell>{row.resource_type}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>usage_quantity</TableCell> | ||
<TableCell>{row.usage_quantity}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>usage_unit</TableCell> | ||
<TableCell>{row.usage_unit}</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell>zone</TableCell> | ||
<TableCell>{row.zone}</TableCell> | ||
</TableRow> | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
</Paper> | ||
</Modal> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as React from "react"; | ||
|
||
import { TableCell, TableRow } from "@material-ui/core"; | ||
|
||
import { toCurrency } from "../../util"; | ||
import { primary } from "../../constants/colors"; | ||
|
||
const displayCurrencyAsLessThanPenny = (amount, currency) => | ||
amount > 0 && amount < 0.01 | ||
? `<${toCurrency(0.01, currency)}` | ||
: toCurrency(amount, currency); | ||
|
||
function capitalizeFirstLetter(string) { | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} | ||
|
||
const ExternalCostRow = ({ | ||
cost, | ||
currency, | ||
onClick, | ||
name, | ||
costType, | ||
}) => { | ||
return ( | ||
<TableRow onClick={onClick}> | ||
<TableCell | ||
align={"left"} | ||
style={{ cursor: "pointer", color: "#346ef2", padding: "1rem" }} | ||
> | ||
{name} | ||
</TableCell> | ||
<TableCell align={"right"} style={{ paddingRight: "2em" }}> | ||
{capitalizeFirstLetter(costType)} | ||
</TableCell> | ||
{/* total cost */} | ||
<TableCell align={"right"} style={{ paddingRight: "2em" }}> | ||
{`${displayCurrencyAsLessThanPenny(cost, currency)}`} | ||
</TableCell> | ||
</TableRow> | ||
); | ||
}; | ||
|
||
export { ExternalCostRow }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as React from "react"; | ||
|
||
import Typography from "@material-ui/core/Typography"; | ||
|
||
import RangeChart from "./rangeChart"; | ||
|
||
const ExternalCostsChart = ({ | ||
graphData, | ||
currency, | ||
n, | ||
height, | ||
aggregateBy, | ||
}) => { | ||
if (graphData.length === 0) { | ||
return ( | ||
<Typography variant="body2" style={{ padding: "4em" }}> | ||
No data | ||
</Typography> | ||
); | ||
} | ||
return ( | ||
<RangeChart | ||
data={graphData} | ||
currency={currency} | ||
height={height} | ||
aggregateBy={aggregateBy} | ||
/> | ||
); | ||
}; | ||
|
||
export default React.memo(ExternalCostsChart); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { makeStyles } from "@material-ui/styles"; | ||
import FormControl from "@material-ui/core/FormControl"; | ||
import InputLabel from "@material-ui/core/InputLabel"; | ||
import MenuItem from "@material-ui/core/MenuItem"; | ||
import Select from "@material-ui/core/Select"; | ||
|
||
import * as React from "react"; | ||
|
||
import SelectWindow from "../../components/SelectWindow"; | ||
import { | ||
windowOptions, | ||
aggregationOptions, | ||
costTypeOptions | ||
} from '../../components/externalCosts/tokens' | ||
|
||
const useStyles = makeStyles({ | ||
wrapper: { | ||
display: "inline-flex", | ||
}, | ||
formControl: { | ||
margin: 8, | ||
minWidth: 120, | ||
}, | ||
}); | ||
|
||
function ExternalCostsControls({ | ||
window, | ||
setWindow, | ||
aggregateBy, | ||
setAggregateBy, | ||
costType, | ||
setCostType | ||
}) { | ||
const classes = useStyles(); | ||
return ( | ||
<div className={classes.wrapper}> | ||
<SelectWindow | ||
windowOptions={windowOptions} | ||
window={window} | ||
setWindow={setWindow} | ||
/> | ||
<FormControl className={classes.formControl}> | ||
<InputLabel id="aggregation-select-label">Breakdown</InputLabel> | ||
<Select | ||
id="aggregation-select" | ||
value={aggregateBy} | ||
onChange={(e) => { | ||
setAggregateBy(e.target.value); | ||
}} | ||
> | ||
{aggregationOptions.map((opt) => ( | ||
<MenuItem key={opt.value} value={opt.value}> | ||
{opt.name} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
<FormControl className={classes.formControl}> | ||
<InputLabel id="aggregation-select-label">Cost Type</InputLabel> | ||
<Select | ||
id="cost-type-select" | ||
value={costType} | ||
onChange={(e) => { | ||
setCostType(e.target.value); | ||
}} | ||
> | ||
{costTypeOptions.map((opt) => ( | ||
<MenuItem key={opt.value} value={opt.value}> | ||
{opt.name} | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</div> | ||
); | ||
} | ||
|
||
export default React.memo(ExternalCostsControls); |
Oops, something went wrong.