aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-04-17 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-04-17 20:20:20 +0200
commit6079c093aeb5e814767f5002dd628a842686cc23 (patch)
tree78776adea94d7bec131ecba730afb845ee3b829a
parentgreat (diff)
downloadhardflip-6079c093aeb5e814767f5002dd628a842686cc23.tar.gz
hardflip-6079c093aeb5e814767f5002dd628a842686cc23.tar.bz2
hardflip-6079c093aeb5e814767f5002dd628a842686cc23.tar.xz
hardflip-6079c093aeb5e814767f5002dd628a842686cc23.tar.zst
hardflip-6079c093aeb5e814767f5002dd628a842686cc23.zip
cool for now
-rw-r--r--src/c_defs.go10
-rw-r--r--src/c_hardflip.go1
-rw-r--r--src/c_lhosts.go6
-rw-r--r--src/i_events.go87
-rw-r--r--src/i_insert.go223
-rw-r--r--src/i_ui.go61
6 files changed, 250 insertions, 138 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index a1da14f..b621382 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -139,7 +139,17 @@ const (
INS_CMD_SILENT
INS_CMD_NOTE
INS_CMD_OK
+ INS_OS_HOST
+ INS_OS_USER
+ INS_OS_PASS
+ INS_OS_USERDOMAINID
+ INS_OS_PROJECTID
+ INS_OS_REGION
+ INS_OS_ENDTYPE
+ INS_OS_INTERFACE
+ INS_OS_IDAPI
// TODO: here
+ INS_OS_OK
)
var (
diff --git a/src/c_hardflip.go b/src/c_hardflip.go
index 7b88913..cf3f2de 100644
--- a/src/c_hardflip.go
+++ b/src/c_hardflip.go
@@ -59,6 +59,7 @@ type HardData struct {
opts HardOpts
folds map[*DirsNode]*ItemsList
data_dir string
+ home_dir string
load_err []error
insert_err []error
keys [][2]string
diff --git a/src/c_lhosts.go b/src/c_lhosts.go
index cb2279a..3510ee1 100644
--- a/src/c_lhosts.go
+++ b/src/c_lhosts.go
@@ -55,13 +55,13 @@ package main
type StackSettings struct {
UserDomainID string `yaml:"user_domain_id,omitempty"`
ProjectID string `yaml:"project_id,omitempty"`
+ RegionName string `yaml:"region_name,omitempty"`
+ EndpointType string `yaml:"endpoint_type,omitempty"`
+ Interface string `yaml:"interface,omitempty"`
IdentityAPI string `yaml:"identity_api_version,omitempty"`
ImageAPI string `yaml:"image_api_version,omitempty"`
NetworkAPI string `yaml:"network_api_version,omitempty"`
VolumeAPI string `yaml:"volume_api_version,omitempty"`
- RegionName string `yaml:"region_name,omitempty"`
- EndpointType string `yaml:"endpoint_type,omitempty"`
- Interface string `yaml:"interface,omitempty"`
}
type JumpSettings struct {
diff --git a/src/i_events.go b/src/i_events.go
index dc6d44f..b3fa6d5 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -351,7 +351,7 @@ func i_set_protocol_defaults(data *HardData, in *HostNode) {
in.Stack.VolumeAPI = "3.42"
in.Stack.EndpointType = "publicURL"
in.Stack.Interface = "public"
- data.ui.insert_sel_max = 2
+ data.ui.insert_sel_max = INS_OS_OK
}
}
@@ -585,6 +585,13 @@ func i_events(data *HardData) {
} else if data.insert.Protocol == PROTOCOL_CMD &&
data.ui.insert_sel == INS_PROTOCOL {
data.ui.insert_sel = INS_CMD_CMD
+ } else if data.insert.Protocol == PROTOCOL_OS &&
+ data.ui.insert_sel == INS_PROTOCOL {
+ data.ui.insert_sel = INS_OS_HOST
+ } else if data.insert.Protocol == PROTOCOL_SSH &&
+ data.ui.insert_sel == INS_SSH_JUMP_HOST &&
+ len(data.insert.Jump.Host) == 0 {
+ data.ui.insert_sel = INS_SSH_NOTE
} else if data.ui.insert_sel < data.ui.insert_sel_max {
data.ui.insert_sel += 1
}
@@ -596,6 +603,13 @@ func i_events(data *HardData) {
} else if data.insert.Protocol == PROTOCOL_CMD &&
data.ui.insert_sel == INS_CMD_CMD {
data.ui.insert_sel = INS_PROTOCOL
+ } else if data.insert.Protocol == PROTOCOL_OS &&
+ data.ui.insert_sel == INS_OS_HOST {
+ data.ui.insert_sel = INS_PROTOCOL
+ } else if data.insert.Protocol == PROTOCOL_SSH &&
+ data.ui.insert_sel == INS_SSH_NOTE &&
+ len(data.insert.Jump.Host) == 0 {
+ data.ui.insert_sel = INS_SSH_JUMP_HOST
} else if data.ui.insert_sel > INS_PROTOCOL {
data.ui.insert_sel -= 1
}
@@ -613,8 +627,18 @@ func i_events(data *HardData) {
event.Key() == tcell.KeyEnter {
data.ui.insert_sel_ok = true
switch data.ui.insert_sel {
+ case INS_SSH_OK,
+ INS_RDP_OK + len(data.insert.Drive),
+ INS_CMD_OK:
+ data.ui.insert_sel_ok = false
+ i_insert_check_ok(data, data.insert)
+ if data.insert_err != nil {
+ break
+ }
+ i_insert_host(data, data.insert)
case INS_SSH_HOST,
- INS_RDP_HOST:
+ INS_RDP_HOST,
+ INS_OS_HOST:
ui.buff = data.insert.Host
case INS_SSH_PORT,
INS_RDP_PORT:
@@ -622,10 +646,12 @@ func i_events(data *HardData) {
ui.buff = strconv.Itoa(int(data.insert.Port))
}
case INS_SSH_USER,
- INS_RDP_USER:
+ INS_RDP_USER,
+ INS_OS_USER:
ui.buff = data.insert.User
case INS_SSH_PASS,
- INS_RDP_PASS:
+ INS_RDP_PASS,
+ INS_OS_PASS:
break
case INS_SSH_PRIV: ui.buff = data.insert.Priv
case INS_SSH_JUMP_HOST: ui.buff = data.insert.Jump.Host
@@ -660,19 +686,22 @@ func i_events(data *HardData) {
data.insert.Silent = true
}
break
+ case INS_OS_USERDOMAINID:
+ ui.buff = data.insert.Stack.UserDomainID
+ case INS_OS_PROJECTID:
+ ui.buff = data.insert.Stack.ProjectID
+ case INS_OS_REGION:
+ ui.buff = data.insert.Stack.RegionName
+ case INS_OS_ENDTYPE:
+ ui.buff = data.insert.Stack.EndpointType
+ case INS_OS_INTERFACE:
+ ui.buff = data.insert.Stack.Interface
+ case INS_OS_IDAPI:
+ ui.buff = data.insert.Stack.IdentityAPI
case INS_SSH_NOTE,
INS_RDP_NOTE + len(data.insert.Drive),
INS_CMD_NOTE:
ui.buff = data.insert.Note
- case INS_SSH_OK,
- INS_RDP_OK + len(data.insert.Drive),
- INS_CMD_OK:
- data.ui.insert_sel_ok = false
- i_insert_check_ok(data, data.insert)
- if data.insert_err != nil {
- break
- }
- i_insert_host(data, data.insert)
}
}
} else {
@@ -808,21 +837,33 @@ func i_events(data *HardData) {
INS_RDP_NOTE + len(data.insert.Drive),
INS_CMD_CMD,
INS_CMD_SHELL,
- INS_CMD_NOTE:
+ INS_CMD_NOTE,
+ INS_OS_HOST,
+ INS_OS_USER,
+ INS_OS_PASS,
+ INS_OS_USERDOMAINID,
+ INS_OS_PROJECTID,
+ INS_OS_REGION,
+ INS_OS_ENDTYPE,
+ INS_OS_INTERFACE,
+ INS_OS_IDAPI:
if event.Key() == tcell.KeyEnter {
switch data.ui.insert_sel {
case INS_SSH_HOST,
- INS_RDP_HOST:
+ INS_RDP_HOST,
+ INS_OS_HOST:
data.insert.Host = ui.buff
case INS_SSH_PORT,
INS_RDP_PORT:
tmp, _ := strconv.Atoi(ui.buff)
data.insert.Port = uint16(tmp)
case INS_SSH_USER,
- INS_RDP_USER:
+ INS_RDP_USER,
+ INS_OS_USER:
data.insert.User = ui.buff
case INS_SSH_PASS,
- INS_RDP_PASS:
+ INS_RDP_PASS,
+ INS_OS_PASS:
data.insert.Pass, _ = c_encrypt_str(ui.buff,
data.opts.GPG)
case INS_SSH_PRIV: data.insert.Priv = ui.buff
@@ -851,6 +892,18 @@ func i_events(data *HardData) {
data.insert.Host = ui.buff
case INS_CMD_SHELL:
data.insert.Shell[0] = ui.buff
+ case INS_OS_USERDOMAINID:
+ data.insert.Stack.UserDomainID = ui.buff
+ case INS_OS_PROJECTID:
+ data.insert.Stack.ProjectID = ui.buff
+ case INS_OS_REGION:
+ data.insert.Stack.RegionName = ui.buff
+ case INS_OS_ENDTYPE:
+ data.insert.Stack.EndpointType = ui.buff
+ case INS_OS_INTERFACE:
+ data.insert.Stack.Interface = ui.buff
+ case INS_OS_IDAPI:
+ data.insert.Stack.IdentityAPI = ui.buff
case INS_SSH_NOTE,
INS_RDP_NOTE + len(data.insert.Drive),
INS_CMD_NOTE:
diff --git a/src/i_insert.go b/src/i_insert.go
index 354bc71..0565c4c 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -43,7 +43,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* hardflip: src/i_insert.go
- * Tue Apr 16 17:11:12 2024
+ * Wed Apr 17 14:00:27 2024
* Joe
*
* insert a new host
@@ -86,7 +86,7 @@ func i_insert_format_filename(name, path string) string {
return str
}
-func i_insert_abs_files(insert *HostNode) {
+func i_insert_abs_files(insert *HostNode, home_dir string) {
files := []*string{
&insert.Priv,
&insert.Jump.Priv,
@@ -96,10 +96,6 @@ func i_insert_abs_files(insert *HostNode) {
for _, v := range files {
if len(*v) > 0 {
if (*v)[0] == '~' {
- home_dir, err := os.UserHomeDir()
- if err != nil {
- return
- }
*v = home_dir + (*v)[1:]
}
*v, _ = filepath.Abs(*v)
@@ -108,10 +104,6 @@ func i_insert_abs_files(insert *HostNode) {
for k, v := range insert.Drive {
if len(v) > 0 {
if (v)[0] == '~' {
- home_dir, err := os.UserHomeDir()
- if err != nil {
- return
- }
v = home_dir + (v)[1:]
}
v, _ = filepath.Abs(v)
@@ -135,7 +127,7 @@ func i_insert_default_users(insert *HostNode) {
}
func i_insert_host(data *HardData, insert *HostNode) {
- i_insert_abs_files(insert)
+ i_insert_abs_files(insert, data.home_dir)
i_insert_default_users(insert)
if len(insert.Drive) == 0 {
insert.Drive = nil
@@ -222,11 +214,7 @@ func i_insert_check_ok(data *HardData, in *HostNode) {
for _, v := range file {
if len(v) > 0 {
if v[0] == '~' {
- home_dir, err := os.UserHomeDir()
- if err != nil {
- return
- }
- v = home_dir + v[1:]
+ v = data.home_dir + v[1:]
}
if stat, err := os.Stat(v);
err != nil {
@@ -240,11 +228,7 @@ func i_insert_check_ok(data *HardData, in *HostNode) {
}
for _, v := range in.Drive {
if v[0] == '~' {
- home_dir, err := os.UserHomeDir()
- if err != nil {
- return
- }
- v = home_dir + v[1:]
+ v = data.home_dir + v[1:]
}
if stat, err := os.Stat(v);
err != nil {
@@ -291,7 +275,8 @@ func i_draw_text_box(ui HardUI, line int, dim Quad, label, content string,
if l <= dim.L { l = dim.L + 1 }
i_draw_text(ui.s, l, line, ui.dim[W] / 2, line,
ui.style[DEF_STYLE], label)
- if (id == INS_SSH_PASS || id == INS_SSH_JUMP_PASS || id == INS_RDP_PASS) &&
+ if (id == INS_SSH_PASS || id == INS_SSH_JUMP_PASS ||
+ id == INS_RDP_PASS || id == INS_OS_PASS) &&
len(content) > 0 {
content = "***"
}
@@ -330,8 +315,86 @@ func i_draw_ok_butt(ui HardUI, line int, id, selected int) {
(ui.dim[W] / 2) + (butt_size / 2), line, style, buff)
}
-func i_draw_insert_panel(ui HardUI, in *HostNode) {
- type draw_insert_func func(ui HardUI, line int, win Quad, in *HostNode) int
+func i_draw_insert_inputs(ui HardUI, in *HostNode, home_dir string) {
+ if ui.insert_sel_ok == false {
+ return
+ }
+ switch ui.insert_sel {
+ case INS_PROTOCOL:
+ i_prompt_list(ui, "Connection type", "Type:",
+ PROTOCOL_STR[:])
+ case INS_SSH_HOST,
+ INS_SSH_JUMP_HOST,
+ INS_RDP_HOST:
+ i_prompt_generic(ui, "Host/IP: ", false, "")
+ case INS_SSH_PORT,
+ INS_SSH_JUMP_PORT,
+ INS_RDP_PORT:
+ i_prompt_generic(ui, "Port: ", false, "")
+ case INS_SSH_USER,
+ INS_SSH_JUMP_USER,
+ INS_RDP_USER,
+ INS_OS_USER:
+ i_prompt_generic(ui, "User: ", false, "")
+ case INS_SSH_PASS,
+ INS_SSH_JUMP_PASS,
+ INS_RDP_PASS,
+ INS_OS_PASS:
+ i_prompt_generic(ui, "Pass: ", true, "")
+ case INS_SSH_PRIV,
+ INS_SSH_JUMP_PRIV:
+ i_prompt_generic(ui, "Private key: ",
+ false, home_dir)
+ case INS_SSH_NOTE,
+ INS_RDP_NOTE + len(in.Drive),
+ INS_CMD_NOTE:
+ i_prompt_generic(ui, "Note: ", false, "")
+ case INS_RDP_DOMAIN:
+ i_prompt_generic(ui, "Domain: ", false, "")
+ case INS_RDP_FILE:
+ i_prompt_generic(ui, "RDP file: ", false, home_dir)
+ case INS_RDP_SCREENSIZE:
+ i_prompt_list(ui, "Window size", "Size:",
+ RDP_SCREENSIZE[:])
+ case INS_RDP_QUALITY:
+ i_prompt_list(ui, "Quality", "Quality:",
+ RDP_QUALITY[:])
+ case INS_RDP_DRIVE + len(in.Drive):
+ if len(ui.drives_buff) == 0 {
+ i_prompt_generic(ui, "Name: ", false, "")
+ } else {
+ i_prompt_dir(ui, "Local directory: ", home_dir)
+ }
+ case INS_CMD_CMD:
+ i_prompt_generic(ui, "Command: ", false, "")
+ case INS_CMD_SHELL:
+ i_prompt_generic(ui, "Shell: ", false, home_dir)
+ case INS_OS_HOST:
+ i_prompt_generic(ui, "Endpoint: ", false, "")
+ case INS_OS_USERDOMAINID:
+ i_prompt_generic(ui, "UserDomainID: ", false, "")
+ case INS_OS_PROJECTID:
+ i_prompt_generic(ui, "ProjectID: ", false, "")
+ case INS_OS_REGION:
+ i_prompt_generic(ui, "Region name: ", false, "")
+ case INS_OS_ENDTYPE:
+ i_prompt_generic(ui, "Endpoint type: ", false, "")
+ case INS_OS_INTERFACE:
+ i_prompt_generic(ui, "Interface: ", false, "")
+ case INS_OS_IDAPI:
+ i_prompt_generic(ui, "Identity API version: ", false, "")
+ }
+ if len(in.Drive) > 0 &&
+ ui.insert_sel >= INS_RDP_DRIVE &&
+ ui.insert_sel < INS_RDP_DRIVE +
+ len(in.Drive) {
+ i_draw_remove_share(ui)
+ }
+}
+
+func i_draw_insert_panel(ui HardUI, in *HostNode, home_dir string) {
+ type draw_insert_func func(ui HardUI, line int, win Quad,
+ in *HostNode, home string) int
if len(in.Name) == 0 {
return
@@ -357,14 +420,16 @@ func i_draw_insert_panel(ui HardUI, in *HostNode) {
i_draw_insert_cmd,
i_draw_insert_os,
}
- end_line = fp[in.Protocol](ui, line, win, in)
+ end_line = fp[in.Protocol](ui, line, win, in, home_dir)
if win.T + end_line >= win.B {
ui.s.SetContent(ui.dim[W] / 2, win.B, '▼', nil, ui.style[BOX_STYLE])
// TODO: scroll or something
}
+ i_draw_insert_inputs(ui, in, home_dir)
}
-func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) int {
+func i_draw_insert_ssh(ui HardUI, line int, win Quad,
+ in *HostNode, home string) int {
red := false
if win.T + line >= win.B { return line }
text := "---- Host settings ----"
@@ -385,7 +450,6 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) int {
if line += 1; win.T + line >= win.B { return line }
if file := in.Priv; len(file) > 0 {
if file[0] == '~' {
- home, _ := os.UserHomeDir()
file = home + file[1:]
}
if stat, err := os.Stat(file);
@@ -409,36 +473,37 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) int {
if line += 2; win.T + line >= win.B { return line }
i_draw_text_box(ui, win.T + line, win, "Host/IP", in.Jump.Host,
INS_SSH_JUMP_HOST, false)
- if line += 1; win.T + line >= win.B { return line }
- i_draw_text_box(ui, win.T + line, win, "Port",
- strconv.Itoa(int(in.Jump.Port)),
- INS_SSH_JUMP_PORT, false)
- if line += 2; win.T + line >= win.B { return line }
- i_draw_text_box(ui, win.T + line, win, "User", in.Jump.User,
- INS_SSH_JUMP_USER, false)
- if line += 1; win.T + line >= win.B { return line }
- i_draw_text_box(ui, win.T + line, win, "Pass", in.Jump.Pass,
- INS_SSH_JUMP_PASS, false)
- if line += 1; win.T + line >= win.B { return line}
- if len(in.Jump.Priv) > 0 {
- file := in.Jump.Priv
- if file[0] == '~' {
- home, _ := os.UserHomeDir()
- file = home + file[1:]
+ if len(in.Jump.Host) > 0 {
+ if line += 1; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Port",
+ strconv.Itoa(int(in.Jump.Port)),
+ INS_SSH_JUMP_PORT, false)
+ if line += 2; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "User", in.Jump.User,
+ INS_SSH_JUMP_USER, false)
+ if line += 1; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Pass", in.Jump.Pass,
+ INS_SSH_JUMP_PASS, false)
+ if line += 1; win.T + line >= win.B { return line}
+ if len(in.Jump.Priv) > 0 {
+ file := in.Jump.Priv
+ if file[0] == '~' {
+ file = home + file[1:]
+ }
+ if stat, err := os.Stat(file);
+ err != nil || stat.IsDir() == true {
+ red = true
+ }
}
- if stat, err := os.Stat(file);
- err != nil || stat.IsDir() == true {
- red = true
+ i_draw_text_box(ui, win.T + line, win, "SSH private key", in.Jump.Priv,
+ INS_SSH_JUMP_PRIV, red)
+ if red == true {
+ if line += 1; win.T + line >= win.B { return line }
+ text := "file does not exist"
+ i_draw_text(ui.s, ui.dim[W] / 2, win.T + line,
+ win.R - 1, win.T + line, ui.style[ERR_STYLE], text)
}
}
- i_draw_text_box(ui, win.T + line, win, "SSH private key", in.Jump.Priv,
- INS_SSH_JUMP_PRIV, red)
- if red == true {
- if line += 1; win.T + line >= win.B { return line }
- text := "file does not exist"
- i_draw_text(ui.s, ui.dim[W] / 2, win.T + line,
- win.R - 1, win.T + line, ui.style[ERR_STYLE], text)
- }
if line += 2; win.T + line >= win.B { return line }
text = "---- Note ----"
i_draw_text(ui.s, ui.dim[W] / 2 - len(text) / 2, win.T + line, win.R - 1,
@@ -451,7 +516,8 @@ func i_draw_insert_ssh(ui HardUI, line int, win Quad, in *HostNode) int {
return line
}
-func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
+func i_draw_insert_rdp(ui HardUI, line int, win Quad,
+ in *HostNode, home string) int {
red := false
if win.T + line >= win.B { return line }
text := "---- Host settings ----"
@@ -479,7 +545,6 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
if line += 2; win.T + line >= win.B { return line }
if file := in.RDPFile; len(file) > 0 {
if file[0] == '~' {
- home, _ := os.UserHomeDir()
file = home + file[1:]
}
if stat, err := os.Stat(file);
@@ -520,7 +585,6 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
red = false
if dir := in.Drive[v]; len(dir) > 0 {
if dir[0] == '~' {
- home, _ := os.UserHomeDir()
dir = home + dir[1:]
}
if stat, err := os.Stat(dir);
@@ -553,7 +617,8 @@ func i_draw_insert_rdp(ui HardUI, line int, win Quad, in *HostNode) int {
return line
}
-func i_draw_insert_cmd(ui HardUI, line int, win Quad, in *HostNode) int {
+func i_draw_insert_cmd(ui HardUI, line int, win Quad,
+ in *HostNode, home string) int {
red := false
if win.T + line >= win.B { return line }
text := "---- Settings ----"
@@ -565,7 +630,6 @@ func i_draw_insert_cmd(ui HardUI, line int, win Quad, in *HostNode) int {
if line += 1; win.T + line >= win.B { return line }
if shell := in.Shell[0]; len(shell) > 0 {
if shell[0] == '~' {
- home, _ := os.UserHomeDir()
shell = home + shell[1:]
}
if stat, err := os.Stat(shell);
@@ -597,6 +661,45 @@ func i_draw_insert_cmd(ui HardUI, line int, win Quad, in *HostNode) int {
return line
}
-func i_draw_insert_os(ui HardUI, line int, win Quad, in *HostNode) int {
+func i_draw_insert_os(ui HardUI, line int, win Quad,
+ in *HostNode, home string) int {
+ if win.T + line >= win.B { return line }
+ text := "---- Host settings ----"
+ i_draw_text(ui.s, ui.dim[W] / 2 - len(text) / 2, win.T + line, win.R - 1,
+ win.T + line, ui.style[DEF_STYLE], text)
+ if line += 2; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Endpoint", in.Host,
+ INS_OS_HOST, false)
+ if line += 2; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "User", in.User,
+ INS_OS_USER, false)
+ if line += 1; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Pass", in.Pass,
+ INS_OS_PASS, false)
+ if line += 2; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "User domain ID",
+ in.Stack.UserDomainID,
+ INS_OS_USERDOMAINID, false)
+ if line += 1; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Project ID", in.Stack.ProjectID,
+ INS_OS_PROJECTID, false)
+ if line += 1; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Region name", in.Stack.RegionName,
+ INS_OS_REGION, false)
+ if line += 2; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Endpoint type",
+ in.Stack.EndpointType,
+ INS_OS_ENDTYPE, false)
+ if line += 1; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Interface", in.Stack.Interface,
+ INS_OS_INTERFACE, false)
+ if line += 2; win.T + line >= win.B { return line }
+ text = "---- API settings ----"
+ i_draw_text(ui.s, ui.dim[W] / 2 - len(text) / 2, win.T + line, win.R - 1,
+ win.T + line, ui.style[DEF_STYLE], text)
+ if line += 2; win.T + line >= win.B { return line }
+ i_draw_text_box(ui, win.T + line, win, "Identity API version",
+ in.Stack.IdentityAPI,
+ INS_OS_IDAPI, false)
return line
}
diff --git a/src/i_ui.go b/src/i_ui.go
index e5800bf..2565f32 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -673,6 +673,7 @@ func i_ui(data_dir string) {
opts,
make(map[*DirsNode]*ItemsList),
data_dir,
+ home_dir,
load_err,
nil,
[][2]string{},
@@ -711,64 +712,8 @@ func i_ui(data_dir string) {
if data.insert == nil {
i_prompt_insert(data.ui, data.litems.curr)
} else {
- i_draw_insert_panel(data.ui, data.insert)
- if data.ui.insert_sel_ok == true {
- switch data.ui.insert_sel {
- case INS_PROTOCOL:
- i_prompt_list(data.ui, "Connection type", "Type:",
- PROTOCOL_STR[:])
- case INS_SSH_HOST,
- INS_SSH_JUMP_HOST,
- INS_RDP_HOST:
- i_prompt_generic(data.ui, "Host/IP: ", false, "")
- case INS_SSH_PORT,
- INS_SSH_JUMP_PORT,
- INS_RDP_PORT:
- i_prompt_generic(data.ui, "Port: ", false, "")
- case INS_SSH_USER,
- INS_SSH_JUMP_USER,
- INS_RDP_USER:
- i_prompt_generic(data.ui, "User: ", false, "")
- case INS_SSH_PASS,
- INS_SSH_JUMP_PASS,
- INS_RDP_PASS:
- i_prompt_generic(data.ui, "Pass: ", true, "")
- case INS_SSH_PRIV,
- INS_SSH_JUMP_PRIV:
- i_prompt_generic(data.ui, "Private key: ",
- false, home_dir)
- case INS_SSH_NOTE,
- INS_RDP_NOTE + len(data.insert.Drive),
- INS_CMD_NOTE:
- i_prompt_generic(data.ui, "Note: ", false, "")
- case INS_RDP_DOMAIN:
- i_prompt_generic(data.ui, "Domain: ", false, "")
- case INS_RDP_FILE:
- i_prompt_generic(data.ui, "RDP file: ", false, home_dir)
- case INS_RDP_SCREENSIZE:
- i_prompt_list(data.ui, "Window size", "Size:",
- RDP_SCREENSIZE[:])
- case INS_RDP_QUALITY:
- i_prompt_list(data.ui, "Quality", "Quality:",
- RDP_QUALITY[:])
- case INS_RDP_DRIVE + len(data.insert.Drive):
- if len(data.ui.drives_buff) == 0 {
- i_prompt_generic(data.ui, "Name: ", false, "")
- } else {
- i_prompt_dir(data.ui, "Local directory: ", home_dir)
- }
- case INS_CMD_CMD:
- i_prompt_generic(data.ui, "Command: ", false, "")
- case INS_CMD_SHELL:
- i_prompt_generic(data.ui, "Shell: ", false, home_dir)
- }
- if len(data.insert.Drive) > 0 &&
- data.ui.insert_sel >= INS_RDP_DRIVE &&
- data.ui.insert_sel < INS_RDP_DRIVE +
- len(data.insert.Drive) {
- i_draw_remove_share(data.ui)
- }
- } else if data.insert_err != nil {
+ i_draw_insert_panel(data.ui, data.insert, data.home_dir)
+ if data.insert_err != nil {
i_draw_insert_err_msg(data.ui, data.insert_err)
}
}