Change dashboard tabs to use custom sub widgets

This commit is contained in:
2023-02-24 00:53:23 -07:00
parent 1ac9d99482
commit 6cf2aefc6d
2 changed files with 247 additions and 39 deletions
+20 -21
View File
@@ -50,7 +50,7 @@ var (
type Dashboard struct {
Tabs []string
TabContent []list.Model
TabContent []tea.Model
activeTab int
width int
height int
@@ -67,8 +67,9 @@ func (m Dashboard) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.width = msg.Width
m.height = msg.Height
for i := 0; i < len(m.TabContent); i++ {
m.TabContent[i].SetWidth(m.width - 10)
m.TabContent[i].SetHeight(m.height - 10)
m.TabContent[i].Update(msg)
// m.TabContent[i].SetWidth(m.width - 10)
// m.TabContent[i].SetHeight(m.height - 10)
}
case tea.KeyMsg:
switch keypress := msg.String(); keypress {
@@ -160,34 +161,32 @@ func createDashboard(s CursoriusServer) (Dashboard, error) {
client := graphql.NewClient(s.Url, http.DefaultClient)
tabs := []string{"Pipelines", "Secrets", "Clone Credentials", "Runners"}
//testTabs := []list.Item{dashboardItem("Pipelines"), dashboardItem("Secrets"), dashboardItem("Clone Credentials"), dashboardItem("Runners")}
pipelineWidget, err := widget.CreatePipelineWidget(client)
if err != nil {
return Dashboard{}, fmt.Errorf("Could not create Pipelines tab: %w", err)
}
secretWidget, err := widget.CreateSecretWidget(client)
if err != nil {
return Dashboard{}, fmt.Errorf("Could not create Secrets tab: %w", err)
}
//secretWidget, err := widget.CreateSecretWidget(client)
//if err != nil {
// return Dashboard{}, fmt.Errorf("Could not create Secrets tab: %w", err)
//}
cloneCredentialWidget, err := widget.CreateCloneCredentialWidget(client)
if err != nil {
return Dashboard{}, fmt.Errorf("Could not create Clone Credentials tab: %w", err)
}
//cloneCredentialWidget, err := widget.CreateCloneCredentialWidget(client)
//if err != nil {
// return Dashboard{}, fmt.Errorf("Could not create Clone Credentials tab: %w", err)
//}
runnerWidget, err := widget.CreateRunnerWidget(client)
if err != nil {
return Dashboard{}, fmt.Errorf("Could not create Runner tab: %w", err)
}
//runnerWidget, err := widget.CreateRunnerWidget(client)
//if err != nil {
// return Dashboard{}, fmt.Errorf("Could not create Runner tab: %w", err)
//}
tabContent := []list.Model{
//list.New(testTabs, dashboardItemDelegate{}, 50, 50),
tabContent := []tea.Model{
pipelineWidget,
secretWidget,
cloneCredentialWidget,
runnerWidget,
//secretWidget,
//cloneCredentialWidget,
//runnerWidget,
}
return Dashboard{