diff --git a/frontend/src/components/icon.svelte b/frontend/src/components/icon.svelte index 4f9f6d0..645a996 100644 --- a/frontend/src/components/icon.svelte +++ b/frontend/src/components/icon.svelte @@ -147,5 +147,7 @@ {:else if name === 'loading'} + {:else if name === 'doc'} + {/if} diff --git a/frontend/src/components/modal.svelte b/frontend/src/components/modal.svelte index a7c9e7d..e1ae1df 100644 --- a/frontend/src/components/modal.svelte +++ b/frontend/src/components/modal.svelte @@ -5,7 +5,6 @@ + +
+
+ +
+ +
+
+
+ + + +
+ + + + +
+ + {#if total} +
+ Total: {total} +
+ {/if} +
+
+ +{#if objectViewerData} + +{/if} + + + {#each autoReloadIntervals as value} + + + diff --git a/frontend/src/styles/style.css b/frontend/src/styles/style.css index 1288c9a..97eada7 100644 --- a/frontend/src/styles/style.css +++ b/frontend/src/styles/style.css @@ -142,7 +142,7 @@ select:disabled { .field > textarea, .field > select { flex: 1; - padding: 0.5rem; + padding: 0 0.5rem; border: 1px solid #ccc; background-color: #fff; appearance: none; diff --git a/frontend/wailsjs/go/app/App.d.ts b/frontend/wailsjs/go/app/App.d.ts index 9e3dd2c..ecd015c 100755 --- a/frontend/wailsjs/go/app/App.d.ts +++ b/frontend/wailsjs/go/app/App.d.ts @@ -24,6 +24,8 @@ export function FindItems(arg1:string,arg2:string,arg3:string,arg4:string):Promi export function GetIndexes(arg1:string,arg2:string,arg3:string):Promise; +export function HostLogs(arg1:string,arg2:string):Promise; + export function Hosts():Promise; export function InsertItems(arg1:string,arg2:string,arg3:string,arg4:string):Promise; diff --git a/frontend/wailsjs/go/app/App.js b/frontend/wailsjs/go/app/App.js index 5552e87..a2548f1 100755 --- a/frontend/wailsjs/go/app/App.js +++ b/frontend/wailsjs/go/app/App.js @@ -38,6 +38,10 @@ export function GetIndexes(arg1, arg2, arg3) { return window['go']['app']['App']['GetIndexes'](arg1, arg2, arg3); } +export function HostLogs(arg1, arg2) { + return window['go']['app']['App']['HostLogs'](arg1, arg2); +} + export function Hosts() { return window['go']['app']['App']['Hosts'](); } diff --git a/internal/app/host_logs.go b/internal/app/host_logs.go new file mode 100644 index 0000000..71586f6 --- /dev/null +++ b/internal/app/host_logs.go @@ -0,0 +1,37 @@ +package app + +import ( + "github.com/wailsapp/wails/v2/pkg/runtime" + "go.mongodb.org/mongo-driver/bson" +) + +type HostLogsResult struct { + Total int32 `json:"total"` + Logs []string `json:"logs"` + Error string `json:"error"` +} + +func (a *App) HostLogs(hostKey, filter string) (result HostLogsResult) { + client, ctx, close, err := a.connectToHost(hostKey) + if err != nil { + result.Error = "Could not connect to host" + return + } + defer close() + + var res bson.M + err = client.Database("admin").RunCommand(ctx, bson.M{"getLog": filter}).Decode(&res) + if err != nil { + runtime.LogWarningf(a.ctx, "Could not get %s logs for %s: %s", filter, hostKey, err.Error()) + result.Error = err.Error() + } + + result.Total = res["totalLinesWritten"].(int32) + result.Logs = make([]string, 0) + + for _, v := range res["log"].(bson.A) { + result.Logs = append(result.Logs, v.(string)) + } + + return +}