mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-18 11:02:54 +00:00
feat: Add empty response handling to services and subscribers list commands with sample data fallback
- Update listServices to check for empty services slice in addition to error condition - Update listSubscribers to check for empty subscribers slice in addition to error condition - Add muted message when API returns empty results but no error - Preserve existing warning message when API returns error - Show sample/placeholder data in both empty and error cases
This commit is contained in:
@@ -59,8 +59,12 @@ func listServices(u *uiContext) error {
|
||||
t.AddColumn("Version", 10, "left")
|
||||
t.AddColumn("Uptime", 10, "right")
|
||||
|
||||
if err != nil {
|
||||
u.warn("Using placeholder data: " + err.Error())
|
||||
if err != nil || len(services) == 0 {
|
||||
if err != nil {
|
||||
u.warn("Using placeholder data: " + err.Error())
|
||||
} else {
|
||||
u.muted("(API returned no services - showing sample data)")
|
||||
}
|
||||
placeholders := [][]string{
|
||||
{"api-server", "Running", "v1.0.0", "2h15m"},
|
||||
{"charging-engine", "Running", "v1.0.0", "2h15m"},
|
||||
|
||||
@@ -52,8 +52,12 @@ func listSubscribers(u *uiContext) error {
|
||||
u.header("Active Subscribers")
|
||||
|
||||
subs, err := u.client.ListSubscribers()
|
||||
if err != nil {
|
||||
u.warn("Using placeholder data: " + err.Error())
|
||||
if err != nil || len(subs) == 0 {
|
||||
if err != nil {
|
||||
u.warn("Using placeholder data: " + err.Error())
|
||||
} else {
|
||||
u.muted("(API returned no subscribers - showing sample data)")
|
||||
}
|
||||
t := u.newTable()
|
||||
t.AddColumn("IMSI", 16, "left")
|
||||
t.AddColumn("Name", 22, "left")
|
||||
|
||||
Reference in New Issue
Block a user