download all button

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-27 15:09:51 -06:00
parent 7b34a318e5
commit 8034921c7d
1 changed files with 34 additions and 10 deletions

View File

@ -34,6 +34,7 @@ type section struct {
group *gui.Node
grid *gui.Node // where the repos are listed
hideCB *gui.Node
downloadAllB *gui.Node
witRepos []*witRepo
}
@ -106,6 +107,27 @@ func downloadRepo(path string) bool {
return true
}
func (r *witRepo) doDownload() bool {
if me.autoDryRun.Checked() {
r.downloadB.SetLabel("uncheck --dry-run")
return false
}
if r.downloadB.String() == "downloaded" {
log.Info("skipping already downloaded", r.path.String())
return true
}
if downloadRepo(r.path.String()) {
log.Info("download", r.path.String(), "worked")
r.downloadB.SetLabel("downloaded")
r.downloadB.Disable()
} else {
r.downloadB.SetLabel("failed")
log.Info("download", r.path.String(), "failed")
return false
}
return true
}
func (s *section) add(path string) {
if s == nil {
return
@ -115,16 +137,7 @@ func (s *section) add(path string) {
tmp.path = s.grid.NewLabel(path)
tmp.downloadB = s.grid.NewButton("download", func() {
lw.Disable()
if me.autoDryRun.Checked() {
tmp.downloadB.SetLabel("uncheck --dry-run")
}
if downloadRepo(tmp.path.String()) {
log.Info("download", tmp.path.String(), "worked")
tmp.downloadB.SetLabel("downloaded")
tmp.downloadB.Disable()
} else {
log.Info("download", tmp.path.String(), "failed")
}
tmp.doDownload()
lw.Enable()
})
if repostatus.VerifyLocalGoRepo(path) {
@ -146,6 +159,17 @@ func NewSection(parent *gui.Node, desc string) *section {
news.hideCB.Custom = func() {
news.toggle()
}
news.downloadAllB = news.box.NewButton("download all", func() {
lw.Disable()
log.Warn("Download all here")
for i, wrepo := range news.witRepos {
log.Warn("download:", i, wrepo.path.String())
wrepo.doDownload()
//wrepo.path.Show()
//wrepo.downloadB.Show()
}
lw.Enable()
})
news.grid = news.parent.NewGrid("sections", 2, 1)
allsections = append(allsections, news)
return news