summaryrefslogtreecommitdiff
path: root/errorBox.go
blob: 0353393d985e2f25dec2d6640af9921eaf82d28c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* 
	Show a box for a configuration error
*/

package main

import (
	"go.wit.com/log"
	"go.wit.com/gui/gui"
	"go.wit.com/gui/gadgets"
)

type errorBox struct {
	name	string // the problem name

	parent	*gui.Node
	group	*gui.Node
	grid	*gui.Node

	l	*gui.Node
	b	*gui.Node

	fixes	map[string]*anError

	something *gadgets.OneLiner
}

type anError struct {
	kind string // what kind of error is it?
	ip string
	status string

	kindLabel *gui.Node
	ipLabel *gui.Node
	statusLabel *gui.Node
	button *gui.Node
}

func NewErrorBox(p *gui.Node, name string, ip string) *errorBox {
	var eb *errorBox
	eb = new(errorBox)
	eb.parent = p
	eb.group = p.NewGroup(name)
	eb.grid = eb.group.NewGrid("stuff", 4, 1)

	eb.grid.NewLabel("Type")
	eb.grid.NewLabel("IP")
	eb.grid.NewLabel("Status")
	eb.grid.NewLabel("")

	eb.fixes = make(map[string]*anError)
	return eb
}


func (eb *errorBox) add(kind string, ip string) bool {
	tmp := kind + " " + ip
	if eb.fixes[tmp] != nil {
		log.Log(WARN, "Error is already here", kind, ip)
		return false
	}

	anErr := new(anError)
	anErr.kind = kind

	anErr.kindLabel = eb.grid.NewLabel(kind)
	anErr.ipLabel = eb.grid.NewLabel(ip)
	anErr.statusLabel = eb.grid.NewLabel("")
	anErr.button = eb.grid.NewButton(kind, func() {
		log.Log(WARN, "got", kind, "here. IP =", ip)
		eb.fix(kind, ip)
	})
	eb.fixes[tmp] = anErr
	return false
}

func (eb *errorBox) fix(name string, ip string) bool {
	log.Log(WARN, "should try to fix", name, "here. IP =", ip)
	return false
}

func (eb *errorBox) update() bool {
	return false
}

func (eb *errorBox) toggle() {
}