Apply suggestions from code review

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
pull/3206/head
rgon10 2 months ago committed by GitHub
parent 5fd2607d3b
commit b02c1f8681
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -11,7 +11,7 @@ To create an API Key, follow [the official TrueNAS documentation](https://www.tr
A detailed pool listing is disabled by default, but can be enabled with the `enablePools` option.
TrueNAS Scale and Core APIs differ, the optional `nasType` parameter is needed if using the `enablePools` option.
To use the `enablePools` option with TrueNAS Core, the `nasType` parameter is required.
```yaml
widget:
@ -21,5 +21,5 @@ widget:
password: pass # not required if using api key
key: yourtruenasapikey # not required if using username / password
enablePools: true # optional, defaults to false
nasType: scale # defaults to scale, values are core or scale
nasType: scale # defaults to scale, must be set to 'core' if using enablePools with TrueNAS Core
```

@ -521,7 +521,7 @@ export function cleanServiceGroups(groups) {
}
if (type === "truenas") {
if (enablePools !== undefined) cleanedService.widget.enablePools = JSON.parse(enablePools);
cleanedService.widget.nasType = nasType ?? "scale";
if (nasType !== undefined) cleanedService.widget.nasType = nasType;
}
if (["diskstation", "qnap"].includes(type)) {
if (volume) cleanedService.widget.volume = volume;

@ -44,10 +44,10 @@ export default function Component({ service }) {
key={pool.id}
name={pool.name}
healthy={pool.healthy}
scaleAllocated={pool.allocated}
scaleFree={pool.free}
allocated={pool.allocated}
free={pool.free}
data={pool.data}
nasType={widget?.nasType}
nasType={widget?.nasType ?? "scale"}
/>
))}
</>

@ -1,16 +1,15 @@
import classNames from "classnames";
import prettyBytes from "pretty-bytes";
export default function Pool({ name, scaleFree, scaleAllocated, healthy, data, nasType }) {
export default function Pool({ name, free, allocated, healthy, data, nasType }) {
let total = 0;
let allocated = 0;
if (nasType === "scale") {
total = scaleFree + scaleAllocated;
allocated = scaleAllocated;
total = free + allocated;
} else {
allocated = 0; // eslint-disable-line no-param-reassign
for (let i = 0; i < data.length; i += 1) {
total += data[i].stats.size;
allocated += data[i].stats.allocated;
allocated += data[i].stats.allocated; // eslint-disable-line no-param-reassign
}
}

Loading…
Cancel
Save