mirror of
https://github.com/unraid/api.git
synced 2026-01-02 14:40:01 -06:00
Compare commits
2 Commits
feat/timez
...
fix/back-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa9a290803 | ||
|
|
9ce2952538 |
@@ -1,5 +1,5 @@
|
||||
[api]
|
||||
version="3.0.1+b26ff388"
|
||||
version="3.1.0"
|
||||
[local]
|
||||
[notifier]
|
||||
apikey="unnotify_30994bfaccf839c65bae75f7fa12dd5ee16e69389f754c3b98ed7d5"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[api]
|
||||
version="3.0.1+b26ff388"
|
||||
version="3.1.0"
|
||||
[local]
|
||||
[notifier]
|
||||
apikey="unnotify_30994bfaccf839c65bae75f7fa12dd5ee16e69389f754c3b98ed7d5"
|
||||
|
||||
@@ -63,9 +63,9 @@ test('Returns generated data', async () => {
|
||||
"array": {
|
||||
"capacity": {
|
||||
"bytes": {
|
||||
"free": 19495825571000,
|
||||
"total": 41994745901000,
|
||||
"used": 22498920330000,
|
||||
"free": 19495825571840,
|
||||
"total": 41994745901056,
|
||||
"used": 22498920329216,
|
||||
},
|
||||
},
|
||||
"state": "STOPPED",
|
||||
|
||||
@@ -23,10 +23,10 @@ test('Creates an array event', async () => {
|
||||
"device": "sda",
|
||||
"exportable": true,
|
||||
"format": "unknown",
|
||||
"fsFree": 3191407,
|
||||
"fsSize": 4042732,
|
||||
"fsFree": 3116608,
|
||||
"fsSize": 3947980,
|
||||
"fsType": "vfat",
|
||||
"fsUsed": 851325,
|
||||
"fsUsed": 831372,
|
||||
"id": "Cruzer",
|
||||
"idx": 32,
|
||||
"name": "flash",
|
||||
@@ -48,10 +48,10 @@ test('Creates an array event', async () => {
|
||||
"device": "sdi",
|
||||
"exportable": false,
|
||||
"format": "MBR: 4KiB-aligned",
|
||||
"fsFree": 111810683,
|
||||
"fsSize": 250059317,
|
||||
"fsFree": 109190120,
|
||||
"fsSize": 244198552,
|
||||
"fsType": "btrfs",
|
||||
"fsUsed": 137273827,
|
||||
"fsUsed": 134056472,
|
||||
"id": "Samsung_SSD_850_EVO_250GB_S2R5NX0H643734Z",
|
||||
"idx": 30,
|
||||
"name": "cache",
|
||||
@@ -97,10 +97,10 @@ test('Creates an array event', async () => {
|
||||
"total": "30",
|
||||
"used": "3",
|
||||
},
|
||||
"kilobytes": {
|
||||
"free": "19495825571",
|
||||
"total": "41994745901",
|
||||
"used": "22498920330",
|
||||
"kibibytes": {
|
||||
"free": "19038892160",
|
||||
"total": "41010494044",
|
||||
"used": "21971601884",
|
||||
},
|
||||
},
|
||||
"disks": [
|
||||
@@ -110,10 +110,10 @@ test('Creates an array event', async () => {
|
||||
"device": "sdf",
|
||||
"exportable": false,
|
||||
"format": "GPT: 4KiB-aligned",
|
||||
"fsFree": 13882739732,
|
||||
"fsSize": 17998742753,
|
||||
"fsFree": 13557363020,
|
||||
"fsSize": 17576897220,
|
||||
"fsType": "xfs",
|
||||
"fsUsed": 4116003021,
|
||||
"fsUsed": 4019534200,
|
||||
"id": "ST18000NM000J-2TV103_ZR5B1W9X",
|
||||
"idx": 1,
|
||||
"name": "disk1",
|
||||
@@ -134,10 +134,10 @@ test('Creates an array event', async () => {
|
||||
"device": "sdj",
|
||||
"exportable": false,
|
||||
"format": "GPT: 4KiB-aligned",
|
||||
"fsFree": 93140746,
|
||||
"fsSize": 11998001574,
|
||||
"fsFree": 90957760,
|
||||
"fsSize": 11716798412,
|
||||
"fsType": "xfs",
|
||||
"fsUsed": 11904860828,
|
||||
"fsUsed": 11625840652,
|
||||
"id": "WDC_WD120EDAZ-11F3RA0_5PJRD45C",
|
||||
"idx": 2,
|
||||
"name": "disk2",
|
||||
@@ -158,10 +158,10 @@ test('Creates an array event', async () => {
|
||||
"device": "sde",
|
||||
"exportable": false,
|
||||
"format": "GPT: 4KiB-aligned",
|
||||
"fsFree": 5519945093,
|
||||
"fsSize": 11998001574,
|
||||
"fsFree": 5390571380,
|
||||
"fsSize": 11716798412,
|
||||
"fsType": "xfs",
|
||||
"fsUsed": 6478056481,
|
||||
"fsUsed": 6326227032,
|
||||
"id": "WDC_WD120EMAZ-11BLFA0_5PH8BTYD",
|
||||
"idx": 3,
|
||||
"name": "disk3",
|
||||
|
||||
@@ -18,7 +18,7 @@ test('Returns both disk and user shares', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "appdata",
|
||||
@@ -28,7 +28,7 @@ test('Returns both disk and user shares', async () => {
|
||||
"smb": {},
|
||||
"splitLevel": "",
|
||||
"type": "user",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -38,7 +38,7 @@ test('Returns both disk and user shares', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "domains",
|
||||
@@ -48,7 +48,7 @@ test('Returns both disk and user shares', async () => {
|
||||
"smb": {},
|
||||
"splitLevel": "1",
|
||||
"type": "user",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -58,7 +58,7 @@ test('Returns both disk and user shares', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "isos",
|
||||
@@ -68,7 +68,7 @@ test('Returns both disk and user shares', async () => {
|
||||
"smb": {},
|
||||
"splitLevel": "",
|
||||
"type": "user",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -78,7 +78,7 @@ test('Returns both disk and user shares', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "system",
|
||||
@@ -88,7 +88,7 @@ test('Returns both disk and user shares', async () => {
|
||||
"smb": {},
|
||||
"splitLevel": "1",
|
||||
"type": "user",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -106,7 +106,7 @@ test('Returns shares by type', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "appdata",
|
||||
@@ -116,7 +116,7 @@ test('Returns shares by type', async () => {
|
||||
"smb": {},
|
||||
"splitLevel": "",
|
||||
"type": "user",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
}
|
||||
`);
|
||||
expect(getShares('users')).toMatchInlineSnapshot(`
|
||||
@@ -129,7 +129,7 @@ test('Returns shares by type', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "appdata",
|
||||
@@ -139,7 +139,7 @@ test('Returns shares by type', async () => {
|
||||
"smb": {},
|
||||
"splitLevel": "",
|
||||
"type": "user",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -149,7 +149,7 @@ test('Returns shares by type', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "domains",
|
||||
@@ -159,7 +159,7 @@ test('Returns shares by type', async () => {
|
||||
"smb": {},
|
||||
"splitLevel": "1",
|
||||
"type": "user",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -169,7 +169,7 @@ test('Returns shares by type', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "isos",
|
||||
@@ -179,7 +179,7 @@ test('Returns shares by type', async () => {
|
||||
"smb": {},
|
||||
"splitLevel": "",
|
||||
"type": "user",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -189,7 +189,7 @@ test('Returns shares by type', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "system",
|
||||
@@ -199,7 +199,7 @@ test('Returns shares by type', async () => {
|
||||
"smb": {},
|
||||
"splitLevel": "1",
|
||||
"type": "user",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
]
|
||||
`);
|
||||
@@ -217,7 +217,7 @@ test('Returns shares by name', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "domains",
|
||||
@@ -227,7 +227,7 @@ test('Returns shares by name', async () => {
|
||||
"smb": {},
|
||||
"splitLevel": "1",
|
||||
"type": "user",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
}
|
||||
`);
|
||||
expect(getShares('user', { name: 'non-existent-user-share' })).toMatchInlineSnapshot('null');
|
||||
|
||||
@@ -174,10 +174,10 @@ test('After init returns values from cfg file for all fields', async () => {
|
||||
"device": "sdf",
|
||||
"exportable": false,
|
||||
"format": "GPT: 4KiB-aligned",
|
||||
"fsFree": 13882739732,
|
||||
"fsSize": 17998742753,
|
||||
"fsFree": 13557363020,
|
||||
"fsSize": 17576897220,
|
||||
"fsType": "xfs",
|
||||
"fsUsed": 4116003021,
|
||||
"fsUsed": 4019534200,
|
||||
"id": "ST18000NM000J-2TV103_ZR5B1W9X",
|
||||
"idx": 1,
|
||||
"name": "disk1",
|
||||
@@ -198,10 +198,10 @@ test('After init returns values from cfg file for all fields', async () => {
|
||||
"device": "sdj",
|
||||
"exportable": false,
|
||||
"format": "GPT: 4KiB-aligned",
|
||||
"fsFree": 93140746,
|
||||
"fsSize": 11998001574,
|
||||
"fsFree": 90957760,
|
||||
"fsSize": 11716798412,
|
||||
"fsType": "xfs",
|
||||
"fsUsed": 11904860828,
|
||||
"fsUsed": 11625840652,
|
||||
"id": "WDC_WD120EDAZ-11F3RA0_5PJRD45C",
|
||||
"idx": 2,
|
||||
"name": "disk2",
|
||||
@@ -222,10 +222,10 @@ test('After init returns values from cfg file for all fields', async () => {
|
||||
"device": "sde",
|
||||
"exportable": false,
|
||||
"format": "GPT: 4KiB-aligned",
|
||||
"fsFree": 5519945093,
|
||||
"fsSize": 11998001574,
|
||||
"fsFree": 5390571380,
|
||||
"fsSize": 11716798412,
|
||||
"fsType": "xfs",
|
||||
"fsUsed": 6478056481,
|
||||
"fsUsed": 6326227032,
|
||||
"id": "WDC_WD120EMAZ-11BLFA0_5PH8BTYD",
|
||||
"idx": 3,
|
||||
"name": "disk3",
|
||||
@@ -246,10 +246,10 @@ test('After init returns values from cfg file for all fields', async () => {
|
||||
"device": "sdi",
|
||||
"exportable": false,
|
||||
"format": "MBR: 4KiB-aligned",
|
||||
"fsFree": 111810683,
|
||||
"fsSize": 250059317,
|
||||
"fsFree": 109190120,
|
||||
"fsSize": 244198552,
|
||||
"fsType": "btrfs",
|
||||
"fsUsed": 137273827,
|
||||
"fsUsed": 134056472,
|
||||
"id": "Samsung_SSD_850_EVO_250GB_S2R5NX0H643734Z",
|
||||
"idx": 30,
|
||||
"name": "cache",
|
||||
@@ -294,10 +294,10 @@ test('After init returns values from cfg file for all fields', async () => {
|
||||
"device": "sda",
|
||||
"exportable": true,
|
||||
"format": "unknown",
|
||||
"fsFree": 3191407,
|
||||
"fsSize": 4042732,
|
||||
"fsFree": 3116608,
|
||||
"fsSize": 3947980,
|
||||
"fsType": "vfat",
|
||||
"fsUsed": 851325,
|
||||
"fsUsed": 831372,
|
||||
"id": "Cruzer",
|
||||
"idx": 32,
|
||||
"name": "flash",
|
||||
@@ -325,14 +325,14 @@ test('After init returns values from cfg file for all fields', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "appdata",
|
||||
"nameOrig": "appdata",
|
||||
"size": 0,
|
||||
"splitLevel": "",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -343,14 +343,14 @@ test('After init returns values from cfg file for all fields', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "domains",
|
||||
"nameOrig": "domains",
|
||||
"size": 0,
|
||||
"splitLevel": "1",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -361,14 +361,14 @@ test('After init returns values from cfg file for all fields', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "isos",
|
||||
"nameOrig": "isos",
|
||||
"size": 0,
|
||||
"splitLevel": "",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -379,14 +379,14 @@ test('After init returns values from cfg file for all fields', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "system",
|
||||
"nameOrig": "system",
|
||||
"size": 0,
|
||||
"splitLevel": "1",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -23,14 +23,14 @@ test('Returns parsed state file', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "appdata",
|
||||
"nameOrig": "appdata",
|
||||
"size": 0,
|
||||
"splitLevel": "",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -41,14 +41,14 @@ test('Returns parsed state file', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "domains",
|
||||
"nameOrig": "domains",
|
||||
"size": 0,
|
||||
"splitLevel": "1",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -59,14 +59,14 @@ test('Returns parsed state file', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "isos",
|
||||
"nameOrig": "isos",
|
||||
"size": 0,
|
||||
"splitLevel": "",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
{
|
||||
"allocator": "highwater",
|
||||
@@ -77,14 +77,14 @@ test('Returns parsed state file', async () => {
|
||||
"cow": "auto",
|
||||
"exclude": [],
|
||||
"floor": "0",
|
||||
"free": 9309372,
|
||||
"free": 9091184,
|
||||
"include": [],
|
||||
"luksStatus": "0",
|
||||
"name": "system",
|
||||
"nameOrig": "system",
|
||||
"size": 0,
|
||||
"splitLevel": "1",
|
||||
"used": 33619300,
|
||||
"used": 32831348,
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
@@ -44,10 +44,10 @@ test('Returns parsed state file', async () => {
|
||||
"device": "sdf",
|
||||
"exportable": false,
|
||||
"format": "GPT: 4KiB-aligned",
|
||||
"fsFree": 13882739732,
|
||||
"fsSize": 17998742753,
|
||||
"fsFree": 13557363020,
|
||||
"fsSize": 17576897220,
|
||||
"fsType": "xfs",
|
||||
"fsUsed": 4116003021,
|
||||
"fsUsed": 4019534200,
|
||||
"id": "ST18000NM000J-2TV103_ZR5B1W9X",
|
||||
"idx": 1,
|
||||
"name": "disk1",
|
||||
@@ -68,10 +68,10 @@ test('Returns parsed state file', async () => {
|
||||
"device": "sdj",
|
||||
"exportable": false,
|
||||
"format": "GPT: 4KiB-aligned",
|
||||
"fsFree": 93140746,
|
||||
"fsSize": 11998001574,
|
||||
"fsFree": 90957760,
|
||||
"fsSize": 11716798412,
|
||||
"fsType": "xfs",
|
||||
"fsUsed": 11904860828,
|
||||
"fsUsed": 11625840652,
|
||||
"id": "WDC_WD120EDAZ-11F3RA0_5PJRD45C",
|
||||
"idx": 2,
|
||||
"name": "disk2",
|
||||
@@ -92,10 +92,10 @@ test('Returns parsed state file', async () => {
|
||||
"device": "sde",
|
||||
"exportable": false,
|
||||
"format": "GPT: 4KiB-aligned",
|
||||
"fsFree": 5519945093,
|
||||
"fsSize": 11998001574,
|
||||
"fsFree": 5390571380,
|
||||
"fsSize": 11716798412,
|
||||
"fsType": "xfs",
|
||||
"fsUsed": 6478056481,
|
||||
"fsUsed": 6326227032,
|
||||
"id": "WDC_WD120EMAZ-11BLFA0_5PH8BTYD",
|
||||
"idx": 3,
|
||||
"name": "disk3",
|
||||
@@ -116,10 +116,10 @@ test('Returns parsed state file', async () => {
|
||||
"device": "sdi",
|
||||
"exportable": false,
|
||||
"format": "MBR: 4KiB-aligned",
|
||||
"fsFree": 111810683,
|
||||
"fsSize": 250059317,
|
||||
"fsFree": 109190120,
|
||||
"fsSize": 244198552,
|
||||
"fsType": "btrfs",
|
||||
"fsUsed": 137273827,
|
||||
"fsUsed": 134056472,
|
||||
"id": "Samsung_SSD_850_EVO_250GB_S2R5NX0H643734Z",
|
||||
"idx": 30,
|
||||
"name": "cache",
|
||||
@@ -164,10 +164,10 @@ test('Returns parsed state file', async () => {
|
||||
"device": "sda",
|
||||
"exportable": true,
|
||||
"format": "unknown",
|
||||
"fsFree": 3191407,
|
||||
"fsSize": 4042732,
|
||||
"fsFree": 3116608,
|
||||
"fsSize": 3947980,
|
||||
"fsType": "vfat",
|
||||
"fsUsed": 851325,
|
||||
"fsUsed": 831372,
|
||||
"id": "Cruzer",
|
||||
"idx": 32,
|
||||
"name": "flash",
|
||||
|
||||
31
api/src/common/dashboard/get-array.ts
Normal file
31
api/src/common/dashboard/get-array.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { type DashboardArrayInput } from '@app/graphql/generated/client/graphql';
|
||||
import { getArrayData } from '@app/core/modules/array/get-array-data';
|
||||
import { ArrayState } from '@app/graphql/generated/api/types';
|
||||
import { convert } from 'convert';
|
||||
|
||||
const KiBToB = (KiB: number | string): number =>
|
||||
convert(Number(KiB), 'KiB').to('B');
|
||||
|
||||
export const getArray = (): DashboardArrayInput => {
|
||||
const array = getArrayData();
|
||||
|
||||
if (!array) {
|
||||
return {
|
||||
state: ArrayState.STOPPED,
|
||||
capacity: {
|
||||
bytes: { free: 0, used: 0, total: 0 },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
state: array.state ?? ArrayState.STOPPED,
|
||||
capacity: {
|
||||
bytes: {
|
||||
free: KiBToB(array.capacity.kibibytes.free),
|
||||
used: KiBToB(array.capacity.kibibytes.used),
|
||||
total: KiBToB(array.capacity.kibibytes.total),
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -34,19 +34,19 @@ export const getArrayData = (getState = store.getState): ArrayType => {
|
||||
const disks = allDisks.filter((disk) => disk.type === ArrayDiskType.DATA);
|
||||
const caches = allDisks.filter((disk) => disk.type === ArrayDiskType.CACHE);
|
||||
// Disk sizes
|
||||
const disksTotalKBytes = sum(disks.map((disk) => disk.fsSize));
|
||||
const disksFreeKBytes = sum(disks.map((disk) => disk.fsFree));
|
||||
const disksUsedKBytes = sum(disks.map((disk) => disk.fsUsed));
|
||||
const disksTotalKiBytes = sum(disks.map((disk) => disk.fsSize));
|
||||
const disksFreeKiBytes = sum(disks.map((disk) => disk.fsFree));
|
||||
const disksUsedKiBytes = sum(disks.map((disk) => disk.fsUsed));
|
||||
|
||||
// Max
|
||||
const maxDisks = emhttp.var.maxArraysz ?? disks.length;
|
||||
|
||||
// Array capacity
|
||||
const capacity: ArrayCapacity = {
|
||||
kilobytes: {
|
||||
free: disksFreeKBytes.toString(),
|
||||
used: disksUsedKBytes.toString(),
|
||||
total: disksTotalKBytes.toString(),
|
||||
kibibytes: {
|
||||
free: disksFreeKiBytes.toString(),
|
||||
used: disksUsedKiBytes.toString(),
|
||||
total: disksTotalKiBytes.toString(),
|
||||
},
|
||||
disks: {
|
||||
free: String(maxDisks - disks.length),
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { convert, type Data } from 'convert';
|
||||
|
||||
// If it's "true", "yes" or "1" then it's true otherwise it's false
|
||||
export const toBoolean = (value: string): boolean =>
|
||||
['true', 'yes', '1'].includes(value?.toLowerCase().trim());
|
||||
@@ -20,18 +18,6 @@ export const toNumberOrNull = (myString: string): number | null => {
|
||||
return null;
|
||||
};
|
||||
|
||||
export const toNumberOrNullConvert = (
|
||||
myString: string,
|
||||
{ startingUnit = 'KiB', endUnit = 'KB' }: { startingUnit: Data; endUnit: Data }
|
||||
): number | null => {
|
||||
const stringParsed = toNumberOrNull(myString);
|
||||
if (stringParsed !== null) {
|
||||
return Math.round(convert(stringParsed, startingUnit).to(endUnit));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const boolToString = (bool: boolean): BooleanString => {
|
||||
if (typeof bool === 'boolean') {
|
||||
throw new Error('Incorrect type, only true/false is allowed.');
|
||||
|
||||
@@ -58,7 +58,7 @@ export type ArrayType = {
|
||||
export type ArrayCapacity = {
|
||||
__typename?: 'ArrayCapacity';
|
||||
disks: Capacity;
|
||||
kilobytes: Capacity;
|
||||
kibibytes: Capacity;
|
||||
};
|
||||
|
||||
export type ArrayDisk = {
|
||||
@@ -71,13 +71,13 @@ export type ArrayDisk = {
|
||||
exportable?: Maybe<Scalars['Boolean']>;
|
||||
/** File format (ex MBR: 4KiB-aligned) */
|
||||
format?: Maybe<Scalars['String']>;
|
||||
/** (KB) Free Size on the FS (Not present on Parity type drive) */
|
||||
/** (KiB) Free Size on the FS (Not present on Parity type drive) */
|
||||
fsFree?: Maybe<Scalars['Long']>;
|
||||
/** (KB) Total Size of the FS (Not present on Parity type drive) */
|
||||
/** (KiB) Total Size of the FS (Not present on Parity type drive) */
|
||||
fsSize?: Maybe<Scalars['Long']>;
|
||||
/** File system type for the disk */
|
||||
fsType?: Maybe<Scalars['String']>;
|
||||
/** (KB) Used Size on the FS (Not present on Parity type drive) */
|
||||
/** (KiB) Used Size on the FS (Not present on Parity type drive) */
|
||||
fsUsed?: Maybe<Scalars['Long']>;
|
||||
/** Disk indentifier, only set for present disks on the system */
|
||||
id: Scalars['ID'];
|
||||
@@ -92,7 +92,7 @@ export type ArrayDisk = {
|
||||
numWrites: Scalars['Long'];
|
||||
/** Is the disk a HDD or SSD. */
|
||||
rotational?: Maybe<Scalars['Boolean']>;
|
||||
/** (KB) Disk Size total */
|
||||
/** (KiB) Disk Size total */
|
||||
size: Scalars['Long'];
|
||||
status?: Maybe<ArrayDiskStatus>;
|
||||
/** Disk temp - will be NaN if array is not started or DISK_NP */
|
||||
@@ -1037,7 +1037,7 @@ export type Share = {
|
||||
/** Disks that're excluded from this share */
|
||||
exclude?: Maybe<Array<Maybe<Scalars['String']>>>;
|
||||
floor?: Maybe<Scalars['String']>;
|
||||
/** (KB) Free space */
|
||||
/** (KiB) Free space */
|
||||
free?: Maybe<Scalars['Long']>;
|
||||
/** Disks that're included in this share */
|
||||
include?: Maybe<Array<Maybe<Scalars['String']>>>;
|
||||
@@ -1045,10 +1045,10 @@ export type Share = {
|
||||
/** Display name */
|
||||
name?: Maybe<Scalars['String']>;
|
||||
nameOrig?: Maybe<Scalars['String']>;
|
||||
/** (KB) Total size */
|
||||
/** (KiB) Total size */
|
||||
size?: Maybe<Scalars['Long']>;
|
||||
splitLevel?: Maybe<Scalars['String']>;
|
||||
/** (KB) Used Size */
|
||||
/** (KiB) Used Size */
|
||||
used?: Maybe<Scalars['Long']>;
|
||||
};
|
||||
|
||||
@@ -1866,7 +1866,7 @@ export type ArrayResolvers<ContextType = Context, ParentType extends ResolversPa
|
||||
|
||||
export type ArrayCapacityResolvers<ContextType = Context, ParentType extends ResolversParentTypes['ArrayCapacity'] = ResolversParentTypes['ArrayCapacity']> = ResolversObject<{
|
||||
disks?: Resolver<ResolversTypes['Capacity'], ParentType, ContextType>;
|
||||
kilobytes?: Resolver<ResolversTypes['Capacity'], ParentType, ContextType>;
|
||||
kibibytes?: Resolver<ResolversTypes['Capacity'], ParentType, ContextType>;
|
||||
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
|
||||
}>;
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ enum ArrayPendingState {
|
||||
}
|
||||
|
||||
type ArrayCapacity {
|
||||
kilobytes: Capacity!
|
||||
kibibytes: Capacity!
|
||||
disks: Capacity!
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ type ArrayDisk {
|
||||
idx: Int!
|
||||
name: String
|
||||
device: String
|
||||
""" (KB) Disk Size total """
|
||||
""" (KiB) Disk Size total """
|
||||
size: Long!
|
||||
status: ArrayDiskStatus
|
||||
""" Is the disk a HDD or SSD. """
|
||||
@@ -139,11 +139,11 @@ type ArrayDisk {
|
||||
numWrites: Long!
|
||||
"""Number of unrecoverable errors reported by the device I/O drivers. Missing data due to unrecoverable array read errors is filled in on-the-fly using parity reconstruct (and we attempt to write this data back to the sector(s) which failed). Any unrecoverable write error results in disabling the disk."""
|
||||
numErrors: Long!
|
||||
""" (KB) Total Size of the FS (Not present on Parity type drive) """
|
||||
""" (KiB) Total Size of the FS (Not present on Parity type drive) """
|
||||
fsSize: Long
|
||||
""" (KB) Free Size on the FS (Not present on Parity type drive)"""
|
||||
""" (KiB) Free Size on the FS (Not present on Parity type drive)"""
|
||||
fsFree: Long
|
||||
""" (KB) Used Size on the FS (Not present on Parity type drive)"""
|
||||
""" (KiB) Used Size on the FS (Not present on Parity type drive)"""
|
||||
fsUsed: Long
|
||||
exportable: Boolean
|
||||
""" Type of Disk - used to differentiate Cache / Flash / Array / Parity """
|
||||
|
||||
@@ -12,11 +12,11 @@ type Subscription {
|
||||
type Share {
|
||||
"""Display name"""
|
||||
name: String
|
||||
"""(KB) Free space"""
|
||||
"""(KiB) Free space"""
|
||||
free: Long
|
||||
"""(KB) Used Size"""
|
||||
"""(KiB) Used Size"""
|
||||
used: Long
|
||||
"""(KB) Total size"""
|
||||
"""(KiB) Total size"""
|
||||
size: Long
|
||||
"""Disks that're included in this share"""
|
||||
include: [String]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import { toNumberOrNullConvert } from '@app/core/utils/casting';
|
||||
import { toNumberOrNull } from '@app/core/utils/casting';
|
||||
import { type Share } from '@app/graphql/generated/api/types';
|
||||
import type { StateFileToIniParserMap } from '@app/store/types';
|
||||
|
||||
@@ -18,18 +18,9 @@ export const parse: StateFileToIniParserMap['shares'] = state => Object.values(s
|
||||
const { name, free, used, size, include, exclude, useCache, ...rest } = item;
|
||||
const share: Share = {
|
||||
name: name ?? '',
|
||||
free: toNumberOrNullConvert(free, {
|
||||
startingUnit: 'KiB',
|
||||
endUnit: 'KB',
|
||||
}) ?? 0,
|
||||
used: toNumberOrNullConvert(used, {
|
||||
startingUnit: 'KiB',
|
||||
endUnit: 'KB',
|
||||
}) ?? 0,
|
||||
size: toNumberOrNullConvert(size, {
|
||||
startingUnit: 'KiB',
|
||||
endUnit: 'KB',
|
||||
}) ?? 0,
|
||||
free: toNumberOrNull(free),
|
||||
used: toNumberOrNull(used),
|
||||
size: toNumberOrNull(size),
|
||||
include: include.split(',').filter((_) => _),
|
||||
exclude: exclude.split(',').filter((_) => _),
|
||||
cache: useCache === 'yes',
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
toNumber,
|
||||
toBoolean,
|
||||
toNumberOrNull,
|
||||
toNumberOrNullConvert,
|
||||
} from '@app/core/utils';
|
||||
import {
|
||||
ArrayDiskStatus,
|
||||
@@ -60,18 +59,9 @@ export const parse: StateFileToIniParserMap['disks'] = (disksIni) =>
|
||||
device: slot.device,
|
||||
comment: slot.comment ?? null,
|
||||
exportable: toBoolean(slot.exportable),
|
||||
fsFree: toNumberOrNullConvert(slot.fsFree, {
|
||||
startingUnit: 'KiB',
|
||||
endUnit: 'KB',
|
||||
}),
|
||||
fsUsed: toNumberOrNullConvert(slot.fsUsed, {
|
||||
startingUnit: 'KiB',
|
||||
endUnit: 'KB',
|
||||
}),
|
||||
fsSize: toNumberOrNullConvert(slot.fsSize, {
|
||||
startingUnit: 'KiB',
|
||||
endUnit: 'KB',
|
||||
}),
|
||||
fsFree: toNumberOrNull(slot.fsFree),
|
||||
fsUsed: toNumberOrNull(slot.fsUsed),
|
||||
fsSize: toNumberOrNull(slot.fsSize),
|
||||
idx: toNumber(slot.idx),
|
||||
name: slot.name,
|
||||
numErrors: toNumber(slot.numErrors),
|
||||
|
||||
Reference in New Issue
Block a user