diff --git a/colors.go b/colors.go new file mode 100644 index 0000000..9b38326 --- /dev/null +++ b/colors.go @@ -0,0 +1,65 @@ +package main + +import "fmt" +import "image/color" +import "runtime" + +// import "github.com/golang/protobuf/proto" +import pb "git.wit.com/wit/witProtobuf" +import "git.wit.com/wit/gui" + +// import "github.com/andlabs/ui" + +var windowsTextVeryLightGrey = color.RGBA{10, 10, 10, 10} +var windowsTextBlack = color.RGBA{200, 200, 200, 200} +var windowsTextWhite = color.RGBA{255, 255, 255, 255} +var windowsTextYellow = color.RGBA{200, 200, 0, 200} +var windowsTextRed = color.RGBA{200, 0, 0, 200} +var windowsTextBlue = color.RGBA{0, 100, 200, 100} +var windowsBgGrey = color.RGBA{100, 100, 100, 142} +var windowsBgBlack = color.RGBA{55, 55, 55, 255} + +var linuxTextBlue = color.RGBA{0, 100, 200, 100} +var linuxTextBlack = color.RGBA{0, 0, 0, 0} +var linuxTextYellow = color.RGBA{200, 200, 0, 200} +var linuxBgMauve = color.RGBA{72, 0, 0, 142} +var linuxBgBlack = color.RGBA{55, 55, 55, 255} +var linuxBgWhite = color.RGBA{0, 0, 0, 0} + +func setRowValues(mh *gui.TableData, row int, vm *pb.Event_VM) { + defaultTextColor := linuxTextBlue + defaultTextYellow := linuxTextYellow + defaultTextBlack := linuxTextBlack + + if runtime.GOOS == "windows" { + defaultTextColor = windowsTextRed + defaultTextBlack = windowsTextBlack + } + // if (row % 2) == 1 { + if (row == 1) { + mh.Rows[row].HumanData[0].Color = color.RGBA{100, 100, 100, 142} // makes the background of each other row grey + } else if (row == 2) { + mh.Rows[row].HumanData[0].Color = color.RGBA{0, 0, 0, 0} // makes the background of each other row grey + } else if (row == 3) { + mh.Rows[row].HumanData[0].Color = color.RGBA{255, 255, 255, 255} // makes the background of each other row grey + } else if (row == 4) { + mh.Rows[row].HumanData[0].Color = color.RGBA{255, 255, 255, 0} // makes the background of each other row grey + } else if (row == 5) { + mh.Rows[row].HumanData[0].Color = color.RGBA{55, 55, 55, 255} // makes the background of each other row grey + } else if (row < 10) { + mh.Rows[row].HumanData[0].Color = linuxBgMauve + } else { + mh.Rows[row].HumanData[0].Color = color.RGBA{250, 250, 250, 250} + } + mh.Rows[row].HumanData[1].Text = vm.Name + mh.Rows[row].HumanData[1].Color = defaultTextColor + mh.Rows[row].HumanData[2].Text = vm.Hostname + mh.Rows[row].HumanData[2].Color = defaultTextYellow + mh.Rows[row].HumanData[3].Text = fmt.Sprintf("%d",vm.Cpus) + mh.Rows[row].HumanData[3].Color = defaultTextColor + mh.Rows[row].HumanData[4].Text = fmt.Sprintf("%d",vm.Memory) + mh.Rows[row].HumanData[4].Color = defaultTextBlack + mh.Rows[row].HumanData[5].Text = fmt.Sprintf("%d",vm.Disk) + mh.Rows[row].HumanData[5].Color = defaultTextBlack + mh.Rows[row].HumanData[6].Text = fmt.Sprintf("Details %s",vm.Name) +} diff --git a/eventChannel.go b/eventChannel.go index 60fee06..7a1ade9 100644 --- a/eventChannel.go +++ b/eventChannel.go @@ -1,21 +1,17 @@ package main -import "fmt" import "log" -import "image/color" -import "runtime" import "github.com/golang/protobuf/proto" import pb "git.wit.com/wit/witProtobuf" +import "github.com/andlabs/ui" import "git.wit.com/wit/gui" -import "github.com/andlabs/ui" - var mychannel chan *pb.Event - var currentMessage *pb.Event +/* var windowsTextVeryLightGrey = color.RGBA{10, 10, 10, 10} var windowsTextBlack = color.RGBA{200, 200, 200, 200} var windowsTextWhite = color.RGBA{255, 255, 255, 255} @@ -31,6 +27,7 @@ var linuxTextYellow = color.RGBA{200, 200, 0, 200} var linuxBgMauve = color.RGBA{72, 0, 0, 142} var linuxBgBlack = color.RGBA{55, 55, 55, 255} var linuxBgWhite = color.RGBA{0, 0, 0, 0} +*/ func initChannel() { mychannel = make(chan *pb.Event) @@ -75,6 +72,46 @@ func countVMS(data *pb.Event) int { return len(vms) } +/* +func setRowValues(mh *gui.TableData, row int, vm *pb.Event_VM) { + defaultTextColor := linuxTextBlue + defaultTextYellow := linuxTextYellow + defaultTextBlack := linuxTextBlack + + if runtime.GOOS == "windows" { + defaultTextColor = windowsTextRed + defaultTextBlack = windowsTextBlack + } + // if (row % 2) == 1 { + if (row == 1) { + mh.Rows[row].HumanData[0].Color = color.RGBA{100, 100, 100, 142} // makes the background of each other row grey + } else if (row == 2) { + mh.Rows[row].HumanData[0].Color = color.RGBA{0, 0, 0, 0} // makes the background of each other row grey + } else if (row == 3) { + mh.Rows[row].HumanData[0].Color = color.RGBA{255, 255, 255, 255} // makes the background of each other row grey + } else if (row == 4) { + mh.Rows[row].HumanData[0].Color = color.RGBA{255, 255, 255, 0} // makes the background of each other row grey + } else if (row == 5) { + mh.Rows[row].HumanData[0].Color = color.RGBA{55, 55, 55, 255} // makes the background of each other row grey + } else if (row < 10) { + mh.Rows[row].HumanData[0].Color = linuxBgMauve + } else { + mh.Rows[row].HumanData[0].Color = color.RGBA{250, 250, 250, 250} + } + mh.Rows[row].HumanData[1].Text = vm.Name + mh.Rows[row].HumanData[1].Color = defaultTextColor + mh.Rows[row].HumanData[2].Text = vm.Hostname + mh.Rows[row].HumanData[2].Color = defaultTextYellow + mh.Rows[row].HumanData[3].Text = fmt.Sprintf("%d",vm.Cpus) + mh.Rows[row].HumanData[3].Color = defaultTextColor + mh.Rows[row].HumanData[4].Text = fmt.Sprintf("%d",vm.Memory) + mh.Rows[row].HumanData[4].Color = defaultTextBlack + mh.Rows[row].HumanData[5].Text = fmt.Sprintf("%d",vm.Disk) + mh.Rows[row].HumanData[5].Color = defaultTextBlack + mh.Rows[row].HumanData[6].Text = fmt.Sprintf("Details %s",vm.Name) +} +*/ + func ReadReceivedData(data *pb.Event, mh *gui.TableData, window *ui.Window, tab *ui.Tab) { msgItems := data.GetResults() log.Println("ReadReceivedData() Event msgItems=", msgItems) @@ -90,62 +127,28 @@ func ReadReceivedData(data *pb.Event, mh *gui.TableData, window *ui.Window, tab vms := data.GetVms() log.Println("ReadReceivedData() Event vms=", vms) - for row, item := range vms { - defaultTextColor := linuxTextBlue - defaultTextYellow := linuxTextYellow - defaultTextBlack := linuxTextBlack - - if runtime.GOOS == "windows" { - defaultTextColor = windowsTextRed - defaultTextBlack = windowsTextBlack - } - // if (row % 2) == 1 { - if (row == 1) { - mh.Rows[row].HumanData[0].Color = color.RGBA{100, 100, 100, 142} // makes the background of each other row grey - } else if (row == 2) { - mh.Rows[row].HumanData[0].Color = color.RGBA{0, 0, 0, 0} // makes the background of each other row grey - } else if (row == 3) { - mh.Rows[row].HumanData[0].Color = color.RGBA{255, 255, 255, 255} // makes the background of each other row grey - } else if (row == 4) { - mh.Rows[row].HumanData[0].Color = color.RGBA{255, 255, 255, 0} // makes the background of each other row grey - } else if (row == 5) { - mh.Rows[row].HumanData[0].Color = color.RGBA{55, 55, 55, 255} // makes the background of each other row grey - } else if (row < 10) { - mh.Rows[row].HumanData[0].Color = linuxBgMauve - } else { - mh.Rows[row].HumanData[0].Color = color.RGBA{250, 250, 250, 250} - } - mh.Rows[row].HumanData[1].Text = item.Name - mh.Rows[row].HumanData[1].Color = defaultTextColor - mh.Rows[row].HumanData[2].Text = item.Hostname - mh.Rows[row].HumanData[2].Color = defaultTextYellow - mh.Rows[row].HumanData[3].Text = fmt.Sprintf("%d",item.Cpus) - mh.Rows[row].HumanData[3].Color = defaultTextColor - mh.Rows[row].HumanData[4].Text = fmt.Sprintf("%d",item.Memory) - mh.Rows[row].HumanData[4].Color = defaultTextBlack - mh.Rows[row].HumanData[5].Text = fmt.Sprintf("%d",item.Disk) - mh.Rows[row].HumanData[5].Color = defaultTextBlack - mh.Rows[row].HumanData[6].Text = fmt.Sprintf("Details %s",item.Name) + for row, vm := range vms { + setRowValues(mh, row, vm) // create 'fake' button entries for the mouse clicks within tables var newButtonMap gui.ButtonMap newButtonMap.Action = "SHOW VM" - newButtonMap.VM = item // set the button to this VM + newButtonMap.VM = vm // set the button to this VM newButtonMap.Account = data.Account newButtonMap.W = window newButtonMap.T = tab gui.Data.AllButtons = append(gui.Data.AllButtons, newButtonMap) mh.Rows[row].HumanData[6].Button = &newButtonMap - mh.Rows[row].HumanData[6].VM = item + mh.Rows[row].HumanData[6].VM = vm - mh.Rows[row].VM = item + mh.Rows[row].VM = vm - log.Println("\titem=", item) - log.Println("\titem.Name=", item.Name) + log.Println("\tvm=", vm) + log.Println("\tvm.Name=", vm.Name) log.Println("\tRows[row]=", mh.Rows[row]) log.Println("\tRows[row]=", row) log.Println("\tRows[row].Name=", mh.Rows[row].Name) - log.Println(item) + log.Println(vm) row += 1 } }