add multi-server functionality pt. 2 - delete server
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"log"
|
||||
"time"
|
||||
@@ -140,7 +141,7 @@ func (m *Controller) ConnectAlbumGridActions(grid *widgets.GridView) {
|
||||
}
|
||||
|
||||
func (m *Controller) PromptForFirstServer() {
|
||||
d := dialogs.NewAddEditServerDialog("Connect to Server", nil, m.MainWindow.Canvas().Focus)
|
||||
d := dialogs.NewAddEditServerDialog("Connect to Server", false, nil, m.MainWindow.Canvas().Focus)
|
||||
pop := widget.NewModalPopUp(d, m.MainWindow.Canvas())
|
||||
d.OnSubmit = func() {
|
||||
d.DisableSubmit()
|
||||
@@ -290,7 +291,7 @@ func (m *Controller) PromptForLoginAndConnect() {
|
||||
}
|
||||
d.OnEditServer = func(server *backend.ServerConfig) {
|
||||
pop.Hide()
|
||||
editD := dialogs.NewAddEditServerDialog("Edit server", server, m.MainWindow.Canvas().Focus)
|
||||
editD := dialogs.NewAddEditServerDialog("Edit server", true, server, m.MainWindow.Canvas().Focus)
|
||||
editPop := widget.NewModalPopUp(editD, m.MainWindow.Canvas())
|
||||
editD.OnSubmit = func() {
|
||||
d.DisableSubmit()
|
||||
@@ -309,16 +310,21 @@ func (m *Controller) PromptForLoginAndConnect() {
|
||||
d.EnableSubmit()
|
||||
}()
|
||||
}
|
||||
editD.OnCancel = func() {
|
||||
editPop.Hide()
|
||||
pop.Show()
|
||||
}
|
||||
editPop.Show()
|
||||
}
|
||||
d.OnNewServer = func() {
|
||||
pop.Hide()
|
||||
newD := dialogs.NewAddEditServerDialog("Add server", nil, m.MainWindow.Canvas().Focus)
|
||||
newD := dialogs.NewAddEditServerDialog("Add server", true, nil, m.MainWindow.Canvas().Focus)
|
||||
newPop := widget.NewModalPopUp(newD, m.MainWindow.Canvas())
|
||||
newD.OnSubmit = func() {
|
||||
d.DisableSubmit()
|
||||
go func() {
|
||||
if m.testConnectionAndUpdateDialogText(newD) {
|
||||
// connection is good
|
||||
newPop.Hide()
|
||||
conn := backend.ServerConnection{
|
||||
Hostname: newD.Host,
|
||||
@@ -333,8 +339,30 @@ func (m *Controller) PromptForLoginAndConnect() {
|
||||
d.EnableSubmit()
|
||||
}()
|
||||
}
|
||||
newD.OnCancel = func() {
|
||||
newPop.Hide()
|
||||
pop.Show()
|
||||
}
|
||||
newPop.Show()
|
||||
}
|
||||
d.OnDeleteServer = func(server *backend.ServerConfig) {
|
||||
pop.Hide()
|
||||
dialog.ShowConfirm("Confirm delete server",
|
||||
fmt.Sprintf("Are you sure you want to delete the server %q?", server.Nickname),
|
||||
func(ok bool) {
|
||||
if ok {
|
||||
m.App.Config.DeleteServer(server.ID)
|
||||
m.App.DeleteServerCacheDir(server.ID)
|
||||
d.SetServers(m.App.Config.Servers)
|
||||
}
|
||||
if len(m.App.Config.Servers) == 0 {
|
||||
m.PromptForFirstServer()
|
||||
} else {
|
||||
pop.Show()
|
||||
}
|
||||
}, m.MainWindow)
|
||||
|
||||
}
|
||||
m.haveModal = true
|
||||
pop.Show()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user