diff options
Diffstat (limited to 'ui')
-rwxr-xr-x | ui/IdleStatusPanel.go | 20 | ||||
-rwxr-xr-x | ui/NetworkPanel.go | 20 | ||||
-rwxr-xr-x | ui/PrintStatusPanel.go | 19 | ||||
-rwxr-xr-x | ui/ui.go | 4 |
4 files changed, 58 insertions, 5 deletions
diff --git a/ui/IdleStatusPanel.go b/ui/IdleStatusPanel.go index 0535e46..a2b3882 100755 --- a/ui/IdleStatusPanel.go +++ b/ui/IdleStatusPanel.go @@ -3,6 +3,8 @@ package ui import ( // "encoding/json" // "fmt" + "os" + "strconv" // "sync" "time" @@ -31,7 +33,23 @@ func IdleStatusPanel(ui *UI) *idleStatusPanel { instance := &idleStatusPanel{ CommonPanel: NewTopLevelCommonPanel("IdleStatusPanel", ui), } - instance.backgroundTask = utils.CreateBackgroundTask(time.Second * 2, instance.update) + + // Default timeout of 20 seconds. + durration := time.Second * 20 + + // Experimental, set the timeout based on config setting, but only if the config is pressent. + updateFrequency := os.Getenv("EXPERIMENTAL_IDLE_UPDATE_FREQUENCY") + if updateFrequency != "" { + logger.Infof("Ui.New() - EXPERIMENTAL_IDLE_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency) + val, err := strconv.Atoi(updateFrequency) + if err == nil { + durration = time.Second * time.Duration(val) + } else { + logger.LogError("Ui.New()", "strconv.Atoi()", err) + } + } + + instance.backgroundTask = utils.CreateBackgroundTask(durration, instance.update) instance.initialize() idleStatusPanelInstance = instance diff --git a/ui/NetworkPanel.go b/ui/NetworkPanel.go index 1feab9a..12d865b 100755 --- a/ui/NetworkPanel.go +++ b/ui/NetworkPanel.go @@ -3,6 +3,8 @@ package ui import ( "fmt" "net" + "os" + "strconv" "time" "pifke.org/wpasupplicant" @@ -33,7 +35,23 @@ func NetworkPanel( CommonPanel: NewCommonPanel("NetworkPanel", ui), } instance.initialize() - instance.backgroundTask = utils.CreateBackgroundTask(time.Second * 3, instance.update) + + // Default timeout of 30 seconds. + durration := time.Second * 30 + + // Experimental, set the timeout based on config setting, but only if the config is pressent. + updateFrequency := os.Getenv("EXPERIMENTAL_NETWORK_UPDATE_FREQUENCY") + if updateFrequency != "" { + logger.Infof("Ui.New() - EXPERIMENTAL_NETWORK_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency) + val, err := strconv.Atoi(updateFrequency) + if err == nil { + durration = time.Second * time.Duration(val) + } else { + logger.LogError("Ui.New()", "strconv.Atoi()", err) + } + } + + instance.backgroundTask = utils.CreateBackgroundTask(durration, instance.update) networkPanelInstance = instance } diff --git a/ui/PrintStatusPanel.go b/ui/PrintStatusPanel.go index cb39cc3..b049c41 100755 --- a/ui/PrintStatusPanel.go +++ b/ui/PrintStatusPanel.go @@ -2,6 +2,8 @@ package ui import ( "fmt" + "os" + "strconv" "strings" "time" @@ -43,9 +45,24 @@ func PrintStatusPanel(ui *UI) *printStatusPanel { CommonPanel: NewTopLevelCommonPanel("PrintStatusPanel", ui), } + // Default timeout of 20 seconds. + durration := time.Second * 20 + + // Experimental, set the timeout based on config setting, but only if the config is pressent. + updateFrequency := os.Getenv("EXPERIMENTAL_PRINT_UPDATE_FREQUENCY") + if updateFrequency != "" { + logger.Infof("Ui.New() - EXPERIMENTAL_PRINT_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency) + val, err := strconv.Atoi(updateFrequency) + if err == nil { + durration = time.Second * time.Duration(val) + } else { + logger.LogError("Ui.New()", "strconv.Atoi()", err) + } + } + // TODO: revisit... some set the background task and then initialize // and others initialize and then set the background task - instance.backgroundTask = utils.CreateBackgroundTask(time.Second * 2, instance.update) + instance.backgroundTask = utils.CreateBackgroundTask(durration, instance.update) instance.initialize() printStatusPanelInstance = instance } @@ -107,9 +107,9 @@ func New(endpoint, key string, width, height int) *UI { durration := time.Second * 20 // Experimental, set the timeout based on config setting, but only if the config is pressent. - updateFrequency := os.Getenv("EXPERIMENTAL_UPDATE_FREQUENCY") + updateFrequency := os.Getenv("EXPERIMENTAL_UI_UPDATE_FREQUENCY") if updateFrequency != "" { - logger.Infof("Ui.New() - EXPERIMENTAL_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency) + logger.Infof("Ui.New() - EXPERIMENTAL_UI_UPDATE_FREQUENCY is present, frequency is %s", updateFrequency) val, err := strconv.Atoi(updateFrequency) if err == nil { durration = time.Second * time.Duration(val) |