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 "time"
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
// 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 (
|
||||
"fmt"
|
||||
|
||||
"github.com/Adembc/lazyssh/internal/core/domain"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
@@ -183,7 +197,7 @@ func (t *tui) hideSearchBar() {
|
||||
func (t *tui) refreshServerList() {
|
||||
query := ""
|
||||
if t.searchVisible {
|
||||
query = t.searchBar.GetText()
|
||||
query = t.searchBar.InputField.GetText()
|
||||
}
|
||||
filtered, _ := t.serverService.ListServers(query)
|
||||
t.serverList.UpdateServers(filtered)
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
// 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 (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
@@ -42,7 +56,7 @@ func (h *AppHeader) build() {
|
||||
|
||||
separator := h.createSeparator()
|
||||
|
||||
h.SetDirection(tview.FlexRow).
|
||||
h.Flex.SetDirection(tview.FlexRow).
|
||||
AddItem(headerBar, 1, 0, false).
|
||||
AddItem(separator, 1, 0, false)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
// 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 (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
// 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 (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
@@ -20,7 +34,7 @@ func NewSearchBar() *SearchBar {
|
||||
}
|
||||
|
||||
func (s *SearchBar) build() {
|
||||
s.SetLabel(" 🔍 Search: ").
|
||||
s.InputField.SetLabel(" 🔍 Search: ").
|
||||
SetFieldBackgroundColor(tcell.Color233).
|
||||
SetFieldTextColor(tcell.Color252).
|
||||
SetFieldWidth(30).
|
||||
@@ -29,13 +43,13 @@ func (s *SearchBar) build() {
|
||||
SetBorderColor(tcell.Color238).
|
||||
SetTitleColor(tcell.Color250)
|
||||
|
||||
s.SetChangedFunc(func(text string) {
|
||||
s.InputField.SetChangedFunc(func(text string) {
|
||||
if s.onSearch != nil {
|
||||
s.onSearch(text)
|
||||
}
|
||||
})
|
||||
|
||||
s.SetDoneFunc(func(key tcell.Key) {
|
||||
s.InputField.SetDoneFunc(func(key tcell.Key) {
|
||||
if key == tcell.KeyEsc || key == tcell.KeyEnter {
|
||||
if s.onEscape != nil {
|
||||
s.onEscape()
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
// 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 (
|
||||
"fmt"
|
||||
|
||||
"github.com/Adembc/lazyssh/internal/core/domain"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
@@ -21,7 +35,7 @@ func NewServerDetails() *ServerDetails {
|
||||
}
|
||||
|
||||
func (sd *ServerDetails) build() {
|
||||
sd.SetDynamicColors(true).
|
||||
sd.TextView.SetDynamicColors(true).
|
||||
SetWrap(true).
|
||||
SetBorder(true).
|
||||
SetTitle("Details").
|
||||
@@ -35,9 +49,9 @@ func (sd *ServerDetails) UpdateServer(server domain.Server) {
|
||||
server.Alias, server.Host, server.User, server.Port,
|
||||
server.Key, joinTags(server.Tags), statusIcon(server.Status),
|
||||
server.LastSeen.Format("2006-01-02 15:04"))
|
||||
sd.SetText(text)
|
||||
sd.TextView.SetText(text)
|
||||
}
|
||||
|
||||
func (sd *ServerDetails) ShowEmpty() {
|
||||
sd.SetText("No servers match the current filter.")
|
||||
sd.TextView.SetText("No servers match the current filter.")
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,8 +1,22 @@
|
||||
// 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 (
|
||||
"github.com/Adembc/lazyssh/internal/core/domain"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
@@ -22,17 +36,17 @@ func NewServerList() *ServerList {
|
||||
}
|
||||
|
||||
func (sl *ServerList) build() {
|
||||
sl.ShowSecondaryText(false)
|
||||
sl.SetBorder(true).
|
||||
sl.List.ShowSecondaryText(false)
|
||||
sl.List.SetBorder(true).
|
||||
SetTitle("Servers").
|
||||
SetBorderColor(tcell.Color238).
|
||||
SetTitleColor(tcell.Color250)
|
||||
sl.
|
||||
sl.List.
|
||||
SetSelectedBackgroundColor(tcell.Color24).
|
||||
SetSelectedTextColor(tcell.Color255).
|
||||
SetHighlightFullLine(true)
|
||||
|
||||
sl.SetChangedFunc(func(index int, mainText string, secondaryText string, shortcut rune) {
|
||||
sl.List.SetChangedFunc(func(index int, mainText string, secondaryText string, shortcut rune) {
|
||||
if index >= 0 && index < len(sl.servers) && sl.onSelectionChange != nil {
|
||||
sl.onSelectionChange(sl.servers[index])
|
||||
}
|
||||
@@ -41,20 +55,20 @@ func (sl *ServerList) build() {
|
||||
|
||||
func (sl *ServerList) UpdateServers(servers []domain.Server) {
|
||||
sl.servers = servers
|
||||
sl.Clear()
|
||||
sl.List.Clear()
|
||||
|
||||
for i := range servers {
|
||||
primary, secondary := formatServerLine(servers[i])
|
||||
idx := i
|
||||
sl.AddItem(primary, secondary, 0, func() {
|
||||
sl.List.AddItem(primary, secondary, 0, func() {
|
||||
if sl.onSelection != nil {
|
||||
sl.onSelection(sl.servers[idx])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if sl.GetItemCount() > 0 {
|
||||
sl.SetCurrentItem(0)
|
||||
if sl.List.GetItemCount() > 0 {
|
||||
sl.List.SetCurrentItem(0)
|
||||
if sl.onSelectionChange != nil {
|
||||
sl.onSelectionChange(sl.servers[0])
|
||||
}
|
||||
@@ -62,7 +76,7 @@ func (sl *ServerList) UpdateServers(servers []domain.Server) {
|
||||
}
|
||||
|
||||
func (sl *ServerList) GetSelectedServer() (domain.Server, bool) {
|
||||
idx := sl.GetCurrentItem()
|
||||
idx := sl.List.GetCurrentItem()
|
||||
if idx >= 0 && idx < len(sl.servers) {
|
||||
return sl.servers[idx], true
|
||||
}
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
// 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 (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
// 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 (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
// 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 (
|
||||
"time"
|
||||
|
||||
"github.com/Adembc/lazyssh/internal/core/ports"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
tcell "github.com/gdamore/tcell/v2" // Explicit alias
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user