@@ -8,11 +8,24 @@ import {
8
8
Tr ,
9
9
useColorModeValue ,
10
10
VStack ,
11
+ Progress ,
12
+ ProgressIndicator ,
13
+ ProgressLabel ,
11
14
} from "@hope-ui/solid"
15
+ import { Show } from "solid-js"
12
16
import { useFetch , useRouter , useT } from "~/hooks"
13
17
import { getMainColor } from "~/store"
14
- import { PEmptyResp , Storage } from "~/types"
15
- import { handleResp , handleRespWithNotifySuccess , notify , r } from "~/utils"
18
+ import { MountDetails , PEmptyResp , Storage } from "~/types"
19
+ import {
20
+ handleResp ,
21
+ handleRespWithNotifySuccess ,
22
+ notify ,
23
+ r ,
24
+ showDiskUsage ,
25
+ usedPercentage ,
26
+ toReadableUsage ,
27
+ nearlyFull ,
28
+ } from "~/utils"
16
29
import { DeletePopover } from "../common/DeletePopover"
17
30
18
31
interface StorageProps {
@@ -70,6 +83,28 @@ function StorageOp(props: StorageProps) {
70
83
)
71
84
}
72
85
86
+ function StorageUsage ( props : { details : MountDetails | undefined } ) {
87
+ return (
88
+ < Show when = { props . details } >
89
+ < Progress
90
+ class = "disk-usage-percentage"
91
+ trackColor = "$info3"
92
+ rounded = "$full"
93
+ size = "md"
94
+ value = { usedPercentage ( props . details ! ) }
95
+ >
96
+ < ProgressIndicator
97
+ color = { nearlyFull ( props . details ! ) ? "$danger6" : "$info6" }
98
+ rounded = "$md"
99
+ />
100
+ < ProgressLabel class = "disk-usage-text" >
101
+ { toReadableUsage ( props . details ! ) }
102
+ </ ProgressLabel >
103
+ </ Progress >
104
+ </ Show >
105
+ )
106
+ }
107
+
73
108
export function StorageGridItem ( props : StorageProps ) {
74
109
const t = useT ( )
75
110
return (
@@ -97,6 +132,15 @@ export function StorageGridItem(props: StorageProps) {
97
132
< Badge colorScheme = "info" >
98
133
{ t ( `drivers.drivers.${ props . storage . driver } ` ) }
99
134
</ Badge >
135
+ < Show when = { props . storage . mount_details } >
136
+ < Badge
137
+ colorScheme = {
138
+ nearlyFull ( props . storage . mount_details ! ) ? "danger" : "success"
139
+ }
140
+ >
141
+ { toReadableUsage ( props . storage . mount_details ! ) }
142
+ </ Badge >
143
+ </ Show >
100
144
</ HStack >
101
145
< HStack >
102
146
< Text > { t ( "storages.common.status" ) } : </ Text >
@@ -125,6 +169,9 @@ export function StorageListItem(props: StorageProps) {
125
169
< Td > { props . storage . mount_path } </ Td >
126
170
< Td > { t ( `drivers.drivers.${ props . storage . driver } ` ) } </ Td >
127
171
< Td > { props . storage . order } </ Td >
172
+ < Td >
173
+ < StorageUsage details = { props . storage . mount_details } />
174
+ </ Td >
128
175
< Td >
129
176
{ t (
130
177
`storages.table_fields.status.${ props . storage . status } ` ,
0 commit comments