mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-07-22 15:18:02 +00:00
Zenity dialogs
This commit is contained in:
@ -3,6 +3,7 @@ package app
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/ncruces/zenity"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@ -14,15 +15,8 @@ func (a *App) RemoveItems(hostKey, dbKey, collKey, jsonData string, many bool) i
|
||||
jsonData = strings.TrimSpace(jsonData)
|
||||
|
||||
if len(jsonData) == 0 {
|
||||
sure, _ := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
|
||||
Title: "Confirm",
|
||||
Message: "Are you sure you want to drop all items in " + collKey + "?",
|
||||
Buttons: []string{"Yes", "No"},
|
||||
DefaultButton: "Yes",
|
||||
CancelButton: "No",
|
||||
Type: runtime.WarningDialog,
|
||||
})
|
||||
if sure != "Yes" {
|
||||
err := zenity.Question("Are you sure you want to drop all items in "+collKey+"?", zenity.Title("Confirm"), zenity.WarningIcon)
|
||||
if err == zenity.ErrCanceled {
|
||||
return 0
|
||||
}
|
||||
} else {
|
||||
@ -30,11 +24,7 @@ func (a *App) RemoveItems(hostKey, dbKey, collKey, jsonData string, many bool) i
|
||||
if err != nil {
|
||||
runtime.LogError(a.ctx, "Could not parse remove query:")
|
||||
runtime.LogError(a.ctx, err.Error())
|
||||
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
|
||||
Type: runtime.ErrorDialog,
|
||||
Title: "Couldn't parse JSON",
|
||||
Message: err.Error(),
|
||||
})
|
||||
zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@ -57,11 +47,7 @@ func (a *App) RemoveItems(hostKey, dbKey, collKey, jsonData string, many bool) i
|
||||
if err != nil {
|
||||
runtime.LogWarning(a.ctx, "Encountered an error while performing remove:")
|
||||
runtime.LogWarning(a.ctx, err.Error())
|
||||
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
|
||||
Type: runtime.ErrorDialog,
|
||||
Title: "Encountered an error while removing items",
|
||||
Message: err.Error(),
|
||||
})
|
||||
zenity.Info(err.Error(), zenity.Title("Error while performing remove"), zenity.ErrorIcon)
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -82,11 +68,8 @@ func (a *App) RemoveItemById(hostKey, dbKey, collKey, itemId string) bool {
|
||||
if err != nil && err != mongo.ErrNoDocuments {
|
||||
runtime.LogWarning(a.ctx, "Encountered an error while performing remove by id:")
|
||||
runtime.LogWarning(a.ctx, err.Error())
|
||||
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
|
||||
Type: runtime.ErrorDialog,
|
||||
Title: "Encountered an error while removing item" + itemId,
|
||||
Message: err.Error(),
|
||||
})
|
||||
zenity.Info(err.Error(), zenity.Title("Error while performing remove"), zenity.ErrorIcon)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user