diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ee846e..5d09274 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * Display host and database statistics generated by the corresponding diagnostic MongoDB commands in addition to collection stats (#15). * Added version number of the running Rolens instance in the about dialog (#25, #28). * Fixed host/database selection bug in grid. +* Added meaningful window titles, and actually show these in the title bar (macOS). ## [v0.2.0] diff --git a/frontend/src/app.svelte b/frontend/src/app.svelte index 700b4d3..1e82bd4 100644 --- a/frontend/src/app.svelte +++ b/frontend/src/app.svelte @@ -6,6 +6,7 @@ import environment from '$lib/stores/environment'; import hosts from '$lib/stores/hosts'; import applicationInited from '$lib/stores/inited'; + import windowTitle from '$lib/stores/windowtitle'; import About from '$organisms/about.svelte'; import Connection from '$organisms/connection/index.svelte'; import Settings from '$organisms/settings/index.svelte'; @@ -42,7 +43,7 @@
-
+
{$windowTitle}
{#if $applicationInited && $hosts && (showWelcomeScreen !== undefined)}
@@ -69,6 +70,10 @@ height: 0; background-color: #00002a; --wails-draggable: drag; + color: #fff; + display: flex; + justify-content: center; + align-items: center; } #root.platform-darwin .titlebar { height: var(--darwin-titlebar-height); diff --git a/frontend/src/lib/stores/windowtitle.js b/frontend/src/lib/stores/windowtitle.js new file mode 100644 index 0000000..82b7c98 --- /dev/null +++ b/frontend/src/lib/stores/windowtitle.js @@ -0,0 +1,14 @@ +import { WindowSetTitle } from "$wails/runtime/runtime"; +import { writable } from "svelte/store"; + +const { set, subscribe } = writable('Rolens'); + +subscribe(newTitle => WindowSetTitle(newTitle)); + +const windowTitle = { + set, + setSegments: (...segments) => set(segments.map(s => s.trim()).join(' — ')), + subscribe, +}; + +export default windowTitle; diff --git a/frontend/src/organisms/connection/hosttree.svelte b/frontend/src/organisms/connection/hosttree.svelte index b63a540..7110d39 100644 --- a/frontend/src/organisms/connection/hosttree.svelte +++ b/frontend/src/organisms/connection/hosttree.svelte @@ -2,11 +2,11 @@ import Grid from '$components/grid.svelte'; import { startProgress } from '$lib/progress'; import connections from '$lib/stores/connections'; - import { WindowSetTitle } from '$wails/runtime/runtime'; import { createEventDispatcher } from 'svelte'; import { DropCollection, DropDatabase, OpenCollection, OpenConnection, OpenDatabase, RemoveHost, TruncateCollection } from '../../../wailsjs/go/app/App'; import hosts from '$lib/stores/hosts'; import { tick } from 'svelte'; + import windowTitle from '$lib/stores/windowtitle'; export let activeHostKey = ''; export let activeDbKey = ''; @@ -50,10 +50,13 @@ activeHostKey = hostKey; dispatch('connected', hostKey); - WindowSetTitle(`${$hosts[activeHostKey].name} - Rolens`); } progress.end(); + + if (databases) { + windowTitle.setSegments($hosts[activeHostKey].name, 'Rolens'); + } } async function removeHost(hostKey) { @@ -80,6 +83,7 @@ } progress.end(); + windowTitle.setSegments(activeDbKey, $hosts[activeHostKey].name, 'Rolens'); } async function dropDatabase(dbKey) { @@ -100,6 +104,7 @@ $connections[activeHostKey].databases[activeDbKey].collections[collKey] = $connections[activeHostKey].databases[activeDbKey].collections[collKey] || {}; $connections[activeHostKey].databases[activeDbKey].collections[collKey].stats = stats; progress.end(); + windowTitle.setSegments(activeDbKey + '.' + activeCollKey, $hosts[activeHostKey].name, 'Rolens'); } async function truncateCollection(dbKey, collKey) {