@backstage-community/plugin-opencost 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/components/AllocationChart/RangeChart.esm.js +39 -34
  3. package/dist/components/AllocationChart/RangeChart.esm.js.map +1 -1
  4. package/dist/components/AllocationChart/SummaryChart.esm.js +12 -12
  5. package/dist/components/AllocationChart/SummaryChart.esm.js.map +1 -1
  6. package/dist/components/AllocationChart/index.esm.js +6 -5
  7. package/dist/components/AllocationChart/index.esm.js.map +1 -1
  8. package/dist/components/AllocationReport.esm.js +96 -64
  9. package/dist/components/AllocationReport.esm.js.map +1 -1
  10. package/dist/components/Controls/Download.esm.js +4 -3
  11. package/dist/components/Controls/Download.esm.js.map +1 -1
  12. package/dist/components/Controls/Edit.esm.js +50 -35
  13. package/dist/components/Controls/Edit.esm.js.map +1 -1
  14. package/dist/components/Controls/index.esm.js +23 -19
  15. package/dist/components/Controls/index.esm.js.map +1 -1
  16. package/dist/components/OpenCostPage/OpenCostPage.esm.js +12 -9
  17. package/dist/components/OpenCostPage/OpenCostPage.esm.js.map +1 -1
  18. package/dist/components/OpenCostReport/OpenCostReport.esm.js +63 -48
  19. package/dist/components/OpenCostReport/OpenCostReport.esm.js.map +1 -1
  20. package/dist/components/Page.esm.js +2 -2
  21. package/dist/components/Page.esm.js.map +1 -1
  22. package/dist/components/SelectWindow.esm.js +103 -90
  23. package/dist/components/SelectWindow.esm.js.map +1 -1
  24. package/dist/components/Subtitle.esm.js +13 -8
  25. package/dist/components/Subtitle.esm.js.map +1 -1
  26. package/dist/components/Warnings.esm.js +5 -2
  27. package/dist/components/Warnings.esm.js.map +1 -1
  28. package/dist/index.d.ts +2 -3
  29. package/package.json +12 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @backstage-community/plugin-opencost
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e81a2e2: Backstage version bump to v1.39.0
8
+
9
+ ## 0.7.0
10
+
11
+ ### Minor Changes
12
+
13
+ - a84ba7d: Backstage version bump to v1.38.1
14
+
3
15
  ## 0.6.1
4
16
 
5
17
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { ResponsiveContainer, BarChart, CartesianGrid, XAxis, YAxis, Tooltip, Bar } from 'recharts';
3
3
  import { makeStyles } from '@material-ui/core/styles';
4
4
  import { reverse } from 'lodash';
@@ -105,45 +105,50 @@ const RangeChart = ({ data, currency, height }) => {
105
105
  }
106
106
  const total = payload.reduce((sum, item) => sum + item.value, 0);
107
107
  if (active) {
108
- return /* @__PURE__ */ React.createElement("div", { className: classes.tooltip }, /* @__PURE__ */ React.createElement(
109
- "p",
110
- {
111
- className: classes.tooltipLineItem,
112
- style: { color: "#000000" }
113
- },
114
- `Total: ${toCurrency(total, currency)}`
115
- ), reverse(payload).map((item, i) => /* @__PURE__ */ React.createElement(
116
- "p",
117
- {
118
- key: i,
119
- className: classes.tooltipLineItem,
120
- style: { color: item.fill }
121
- },
122
- `${item.name}: ${toCurrency(item.value, currency)}`
123
- )));
108
+ return /* @__PURE__ */ jsxs("div", { className: classes.tooltip, children: [
109
+ /* @__PURE__ */ jsx(
110
+ "p",
111
+ {
112
+ className: classes.tooltipLineItem,
113
+ style: { color: "#000000" },
114
+ children: `Total: ${toCurrency(total, currency)}`
115
+ }
116
+ ),
117
+ reverse(payload).map((item, i) => /* @__PURE__ */ jsx(
118
+ "p",
119
+ {
120
+ className: classes.tooltipLineItem,
121
+ style: { color: item.fill },
122
+ children: `${item.name}: ${toCurrency(item.value, currency)}`
123
+ },
124
+ i
125
+ ))
126
+ ] });
124
127
  }
125
128
  return null;
126
129
  };
127
- return /* @__PURE__ */ React.createElement(ResponsiveContainer, { width: "100%", height }, /* @__PURE__ */ React.createElement(
130
+ return /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs(
128
131
  BarChart,
129
132
  {
130
133
  data: barData,
131
- margin: { top: 30, right: 30, left: 30, bottom: 12 }
132
- },
133
- /* @__PURE__ */ React.createElement(CartesianGrid, { strokeDasharray: "3 3" }),
134
- /* @__PURE__ */ React.createElement(XAxis, { dataKey: "start" }),
135
- /* @__PURE__ */ React.createElement(YAxis, null),
136
- /* @__PURE__ */ React.createElement(Tooltip, { content: /* @__PURE__ */ React.createElement(CustomTooltip, null) }),
137
- barLabels.map((barLabel, i) => /* @__PURE__ */ React.createElement(
138
- Bar,
139
- {
140
- key: i,
141
- dataKey: barLabel.dataKey,
142
- stackId: "a",
143
- fill: barLabel.fill
144
- }
145
- ))
146
- ));
134
+ margin: { top: 30, right: 30, left: 30, bottom: 12 },
135
+ children: [
136
+ /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
137
+ /* @__PURE__ */ jsx(XAxis, { dataKey: "start" }),
138
+ /* @__PURE__ */ jsx(YAxis, {}),
139
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}) }),
140
+ barLabels.map((barLabel, i) => /* @__PURE__ */ jsx(
141
+ Bar,
142
+ {
143
+ dataKey: barLabel.dataKey,
144
+ stackId: "a",
145
+ fill: barLabel.fill
146
+ },
147
+ i
148
+ ))
149
+ ]
150
+ }
151
+ ) });
147
152
  };
148
153
 
149
154
  export { RangeChart as default };
@@ -1 +1 @@
1
- {"version":3,"file":"RangeChart.esm.js","sources":["../../../src/components/AllocationChart/RangeChart.jsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport {\n BarChart,\n Bar,\n XAxis,\n YAxis,\n CartesianGrid,\n Tooltip,\n ResponsiveContainer,\n} from 'recharts';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { reverse } from 'lodash';\nimport { primary, greyscale, browns } from '../../constants/colors';\nimport { toCurrency } from '../../util';\n\nconst useStyles = makeStyles({\n tooltip: {\n borderRadius: 2,\n background: 'rgba(255, 255, 255, 0.95)',\n padding: 12,\n },\n tooltipLineItem: {\n fontSize: '1rem',\n margin: 0,\n marginBottom: 4,\n padding: 0,\n },\n});\n\nfunction toBarLabels(allocationRange) {\n const keyToFill = {};\n let p = 0;\n let g = 0;\n let b = 0;\n\n for (const { idle } of allocationRange) {\n for (const allocation of idle) {\n const key = allocation.name;\n if (keyToFill[key] === undefined) {\n // idle allocations are assigned grey\n keyToFill[key] = greyscale[g];\n g = (g + 1) % greyscale.length;\n }\n }\n }\n\n for (const { top } of allocationRange) {\n for (const allocation of top) {\n const key = allocation.name;\n if (keyToFill[key] === undefined) {\n if (key === '__unallocated__') {\n // unallocated gets black (clean up)\n keyToFill[key] = '#212121';\n } else {\n // non-idle allocations get the next available color\n keyToFill[key] = primary[p];\n p = (p + 1) % primary.length;\n }\n }\n }\n }\n\n for (const { other } of allocationRange) {\n for (const allocation of other) {\n const key = allocation.name;\n if (keyToFill[key] === undefined) {\n // idle allocations are assigned grey\n keyToFill[key] = browns[b];\n b = (b + 1) % browns.length;\n }\n }\n }\n\n const labels = [];\n for (const key in keyToFill) {\n if (Object.hasOwn(keyToFill, key)) {\n labels.push({\n dataKey: key,\n fill: keyToFill[key],\n });\n }\n }\n\n return reverse(labels);\n}\n\nfunction toBar(datum) {\n const { top, other, idle } = datum;\n const bar = {};\n\n for (const key in top) {\n if (Object.hasOwn(top, key)) {\n const allocation = top[key];\n const start = new Date(allocation.start);\n bar.start = `${start.getUTCFullYear()}-${\n start.getUTCMonth() + 1\n }-${start.getUTCDate()}`;\n bar[allocation.name] = allocation.totalCost;\n }\n }\n\n for (const key in other) {\n if (Object.hasOwn(other, key)) {\n const allocation = other[key];\n const start = new Date(allocation.start);\n bar.start = `${start.getUTCFullYear()}-${\n start.getUTCMonth() + 1\n }-${start.getUTCDate()}`;\n bar[allocation.name] = allocation.totalCost;\n }\n }\n\n for (const key in idle) {\n if (Object.hasOwn(idle, key)) {\n const allocation = idle[key];\n const start = new Date(allocation.start);\n bar.start = `${start.getUTCFullYear()}-${\n start.getUTCMonth() + 1\n }-${start.getUTCDate()}`;\n bar[allocation.name] = allocation.totalCost;\n }\n }\n\n return bar;\n}\n\nconst RangeChart = ({ data, currency, height }) => {\n const classes = useStyles();\n\n const barData = data.map(toBar);\n const barLabels = toBarLabels(data);\n\n const CustomTooltip = params => {\n const { active, payload } = params;\n\n if (!payload || payload.length === 0) {\n return null;\n }\n\n const total = payload.reduce((sum, item) => sum + item.value, 0.0);\n if (active) {\n /* eslint react/forbid-elements: [0, { allow: [\"warning\"] }] */\n return (\n <div className={classes.tooltip}>\n <p\n className={classes.tooltipLineItem}\n style={{ color: '#000000' }}\n >{`Total: ${toCurrency(total, currency)}`}</p>\n {reverse(payload).map((item, i) => (\n <p\n key={i}\n className={classes.tooltipLineItem}\n style={{ color: item.fill }}\n >{`${item.name}: ${toCurrency(item.value, currency)}`}</p>\n ))}\n </div>\n );\n }\n\n return null;\n };\n\n return (\n <ResponsiveContainer width=\"100%\" height={height}>\n <BarChart\n data={barData}\n margin={{ top: 30, right: 30, left: 30, bottom: 12 }}\n >\n <CartesianGrid strokeDasharray=\"3 3\" />\n <XAxis dataKey=\"start\" />\n <YAxis />\n <Tooltip content={<CustomTooltip />} />\n {barLabels.map((barLabel, i) => (\n <Bar\n key={i}\n dataKey={barLabel.dataKey}\n stackId=\"a\"\n fill={barLabel.fill}\n />\n ))}\n </BarChart>\n </ResponsiveContainer>\n );\n};\n\nexport default RangeChart;\n"],"names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,EAAO,QAAQ,CAAC,CAAA;AAAA,OACpD,CACH,CAAA;AAAA;AAIJ,IAAO,OAAA,IAAA;AAAA,GACT;AAEA,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAA,EAAoB,KAAM,EAAA,MAAA,EAAO,MAChC,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,IAAM,EAAA,OAAA;AAAA,MACN,MAAA,EAAQ,EAAE,GAAK,EAAA,EAAA,EAAI,OAAO,EAAI,EAAA,IAAA,EAAM,EAAI,EAAA,MAAA,EAAQ,EAAG;AAAA,KAAA;AAAA,oBAEnD,KAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,eAAA,EAAgB,KAAM,EAAA,CAAA;AAAA,oBACrC,KAAA,CAAA,aAAA,CAAC,KAAM,EAAA,EAAA,OAAA,EAAQ,OAAQ,EAAA,CAAA;AAAA,wCACtB,KAAM,EAAA,IAAA,CAAA;AAAA,oBACN,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,OAAS,kBAAA,KAAA,CAAA,aAAA,CAAC,mBAAc,CAAI,EAAA,CAAA;AAAA,IACpC,SAAU,CAAA,GAAA,CAAI,CAAC,QAAA,EAAU,CACxB,qBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,GAAA;AAAA,MAAA;AAAA,QACC,GAAK,EAAA,CAAA;AAAA,QACL,SAAS,QAAS,CAAA,OAAA;AAAA,QAClB,OAAQ,EAAA,GAAA;AAAA,QACR,MAAM,QAAS,CAAA;AAAA;AAAA,KAElB;AAAA,GAEL,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"RangeChart.esm.js","sources":["../../../src/components/AllocationChart/RangeChart.jsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n BarChart,\n Bar,\n XAxis,\n YAxis,\n CartesianGrid,\n Tooltip,\n ResponsiveContainer,\n} from 'recharts';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { reverse } from 'lodash';\nimport { primary, greyscale, browns } from '../../constants/colors';\nimport { toCurrency } from '../../util';\n\nconst useStyles = makeStyles({\n tooltip: {\n borderRadius: 2,\n background: 'rgba(255, 255, 255, 0.95)',\n padding: 12,\n },\n tooltipLineItem: {\n fontSize: '1rem',\n margin: 0,\n marginBottom: 4,\n padding: 0,\n },\n});\n\nfunction toBarLabels(allocationRange) {\n const keyToFill = {};\n let p = 0;\n let g = 0;\n let b = 0;\n\n for (const { idle } of allocationRange) {\n for (const allocation of idle) {\n const key = allocation.name;\n if (keyToFill[key] === undefined) {\n // idle allocations are assigned grey\n keyToFill[key] = greyscale[g];\n g = (g + 1) % greyscale.length;\n }\n }\n }\n\n for (const { top } of allocationRange) {\n for (const allocation of top) {\n const key = allocation.name;\n if (keyToFill[key] === undefined) {\n if (key === '__unallocated__') {\n // unallocated gets black (clean up)\n keyToFill[key] = '#212121';\n } else {\n // non-idle allocations get the next available color\n keyToFill[key] = primary[p];\n p = (p + 1) % primary.length;\n }\n }\n }\n }\n\n for (const { other } of allocationRange) {\n for (const allocation of other) {\n const key = allocation.name;\n if (keyToFill[key] === undefined) {\n // idle allocations are assigned grey\n keyToFill[key] = browns[b];\n b = (b + 1) % browns.length;\n }\n }\n }\n\n const labels = [];\n for (const key in keyToFill) {\n if (Object.hasOwn(keyToFill, key)) {\n labels.push({\n dataKey: key,\n fill: keyToFill[key],\n });\n }\n }\n\n return reverse(labels);\n}\n\nfunction toBar(datum) {\n const { top, other, idle } = datum;\n const bar = {};\n\n for (const key in top) {\n if (Object.hasOwn(top, key)) {\n const allocation = top[key];\n const start = new Date(allocation.start);\n bar.start = `${start.getUTCFullYear()}-${\n start.getUTCMonth() + 1\n }-${start.getUTCDate()}`;\n bar[allocation.name] = allocation.totalCost;\n }\n }\n\n for (const key in other) {\n if (Object.hasOwn(other, key)) {\n const allocation = other[key];\n const start = new Date(allocation.start);\n bar.start = `${start.getUTCFullYear()}-${\n start.getUTCMonth() + 1\n }-${start.getUTCDate()}`;\n bar[allocation.name] = allocation.totalCost;\n }\n }\n\n for (const key in idle) {\n if (Object.hasOwn(idle, key)) {\n const allocation = idle[key];\n const start = new Date(allocation.start);\n bar.start = `${start.getUTCFullYear()}-${\n start.getUTCMonth() + 1\n }-${start.getUTCDate()}`;\n bar[allocation.name] = allocation.totalCost;\n }\n }\n\n return bar;\n}\n\nconst RangeChart = ({ data, currency, height }) => {\n const classes = useStyles();\n\n const barData = data.map(toBar);\n const barLabels = toBarLabels(data);\n\n const CustomTooltip = params => {\n const { active, payload } = params;\n\n if (!payload || payload.length === 0) {\n return null;\n }\n\n const total = payload.reduce((sum, item) => sum + item.value, 0.0);\n if (active) {\n /* eslint react/forbid-elements: [0, { allow: [\"warning\"] }] */\n return (\n <div className={classes.tooltip}>\n <p\n className={classes.tooltipLineItem}\n style={{ color: '#000000' }}\n >{`Total: ${toCurrency(total, currency)}`}</p>\n {reverse(payload).map((item, i) => (\n <p\n key={i}\n className={classes.tooltipLineItem}\n style={{ color: item.fill }}\n >{`${item.name}: ${toCurrency(item.value, currency)}`}</p>\n ))}\n </div>\n );\n }\n\n return null;\n };\n\n return (\n <ResponsiveContainer width=\"100%\" height={height}>\n <BarChart\n data={barData}\n margin={{ top: 30, right: 30, left: 30, bottom: 12 }}\n >\n <CartesianGrid strokeDasharray=\"3 3\" />\n <XAxis dataKey=\"start\" />\n <YAxis />\n <Tooltip content={<CustomTooltip />} />\n {barLabels.map((barLabel, i) => (\n <Bar\n key={i}\n dataKey={barLabel.dataKey}\n stackId=\"a\"\n fill={barL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AG,KAAK,IAAI,CAAA,EAAA,EAAK,WAAW,IAAK,CAAA,KAAA,EAAO,QAAQ,CAAC,CAAA;AAAA,WAAA;AAAA,UAH5C;AAAA,SAIR;AAAA,OACH,EAAA,CAAA;AAAA;AAIJ,IAAO,OAAA,IAAA;AAAA,GACT;AAEA,EAAA,uBACG,GAAA,CAAA,mBAAA,EAAA,EAAoB,KAAM,EAAA,MAAA,EAAO,MAChC,EAAA,QAAA,kBAAA,IAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,IAAM,EAAA,OAAA;AAAA,MACN,MAAA,EAAQ,EAAE,GAAK,EAAA,EAAA,EAAI,OAAO,EAAI,EAAA,IAAA,EAAM,EAAI,EAAA,MAAA,EAAQ,EAAG,EAAA;AAAA,MAEnD,QAAA,EAAA;AAAA,wBAAC,GAAA,CAAA,aAAA,EAAA,EAAc,iBAAgB,KAAM,EAAA,CAAA;AAAA,wBACrC,GAAA,CAAC,KAAM,EAAA,EAAA,OAAA,EAAQ,OAAQ,EAAA,CAAA;AAAA,4BACtB,KAAM,EAAA,EAAA,CAAA;AAAA,wBACN,GAAA,CAAA,OAAA,EAAA,EAAQ,OAAS,kBAAA,GAAA,CAAC,iBAAc,CAAI,EAAA,CAAA;AAAA,QACpC,SAAU,CAAA,GAAA,CAAI,CAAC,QAAA,EAAU,CACxB,qBAAA,GAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YAEC,SAAS,QAAS,CAAA,OAAA;AAAA,YAClB,OAAQ,EAAA,GAAA;AAAA,YACR,MAAM,QAAS,CAAA;AAAA,WAAA;AAAA,UAHV;AAAA,SAKR;AAAA;AAAA;AAAA,GAEL,EAAA,CAAA;AAEJ;;;;"}
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { jsx } from 'react/jsx-runtime';
2
2
  import { ResponsiveContainer, PieChart, Pie, Cell } from 'recharts';
3
3
  import { primary, browns, greyscale } from '../../constants/colors.esm.js';
4
4
  import { toCurrency } from '../../util.esm.js';
@@ -52,21 +52,21 @@ const SummaryChart = ({ top, other, idle, currency, height }) => {
52
52
  if (percent < 0.02) {
53
53
  return void 0;
54
54
  }
55
- return /* @__PURE__ */ React.createElement(
55
+ return /* @__PURE__ */ jsx(
56
56
  "text",
57
57
  {
58
58
  x,
59
59
  y,
60
60
  fill,
61
61
  textAnchor: x > cx ? "start" : "end",
62
- dominantBaseline: "central"
63
- },
64
- `${name}: ${toCurrency(value, currency)} (${(percent * 100).toFixed(
65
- 1
66
- )}%)`
62
+ dominantBaseline: "central",
63
+ children: `${name}: ${toCurrency(value, currency)} (${(percent * 100).toFixed(
64
+ 1
65
+ )}%)`
66
+ }
67
67
  );
68
68
  };
69
- return /* @__PURE__ */ React.createElement(ResponsiveContainer, { width: "100%", height }, /* @__PURE__ */ React.createElement(PieChart, null, /* @__PURE__ */ React.createElement(
69
+ return /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsx(PieChart, { children: /* @__PURE__ */ jsx(
70
70
  Pie,
71
71
  {
72
72
  data: pieData,
@@ -79,10 +79,10 @@ const SummaryChart = ({ top, other, idle, currency, height }) => {
79
79
  outerRadius: "140%",
80
80
  innerRadius: "60%",
81
81
  startAngle: 180,
82
- endAngle: 0
83
- },
84
- pieData.map((datum, i) => /* @__PURE__ */ React.createElement(Cell, { key: i, fill: datum.fill }))
85
- )));
82
+ endAngle: 0,
83
+ children: pieData.map((datum, i) => /* @__PURE__ */ jsx(Cell, { fill: datum.fill }, i))
84
+ }
85
+ ) }) });
86
86
  };
87
87
 
88
88
  export { SummaryChart as default };
@@ -1 +1 @@
1
- {"version":3,"file":"SummaryChart.esm.js","sources":["../../../src/components/AllocationChart/SummaryChart.jsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { ResponsiveContainer, PieChart, Pie, Cell } from 'recharts';\nimport { primary, greyscale, browns } from '../../constants/colors';\nimport { toCurrency } from '../../util';\n\nfunction toPieData(top, other, idle) {\n const slices = [];\n\n for (const i in top) {\n if (Object.hasOwn(top, i)) {\n const allocation = top[i];\n const fill =\n allocation.name === '__unallocated__'\n ? '#212121'\n : primary[i % primary.length];\n\n slices.push({\n name: allocation.name,\n value: allocation.totalCost,\n fill: fill,\n });\n }\n }\n\n for (const i in other) {\n if (Object.hasOwn(other, i)) {\n const allocation = other[i];\n const fill = browns[i % browns.length];\n slices.push({\n name: allocation.name,\n value: allocation.totalCost,\n fill: fill,\n });\n }\n }\n\n for (const i in idle) {\n if (Object.hasOwn(idle, i)) {\n const allocation = idle[i];\n const fill = greyscale[i % greyscale.length];\n slices.push({\n name: allocation.name,\n value: allocation.totalCost,\n fill: fill,\n });\n }\n }\n\n return slices;\n}\n\nconst SummaryChart = ({ top, other, idle, currency, height }) => {\n const pieData = toPieData(top, other, idle);\n\n const renderLabel = params => {\n const { cx, cy, midAngle, outerRadius, percent, name, fill, value } =\n params;\n\n const RADIAN = Math.PI / 180;\n const radius = outerRadius * 1.1;\n let x = cx + radius * Math.cos(-midAngle * RADIAN);\n x += x > cx ? 2 : -2;\n const y = cy + radius * Math.sin(-midAngle * RADIAN);\n // y -= Math.min(Math.abs(2 / Math.cos(-midAngle * RADIAN)), 8)\n\n if (percent < 0.02) {\n return undefined;\n }\n\n return (\n <text\n x={x}\n y={y}\n fill={fill}\n textAnchor={x > cx ? 'start' : 'end'}\n dominantBaseline=\"central\"\n >\n {`${name}: ${toCurrency(value, currency)} (${(percent * 100).toFixed(\n 1,\n )}%)`}\n </text>\n );\n };\n\n return (\n <ResponsiveContainer width=\"100%\" height={height}>\n <PieChart>\n <Pie\n data={pieData}\n dataKey=\"value\"\n nameKey=\"name\"\n label={renderLabel}\n labelLine\n // niko: if tooltips error, try disabling animation\n // isAnimationActive={false}\n animationDuration={400}\n cy=\"90%\"\n outerRadius=\"140%\"\n innerRadius=\"60%\"\n startAngle={180}\n endAngle={0}\n >\n {pieData.map((datum, i) => (\n <Cell key={i} fill={datum.fill} />\n ))}\n </Pie>\n </PieChart>\n </ResponsiveContainer>\n );\n};\n\nexport default SummaryChart;\n"],"names":[],"mappings":";;;;;AAoBA,SAAS,SAAA,CAAU,GAAK,EAAA,KAAA,EAAO,IAAM,EAAA;AACnC,EAAA,MAAM,SAAS,EAAC;AAEhB,EAAA,KAAA,MAAW,KAAK,GAAK,EAAA;AACnB,IAAA,IAAI,MAAO,CAAA,MAAA,CAAO,GAAK,EAAA,CAAC,CAAG,EAAA;AACzB,MAAM,MAAA,UAAA,GAAa,IAAI,CAAC,CAAA;AACxB,MAAM,MAAA,IAAA,GACJ,WAAW,IAAS,KAAA,iBAAA,GAChB,YACA,OAAQ,CAAA,CAAA,GAAI,QAAQ,MAAM,CAAA;AAEhC,MAAA,MAAA,CAAO,IAAK,CAAA;AAAA,QACV,MAAM,UAAW,CAAA,IAAA;AAAA,QACjB,OAAO,UAAW,CAAA,SAAA;AAAA,QAClB;AAAA,OACD,CAAA;AAAA;AACH;AAGF,EAAA,KAAA,MAAW,KAAK,KAAO,EAAA;AACrB,IAAA,IAAI,MAAO,CAAA,MAAA,CAAO,KAAO,EAAA,CAAC,CAAG,EAAA;AAC3B,MAAM,MAAA,UAAA,GAAa,MAAM,CAAC,CAAA;AAC1B,MAAA,MAAM,IAAO,GAAA,MAAA,CAAO,CAAI,GAAA,MAAA,CAAO,MAAM,CAAA;AACrC,MAAA,MAAA,CAAO,IAAK,CAAA;AAAA,QACV,MAAM,UAAW,CAAA,IAAA;AAAA,QACjB,OAAO,UAAW,CAAA,SAAA;AAAA,QAClB;AAAA,OACD,CAAA;AAA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;AAAA,MAAA;AAAA,QACC,CAAA;AAAA,QACA,CAAA;AAAA,QACA,IAAA;AAAA,QACA,UAAA,EAAY,CAAI,GAAA,EAAA,GAAK,OAAU,GAAA,KAAA;AAAA,QAC/B,gBAAiB,EAAA;AAAA,OAAA;AAAA,MAEhB,CAAA,EAAG,IAAI,CAAK,EAAA,EAAA,UAAA,CAAW,OAAO,QAAQ,CAAC,CAAM,EAAA,EAAA,CAAA,OAAA,GAAU,GAAK,EAAA,OAAA;AAAA,QAC3D;AAAA,OACD,CAAA,EAAA;AAAA,KACH;AAAA,GAEJ;AAEA,EAAA,2CACG,mBAAoB,EAAA,EAAA,KAAA,EAAM,MAAO,EAAA,MAAA,EAAA,sCAC/B,QACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,IAAM,EAAA,OAAA;AAAA,MACN,OAAQ,EAAA,OAAA;AAAA,MACR,OAAQ,EAAA,MAAA;AAAA,MACR,KAAO,EAAA,WAAA;AAAA,MACP,SAAS,EAAA,IAAA;AAAA,MAGT,iBAAmB,EAAA,GAAA;AAAA,MACnB,EAAG,EAAA,KAAA;AAAA,MACH,WAAY,EAAA,MAAA;AAAA,MACZ,WAAY,EAAA,KAAA;AAAA,MACZ,UAAY,EAAA,GAAA;AAAA,MACZ,QAAU,EAAA;AAAA,KAAA;AAAA,IAET,OAAQ,CAAA,GAAA,CAAI,CAAC,KAAA,EAAO,CACnB,qBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,GAAA,EAAK,CAAG,EAAA,IAAA,EAAM,KAAM,CAAA,IAAA,EAAM,CACjC;AAAA,GAEL,CACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"SummaryChart.esm.js","sources":["../../../src/components/AllocationChart/SummaryChart.jsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ResponsiveContainer, PieChart, Pie, Cell } from 'recharts';\nimport { primary, greyscale, browns } from '../../constants/colors';\nimport { toCurrency } from '../../util';\n\nfunction toPieData(top, other, idle) {\n const slices = [];\n\n for (const i in top) {\n if (Object.hasOwn(top, i)) {\n const allocation = top[i];\n const fill =\n allocation.name === '__unallocated__'\n ? '#212121'\n : primary[i % primary.length];\n\n slices.push({\n name: allocation.name,\n value: allocation.totalCost,\n fill: fill,\n });\n }\n }\n\n for (const i in other) {\n if (Object.hasOwn(other, i)) {\n const allocation = other[i];\n const fill = browns[i % browns.length];\n slices.push({\n name: allocation.name,\n value: allocation.totalCost,\n fill: fill,\n });\n }\n }\n\n for (const i in idle) {\n if (Object.hasOwn(idle, i)) {\n const allocation = idle[i];\n const fill = greyscale[i % greyscale.length];\n slices.push({\n name: allocation.name,\n value: allocation.totalCost,\n fill: fill,\n });\n }\n }\n\n return slices;\n}\n\nconst SummaryChart = ({ top, other, idle, currency, height }) => {\n const pieData = toPieData(top, other, idle);\n\n const renderLabel = params => {\n const { cx, cy, midAngle, outerRadius, percent, name, fill, value } =\n params;\n\n const RADIAN = Math.PI / 180;\n const radius = outerRadius * 1.1;\n let x = cx + radius * Math.cos(-midAngle * RADIAN);\n x += x > cx ? 2 : -2;\n const y = cy + radius * Math.sin(-midAngle * RADIAN);\n // y -= Math.min(Math.abs(2 / Math.cos(-midAngle * RADIAN)), 8)\n\n if (percent < 0.02) {\n return undefined;\n }\n\n return (\n <text\n x={x}\n y={y}\n fill={fill}\n textAnchor={x > cx ? 'start' : 'end'}\n dominantBaseline=\"central\"\n >\n {`${name}: ${toCurrency(value, currency)} (${(percent * 100).toFixed(\n 1,\n )}%)`}\n </text>\n );\n };\n\n return (\n <ResponsiveContainer width=\"100%\" height={height}>\n <PieChart>\n <Pie\n data={pieData}\n dataKey=\"value\"\n nameKey=\"name\"\n label={renderLabel}\n labelLine\n // niko: if tooltips error, try disabling animation\n // isAnimationActive={false}\n animationDuration={400}\n cy=\"90%\"\n outerRadius=\"140%\"\n innerRadius=\"60%\"\n startAngle={180}\n endAngle={0}\n >\n {pieData.map((datum, i) => (\n <Cell key={i} fill={datum.fill} />\n ))}\n </Pie>\n </PieChart>\n </ResponsiveContainer>\n );\n};\n\nexport default SummaryChart;\n"],"names":[],"mappings":";;;;;AAmBA,SAAS,SAAA,CAAU,GAAK,EAAA,KAAA,EAAO,IAAM,EAAA;AACnC,EAAA,MAAM,SAAS,EAAC;AAEhB,EAAA,KAAA,MAAW,KAAK,GAAK,EAAA;AACnB,IAAA,IAAI,MAAO,CAAA,MAAA,CAAO,GAAK,EAAA,CAAC,CAAG,EAAA;AACzB,MAAM,MAAA,UAAA,GAAa,IAAI,CAAC,CAAA;AACxB,MAAM,MAAA,IAAA,GACJ,WAAW,IAAS,KAAA,iBAAA,GAChB,YACA,OAAQ,CAAA,CAAA,GAAI,QAAQ,MAAM,CAAA;AAEhC,MAAA,MAAA,CAAO,IAAK,CAAA;AAAA,QACV,MAAM,UAAW,CAAA,IAAA;AAAA,QACjB,OAAO,UAAW,CAAA,SAAA;AAAA,QAClB;AAAA,OACD,CAAA;AAAA;AACH;AAGF,EAAA,KAAA,MAAW,KAAK,KAAO,EAAA;AACrB,IAAA,IAAI,MAAO,CAAA,MAAA,CAAO,KAAO,EAAA,CAAC,CAAG,EAAA;AAC3B,MAAM,MAAA,UAAA,GAAa,MAAM,CAAC,CAAA;AAC1B,MAAA,MAAM,IAAO,GAAA,MAAA,CAAO,CAAI,GAAA,MAAA,CAAO,MAAM,CAAA;AACrC,MAAA,MAAA,CAAO,IAAK,CAAA;AAAA,QACV,MAAM,UAAW,CAAA,IAAA;AAAA,QACjB,OAAO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AGT,IACE,uBAAA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,CAAA;AAAA,QACA,CAAA;AAAA,QACA,IAAA;AAAA,QACA,UAAA,EAAY,CAAI,GAAA,EAAA,GAAK,OAAU,GAAA,KAAA;AAAA,QAC/B,gBAAiB,EAAA,SAAA;AAAA,QAEhB,QAAA,EAAA,CAAA,EAAG,IAAI,CAAK,EAAA,EAAA,UAAA,CAAW,OAAO,QAAQ,CAAC,CAAM,EAAA,EAAA,CAAA,OAAA,GAAU,GAAK,EAAA,OAAA;AAAA,UAC3D;AAAA,SACD,CAAA,EAAA;AAAA;AAAA,KACH;AAAA,GAEJ;AAEA,EAAA,2BACG,mBAAoB,EAAA,EAAA,KAAA,EAAM,MAAO,EAAA,MAAA,EAChC,8BAAC,QACC,EAAA,EAAA,QAAA,kBAAA,GAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,IAAM,EAAA,OAAA;AAAA,MACN,OAAQ,EAAA,OAAA;AAAA,MACR,OAAQ,EAAA,MAAA;AAAA,MACR,KAAO,EAAA,WAAA;AAAA,MACP,SAAS,EAAA,IAAA;AAAA,MAGT,iBAAmB,EAAA,GAAA;AAAA,MACnB,EAAG,EAAA,KAAA;AAAA,MACH,WAAY,EAAA,MAAA;AAAA,MACZ,WAAY,EAAA,KAAA;AAAA,MACZ,UAAY,EAAA,GAAA;AAAA,MACZ,QAAU,EAAA,CAAA;AAAA,MAET,QAAA,EAAA,OAAA,CAAQ,GAAI,CAAA,CAAC,KAAO,EAAA,CAAA,qBAClB,GAAA,CAAA,IAAA,EAAA,EAAa,IAAM,EAAA,KAAA,CAAM,IAAf,EAAA,EAAA,CAAqB,CACjC;AAAA;AAAA,KAEL,CACF,EAAA,CAAA;AAEJ;;;;"}
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { memo } from 'react';
2
3
  import { isArray, map, reverse, sortBy, filter, reduce } from 'lodash';
3
4
  import Typography from '@material-ui/core/Typography';
4
5
  import RangeChart from './RangeChart.esm.js';
@@ -60,11 +61,11 @@ function top(n, by) {
60
61
  }
61
62
  const AllocationChart = ({ allocationRange, currency, n, height }) => {
62
63
  if (allocationRange.length === 0) {
63
- return /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, "No data");
64
+ return /* @__PURE__ */ jsx(Typography, { variant: "body2", children: "No data" });
64
65
  }
65
66
  if (allocationRange.length === 1) {
66
67
  const datum = top(n, (alloc) => alloc.totalCost)(allocationRange[0]);
67
- return /* @__PURE__ */ React.createElement(
68
+ return /* @__PURE__ */ jsx(
68
69
  SummaryChart,
69
70
  {
70
71
  top: datum.top,
@@ -76,9 +77,9 @@ const AllocationChart = ({ allocationRange, currency, n, height }) => {
76
77
  );
77
78
  }
78
79
  const data = top(n, (alloc) => alloc.totalCost)(allocationRange);
79
- return /* @__PURE__ */ React.createElement(RangeChart, { data, currency, height });
80
+ return /* @__PURE__ */ jsx(RangeChart, { data, currency, height });
80
81
  };
81
- var AllocationChart$1 = React.memo(AllocationChart);
82
+ var AllocationChart$1 = memo(AllocationChart);
82
83
 
83
84
  export { AllocationChart$1 as default };
84
85
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../../../src/components/AllocationChart/index.jsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport React from 'react';\nimport { isArray, filter, map, reduce, reverse, sortBy } from 'lodash';\n\nimport Typography from '@material-ui/core/Typography';\n\nimport RangeChart from './RangeChart';\nimport SummaryChart from './SummaryChart';\n\n// TODO niko/etl\n/* eslint @typescript-eslint/no-shadow: [\"error\", { \"allow\": [\"agg\"] }]*/\nfunction agg(allocationSet, name) {\n if (allocationSet.length === 0) {\n return null;\n }\n\n return reduce(\n allocationSet,\n (agg, cur) => ({\n name: agg.name,\n aggregatedBy: cur.aggregatedBy,\n properties: agg.properties,\n start: cur.start,\n end: cur.end,\n cpuCost: agg.cpuCost + cur.cpuCost,\n gpuCost: agg.gpuCost + cur.gpuCost,\n ramCost: agg.ramCost + cur.ramCost,\n pvCost: agg.pvCost + cur.pvCost,\n totalCost: agg.totalCost + cur.totalCost,\n count: agg.count + 1,\n }),\n {\n name: name,\n properties: null,\n cpuCost: 0.0,\n gpuCost: 0.0,\n ramCost: 0.0,\n pvCost: 0.0,\n totalCost: 0.0,\n count: 0,\n },\n );\n}\n\nfunction isIdle(allocation) {\n return allocation.name.indexOf('__idle__') >= 0;\n}\n\nfunction top(n, by) {\n return allocations => {\n if (isArray(allocations[0])) {\n return map(allocations, top(n, by));\n }\n\n const sorted = reverse(sortBy(allocations, by));\n const active = filter(sorted, a => !isIdle(a));\n const idle = filter(sorted, a => isIdle(a));\n const topn = active.slice(0, n);\n const other = [];\n if (active.length > n) {\n other.push(agg(active.slice(n), 'other'));\n }\n\n return {\n top: topn,\n other: other,\n idle: idle,\n };\n };\n}\n\nconst AllocationChart = ({ allocationRange, currency, n, height }) => {\n if (allocationRange.length === 0) {\n return <Typography variant=\"body2\">No data</Typography>;\n }\n\n if (allocationRange.length === 1) {\n const datum = top(n, alloc => alloc.totalCost)(allocationRange[0]);\n return (\n <SummaryChart\n top={datum.top}\n other={datum.other}\n idle={datum.idle}\n currency={currency}\n height={height}\n />\n );\n }\n\n const data = top(n, alloc => alloc.totalCost)(allocationRange);\n return <RangeChart data={data} currency={currency} height={height} />;\n};\n\nexport default React.memo(AllocationChart);\n"],"names":["agg"],"mappings":";;;;;;AAyBA,SAAS,GAAA,CAAI,eAAe,IAAM,EAAA;AACh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AK,KAAM,CAAA,GAAA;AAAA,QACX,OAAO,KAAM,CAAA,KAAA;AAAA,QACb,MAAM,KAAM,CAAA,IAAA;AAAA,QACZ,QAAA;AAAA,QACA;AAAA;AAAA,KACF;AAAA;AAIJ,EAAA,MAAM,OAAO,GAAI,CAAA,CAAA,EAAG,WAAS,KAAM,CAAA,SAAS,EAAE,eAAe,CAAA;AAC7D,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,IAAY,EAAA,QAAA,EAAoB,MAAgB,EAAA,CAAA;AACrE,CAAA;AAEA,wBAAe,KAAA,CAAM,KAAK,eAAe,CAAA;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../../../src/components/AllocationChart/index.jsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { memo } from 'react';\nimport { isArray, filter, map, reduce, reverse, sortBy } from 'lodash';\n\nimport Typography from '@material-ui/core/Typography';\n\nimport RangeChart from './RangeChart';\nimport SummaryChart from './SummaryChart';\n\n// TODO niko/etl\n/* eslint @typescript-eslint/no-shadow: [\"error\", { \"allow\": [\"agg\"] }]*/\nfunction agg(allocationSet, name) {\n if (allocationSet.length === 0) {\n return null;\n }\n\n return reduce(\n allocationSet,\n (agg, cur) => ({\n name: agg.name,\n aggregatedBy: cur.aggregatedBy,\n properties: agg.properties,\n start: cur.start,\n end: cur.end,\n cpuCost: agg.cpuCost + cur.cpuCost,\n gpuCost: agg.gpuCost + cur.gpuCost,\n ramCost: agg.ramCost + cur.ramCost,\n pvCost: agg.pvCost + cur.pvCost,\n totalCost: agg.totalCost + cur.totalCost,\n count: agg.count + 1,\n }),\n {\n name: name,\n properties: null,\n cpuCost: 0.0,\n gpuCost: 0.0,\n ramCost: 0.0,\n pvCost: 0.0,\n totalCost: 0.0,\n count: 0,\n },\n );\n}\n\nfunction isIdle(allocation) {\n return allocation.name.indexOf('__idle__') >= 0;\n}\n\nfunction top(n, by) {\n return allocations => {\n if (isArray(allocations[0])) {\n return map(allocations, top(n, by));\n }\n\n const sorted = reverse(sortBy(allocations, by));\n const active = filter(sorted, a => !isIdle(a));\n const idle = filter(sorted, a => isIdle(a));\n const topn = active.slice(0, n);\n const other = [];\n if (active.length > n) {\n other.push(agg(active.slice(n), 'other'));\n }\n\n return {\n top: topn,\n other: other,\n idle: idle,\n };\n };\n}\n\nconst AllocationChart = ({ allocationRange, currency, n, height }) => {\n if (allocationRange.length === 0) {\n return <Typography variant=\"body2\">No data</Typography>;\n }\n\n if (allocationRange.length === 1) {\n const datum = top(n, alloc => alloc.totalCost)(allocationRange[0]);\n return (\n <SummaryChart\n top={datum.top}\n other={datum.other}\n idle={datum.idle}\n currency={currency}\n height={height}\n />\n );\n }\n\n const data = top(n, alloc => alloc.totalCost)(allocationRange);\n return <RangeChart data={data} currency={currency} height={height} />;\n};\n\nexport default memo(AllocationChart);\n"],"names":["agg"],"mappings":";;;;;;;AAyBA,SAAS,GAAA,CAAI,eAAe,IAAM,EAAA;AAChC,EAAI,IAAA,aAAA,CAAc,WAAW,CAAG,EAAA;AAC9B,IAAO,OAAA,IAAA;AAAA;AAGT,EAAO,OAAA,MAAA;AAAA,IACL,aAAA;AAAA,IACA,CAACA,MAAK,GAAS,MAAA;AAAA,MACb,MAAMA,IAAI,CAAA,IAAA;AAAA,MACV,cAAc,GAAI,CAAA,YAAA;AAAA,MAClB,YAAYA,IAAI,CAAA,UAAA;AAAA,MAChB,OAAO,GAAI,CAAA,KAAA;AAAA,MACX,KAAK,GAAI,CAAA,GAAA;AAAA,MACT,OAAA,EAASA,IAAI,CA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;;;"}
@@ -1,4 +1,6 @@
1
- import React, { useState, useEffect } from 'react';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { useState, useEffect } from 'react';
2
4
  import { round, get } from 'lodash';
3
5
  import { makeStyles } from '@material-ui/core/styles';
4
6
  import Table from '@material-ui/core/Table';
@@ -55,7 +57,7 @@ const AllocationReport = ({
55
57
  }) => {
56
58
  const classes = useStyles();
57
59
  if (allocationData.length === 0) {
58
- return /* @__PURE__ */ React.createElement(Typography, { variant: "body2", className: classes.noResults }, "No results");
60
+ return /* @__PURE__ */ jsx(Typography, { variant: "body2", className: classes.noResults, children: "No results" });
59
61
  }
60
62
  const [order, setOrder] = React.useState("desc");
61
63
  const [orderBy, setOrderBy] = React.useState("totalCost");
@@ -82,70 +84,100 @@ const AllocationReport = ({
82
84
  page * rowsPerPage,
83
85
  page * rowsPerPage + rowsPerPage
84
86
  );
85
- return /* @__PURE__ */ React.createElement("div", { id: "report" }, /* @__PURE__ */ React.createElement(
86
- AllocationChart,
87
- {
88
- allocationRange: allocationData,
89
- currency,
90
- n: 10,
91
- height: 300
92
- }
93
- ), /* @__PURE__ */ React.createElement(TableContainer, null, /* @__PURE__ */ React.createElement(Table, null, /* @__PURE__ */ React.createElement(TableHead, null, /* @__PURE__ */ React.createElement(TableRow, null, headCells.map((cell) => /* @__PURE__ */ React.createElement(
94
- TableCell,
95
- {
96
- key: cell.id,
97
- colSpan: cell.colspan,
98
- align: cell.numeric ? "right" : "left",
99
- sortDirection: orderBy === cell.id ? order : false,
100
- style: { width: cell.width }
101
- },
102
- /* @__PURE__ */ React.createElement(
103
- TableSortLabel,
87
+ return /* @__PURE__ */ jsxs("div", { id: "report", children: [
88
+ /* @__PURE__ */ jsx(
89
+ AllocationChart,
104
90
  {
105
- active: orderBy === cell.id,
106
- direction: orderBy === cell.id ? order : "asc",
107
- onClick: createSortHandler(cell.id)
108
- },
109
- cell.label
110
- )
111
- )))), /* @__PURE__ */ React.createElement(TableBody, null, /* @__PURE__ */ React.createElement(TableRow, null, headCells.map((cell) => {
112
- return /* @__PURE__ */ React.createElement(
113
- TableCell,
91
+ allocationRange: allocationData,
92
+ currency,
93
+ n: 10,
94
+ height: 300
95
+ }
96
+ ),
97
+ /* @__PURE__ */ jsx(TableContainer, { children: /* @__PURE__ */ jsxs(Table, { children: [
98
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(TableRow, { children: headCells.map((cell) => /* @__PURE__ */ jsx(
99
+ TableCell,
100
+ {
101
+ colSpan: cell.colspan,
102
+ align: cell.numeric ? "right" : "left",
103
+ sortDirection: orderBy === cell.id ? order : false,
104
+ style: { width: cell.width },
105
+ children: /* @__PURE__ */ jsx(
106
+ TableSortLabel,
107
+ {
108
+ active: orderBy === cell.id,
109
+ direction: orderBy === cell.id ? order : "asc",
110
+ onClick: createSortHandler(cell.id),
111
+ children: cell.label
112
+ }
113
+ )
114
+ },
115
+ cell.id
116
+ )) }) }),
117
+ /* @__PURE__ */ jsxs(TableBody, { children: [
118
+ /* @__PURE__ */ jsx(TableRow, { children: headCells.map((cell) => {
119
+ return /* @__PURE__ */ jsx(
120
+ TableCell,
121
+ {
122
+ colSpan: cell.colspan,
123
+ align: cell.numeric ? "right" : "left",
124
+ style: { fontWeight: 500 },
125
+ children: cell.numeric ? cell.label === "Efficiency" ? totalData.totalEfficiency === 1 && totalData.cpuReqCoreHrs === 0 && totalData.ramReqByteHrs === 0 ? "Inf%" : `${round(totalData.totalEfficiency * 100, 1)}%` : toCurrency(totalData[cell.id], currency) : totalData[cell.id]
126
+ },
127
+ cell.id
128
+ );
129
+ }) }),
130
+ pageRows.map((row, key) => {
131
+ if (row.name === "__unmounted__") {
132
+ row.name = "Unmounted PVs";
133
+ }
134
+ const isIdle = row.name.indexOf("__idle__") >= 0;
135
+ const isUnallocated = row.name.indexOf("__unallocated__") >= 0;
136
+ const isUnmounted = row.name.indexOf("Unmounted PVs") >= 0;
137
+ let efficiency = round(row.totalEfficiency * 100, 1);
138
+ if (row.totalEfficiency === 1 && row.cpuReqCoreHrs === 0 && row.ramReqByteHrs === 0) {
139
+ efficiency = "Inf";
140
+ }
141
+ if (isIdle || isUnallocated || isUnmounted) {
142
+ return /* @__PURE__ */ jsxs(TableRow, { children: [
143
+ /* @__PURE__ */ jsx(TableCell, { align: "left", children: row.name }),
144
+ /* @__PURE__ */ jsx(TableCell, { align: "right", children: toCurrency(row.cpuCost, currency) }),
145
+ /* @__PURE__ */ jsx(TableCell, { align: "right", children: toCurrency(row.ramCost, currency) }),
146
+ /* @__PURE__ */ jsx(TableCell, { align: "right", children: toCurrency(row.pvCost, currency) }),
147
+ isIdle ? /* @__PURE__ */ jsx(TableCell, { align: "right", children: "\u2014" }) : /* @__PURE__ */ jsxs(TableCell, { align: "right", children: [
148
+ efficiency,
149
+ "%"
150
+ ] }),
151
+ /* @__PURE__ */ jsx(TableCell, { align: "right", children: toCurrency(row.totalCost, currency) })
152
+ ] }, key);
153
+ }
154
+ return /* @__PURE__ */ jsxs(TableRow, { children: [
155
+ /* @__PURE__ */ jsx(TableCell, { align: "left", children: row.name }),
156
+ /* @__PURE__ */ jsx(TableCell, { align: "right", children: toCurrency(row.cpuCost, currency) }),
157
+ /* @__PURE__ */ jsx(TableCell, { align: "right", children: toCurrency(row.ramCost, currency) }),
158
+ /* @__PURE__ */ jsx(TableCell, { align: "right", children: toCurrency(row.pvCost, currency) }),
159
+ /* @__PURE__ */ jsxs(TableCell, { align: "right", children: [
160
+ efficiency,
161
+ "%"
162
+ ] }),
163
+ /* @__PURE__ */ jsx(TableCell, { align: "right", children: toCurrency(row.totalCost, currency) })
164
+ ] }, key);
165
+ })
166
+ ] })
167
+ ] }) }),
168
+ /* @__PURE__ */ jsx(
169
+ TablePagination,
114
170
  {
115
- key: cell.id,
116
- colSpan: cell.colspan,
117
- align: cell.numeric ? "right" : "left",
118
- style: { fontWeight: 500 }
119
- },
120
- cell.numeric ? cell.label === "Efficiency" ? totalData.totalEfficiency === 1 && totalData.cpuReqCoreHrs === 0 && totalData.ramReqByteHrs === 0 ? "Inf%" : `${round(totalData.totalEfficiency * 100, 1)}%` : toCurrency(totalData[cell.id], currency) : totalData[cell.id]
121
- );
122
- })), pageRows.map((row, key) => {
123
- if (row.name === "__unmounted__") {
124
- row.name = "Unmounted PVs";
125
- }
126
- const isIdle = row.name.indexOf("__idle__") >= 0;
127
- const isUnallocated = row.name.indexOf("__unallocated__") >= 0;
128
- const isUnmounted = row.name.indexOf("Unmounted PVs") >= 0;
129
- let efficiency = round(row.totalEfficiency * 100, 1);
130
- if (row.totalEfficiency === 1 && row.cpuReqCoreHrs === 0 && row.ramReqByteHrs === 0) {
131
- efficiency = "Inf";
132
- }
133
- if (isIdle || isUnallocated || isUnmounted) {
134
- return /* @__PURE__ */ React.createElement(TableRow, { key }, /* @__PURE__ */ React.createElement(TableCell, { align: "left" }, row.name), /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, toCurrency(row.cpuCost, currency)), /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, toCurrency(row.ramCost, currency)), /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, toCurrency(row.pvCost, currency)), isIdle ? /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, "\u2014") : /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, efficiency, "%"), /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, toCurrency(row.totalCost, currency)));
135
- }
136
- return /* @__PURE__ */ React.createElement(TableRow, { key }, /* @__PURE__ */ React.createElement(TableCell, { align: "left" }, row.name), /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, toCurrency(row.cpuCost, currency)), /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, toCurrency(row.ramCost, currency)), /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, toCurrency(row.pvCost, currency)), /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, efficiency, "%"), /* @__PURE__ */ React.createElement(TableCell, { align: "right" }, toCurrency(row.totalCost, currency)));
137
- })))), /* @__PURE__ */ React.createElement(
138
- TablePagination,
139
- {
140
- component: "div",
141
- count: numData,
142
- rowsPerPage,
143
- rowsPerPageOptions: [10, 25, 50],
144
- page: Math.min(page, lastPage),
145
- onPageChange: handleChangePage,
146
- onRowsPerPageChange: handleChangeRowsPerPage
147
- }
148
- ));
171
+ component: "div",
172
+ count: numData,
173
+ rowsPerPage,
174
+ rowsPerPageOptions: [10, 25, 50],
175
+ page: Math.min(page, lastPage),
176
+ onPageChange: handleChangePage,
177
+ onRowsPerPageChange: handleChangeRowsPerPage
178
+ }
179
+ )
180
+ ] });
149
181
  };
150
182
  var AllocationReport$1 = React.memo(AllocationReport);
151
183
 
@@ -1 +1 @@
1
- {"version":3,"file":"AllocationReport.esm.js","sources":["../../src/components/AllocationReport.jsx"],"sourcesContent":["/* not changing the working code at this point */\n/* eslint no-nested-ternary: 0 */\n/* eslint react-hooks/rules-of-hooks: 0 */\n\n/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useState } from 'react';\nimport { get, round } from 'lodash';\nimport { makeStyles } from '@material-ui/core/styles';\nimport Table from '@material-ui/core/Table';\nimport TableBody from '@material-ui/core/TableBody';\nimport TableCell from '@material-ui/core/TableCell';\nimport TableContainer from '@material-ui/core/TableContainer';\nimport TableHead from '@material-ui/core/TableHead';\nimport TablePagination from '@material-ui/core/TablePagination';\nimport TableRow from '@material-ui/core/TableRow';\nimport TableSortLabel from '@material-ui/core/TableSortLabel';\nimport Typography from '@material-ui/core/Typography';\nimport AllocationChart from './AllocationChart';\nimport { toCurrency } from '../util';\n\nconst useStyles = makeStyles({\n noResults: {\n padding: 24,\n },\n});\n\nfunction descendingComparator(a, b, orderBy) {\n if (get(b, orderBy) < get(a, orderBy)) {\n return -1;\n }\n if (get(b, orderBy) > get(a, orderBy)) {\n return 1;\n }\n return 0;\n}\n\nfunction getComparator(order, orderBy) {\n return order === 'desc'\n ? (a, b) => descendingComparator(a, b, orderBy)\n : (a, b) => -descendingComparator(a, b, orderBy);\n}\n\nfunction stableSort(array, comparator) {\n const stabilizedThis = array.map((el, index) => [el, index]);\n stabilizedThis.sort((a, b) => {\n const order = comparator(a[0], b[0]);\n if (order !== 0) return order;\n return a[1] - b[1];\n });\n return stabilizedThis.map(el => el[0]);\n}\n\nconst headCells = [\n { id: 'name', numeric: false, label: 'Name', width: 'auto' },\n { id: 'cpuCost', numeric: true, label: 'CPU', width: 100 },\n { id: 'ramCost', numeric: true, label: 'RAM', width: 100 },\n { id: 'pvCost', numeric: true, label: 'PV', width: 100 },\n { id: 'totalEfficiency', numeric: true, label: 'Efficiency', width: 130 },\n { id: 'totalCost', numeric: true, label: 'Total cost', width: 130 },\n];\n\nconst AllocationReport = ({\n allocationData,\n cumulativeData,\n totalData,\n currency,\n}) => {\n const classes = useStyles();\n\n if (allocationData.length === 0) {\n return (\n <Typography variant=\"body2\" className={classes.noResults}>\n No results\n </Typography>\n );\n }\n\n const [order, setOrder] = React.useState('desc');\n const [orderBy, setOrderBy] = React.useState('totalCost');\n const [page, setPage] = useState(0);\n const [rowsPerPage, setRowsPerPage] = useState(25);\n const numData = cumulativeData.length;\n\n useEffect(() => {\n setPage(0);\n }, [numData]);\n\n const lastPage = Math.floor(numData / rowsPerPage);\n\n const handleChangePage = (event, newPage) => setPage(newPage);\n\n const handleChangeRowsPerPage = event => {\n setRowsPerPage(parseInt(event.target.value, 10));\n setPage(0);\n };\n\n const handleRequestSort = (event, property) => {\n const isDesc = orderBy === property && order === 'desc';\n setOrder(isDesc ? 'asc' : 'desc');\n setOrderBy(property);\n };\n\n const createSortHandler = property => event =>\n handleRequestSort(event, property);\n\n const orderedRows = stableSort(cumulativeData, getComparator(order, orderBy));\n const pageRows = orderedRows.slice(\n page * rowsPerPage,\n page * rowsPerPage + rowsPerPage,\n );\n\n return (\n <div id=\"report\">\n <AllocationChart\n allocationRange={allocationData}\n currency={currency}\n n={10}\n height={300}\n />\n <TableContainer>\n <Table>\n <TableHead>\n <TableRow>\n {headCells.map(cell => (\n <TableCell\n key={cell.id}\n colSpan={cell.colspan}\n align={cell.numeric ? 'right' : 'left'}\n sortDirection={orderBy === cell.id ? order : false}\n style={{ width: cell.width }}\n >\n <TableSortLabel\n active={orderBy === cell.id}\n direction={orderBy === cell.id ? order : 'asc'}\n onClick={createSortHandler(cell.id)}\n >\n {cell.label}\n </TableSortLabel>\n </TableCell>\n ))}\n </TableRow>\n </TableHead>\n <TableBody>\n <TableRow>\n {headCells.map(cell => {\n return (\n <TableCell\n key={cell.id}\n colSpan={cell.colspan}\n align={cell.numeric ? 'right' : 'left'}\n style={{ fontWeight: 500 }}\n >\n {cell.numeric\n ? cell.label === 'Efficiency'\n ? totalData.totalEfficiency === 1.0 &&\n totalData.cpuReqCoreHrs === 0 &&\n totalData.ramReqByteHrs === 0\n ? 'Inf%'\n : `${round(totalData.totalEfficiency * 100, 1)}%`\n : toCurrency(totalData[cell.id], currency)\n : totalData[cell.id]}\n </TableCell>\n );\n })}\n </TableRow>\n {pageRows.map((row, key) => {\n if (row.name === '__unmounted__') {\n row.name = 'Unmounted PVs';\n }\n\n const isIdle = row.name.indexOf('__idle__') >= 0;\n const isUnallocated = row.name.indexOf('__unallocated__') >= 0;\n const isUnmounted = row.name.indexOf('Unmounted PVs') >= 0;\n\n // Replace \"efficiency\" with Inf if there is usage w/o request\n let efficiency = round(row.totalEfficiency * 100, 1);\n if (\n row.totalEfficiency === 1.0 &&\n row.cpuReqCoreHrs === 0 &&\n row.ramReqByteHrs === 0\n ) {\n efficiency = 'Inf';\n }\n\n // Do not allow drill-down for idle and unallocated rows\n if (isIdle || isUnallocated || isUnmounted) {\n return (\n <TableRow key={key}>\n <TableCell align=\"left\">{row.name}</TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.cpuCost, currency)}\n </TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.ramCost, currency)}\n </TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.pvCost, currency)}\n </TableCell>\n {isIdle ? (\n <TableCell align=\"right\">&mdash;</TableCell>\n ) : (\n <TableCell align=\"right\">{efficiency}%</TableCell>\n )}\n <TableCell align=\"right\">\n {toCurrency(row.totalCost, currency)}\n </TableCell>\n </TableRow>\n );\n }\n\n return (\n <TableRow key={key}>\n <TableCell align=\"left\">{row.name}</TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.cpuCost, currency)}\n </TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.ramCost, currency)}\n </TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.pvCost, currency)}\n </TableCell>\n <TableCell align=\"right\">{efficiency}%</TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.totalCost, currency)}\n </TableCell>\n </TableRow>\n );\n })}\n </TableBody>\n </Table>\n </TableContainer>\n <TablePagination\n component=\"div\"\n count={numData}\n rowsPerPage={rowsPerPage}\n rowsPerPageOptions={[10, 25, 50]}\n page={Math.min(page, lastPage)}\n onPageChange={handleChangePage}\n onRowsPerPageChange={handleChangeRowsPerPage}\n />\n </div>\n );\n};\n\nexport default React.memo(AllocationReport);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,SAAW,EAAA;AAAA,IACT,OAAS,EAAA;AAAA;AAEb,CAAC,CAAA;AAED,SAAS,oBAAA,CAAqB,CAAG,EAAA,CAAA,EAAG,OAAS,EAAA;AAC3C,EAAA,IAAI,IAAI,CAAG,EAAA,OAAO,IAAI,GAAI,CAAA,CAAA,EAAG,OAAO,CAAG,EAAA;AACrC,IAAO,OAAA,CAA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,aAAA,CAAC,SAAU,EAAA,EAAA,KAAA,EAAM,WAAS,UAAW,EAAA,GAAC,CACtC,kBAAA,KAAA,CAAA,aAAA,CAAC,SAAU,EAAA,EAAA,KAAA,EAAM,OACd,EAAA,EAAA,UAAA,CAAW,GAAI,CAAA,SAAA,EAAW,QAAQ,CACrC,CACF,CAAA;AAAA,GAEH,CACH,CACF,CACF,CACA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,SAAU,EAAA,KAAA;AAAA,MACV,KAAO,EAAA,OAAA;AAAA,MACP,WAAA;AAAA,MACA,kBAAoB,EAAA,CAAC,EAAI,EAAA,EAAA,EAAI,EAAE,CAAA;AAAA,MAC/B,IAAM,EAAA,IAAA,CAAK,GAAI,CAAA,IAAA,EAAM,QAAQ,CAAA;AAAA,MAC7B,YAAc,EAAA,gBAAA;AAAA,MACd,mBAAqB,EAAA;AAAA;AAAA,GAEzB,CAAA;AAEJ,CAAA;AAEA,yBAAe,KAAA,CAAM,KAAK,gBAAgB,CAAA;;;;"}
1
+ {"version":3,"file":"AllocationReport.esm.js","sources":["../../src/components/AllocationReport.jsx"],"sourcesContent":["/* not changing the working code at this point */\n/* eslint no-nested-ternary: 0 */\n/* eslint react-hooks/rules-of-hooks: 0 */\n\n/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from 'react';\n\nimport * as React from 'react';\nimport { get, round } from 'lodash';\nimport { makeStyles } from '@material-ui/core/styles';\nimport Table from '@material-ui/core/Table';\nimport TableBody from '@material-ui/core/TableBody';\nimport TableCell from '@material-ui/core/TableCell';\nimport TableContainer from '@material-ui/core/TableContainer';\nimport TableHead from '@material-ui/core/TableHead';\nimport TablePagination from '@material-ui/core/TablePagination';\nimport TableRow from '@material-ui/core/TableRow';\nimport TableSortLabel from '@material-ui/core/TableSortLabel';\nimport Typography from '@material-ui/core/Typography';\nimport AllocationChart from './AllocationChart';\nimport { toCurrency } from '../util';\n\nconst useStyles = makeStyles({\n noResults: {\n padding: 24,\n },\n});\n\nfunction descendingComparator(a, b, orderBy) {\n if (get(b, orderBy) < get(a, orderBy)) {\n return -1;\n }\n if (get(b, orderBy) > get(a, orderBy)) {\n return 1;\n }\n return 0;\n}\n\nfunction getComparator(order, orderBy) {\n return order === 'desc'\n ? (a, b) => descendingComparator(a, b, orderBy)\n : (a, b) => -descendingComparator(a, b, orderBy);\n}\n\nfunction stableSort(array, comparator) {\n const stabilizedThis = array.map((el, index) => [el, index]);\n stabilizedThis.sort((a, b) => {\n const order = comparator(a[0], b[0]);\n if (order !== 0) return order;\n return a[1] - b[1];\n });\n return stabilizedThis.map(el => el[0]);\n}\n\nconst headCells = [\n { id: 'name', numeric: false, label: 'Name', width: 'auto' },\n { id: 'cpuCost', numeric: true, label: 'CPU', width: 100 },\n { id: 'ramCost', numeric: true, label: 'RAM', width: 100 },\n { id: 'pvCost', numeric: true, label: 'PV', width: 100 },\n { id: 'totalEfficiency', numeric: true, label: 'Efficiency', width: 130 },\n { id: 'totalCost', numeric: true, label: 'Total cost', width: 130 },\n];\n\nconst AllocationReport = ({\n allocationData,\n cumulativeData,\n totalData,\n currency,\n}) => {\n const classes = useStyles();\n\n if (allocationData.length === 0) {\n return (\n <Typography variant=\"body2\" className={classes.noResults}>\n No results\n </Typography>\n );\n }\n\n const [order, setOrder] = React.useState('desc');\n const [orderBy, setOrderBy] = React.useState('totalCost');\n const [page, setPage] = useState(0);\n const [rowsPerPage, setRowsPerPage] = useState(25);\n const numData = cumulativeData.length;\n\n useEffect(() => {\n setPage(0);\n }, [numData]);\n\n const lastPage = Math.floor(numData / rowsPerPage);\n\n const handleChangePage = (event, newPage) => setPage(newPage);\n\n const handleChangeRowsPerPage = event => {\n setRowsPerPage(parseInt(event.target.value, 10));\n setPage(0);\n };\n\n const handleRequestSort = (event, property) => {\n const isDesc = orderBy === property && order === 'desc';\n setOrder(isDesc ? 'asc' : 'desc');\n setOrderBy(property);\n };\n\n const createSortHandler = property => event =>\n handleRequestSort(event, property);\n\n const orderedRows = stableSort(cumulativeData, getComparator(order, orderBy));\n const pageRows = orderedRows.slice(\n page * rowsPerPage,\n page * rowsPerPage + rowsPerPage,\n );\n\n return (\n <div id=\"report\">\n <AllocationChart\n allocationRange={allocationData}\n currency={currency}\n n={10}\n height={300}\n />\n <TableContainer>\n <Table>\n <TableHead>\n <TableRow>\n {headCells.map(cell => (\n <TableCell\n key={cell.id}\n colSpan={cell.colspan}\n align={cell.numeric ? 'right' : 'left'}\n sortDirection={orderBy === cell.id ? order : false}\n style={{ width: cell.width }}\n >\n <TableSortLabel\n active={orderBy === cell.id}\n direction={orderBy === cell.id ? order : 'asc'}\n onClick={createSortHandler(cell.id)}\n >\n {cell.label}\n </TableSortLabel>\n </TableCell>\n ))}\n </TableRow>\n </TableHead>\n <TableBody>\n <TableRow>\n {headCells.map(cell => {\n return (\n <TableCell\n key={cell.id}\n colSpan={cell.colspan}\n align={cell.numeric ? 'right' : 'left'}\n style={{ fontWeight: 500 }}\n >\n {cell.numeric\n ? cell.label === 'Efficiency'\n ? totalData.totalEfficiency === 1.0 &&\n totalData.cpuReqCoreHrs === 0 &&\n totalData.ramReqByteHrs === 0\n ? 'Inf%'\n : `${round(totalData.totalEfficiency * 100, 1)}%`\n : toCurrency(totalData[cell.id], currency)\n : totalData[cell.id]}\n </TableCell>\n );\n })}\n </TableRow>\n {pageRows.map((row, key) => {\n if (row.name === '__unmounted__') {\n row.name = 'Unmounted PVs';\n }\n\n const isIdle = row.name.indexOf('__idle__') >= 0;\n const isUnallocated = row.name.indexOf('__unallocated__') >= 0;\n const isUnmounted = row.name.indexOf('Unmounted PVs') >= 0;\n\n // Replace \"efficiency\" with Inf if there is usage w/o request\n let efficiency = round(row.totalEfficiency * 100, 1);\n if (\n row.totalEfficiency === 1.0 &&\n row.cpuReqCoreHrs === 0 &&\n row.ramReqByteHrs === 0\n ) {\n efficiency = 'Inf';\n }\n\n // Do not allow drill-down for idle and unallocated rows\n if (isIdle || isUnallocated || isUnmounted) {\n return (\n <TableRow key={key}>\n <TableCell align=\"left\">{row.name}</TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.cpuCost, currency)}\n </TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.ramCost, currency)}\n </TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.pvCost, currency)}\n </TableCell>\n {isIdle ? (\n <TableCell align=\"right\">&mdash;</TableCell>\n ) : (\n <TableCell align=\"right\">{efficiency}%</TableCell>\n )}\n <TableCell align=\"right\">\n {toCurrency(row.totalCost, currency)}\n </TableCell>\n </TableRow>\n );\n }\n\n return (\n <TableRow key={key}>\n <TableCell align=\"left\">{row.name}</TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.cpuCost, currency)}\n </TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.ramCost, currency)}\n </TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.pvCost, currency)}\n </TableCell>\n <TableCell align=\"right\">{efficiency}%</TableCell>\n <TableCell align=\"right\">\n {toCurrency(row.totalCost, currency)}\n </TableCell>\n </TableRow>\n );\n })}\n </TableBody>\n </Table>\n </TableContainer>\n <TablePagination\n component=\"div\"\n count={numData}\n rowsPerPage={rowsPerPage}\n rowsPerPageOptions={[10, 25, 50]}\n page={Math.min(page, lastPage)}\n onPageChange={handleChangePage}\n onRowsPerPageChange={handleChangeRowsPerPage}\n />\n </div>\n );\n};\n\nexport default React.memo(AllocationReport);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAqCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,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;AAAA,4BACA,GAAA,CAAC,aAAU,KAAM,EAAA,OAAA,EACd,qBAAW,GAAI,CAAA,MAAA,EAAQ,QAAQ,CAClC,EAAA,CAAA;AAAA,4BACA,IAAA,CAAC,SAAU,EAAA,EAAA,KAAA,EAAM,OAAS,EAAA,QAAA,EAAA;AAAA,cAAA,UAAA;AAAA,cAAW;AAAA,aAAC,EAAA,CAAA;AAAA,4BACtC,GAAA,CAAC,aAAU,KAAM,EAAA,OAAA,EACd,qBAAW,GAAI,CAAA,SAAA,EAAW,QAAQ,CACrC,EAAA;AAAA,WAAA,EAAA,EAda,GAef,CAAA;AAAA,SAEH;AAAA,OACH,EAAA;AAAA,KAAA,EACF,CACF,EAAA,CAAA;AAAA,oBACA,GAAA;AAAA,MAAC,eAAA;AAAA,MAAA;AAAA,QACC,SAAU,EAAA,KAAA;AAAA,QACV,KAAO,EAAA,OAAA;AAAA,QACP,WAAA;AAAA,QACA,kBAAoB,EAAA,CAAC,EAAI,EAAA,EAAA,EAAI,EAAE,CAAA;AAAA,QAC/B,IAAM,EAAA,IAAA,CAAK,GAAI,CAAA,IAAA,EAAM,QAAQ,CAAA;AAAA,QAC7B,YAAc,EAAA,gBAAA;AAAA,QACd,mBAAqB,EAAA;AAAA;AAAA;AACvB,GACF,EAAA,CAAA;AAEJ,CAAA;AAEA,yBAAe,KAAA,CAAM,KAAK,gBAAgB,CAAA;;;;"}
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { memo } from 'react';
2
3
  import { reverse, sortBy, forEach, round, get } from 'lodash';
3
4
  import ExportIcon from '@material-ui/icons/GetApp';
4
5
  import IconButton from '@material-ui/core/IconButton';
@@ -71,9 +72,9 @@ ${body}`;
71
72
  a.click();
72
73
  document.body.removeChild(a);
73
74
  }
74
- return /* @__PURE__ */ React.createElement(Tooltip, { title: "Download CSV" }, /* @__PURE__ */ React.createElement(IconButton, { onClick: downloadReport }, /* @__PURE__ */ React.createElement(ExportIcon, null)));
75
+ return /* @__PURE__ */ jsx(Tooltip, { title: "Download CSV", children: /* @__PURE__ */ jsx(IconButton, { onClick: downloadReport, children: /* @__PURE__ */ jsx(ExportIcon, {}) }) });
75
76
  };
76
- var DownloadControl$1 = React.memo(DownloadControl);
77
+ var DownloadControl$1 = memo(DownloadControl);
77
78
 
78
79
  export { DownloadControl$1 as default };
79
80
  //# sourceMappingURL=Download.esm.js.map