-
Notifications
You must be signed in to change notification settings - Fork 26
/
sqs.go
42 lines (38 loc) · 1.32 KB
/
sqs.go
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
package view
import (
"github.com/gdamore/tcell/v2"
"github.com/one2nc/cloudlens/internal/ui"
)
type SQS struct {
ResourceViewer
}
// NewPod returns a new viewer.
func NewSQS(resource string) ResourceViewer {
var sqs SQS
sqs.ResourceViewer = NewBrowser(resource)
sqs.AddBindKeysFn(sqs.bindKeys)
// e.GetTable().SetEnterFn(e.describeInstace)
return &sqs
}
func (sqs *SQS) bindKeys(aa ui.KeyActions) {
aa.Add(ui.KeyActions{
ui.KeyShiftN: ui.NewKeyAction("Sort Name", sqs.GetTable().SortColCmd("Name", true), true),
ui.KeyShiftT: ui.NewKeyAction("Sort Type", sqs.GetTable().SortColCmd("Type", true), true),
ui.KeyShiftC: ui.NewKeyAction("Sort Created", sqs.GetTable().SortColCmd("Created", true), true),
ui.KeyShiftM: ui.NewKeyAction("Sort Messages-Available", sqs.GetTable().SortColCmd("Messages-Available", true), true),
tcell.KeyEscape: ui.NewKeyAction("Back", sqs.App().PrevCmd, false),
tcell.KeyEnter: ui.NewKeyAction("View", sqs.enterCmd, false),
})
}
func (sqs *SQS) enterCmd(evt *tcell.EventKey) *tcell.EventKey {
queueUrl := sqs.GetTable().GetSelectedItem()
if queueUrl != "" {
f := describeResource
if sqs.GetTable().enterFn != nil {
f = sqs.GetTable().enterFn
}
f(sqs.App(), sqs.GetTable().GetModel(), sqs.Resource(), queueUrl)
sqs.App().Flash().Info("Queue URL:" + queueUrl)
}
return nil
}