Skip to content

Commit

Permalink
Merge pull request #1169 from SebastianOsinski/diskstation_volume
Browse files Browse the repository at this point in the history
Add option to specify volume in Diskstation widget
  • Loading branch information
shamoon authored Apr 3, 2023
2 parents 2a56fd9 + 616e8f2 commit 2ab8e63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/utils/config/service-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ export function cleanServiceGroups(groups) {
podSelector,
wan, // opnsense widget,
enableBlocks, // emby/jellyfin
enableNowPlaying
enableNowPlaying,
volume // diskstation widget
} = cleanedService.widget;

const fieldsList = typeof fields === 'string' ? JSON.parse(fields) : fields;
Expand Down Expand Up @@ -284,6 +285,9 @@ export function cleanServiceGroups(groups) {
if (enableBlocks) cleanedService.widget.enableBlocks = enableBlocks === 'true';
if (enableNowPlaying) cleanedService.widget.enableNowPlaying = enableNowPlaying === 'true';
}
if (type === "diskstation") {
if (volume) cleanedService.widget.volume = volume;
}
}

return cleanedService;
Expand Down
3 changes: 1 addition & 2 deletions src/widgets/diskstation/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export default function Component({ service }) {
const uptime = `${ t("common.number", { value: days }) } ${ t("diskstation.days") }`;

// storage info
// TODO: figure out how to display info for more than one volume
const volume = storageData.data.vol_info?.[0];
const volume = widget.volume ? storageData.data.vol_info?.find(vol => vol.name === widget.volume) : storageData.data.vol_info?.[0];
const usedBytes = parseFloat(volume?.used_size);
const totalBytes = parseFloat(volume?.total_size);
const freeBytes = totalBytes - usedBytes;
Expand Down

0 comments on commit 2ab8e63

Please sign in to comment.