1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Correct use of zenity methods

This commit is contained in:
Romein van Buren 2023-02-21 17:27:44 +01:00
parent 1f76b16e75
commit 5b1f410a50
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
15 changed files with 64 additions and 64 deletions

View File

@ -97,7 +97,7 @@ func (a *App) PurgeLogDirectory() {
if err == nil { if err == nil {
zenity.Info("Successfully purged log directory.", zenity.InfoIcon) zenity.Info("Successfully purged log directory.", zenity.InfoIcon)
} else { } else {
zenity.Info(err.Error(), zenity.Title("Encountered an error while purging log directory."), zenity.WarningIcon) zenity.Error(err.Error(), zenity.Title("Encountered an error while purging log directory."), zenity.WarningIcon)
} }
} }
@ -173,7 +173,7 @@ func (a *App) EnterText(title, info, defaultEntry string) string {
if err == zenity.ErrCanceled { if err == zenity.ErrCanceled {
return "" return ""
} else if err != nil { } else if err != nil {
zenity.Info(err.Error(), zenity.Title("Encountered an error!"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Encountered an error!"), zenity.ErrorIcon)
return "" return ""
} else { } else {
return input return input

View File

@ -47,7 +47,7 @@ func (a *App) Settings() Settings {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Cannot unmarshal settings.json:") runtime.LogWarning(a.ctx, "Cannot unmarshal settings.json:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info("Could not retrieve application settings, using defaults!", zenity.Title("Information"), zenity.WarningIcon) zenity.Warning("Could not retrieve application settings, using defaults!", zenity.WarningIcon)
} }
return s return s
} }
@ -59,7 +59,7 @@ func (a *App) UpdateSettings(jsonData string) Settings {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Malformed JSON for settings file:") runtime.LogError(a.ctx, "Malformed JSON for settings file:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon)
return s return s
} }
@ -67,7 +67,7 @@ func (a *App) UpdateSettings(jsonData string) Settings {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not marshal settings into JSON:") runtime.LogError(a.ctx, "Could not marshal settings into JSON:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon)
return s return s
} }
@ -76,7 +76,7 @@ func (a *App) UpdateSettings(jsonData string) Settings {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not update host list:") runtime.LogError(a.ctx, "Could not update host list:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Could not update host list"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not update host list"), zenity.ErrorIcon)
} }
return s return s

View File

@ -19,7 +19,7 @@ func (a *App) OpenCollection(hostKey, dbKey, collKey string) (result bson.M) {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not retrieve collection stats for "+collKey) runtime.LogWarning(a.ctx, "Could not retrieve collection stats for "+collKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Could not get stats"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not get stats"), zenity.ErrorIcon)
return nil return nil
} }
@ -42,7 +42,7 @@ func (a *App) RenameCollection(hostKey, dbKey, collKey, newCollKey string) bool
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not rename collection "+collKey) runtime.LogWarning(a.ctx, "Could not rename collection "+collKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while renaming collection"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while renaming collection"), zenity.ErrorIcon)
return false return false
} }
@ -65,7 +65,7 @@ func (a *App) TruncateCollection(hostKey, dbKey, collKey string) bool {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not truncate collection "+collKey) runtime.LogWarning(a.ctx, "Could not truncate collection "+collKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while truncating collection"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while truncating collection"), zenity.ErrorIcon)
return false return false
} }
@ -88,7 +88,7 @@ func (a *App) DropCollection(hostKey, dbKey, collKey string) bool {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not drop collection "+collKey) runtime.LogWarning(a.ctx, "Could not drop collection "+collKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while dropping collection"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while dropping collection"), zenity.ErrorIcon)
return false return false
} }

View File

@ -16,7 +16,7 @@ func (a *App) Aggregate(hostKey, dbKey, collKey, pipelineJson, settingsJson stri
if err := json.Unmarshal([]byte(settingsJson), &settings); err != nil { if err := json.Unmarshal([]byte(settingsJson), &settings); err != nil {
runtime.LogError(a.ctx, "Could not parse aggregation settings:") runtime.LogError(a.ctx, "Could not parse aggregation settings:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Couldn't parse aggregation settings"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Couldn't parse aggregation settings"), zenity.ErrorIcon)
return return
} }
@ -24,7 +24,7 @@ func (a *App) Aggregate(hostKey, dbKey, collKey, pipelineJson, settingsJson stri
if err := bson.UnmarshalExtJSON([]byte(pipelineJson), true, &pipeline); err != nil { if err := bson.UnmarshalExtJSON([]byte(pipelineJson), true, &pipeline); err != nil {
runtime.LogWarning(a.ctx, "Could not parse aggregation pipeline:") runtime.LogWarning(a.ctx, "Could not parse aggregation pipeline:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Couldn't parse aggregation pipeline"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Couldn't parse aggregation pipeline"), zenity.ErrorIcon)
return return
} }
@ -39,7 +39,7 @@ func (a *App) Aggregate(hostKey, dbKey, collKey, pipelineJson, settingsJson stri
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not get aggregation cursor:") runtime.LogWarning(a.ctx, "Could not get aggregation cursor:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Couldn't get aggregation cursor"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Couldn't get aggregation cursor"), zenity.ErrorIcon)
return return
} }
@ -47,7 +47,7 @@ func (a *App) Aggregate(hostKey, dbKey, collKey, pipelineJson, settingsJson stri
if err := cursor.All(ctx, &results); err != nil { if err := cursor.All(ctx, &results); err != nil {
runtime.LogInfo(a.ctx, "Error while running aggregation pipeline:") runtime.LogInfo(a.ctx, "Error while running aggregation pipeline:")
runtime.LogInfo(a.ctx, err.Error()) runtime.LogInfo(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while running aggregation pipeline"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while running aggregation pipeline"), zenity.ErrorIcon)
return return
} }

View File

@ -30,7 +30,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse find form:") runtime.LogError(a.ctx, "Could not parse find form:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Could not parse form"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not parse form"), zenity.ErrorIcon)
return out return out
} }
@ -48,7 +48,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogInfo(a.ctx, "Invalid find query:") runtime.LogInfo(a.ctx, "Invalid find query:")
runtime.LogInfo(a.ctx, err.Error()) runtime.LogInfo(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Invalid query"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Invalid query"), zenity.ErrorIcon)
return out return out
} }
@ -56,7 +56,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogInfo(a.ctx, "Invalid find projection:") runtime.LogInfo(a.ctx, "Invalid find projection:")
runtime.LogInfo(a.ctx, err.Error()) runtime.LogInfo(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Invalid projection"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Invalid projection"), zenity.ErrorIcon)
return out return out
} }
@ -64,7 +64,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogInfo(a.ctx, "Invalid find sort:") runtime.LogInfo(a.ctx, "Invalid find sort:")
runtime.LogInfo(a.ctx, err.Error()) runtime.LogInfo(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Invalid sort"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Invalid sort"), zenity.ErrorIcon)
return out return out
} }
@ -79,7 +79,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while counting documents:") runtime.LogWarning(a.ctx, "Encountered an error while counting documents:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while counting docs"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while counting docs"), zenity.ErrorIcon)
return out return out
} }
@ -87,7 +87,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while performing query:") runtime.LogWarning(a.ctx, "Encountered an error while performing query:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while querying"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while querying"), zenity.ErrorIcon)
return out return out
} }
@ -98,7 +98,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while performing query:") runtime.LogWarning(a.ctx, "Encountered an error while performing query:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while querying"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while querying"), zenity.ErrorIcon)
return out return out
} }
@ -109,7 +109,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Failed to marshal find BSON:") runtime.LogError(a.ctx, "Failed to marshal find BSON:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Failed to marshal JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Failed to marshal JSON"), zenity.ErrorIcon)
return out return out
} }
out.Results = append(out.Results, string(marshalled)) out.Results = append(out.Results, string(marshalled))

View File

@ -64,7 +64,7 @@ func (a *App) SaveQuery(jsonData string) string {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Add query: malformed form") runtime.LogError(a.ctx, "Add query: malformed form")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon)
return "" return ""
} }
@ -72,7 +72,7 @@ func (a *App) SaveQuery(jsonData string) string {
queries[query.Name] = query queries[query.Name] = query
err = updateQueryFile(a, queries) err = updateQueryFile(a, queries)
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Could not update query list"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not update query list"), zenity.ErrorIcon)
return "" return ""
} }
@ -83,7 +83,7 @@ func (a *App) RemoveQuery(queryName string) {
queries := a.SavedQueries() queries := a.SavedQueries()
delete(queries, queryName) delete(queries, queryName)
if err := updateQueryFile(a, queries); err != nil { if err := updateQueryFile(a, queries); err != nil {
zenity.Info(err.Error(), zenity.Title("Could not update query list"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not update query list"), zenity.ErrorIcon)
} }
} }
@ -93,13 +93,13 @@ func (a *App) UpdateQueries(jsonData string) bool {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Update queries: malformed form") runtime.LogError(a.ctx, "Update queries: malformed form")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon)
return false return false
} }
err = updateQueryFile(a, queries) err = updateQueryFile(a, queries)
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Could not save queries"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not save queries"), zenity.ErrorIcon)
return false return false
} }

View File

@ -22,7 +22,7 @@ func (a *App) GetIndexes(hostKey, dbKey, collKey string) []bson.M {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while creating index cursor:") runtime.LogWarning(a.ctx, "Encountered an error while creating index cursor:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while creating cursor"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while creating cursor"), zenity.ErrorIcon)
return nil return nil
} }
@ -31,7 +31,7 @@ func (a *App) GetIndexes(hostKey, dbKey, collKey string) []bson.M {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while executing index cursor:") runtime.LogWarning(a.ctx, "Encountered an error while executing index cursor:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while running cursor"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while running cursor"), zenity.ErrorIcon)
return nil return nil
} }
@ -63,7 +63,7 @@ func (a *App) CreateIndex(hostKey, dbKey, collKey, jsonData string) string {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse index JSON:") runtime.LogError(a.ctx, "Could not parse index JSON:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
return "" return ""
} }
@ -93,7 +93,7 @@ func (a *App) CreateIndex(hostKey, dbKey, collKey, jsonData string) string {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while creating index:") runtime.LogWarning(a.ctx, "Encountered an error while creating index:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while creating index"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while creating index"), zenity.ErrorIcon)
return "" return ""
} }
@ -111,7 +111,7 @@ func (a *App) DropIndex(hostKey, dbKey, collKey, indexName string) bool {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Encountered an error while creating index drop cursor:") runtime.LogError(a.ctx, "Encountered an error while creating index drop cursor:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while creating drop cursor"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while creating drop cursor"), zenity.ErrorIcon)
return false return false
} }

View File

@ -20,7 +20,7 @@ func (a *App) InsertItems(hostKey, dbKey, collKey, jsonData string) interface{}
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse insert JSON:") runtime.LogError(a.ctx, "Could not parse insert JSON:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
return nil return nil
} }
@ -34,7 +34,7 @@ func (a *App) InsertItems(hostKey, dbKey, collKey, jsonData string) interface{}
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while performing insert:") runtime.LogWarning(a.ctx, "Encountered an error while performing insert:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while performing insert"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while performing insert"), zenity.ErrorIcon)
return nil return nil
} }

View File

@ -24,7 +24,7 @@ func (a *App) RemoveItems(hostKey, dbKey, collKey, jsonData string, many bool) i
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse remove query:") runtime.LogError(a.ctx, "Could not parse remove query:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
return 0 return 0
} }
} }
@ -47,7 +47,7 @@ func (a *App) RemoveItems(hostKey, dbKey, collKey, jsonData string, many bool) i
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while performing remove:") runtime.LogWarning(a.ctx, "Encountered an error while performing remove:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while performing remove"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while performing remove"), zenity.ErrorIcon)
return 0 return 0
} }
@ -68,7 +68,7 @@ func (a *App) RemoveItemById(hostKey, dbKey, collKey, itemId string) bool {
if err != nil && err != mongo.ErrNoDocuments { if err != nil && err != mongo.ErrNoDocuments {
runtime.LogWarning(a.ctx, "Encountered an error while performing remove by id:") runtime.LogWarning(a.ctx, "Encountered an error while performing remove by id:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while performing remove"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while performing remove"), zenity.ErrorIcon)
return false return false
} }

View File

@ -26,7 +26,7 @@ func (a *App) UpdateItems(hostKey, dbKey, collKey string, formJson string) int64
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse update form:") runtime.LogError(a.ctx, "Could not parse update form:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Could not parse form"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not parse form"), zenity.ErrorIcon)
return 0 return 0
} }
@ -44,7 +44,7 @@ func (a *App) UpdateItems(hostKey, dbKey, collKey string, formJson string) int64
runtime.LogWarning(a.ctx, "Invalid update query:") runtime.LogWarning(a.ctx, "Invalid update query:")
runtime.LogWarning(a.ctx, form.Query) runtime.LogWarning(a.ctx, form.Query)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Invalid update query"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Invalid update query"), zenity.ErrorIcon)
return 0 return 0
} }
@ -57,7 +57,7 @@ func (a *App) UpdateItems(hostKey, dbKey, collKey string, formJson string) int64
runtime.LogWarning(a.ctx, "Invalid update parameter value:") runtime.LogWarning(a.ctx, "Invalid update parameter value:")
runtime.LogWarning(a.ctx, param.Value) runtime.LogWarning(a.ctx, param.Value)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Invalid update query"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Invalid update query"), zenity.ErrorIcon)
return 0 return 0
} }
} }
@ -74,7 +74,7 @@ func (a *App) UpdateItems(hostKey, dbKey, collKey string, formJson string) int64
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while performing update:") runtime.LogWarning(a.ctx, "Encountered an error while performing update:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while performing update"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while performing update"), zenity.ErrorIcon)
return 0 return 0
} }

View File

@ -15,14 +15,14 @@ import (
func (a *App) connectToHost(hostKey string) (*mongo.Client, context.Context, func(), error) { func (a *App) connectToHost(hostKey string) (*mongo.Client, context.Context, func(), error) {
hosts, err := a.Hosts() hosts, err := a.Hosts()
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while getting hosts"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while getting hosts"), zenity.ErrorIcon)
return nil, nil, nil, errors.New("could not retrieve hosts") return nil, nil, nil, errors.New("could not retrieve hosts")
} }
h := hosts[hostKey] h := hosts[hostKey]
if len(h.URI) == 0 { if len(h.URI) == 0 {
runtime.LogInfo(a.ctx, "Invalid URI (len == 0) for host "+hostKey) runtime.LogInfo(a.ctx, "Invalid URI (len == 0) for host "+hostKey)
zenity.Info("You haven't specified a valid uri for the selected host.", zenity.Title("Invalid query"), zenity.ErrorIcon) zenity.Warning("You haven't specified a valid uri for the selected host.", zenity.Title("Invalid query"), zenity.WarningIcon)
return nil, nil, nil, errors.New("invalid uri") return nil, nil, nil, errors.New("invalid uri")
} }
@ -31,7 +31,7 @@ func (a *App) connectToHost(hostKey string) (*mongo.Client, context.Context, fun
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not connect to host "+hostKey) runtime.LogWarning(a.ctx, "Could not connect to host "+hostKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while connecting to "+h.Name), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while connecting to "+h.Name), zenity.ErrorIcon)
return nil, nil, nil, errors.New("could not establish a connection with " + h.Name) return nil, nil, nil, errors.New("could not establish a connection with " + h.Name)
} }
@ -52,7 +52,7 @@ func (a *App) OpenConnection(hostKey string) (databases []string) {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not retrieve database names for host "+hostKey) runtime.LogWarning(a.ctx, "Could not retrieve database names for host "+hostKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while getting databases"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while getting databases"), zenity.ErrorIcon)
return nil return nil
} }
defer close() defer close()

View File

@ -16,7 +16,7 @@ func (a *App) OpenDatabase(hostKey, dbKey string) (collections []string) {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not retrieve collection list for db "+dbKey) runtime.LogWarning(a.ctx, "Could not retrieve collection list for db "+dbKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while getting collections"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while getting collections"), zenity.ErrorIcon)
return nil return nil
} }
@ -39,7 +39,7 @@ func (a *App) DropDatabase(hostKey, dbKey string) bool {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not drop db "+dbKey) runtime.LogWarning(a.ctx, "Could not drop db "+dbKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while dropping database"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while dropping database"), zenity.ErrorIcon)
return false return false
} }

View File

@ -33,13 +33,13 @@ func (a *App) PerformExport(jsonData string) bool {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not unmarshal export form") runtime.LogError(a.ctx, "Could not unmarshal export form")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
return false return false
} }
hosts, err := a.Hosts() hosts, err := a.Hosts()
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while getting hosts"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while getting hosts"), zenity.ErrorIcon)
return false return false
} }
host := hosts[info.HostKey] host := hosts[info.HostKey]
@ -51,7 +51,7 @@ func (a *App) PerformExport(jsonData string) bool {
case FileTypeDump: case FileTypeDump:
if !a.Env.HasMongoDump { if !a.Env.HasMongoDump {
zenity.Info("You need to install mongodump to perform a dump.", zenity.Title("Additional software required"), zenity.ErrorIcon) zenity.Error("You need to install mongodump to perform a dump.", zenity.Title("Additional tooling required"), zenity.ErrorIcon)
return false return false
} }
@ -82,7 +82,7 @@ func (a *App) PerformExport(jsonData string) bool {
} }
default: default:
zenity.Info(fmt.Sprintf("File type '%v' is not known.", info.FileType), zenity.Title("Unrecognised file type"), zenity.ErrorIcon) zenity.Error(fmt.Sprintf("File type '%v' is not known.", info.FileType), zenity.Title("Unrecognised file type"), zenity.ErrorIcon)
return false return false
} }

View File

@ -57,7 +57,7 @@ func (a *App) Hosts() (map[string]Host, error) {
func (a *App) AddHost(jsonData string) error { func (a *App) AddHost(jsonData string) error {
hosts, err := a.Hosts() hosts, err := a.Hosts()
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while retrieving hosts"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while retrieving hosts"), zenity.ErrorIcon)
return errors.New("could not retrieve existing host list") return errors.New("could not retrieve existing host list")
} }
@ -66,7 +66,7 @@ func (a *App) AddHost(jsonData string) error {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Add host: malformed form") runtime.LogError(a.ctx, "Add host: malformed form")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
return errors.New("invalid JSON") return errors.New("invalid JSON")
} }
@ -74,14 +74,14 @@ func (a *App) AddHost(jsonData string) error {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Add host: failed to generate a UUID") runtime.LogError(a.ctx, "Add host: failed to generate a UUID")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Error while generating UUID"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while generating UUID"), zenity.ErrorIcon)
return errors.New("could not generate a UUID") return errors.New("could not generate a UUID")
} }
hosts[id.String()] = newHost hosts[id.String()] = newHost
err = updateHostsFile(a, hosts) err = updateHostsFile(a, hosts)
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while updating host list"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while updating host list"), zenity.ErrorIcon)
return errors.New("could not update host list") return errors.New("could not update host list")
} }
@ -91,7 +91,7 @@ func (a *App) AddHost(jsonData string) error {
func (a *App) UpdateHost(hostKey string, jsonData string) error { func (a *App) UpdateHost(hostKey string, jsonData string) error {
hosts, err := a.Hosts() hosts, err := a.Hosts()
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while getting hosts"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while getting hosts"), zenity.ErrorIcon)
return errors.New("could not retrieve existing host list") return errors.New("could not retrieve existing host list")
} }
@ -100,14 +100,14 @@ func (a *App) UpdateHost(hostKey string, jsonData string) error {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse update host JSON") runtime.LogError(a.ctx, "Could not parse update host JSON")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
return errors.New("invalid JSON") return errors.New("invalid JSON")
} }
hosts[hostKey] = host hosts[hostKey] = host
err = updateHostsFile(a, hosts) err = updateHostsFile(a, hosts)
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while updating hosts"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while updating hosts"), zenity.ErrorIcon)
return errors.New("could not update host list") return errors.New("could not update host list")
} }
@ -117,7 +117,7 @@ func (a *App) UpdateHost(hostKey string, jsonData string) error {
func (a *App) RemoveHost(key string) error { func (a *App) RemoveHost(key string) error {
hosts, err := a.Hosts() hosts, err := a.Hosts()
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while retrieving hosts"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while retrieving hosts"), zenity.ErrorIcon)
return errors.New("could not retrieve existing host list") return errors.New("could not retrieve existing host list")
} }
@ -130,7 +130,7 @@ func (a *App) RemoveHost(key string) error {
err = updateHostsFile(a, hosts) err = updateHostsFile(a, hosts)
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while updating hosts"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while updating hosts"), zenity.ErrorIcon)
return errors.New("could not update host list") return errors.New("could not update host list")
} }
return nil return nil

View File

@ -101,13 +101,13 @@ func (a *App) UpdateViewStore(jsonData string) error {
var viewStore ViewStore var viewStore ViewStore
err := json.Unmarshal([]byte(jsonData), &viewStore) err := json.Unmarshal([]byte(jsonData), &viewStore)
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
return errors.New("invalid JSON") return errors.New("invalid JSON")
} }
err = updateViewStore(a, viewStore) err = updateViewStore(a, viewStore)
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while updating view store"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while updating view store"), zenity.ErrorIcon)
return errors.New("could not update view store") return errors.New("could not update view store")
} }
@ -117,7 +117,7 @@ func (a *App) UpdateViewStore(jsonData string) error {
func (a *App) RemoveView(viewKey string) error { func (a *App) RemoveView(viewKey string) error {
views, err := a.Views() views, err := a.Views()
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while getting views"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while getting views"), zenity.ErrorIcon)
return errors.New("could not retrieve existing view store") return errors.New("could not retrieve existing view store")
} }
@ -130,7 +130,7 @@ func (a *App) RemoveView(viewKey string) error {
err = updateViewStore(a, views) err = updateViewStore(a, views)
if err != nil { if err != nil {
zenity.Info(err.Error(), zenity.Title("Error while updating view store"), zenity.ErrorIcon) zenity.Error(err.Error(), zenity.Title("Error while updating view store"), zenity.ErrorIcon)
return errors.New("could not update view store") return errors.New("could not update view store")
} }
return nil return nil