Utku Ozdemir 9e07832db9
feat: implement summary dashboard
Implement the new summary dashboard with node info and logs.
Replace the previous metrics dashboard with the new dashboard which has multiple screens for node summary, metrics and editing network config.

Port the old metrics dashboard to the tview library and assign it to be a screen in the new dashboard, accessible by F2 key.

Add a new resource, infos.cluster.talos.dev which contains the cluster name and id of a node.

Disable the network config editor screen in the new dashboard until it is fully implemented with its backend.

Closes siderolabs/talos#4790.

Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
2023-03-15 13:13:28 +01:00

53 lines
1.1 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package dashboard
import (
"time"
)
type options struct {
interval time.Duration
allowExitKeys bool
screens []Screen
}
func defaultOptions() *options {
return &options{
interval: 5 * time.Second,
allowExitKeys: true,
screens: []Screen{
ScreenSummary,
ScreenMonitor,
ScreenNetworkConfig,
},
}
}
// Option is a functional option for Dashboard.
type Option func(*options)
// WithInterval sets the interval for the dashboard.
func WithInterval(interval time.Duration) Option {
return func(o *options) {
o.interval = interval
}
}
// WithAllowExitKeys sets whether the dashboard should allow exit keys (Ctrl + C).
func WithAllowExitKeys(allowExitKeys bool) Option {
return func(o *options) {
o.allowExitKeys = allowExitKeys
}
}
// WithScreens sets the screens to display.
// The order is preserved.
func WithScreens(screens ...Screen) Option {
return func(o *options) {
o.screens = screens
}
}