mirror of
https://github.com/Adembc/lazyssh.git
synced 2026-07-14 12:13:34 +02:00
configure lint and fix its problems
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
// Copyright 2025.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ui
|
||||
|
||||
import (
|
||||
@@ -7,7 +21,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/Adembc/lazyssh/internal/core/domain"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
@@ -42,7 +56,7 @@ func (sf *ServerForm) build() {
|
||||
title = "Edit Server"
|
||||
}
|
||||
|
||||
sf.SetBorder(true).
|
||||
sf.Form.SetBorder(true).
|
||||
SetTitle(title).
|
||||
SetTitleAlign(tview.AlignLeft).
|
||||
SetBorderColor(tcell.Color238).
|
||||
@@ -50,9 +64,9 @@ func (sf *ServerForm) build() {
|
||||
|
||||
sf.addFormFields()
|
||||
|
||||
sf.AddButton("Save", sf.handleSave)
|
||||
sf.AddButton("Cancel", sf.handleCancel)
|
||||
sf.SetCancelFunc(sf.handleCancel)
|
||||
sf.Form.AddButton("Save", sf.handleSave)
|
||||
sf.Form.AddButton("Cancel", sf.handleCancel)
|
||||
sf.Form.SetCancelFunc(sf.handleCancel)
|
||||
}
|
||||
|
||||
func (sf *ServerForm) addFormFields() {
|
||||
@@ -76,12 +90,12 @@ func (sf *ServerForm) addFormFields() {
|
||||
}
|
||||
}
|
||||
|
||||
sf.AddInputField("Alias:", defaultValues.Alias, 20, nil, nil)
|
||||
sf.AddInputField("Host/IP:", defaultValues.Host, 20, nil, nil)
|
||||
sf.AddInputField("User:", defaultValues.User, 20, nil, nil)
|
||||
sf.AddInputField("Port:", defaultValues.Port, 20, nil, nil)
|
||||
sf.AddInputField("Key:", defaultValues.Key, 40, nil, nil)
|
||||
sf.AddInputField("Tags (comma):", defaultValues.Tags, 30, nil, nil)
|
||||
sf.Form.AddInputField("Alias:", defaultValues.Alias, 20, nil, nil)
|
||||
sf.Form.AddInputField("Host/IP:", defaultValues.Host, 20, nil, nil)
|
||||
sf.Form.AddInputField("User:", defaultValues.User, 20, nil, nil)
|
||||
sf.Form.AddInputField("Port:", defaultValues.Port, 20, nil, nil)
|
||||
sf.Form.AddInputField("Key:", defaultValues.Key, 40, nil, nil)
|
||||
sf.Form.AddInputField("Tags (comma):", defaultValues.Tags, 30, nil, nil)
|
||||
|
||||
statusDD := tview.NewDropDown().SetLabel("Status: ")
|
||||
statusOptions := []string{"online", "warn", "offline"}
|
||||
@@ -93,7 +107,7 @@ func (sf *ServerForm) addFormFields() {
|
||||
break
|
||||
}
|
||||
}
|
||||
sf.AddFormItem(statusDD)
|
||||
sf.Form.AddFormItem(statusDD)
|
||||
}
|
||||
|
||||
type ServerFormData struct {
|
||||
@@ -108,12 +122,12 @@ type ServerFormData struct {
|
||||
|
||||
func (sf *ServerForm) getFormData() ServerFormData {
|
||||
return ServerFormData{
|
||||
Alias: strings.TrimSpace(sf.GetFormItem(0).(*tview.InputField).GetText()),
|
||||
Host: strings.TrimSpace(sf.GetFormItem(1).(*tview.InputField).GetText()),
|
||||
User: strings.TrimSpace(sf.GetFormItem(2).(*tview.InputField).GetText()),
|
||||
Port: strings.TrimSpace(sf.GetFormItem(3).(*tview.InputField).GetText()),
|
||||
Key: strings.TrimSpace(sf.GetFormItem(4).(*tview.InputField).GetText()),
|
||||
Tags: strings.TrimSpace(sf.GetFormItem(5).(*tview.InputField).GetText()),
|
||||
Alias: strings.TrimSpace(sf.Form.GetFormItem(0).(*tview.InputField).GetText()),
|
||||
Host: strings.TrimSpace(sf.Form.GetFormItem(1).(*tview.InputField).GetText()),
|
||||
User: strings.TrimSpace(sf.Form.GetFormItem(2).(*tview.InputField).GetText()),
|
||||
Port: strings.TrimSpace(sf.Form.GetFormItem(3).(*tview.InputField).GetText()),
|
||||
Key: strings.TrimSpace(sf.Form.GetFormItem(4).(*tview.InputField).GetText()),
|
||||
Tags: strings.TrimSpace(sf.Form.GetFormItem(5).(*tview.InputField).GetText()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +169,7 @@ func (sf *ServerForm) dataToServer(data ServerFormData) domain.Server {
|
||||
}
|
||||
}
|
||||
|
||||
_, status := sf.GetFormItem(6).(*tview.DropDown).GetCurrentOption()
|
||||
_, status := sf.Form.GetFormItem(6).(*tview.DropDown).GetCurrentOption()
|
||||
return domain.Server{
|
||||
Alias: data.Alias,
|
||||
Host: data.Host,
|
||||
|
||||
Reference in New Issue
Block a user