fix: handle 'default' collection filter in cluster volumes page
- Update matchesCollection to recognize 'default' as filter for empty collection - Remove incorrect conversion of 'default' to empty string in handlers - Fixes issue where ?collection=default would show all collections instead of just default collection
This commit is contained in:
@@ -16,8 +16,8 @@ import (
|
|||||||
// matchesCollection checks if a volume/EC volume collection matches the filter collection.
|
// matchesCollection checks if a volume/EC volume collection matches the filter collection.
|
||||||
// Handles the special case where empty collection ("") represents the "default" collection.
|
// Handles the special case where empty collection ("") represents the "default" collection.
|
||||||
func matchesCollection(volumeCollection, filterCollection string) bool {
|
func matchesCollection(volumeCollection, filterCollection string) bool {
|
||||||
// Both empty means default collection matches default filter
|
// Handle special case where "default" filter matches empty collection
|
||||||
if volumeCollection == "" && filterCollection == "" {
|
if filterCollection == "default" && volumeCollection == "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Direct string match for named collections
|
// Direct string match for named collections
|
||||||
|
|||||||
@@ -170,12 +170,6 @@ func (h *ClusterHandlers) ShowCollectionDetails(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map "default" collection to empty string for backend filtering
|
|
||||||
actualCollectionName := collectionName
|
|
||||||
if collectionName == "default" {
|
|
||||||
actualCollectionName = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse query parameters
|
// Parse query parameters
|
||||||
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||||
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "25"))
|
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "25"))
|
||||||
@@ -183,7 +177,7 @@ func (h *ClusterHandlers) ShowCollectionDetails(c *gin.Context) {
|
|||||||
sortOrder := c.DefaultQuery("sort_order", "asc")
|
sortOrder := c.DefaultQuery("sort_order", "asc")
|
||||||
|
|
||||||
// Get collection details data (volumes and EC volumes)
|
// Get collection details data (volumes and EC volumes)
|
||||||
collectionDetailsData, err := h.adminServer.GetCollectionDetails(actualCollectionName, page, pageSize, sortBy, sortOrder)
|
collectionDetailsData, err := h.adminServer.GetCollectionDetails(collectionName, page, pageSize, sortBy, sortOrder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get collection details: " + err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get collection details: " + err.Error()})
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user