MCPcopy Create free account
hub / github.com/Xpl0itU/passiveMachine / ConfigureForm

Method ConfigureForm

pawnsapp.go:23–68  ·  view source on GitHub ↗
(form *tview.Form, frame *tview.Frame, app *tview.Application)

Source from the content-addressed store, hash-verified

21}
22
23func (i *PawnsAppConfig) ConfigureForm(form *tview.Form, frame *tview.Frame, app *tview.Application) {
24 email := ""
25 password := ""
26 deviceName := ""
27 isError := false
28 showingError := false
29 form.AddInputField("Device Name", i.DeviceName, 15, nil, func(text string) {
30 deviceName = text
31 })
32 form.AddInputField("Email", i.Email, 50, nil, func(text string) {
33 email = text
34 })
35 form.AddPasswordField("Password", i.Password, 20, '*', func(text string) {
36 password = text
37 })
38 form.AddButton("Save", func() {
39 isError = stringIsEmpty(email) || stringIsEmpty(password) || stringIsEmpty(deviceName)
40 if isError {
41 if !showingError {
42 form.AddTextView("Error", "All fields are required", 0, 1, true, true)
43 showingError = true
44 }
45 return
46 }
47 i.Email = email
48 i.Password = password
49 i.DeviceName = deviceName
50 i.Configured = true
51 returnToMenu(frame, app)
52 })
53 form.AddButton("Cancel", func() {
54 returnToMenu(frame, app)
55 })
56 form.AddButton("Register", func() {
57 modal := tview.NewModal().
58 SetText("Register on PawnsApp\n" + PAWNSAPP_REFERRAL_LINK).
59 AddButtons([]string{"Open", "Cancel"}).
60 SetDoneFunc(func(buttonIndex int, buttonLabel string) {
61 if buttonLabel == "Open" {
62 webbrowser.Open(PAWNSAPP_REFERRAL_LINK)
63 }
64 app.SetRoot(form, true)
65 })
66 app.SetRoot(modal, true)
67 })
68}
69
70func (i *PawnsAppConfig) ConfigureDocker(kind DockerConfigKind, form *tview.Form) (string, error) {
71 switch kind {

Callers

nothing calls this directly

Calls 2

stringIsEmptyFunction · 0.85
returnToMenuFunction · 0.85

Tested by

no test coverage detected