Example #1
0
func doUI(client *rest.Client, url string, logger *log.Logger) error {
	app := ui.NewApp(client, url)
	app.SetLogger(logger)

	if e := topsl.AppInit(); e != nil {
		return e
	}
	app.Logf("Starting up user interface")
	topsl.SetApplication(app)
	app.ShowMain()
	// periodic updates please
	go func() {
		for {
			topsl.AppDraw()
			time.Sleep(time.Second)
		}
	}()
	topsl.RunApplication()
	return nil
}
Example #2
0
func (a *App) refresh() {
	client := a.client
	etag := ""
	for {
		items, e := a.getItems()

		topsl.AppLock()
		a.items = items
		a.err = e
		topsl.AppUnlock()
		topsl.AppDraw()
		ctx, cancel := context.WithTimeout(context.Background(),
			time.Hour)
		etag, e = client.Watch(ctx, etag)
		cancel()
		if e != nil {
			time.Sleep(2 * time.Second)
		}
	}
}
Example #3
0
func (a *App) refreshLog(ctx context.Context, name string) {
	info, e := a.client.GetLog(name)

	for {
		topsl.AppLock()
		if a.logName == name {
			a.logInfo = info
			a.logErr = e

			topsl.AppUnlock()
			topsl.AppDraw()
		} else {
			topsl.AppUnlock()
			return
		}
		select {
		case <-ctx.Done():
			return
		default:
		}
		info, e = a.client.WatchLog(ctx, name, info)
	}
}