MCPcopy Create free account
hub / github.com/Macmod/godap / openSearchBaseDNForm

Function openSearchBaseDNForm

tui/search.go:536–591  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

534}
535
536func openSearchBaseDNForm() {
537 currentFocus := app.GetFocus()
538
539 scopeOptions := []string{"WholeSubtree", "SingleLevel", "BaseObject"}
540 scopeValues := []int{ldap.ScopeWholeSubtree, ldap.ScopeSingleLevel, ldap.ScopeBaseObject}
541 currentScopeIdx := 0
542 for i, v := range scopeValues {
543 if v == searchScope {
544 currentScopeIdx = i
545 break
546 }
547 }
548
549 baseDNField := tview.NewInputField().
550 SetLabel("Base DN").
551 SetText(searchBaseDN)
552 assignInputFieldTheme(baseDNField)
553
554 attrsField := tview.NewInputField().
555 SetLabel("Attributes").
556 SetText(searchAttrsList)
557 assignInputFieldTheme(attrsField)
558
559 selectedScopeIdx := currentScopeIdx
560
561 form := NewXForm()
562 form.
563 AddFormItem(baseDNField).
564 AddDropDown("Scope", scopeOptions, currentScopeIdx, func(_ string, idx int) {
565 selectedScopeIdx = idx
566 }).
567 AddFormItem(attrsField).
568 AddButton("Go Back", func() {
569 app.SetRoot(appPanel, true).SetFocus(currentFocus)
570 }).
571 AddButton("Set", func() {
572 newAttrsList := attrsField.GetText()
573 warnAttrsList(newAttrsList, currentFocus, func() {
574 searchBaseDN = baseDNField.GetText()
575 searchScope = scopeValues[selectedScopeIdx]
576 searchAttrsList = newAttrsList
577 updateLog("Search settings updated. Rerun the search to get new results.", "green")
578 app.SetRoot(appPanel, true).SetFocus(currentFocus)
579 })
580 })
581
582 form.SetTitle("Search Settings").SetBorder(true)
583 form.SetInputCapture(handleEscape(currentFocus))
584
585 centeredForm := tview.NewGrid().
586 SetColumns(0, 60, 0).
587 SetRows(0, 11, 0).
588 AddItem(form, 1, 1, 1, 1, 0, 0, true)
589
590 app.SetRoot(centeredForm, true).SetFocus(form)
591}
592
593func searchPageKeyHandler(event *tcell.EventKey) *tcell.EventKey {

Callers 1

searchPageKeyHandlerFunction · 0.85

Calls 6

assignInputFieldThemeFunction · 0.85
NewXFormFunction · 0.85
warnAttrsListFunction · 0.85
updateLogFunction · 0.85
handleEscapeFunction · 0.85
AddDropDownMethod · 0.80

Tested by

no test coverage detected