Open service in browser

pull/252/head
Konstantin Mikhailov 3 years ago
parent c88fba546f
commit 6c27cf3f32

@ -42,6 +42,7 @@
<kbd>R</kbd>: zeige Neustartoptionen
<kbd>c</kbd>: führe vordefinierten benutzerdefinierten Befehl aus
<kbd>b</kbd>: view bulk commands
<kbd>w</kbd>: open in browser (first port is http)
<kbd>enter</kbd>: fokussieren aufs Hauptpanel
</pre>

@ -42,6 +42,7 @@
<kbd>R</kbd>: view restart options
<kbd>c</kbd>: run predefined custom command
<kbd>b</kbd>: view bulk commands
<kbd>w</kbd>: open in browser (first port is http)
<kbd>enter</kbd>: focus main panel
</pre>

@ -42,6 +42,7 @@
<kbd>R</kbd>: bekijk herstart opties
<kbd>c</kbd>: draai een vooraf bedacht aangepaste opdracht
<kbd>b</kbd>: view bulk commands
<kbd>w</kbd>: open in browser (first port is http)
<kbd>enter</kbd>: focus hoofdpaneel
</pre>

@ -42,6 +42,7 @@
<kbd>R</kbd>: pokaż opcje restartu
<kbd>c</kbd>: wykonaj predefiniowaną własną komende
<kbd>b</kbd>: view bulk commands
<kbd>w</kbd>: open in browser (first port is http)
<kbd>enter</kbd>: skup na głównym panelu
</pre>

@ -42,6 +42,7 @@
<kbd>R</kbd>: yeniden başlatma seçeneklerini görüntüle
<kbd>c</kbd>: önceden tanımlanmış özel komutu çalıştır
<kbd>b</kbd>: view bulk commands
<kbd>w</kbd>: open in browser (first port is http)
<kbd>enter</kbd>: ana panele odaklan
</pre>

@ -346,6 +346,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.handleServicesBulkCommand,
Description: gui.Tr.ViewBulkCommands,
},
{
ViewName: "services",
Key: 'w',
Modifier: gocui.ModNone,
Handler: gui.handleServicesOpenInBrowserCommand,
Description: gui.Tr.OpenInBrowser,
},
{
ViewName: "images",
Key: '[',

@ -409,3 +409,31 @@ func (gui *Gui) handleServicesBulkCommand(g *gocui.Gui, v *gocui.View) error {
return gui.createBulkCommandMenu(bulkCommands, commandObject)
}
func (gui *Gui) handleServicesOpenInBrowserCommand(g *gocui.Gui, v *gocui.View) error {
service, err := gui.getSelectedService()
if err != nil {
return nil
}
container := service.Container
if container == nil {
return gui.createErrorPanel(gui.g, gui.Tr.NoContainers)
}
// skip if no any ports
if len(container.Container.Ports) == 0 {
return nil
}
// skip if the first port is not published
port := container.Container.Ports[0]
if port.IP == "" {
return nil
}
ip := port.IP
if ip == "0.0.0.0" {
ip = "localhost"
}
link := fmt.Sprintf("http://%s:%d/", ip, port.PublicPort)
return gui.OSCommand.OpenLink(link)
}

Loading…
Cancel
Save