@@ -138,39 +138,9 @@ PulseApp.ui.storage = (() => {
138
138
}
139
139
140
140
const sortedNodeStorageData = sortNodeStorageData ( nodeStorageData ) ;
141
-
142
141
sortedNodeStorageData . forEach ( store => {
143
- const row = document . createElement ( 'tr' ) ;
144
- const isDisabled = store . enabled === 0 || store . active === 0 ;
145
- row . className = `transition-all duration-150 ease-out hover:bg-gray-100 dark:hover:bg-gray-700/60 hover:shadow-md hover:-translate-y-px ${ isDisabled ? 'opacity-50 grayscale-[50%]' : '' } ` ;
146
-
147
- const usagePercent = store . total > 0 ? ( store . used / store . total ) * 100 : 0 ;
148
- const usageTooltipText = `${ PulseApp . utils . formatBytes ( store . used ) } / ${ PulseApp . utils . formatBytes ( store . total ) } (${ usagePercent . toFixed ( 1 ) } %)` ;
149
-
150
- const usageColorClass = PulseApp . utils . getUsageColor ( usagePercent ) ;
151
- const sharedIconTooltip = store . shared === 1 ? 'Shared across cluster' : 'Local to node' ;
152
- const sharedIcon = store . shared === 1 ? `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block text-green-600 dark:text-green-400"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>`
153
- : `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block text-gray-400 dark:text-gray-500 opacity-50"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>` ;
154
-
155
- const contentTypes = ( store . content || '' ) . split ( ',' ) . map ( ct => ct . trim ( ) ) . filter ( ct => ct ) ;
156
- contentTypes . sort ( ) ;
157
- const contentBadges = contentTypes . map ( ct => {
158
- const details = getContentBadgeDetails ( ct ) ;
159
- return `<span data-tooltip="${ details . tooltip } " class="storage-tooltip-trigger inline-block ${ details . badgeClass } rounded px-1.5 py-0.5 text-xs font-medium mr-1 cursor-default">${ ct } </span>` ;
160
- } ) . join ( '' ) ;
161
-
162
- const usageBarHTML = PulseApp . utils . createProgressTextBarHTML ( usagePercent , usageTooltipText , usageColorClass ) ;
163
-
164
- row . innerHTML = `
165
- <td class="p-1 px-2 whitespace-nowrap text-gray-900 dark:text-gray-100 font-medium">${ store . storage || 'N/A' } </td>
166
- <td class="p-1 px-2 whitespace-nowrap text-gray-600 dark:text-gray-300 text-xs flex items-center">${ contentBadges || '-' } </td>
167
- <td class="p-1 px-2 whitespace-nowrap text-gray-600 dark:text-gray-300">${ store . type || 'N/A' } </td>
168
- <td class="p-1 px-2 whitespace-nowrap storage-tooltip-trigger cursor-default" data-tooltip="${ sharedIconTooltip } ">${ sharedIcon } </td>
169
- <td class="p-1 px-2 text-gray-600 dark:text-gray-300 min-w-[250px]">${ usageBarHTML } </td>
170
- <td class="p-1 px-2 whitespace-nowrap text-gray-600 dark:text-gray-300">${ PulseApp . utils . formatBytes ( store . avail ) } </td>
171
- <td class="p-1 px-2 whitespace-nowrap text-gray-600 dark:text-gray-300">${ PulseApp . utils . formatBytes ( store . total ) } </td>
172
- ` ;
173
- tbody . appendChild ( row ) ;
142
+ const row = _createStorageRow ( store ) ;
143
+ tbody . appendChild ( row ) ;
174
144
} ) ;
175
145
} ) ;
176
146
@@ -179,7 +149,40 @@ PulseApp.ui.storage = (() => {
179
149
contentDiv . appendChild ( table ) ;
180
150
}
181
151
152
+ function _createStorageRow ( store ) {
153
+ const row = document . createElement ( 'tr' ) ;
154
+ const isDisabled = store . enabled === 0 || store . active === 0 ;
155
+ row . className = `transition-all duration-150 ease-out hover:bg-gray-100 dark:hover:bg-gray-700/60 hover:shadow-md hover:-translate-y-px ${ isDisabled ? 'opacity-50 grayscale-[50%]' : '' } ` ;
156
+
157
+ const usagePercent = store . total > 0 ? ( store . used / store . total ) * 100 : 0 ;
158
+ const usageTooltipText = `${ PulseApp . utils . formatBytes ( store . used ) } / ${ PulseApp . utils . formatBytes ( store . total ) } (${ usagePercent . toFixed ( 1 ) } %)` ;
159
+ const usageColorClass = PulseApp . utils . getUsageColor ( usagePercent ) ;
160
+ const usageBarHTML = PulseApp . utils . createProgressTextBarHTML ( usagePercent , usageTooltipText , usageColorClass ) ;
161
+
162
+ const sharedIconTooltip = store . shared === 1 ? 'Shared across cluster' : 'Local to node' ;
163
+ const sharedIcon = store . shared === 1 ? `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block text-green-600 dark:text-green-400"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>`
164
+ : `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="inline-block text-gray-400 dark:text-gray-500 opacity-50"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></svg>` ;
165
+
166
+ const contentTypes = ( store . content || '' ) . split ( ',' ) . map ( ct => ct . trim ( ) ) . filter ( ct => ct ) ;
167
+ contentTypes . sort ( ) ;
168
+ const contentBadges = contentTypes . map ( ct => {
169
+ const details = getContentBadgeDetails ( ct ) ;
170
+ return `<span data-tooltip="${ details . tooltip } " class="storage-tooltip-trigger inline-block ${ details . badgeClass } rounded px-1.5 py-0.5 text-xs font-medium mr-1 cursor-default">${ ct } </span>` ;
171
+ } ) . join ( '' ) ;
172
+
173
+ row . innerHTML = `
174
+ <td class="p-1 px-2 whitespace-nowrap text-gray-900 dark:text-gray-100 font-medium">${ store . storage || 'N/A' } </td>
175
+ <td class="p-1 px-2 whitespace-nowrap text-gray-600 dark:text-gray-300 text-xs flex items-center">${ contentBadges || '-' } </td>
176
+ <td class="p-1 px-2 whitespace-nowrap text-gray-600 dark:text-gray-300">${ store . type || 'N/A' } </td>
177
+ <td class="p-1 px-2 whitespace-nowrap storage-tooltip-trigger cursor-default" data-tooltip="${ sharedIconTooltip } ">${ sharedIcon } </td>
178
+ <td class="p-1 px-2 text-gray-600 dark:text-gray-300 min-w-[250px]">${ usageBarHTML } </td>
179
+ <td class="p-1 px-2 whitespace-nowrap text-gray-600 dark:text-gray-300">${ PulseApp . utils . formatBytes ( store . avail ) } </td>
180
+ <td class="p-1 px-2 whitespace-nowrap text-gray-600 dark:text-gray-300">${ PulseApp . utils . formatBytes ( store . total ) } </td>
181
+ ` ;
182
+ return row ;
183
+ }
184
+
182
185
return {
183
186
updateStorageInfo
184
187
} ;
185
- } ) ( ) ;
188
+ } ) ( ) ;
0 commit comments