Show protocol enable state and which nodes have each protocol installed.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -25,8 +25,40 @@ type Protocol struct {
|
||||
SortOrder int `json:"sort_order"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
InstalledOn []NodeProtoRef `json:"installed_on,omitempty"`
|
||||
EnabledOn []NodeProtoRef `json:"enabled_on,omitempty"`
|
||||
}
|
||||
|
||||
type NodeProtoRef struct {
|
||||
NodeID uuid.UUID `json:"node_id"`
|
||||
NodeName string `json:"node_name"`
|
||||
Host string `json:"host"`
|
||||
Status NodeStatus `json:"status"`
|
||||
}
|
||||
|
||||
type NodeProtocol struct {
|
||||
NodeID uuid.UUID `json:"node_id"`
|
||||
ProtocolID uuid.UUID `json:"protocol_id"`
|
||||
ProtocolCode string `json:"protocol_code"`
|
||||
ProtocolName string `json:"protocol_name"`
|
||||
Port int `json:"port"`
|
||||
Installed bool `json:"installed"`
|
||||
Enabled bool `json:"enabled"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (p Protocol) EnabledLabel() string {
|
||||
if p.Enabled {
|
||||
return "Включён"
|
||||
}
|
||||
return "Выключен"
|
||||
}
|
||||
|
||||
func (p Protocol) InstallCount() int { return len(p.InstalledOn) }
|
||||
func (p Protocol) ActiveCount() int { return len(p.EnabledOn) }
|
||||
|
||||
|
||||
type NodeStatus string
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user