mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-20 09:42:06 +08:00
fix link to volume server; display volume space usage
This commit is contained in:
parent
e85fbd29a1
commit
d8da465cd3
@ -83,11 +83,12 @@ type VolumeWithTopology struct {
|
||||
}
|
||||
|
||||
type ClusterVolumesData struct {
|
||||
Username string `json:"username"`
|
||||
Volumes []VolumeWithTopology `json:"volumes"`
|
||||
TotalVolumes int `json:"total_volumes"`
|
||||
TotalSize int64 `json:"total_size"`
|
||||
LastUpdated time.Time `json:"last_updated"`
|
||||
Username string `json:"username"`
|
||||
Volumes []VolumeWithTopology `json:"volumes"`
|
||||
TotalVolumes int `json:"total_volumes"`
|
||||
TotalSize int64 `json:"total_size"`
|
||||
VolumeSizeLimit uint64 `json:"volume_size_limit"`
|
||||
LastUpdated time.Time `json:"last_updated"`
|
||||
|
||||
// Pagination
|
||||
CurrentPage int `json:"current_page"`
|
||||
|
||||
@ -119,6 +119,21 @@ func (s *AdminServer) GetClusterVolumes(page int, pageSize int, sortBy string, s
|
||||
// Sort volumes
|
||||
s.sortVolumes(volumes, sortBy, sortOrder)
|
||||
|
||||
// Get volume size limit from master
|
||||
var volumeSizeLimit uint64
|
||||
err = s.WithMasterClient(func(client master_pb.SeaweedClient) error {
|
||||
resp, err := client.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
volumeSizeLimit = uint64(resp.VolumeSizeLimitMB) * 1024 * 1024 // Convert MB to bytes
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
// If we can't get the limit, set a default
|
||||
volumeSizeLimit = 30 * 1024 * 1024 * 1024 // 30GB default
|
||||
}
|
||||
|
||||
// Calculate pagination
|
||||
totalVolumes := len(volumes)
|
||||
totalPages := (totalVolumes + pageSize - 1) / pageSize
|
||||
@ -195,6 +210,7 @@ func (s *AdminServer) GetClusterVolumes(page int, pageSize int, sortBy string, s
|
||||
Volumes: volumes,
|
||||
TotalVolumes: totalVolumes,
|
||||
TotalSize: totalSize,
|
||||
VolumeSizeLimit: volumeSizeLimit,
|
||||
LastUpdated: time.Now(),
|
||||
CurrentPage: page,
|
||||
TotalPages: totalPages,
|
||||
|
||||
@ -199,7 +199,7 @@ templ Admin(data dash.AdminData) {
|
||||
<tr>
|
||||
<td>{vs.ID}</td>
|
||||
<td>
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s", vs.PublicURL))} target="_blank">
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", vs.PublicURL))} target="_blank">
|
||||
{vs.Address}
|
||||
<i class="fas fa-external-link-alt ms-1 text-muted"></i>
|
||||
</a>
|
||||
|
||||
@ -172,7 +172,7 @@ func Admin(data dash.AdminData) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 templ.SafeURL = templ.SafeURL(fmt.Sprintf("http://%s", vs.PublicURL))
|
||||
var templ_7745c5c3_Var10 templ.SafeURL = templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", vs.PublicURL))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var10)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
|
||||
@ -115,7 +115,7 @@ templ ClusterVolumeServers(data dash.ClusterVolumeServersData) {
|
||||
<code>{host.ID}</code>
|
||||
</td>
|
||||
<td>
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s", host.PublicURL))} target="_blank" class="text-decoration-none">
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", host.PublicURL))} target="_blank" class="text-decoration-none">
|
||||
{host.Address}
|
||||
<i class="fas fa-external-link-alt ms-1 text-muted"></i>
|
||||
</a>
|
||||
|
||||
@ -100,7 +100,7 @@ func ClusterVolumeServers(data dash.ClusterVolumeServersData) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 templ.SafeURL = templ.SafeURL(fmt.Sprintf("http://%s", host.PublicURL))
|
||||
var templ_7745c5c3_Var6 templ.SafeURL = templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", host.PublicURL))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var6)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
|
||||
@ -277,6 +277,7 @@ templ ClusterVolumes(data dash.ClusterVolumesData) {
|
||||
@getSortIcon("size", data.SortBy, data.SortOrder)
|
||||
</a>
|
||||
</th>
|
||||
<th>Storage Usage</th>
|
||||
<th>
|
||||
<a href="#" onclick="sortTable('filecount')" class="text-decoration-none text-dark">
|
||||
File Count
|
||||
@ -315,7 +316,7 @@ templ ClusterVolumes(data dash.ClusterVolumesData) {
|
||||
<code>{fmt.Sprintf("%d", volume.Id)}</code>
|
||||
</td>
|
||||
<td>
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s", volume.Server))} target="_blank" class="text-decoration-none">
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", volume.Server))} target="_blank" class="text-decoration-none">
|
||||
{volume.Server}
|
||||
<i class="fas fa-external-link-alt ms-1 text-muted"></i>
|
||||
</a>
|
||||
@ -344,6 +345,50 @@ templ ClusterVolumes(data dash.ClusterVolumesData) {
|
||||
</td>
|
||||
}
|
||||
<td>{formatBytes(int64(volume.Size))}</td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="progress me-2" style="width: 80px; height: 16px; background-color: #e9ecef;">
|
||||
<!-- Active data (green) -->
|
||||
<div class="progress-bar bg-success" role="progressbar"
|
||||
style={fmt.Sprintf("width: %.1f%%",
|
||||
func() float64 {
|
||||
if volume.Size > 0 {
|
||||
activePct := float64(volume.Size - volume.DeletedByteCount) / float64(volume.Size) * 100
|
||||
if data.VolumeSizeLimit > 0 {
|
||||
return activePct * float64(volume.Size) / float64(data.VolumeSizeLimit) * 100
|
||||
}
|
||||
return activePct
|
||||
}
|
||||
return 0
|
||||
}())}
|
||||
title={fmt.Sprintf("Active: %s", formatBytes(int64(volume.Size - volume.DeletedByteCount)))}>
|
||||
</div>
|
||||
<!-- Garbage data (red) -->
|
||||
<div class="progress-bar bg-danger" role="progressbar"
|
||||
style={fmt.Sprintf("width: %.1f%%",
|
||||
func() float64 {
|
||||
if volume.Size > 0 && volume.DeletedByteCount > 0 {
|
||||
garbagePct := float64(volume.DeletedByteCount) / float64(volume.Size) * 100
|
||||
if data.VolumeSizeLimit > 0 {
|
||||
return garbagePct * float64(volume.Size) / float64(data.VolumeSizeLimit) * 100
|
||||
}
|
||||
return garbagePct
|
||||
}
|
||||
return 0
|
||||
}())}
|
||||
title={fmt.Sprintf("Garbage: %s", formatBytes(int64(volume.DeletedByteCount)))}>
|
||||
</div>
|
||||
</div>
|
||||
<small class="text-muted">
|
||||
{func() string {
|
||||
if data.VolumeSizeLimit > 0 {
|
||||
return fmt.Sprintf("%.0f%%", float64(volume.Size)/float64(data.VolumeSizeLimit)*100)
|
||||
}
|
||||
return "N/A"
|
||||
}()}
|
||||
</small>
|
||||
</div>
|
||||
</td>
|
||||
<td>{fmt.Sprintf("%d", volume.FileCount)}</td>
|
||||
<td>
|
||||
<span class="badge bg-info">{fmt.Sprintf("%03d", volume.ReplicaPlacement)}</span>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -51,7 +51,7 @@ templ VolumeDetails(data dash.VolumeDetailsData) {
|
||||
<div class="mb-3">
|
||||
<label class="form-label"><strong>Server:</strong></label>
|
||||
<div>
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s", data.Volume.Server))} target="_blank" class="text-decoration-none">
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", data.Volume.Server))} target="_blank" class="text-decoration-none">
|
||||
{data.Volume.Server}
|
||||
<i class="fas fa-external-link-alt ms-1 text-muted"></i>
|
||||
</a>
|
||||
@ -298,7 +298,7 @@ templ VolumeDetails(data dash.VolumeDetailsData) {
|
||||
<tr class="table-primary">
|
||||
<td>
|
||||
<strong>
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s", data.Volume.Server))} target="_blank" class="text-decoration-none">
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", data.Volume.Server))} target="_blank" class="text-decoration-none">
|
||||
{data.Volume.Server}
|
||||
<i class="fas fa-external-link-alt ms-1 text-muted"></i>
|
||||
</a>
|
||||
@ -318,7 +318,7 @@ templ VolumeDetails(data dash.VolumeDetailsData) {
|
||||
for _, replica := range data.Replicas {
|
||||
<tr>
|
||||
<td>
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s", replica.Server))} target="_blank" class="text-decoration-none">
|
||||
<a href={templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", replica.Server))} target="_blank" class="text-decoration-none">
|
||||
{replica.Server}
|
||||
<i class="fas fa-external-link-alt ms-1 text-muted"></i>
|
||||
</a>
|
||||
|
||||
@ -65,7 +65,7 @@ func VolumeDetails(data dash.VolumeDetailsData) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 templ.SafeURL = templ.SafeURL(fmt.Sprintf("http://%s", data.Volume.Server))
|
||||
var templ_7745c5c3_Var4 templ.SafeURL = templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", data.Volume.Server))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var4)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
@ -461,7 +461,7 @@ func VolumeDetails(data dash.VolumeDetailsData) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var28 templ.SafeURL = templ.SafeURL(fmt.Sprintf("http://%s", data.Volume.Server))
|
||||
var templ_7745c5c3_Var28 templ.SafeURL = templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", data.Volume.Server))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var28)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
@ -540,7 +540,7 @@ func VolumeDetails(data dash.VolumeDetailsData) templ.Component {
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var34 templ.SafeURL = templ.SafeURL(fmt.Sprintf("http://%s", replica.Server))
|
||||
var templ_7745c5c3_Var34 templ.SafeURL = templ.SafeURL(fmt.Sprintf("http://%s/ui/index.html", replica.Server))
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var34)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
|
||||
Loading…
Reference in New Issue
Block a user