mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-24 08:01:03 +00:00
Made the information pulling time dynamic
This commit is contained in:
parent
0e81129024
commit
fd4d4a1dc6
3 changed files with 47 additions and 10 deletions
|
|
@ -13,7 +13,7 @@ Changes to the user config will only take place after closing and re-opening laz
|
||||||
|
|
||||||
## Default:
|
## Default:
|
||||||
|
|
||||||
```
|
```yml
|
||||||
gui:
|
gui:
|
||||||
scrollHeight: 2
|
scrollHeight: 2
|
||||||
theme:
|
theme:
|
||||||
|
|
@ -53,6 +53,9 @@ oS:
|
||||||
openCommand: open {{filename}}
|
openCommand: open {{filename}}
|
||||||
openLinkCommand: open {{link}}
|
openLinkCommand: open {{link}}
|
||||||
update:
|
update:
|
||||||
|
refreshProjectTime: 100ms
|
||||||
|
refreshContainersAndServicesTime: 100ms
|
||||||
|
refreshVolumesTime: 100ms
|
||||||
method: never
|
method: never
|
||||||
stats:
|
stats:
|
||||||
graphs:
|
graphs:
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,7 @@ type UserConfig struct {
|
||||||
// OS determines what defaults are set for opening files and links
|
// OS determines what defaults are set for opening files and links
|
||||||
OS OSConfig `yaml:"oS,omitempty"`
|
OS OSConfig `yaml:"oS,omitempty"`
|
||||||
|
|
||||||
// Update is currently not being used, but like lazydocker, it may be used down
|
// UpdateConfig determines what the default settings are for updating the ui
|
||||||
// the line to help you update automatically.
|
|
||||||
Update UpdateConfig `yaml:"update,omitempty"`
|
Update UpdateConfig `yaml:"update,omitempty"`
|
||||||
|
|
||||||
// Stats determines how long lazydocker will gather container stats for, and
|
// Stats determines how long lazydocker will gather container stats for, and
|
||||||
|
|
@ -191,10 +190,21 @@ type OSConfig struct {
|
||||||
OpenLinkCommand string `yaml:"openLinkCommand,omitempty"`
|
OpenLinkCommand string `yaml:"openLinkCommand,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateConfig is currently not being used, but may be used down the line to
|
// UpdateConfig determines what the default settings are for updating the ui
|
||||||
// allow for automatic updates
|
//
|
||||||
|
// For the RefreshProjectTime, RefreshContainersAndServicesTime and RefreshVolumesTime
|
||||||
|
// the application expects a valid duration like: 100ms, 2s, 200ns
|
||||||
|
// for docs see: https://golang.org/pkg/time/#ParseDuration
|
||||||
type UpdateConfig struct {
|
type UpdateConfig struct {
|
||||||
Method string `yaml:"method,omitempty"`
|
// RefreshProjectTime determines the time betweens updates of the project panel
|
||||||
|
RefreshProjectTime string `yaml:"refreshProjectTime,omitempty"`
|
||||||
|
|
||||||
|
// RefreshContainersAndServicesTime determines the time betweens updates of the containers and services panel
|
||||||
|
RefreshContainersAndServicesTime string `yaml:"refreshContainersAndServicesTime,omitempty"`
|
||||||
|
|
||||||
|
// RefreshVolumesTime determines the time betweens updates of the volumes panel
|
||||||
|
RefreshVolumesTime string `yaml:"refreshVolumesTime,omitempty"`
|
||||||
|
Method string `yaml:"method,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GraphConfig specifies how to make a graph of recorded container stats
|
// GraphConfig specifies how to make a graph of recorded container stats
|
||||||
|
|
@ -346,7 +356,10 @@ func GetDefaultConfig() UserConfig {
|
||||||
},
|
},
|
||||||
OS: GetPlatformDefaultConfig(),
|
OS: GetPlatformDefaultConfig(),
|
||||||
Update: UpdateConfig{
|
Update: UpdateConfig{
|
||||||
Method: "never",
|
RefreshProjectTime: "100ms",
|
||||||
|
RefreshContainersAndServicesTime: "100ms",
|
||||||
|
RefreshVolumesTime: "100ms",
|
||||||
|
Method: "never",
|
||||||
},
|
},
|
||||||
Stats: StatsConfig{
|
Stats: StatsConfig{
|
||||||
MaxDuration: duration,
|
MaxDuration: duration,
|
||||||
|
|
|
||||||
|
|
@ -267,13 +267,34 @@ func (gui *Gui) Run() error {
|
||||||
gui.waitForIntro.Add(1)
|
gui.waitForIntro.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updates := gui.Config.UserConfig.Update
|
||||||
|
projectDuration := time.Millisecond * 100
|
||||||
|
containersAndServicesDuration := time.Millisecond * 100
|
||||||
|
volumesDuration := time.Millisecond * 100
|
||||||
|
toBind := []struct {
|
||||||
|
BindTo *time.Duration
|
||||||
|
Value string
|
||||||
|
}{
|
||||||
|
{&projectDuration, updates.RefreshProjectTime},
|
||||||
|
{&containersAndServicesDuration, updates.RefreshContainersAndServicesTime},
|
||||||
|
{&volumesDuration, updates.RefreshVolumesTime},
|
||||||
|
}
|
||||||
|
for _, item := range toBind {
|
||||||
|
duration, err := time.ParseDuration(item.Value)
|
||||||
|
if err == nil {
|
||||||
|
*item.BindTo = duration
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
gui.Log.Error("Can't parse duration:", err)
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
gui.waitForIntro.Wait()
|
gui.waitForIntro.Wait()
|
||||||
gui.goEvery(time.Millisecond*50, gui.renderAppStatus)
|
gui.goEvery(time.Millisecond*50, gui.renderAppStatus)
|
||||||
gui.goEvery(time.Millisecond*30, gui.reRenderMain)
|
gui.goEvery(time.Millisecond*30, gui.reRenderMain)
|
||||||
gui.goEvery(time.Millisecond*100, gui.refreshProject)
|
gui.goEvery(projectDuration, gui.refreshProject)
|
||||||
gui.goEvery(time.Millisecond*100, gui.refreshContainersAndServices)
|
gui.goEvery(containersAndServicesDuration, gui.refreshContainersAndServices)
|
||||||
gui.goEvery(time.Millisecond*100, gui.refreshVolumes)
|
gui.goEvery(volumesDuration, gui.refreshVolumes)
|
||||||
gui.goEvery(time.Millisecond*1000, gui.DockerCommand.UpdateContainerDetails)
|
gui.goEvery(time.Millisecond*1000, gui.DockerCommand.UpdateContainerDetails)
|
||||||
gui.goEvery(time.Millisecond*1000, gui.checkForContextChange)
|
gui.goEvery(time.Millisecond*1000, gui.checkForContextChange)
|
||||||
}()
|
}()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue