feat(client): show Dawarich stays, routes and marks where they belong

The trip planner and the journal get a "From Dawarich" list: the stays
recorded for those dates, each one a row that can be dismissed or turned
into a place or an entry after a review step that shows time, name, note
and day. A place that came from a recording carries the Dawarich mark
next to its name so its origin stays visible afterwards.

The recorded route lies over the trip and journal maps as an overlay,
coloured per day and cut along the reader's own timezone rather than
UTC. It is fetched for the window on screen and never stored.

The Atlas gets its own panel beside the map for the countries and cities
the recordings prove, and the wish list is ticked off there, on the day
of the visit, undoably. The phone has its own take on all of it, in the
mobile shell's colours and with native sheets.
This commit is contained in:
Maurice
2026-09-12 23:35:43 +02:00
parent 5678eed55c
commit 5b4a7e82ff
108 changed files with 8945 additions and 295 deletions
@@ -0,0 +1,120 @@
import React from 'react'
import { Plug, Save, RefreshCw, Unplug } from 'lucide-react'
import { useTranslation } from '../../../i18n'
import { useDawarichConnection } from '../../../hooks/useDawarichConnection'
import { MSetCard, MSetRow, MSetInput, MSetButton, MSetHint } from './MSettingsUi'
import MToggle from '../../components/MToggle'
/**
* Phone twin of components/Settings/DawarichConnectionSection.
*
* Presentation only: every piece of behaviour lives in `useDawarichConnection`,
* which both shells share. That is not tidiness — SonarCloud allows 3%
* duplicated lines on a PR's new code, and a second copy of the connect / test /
* sync logic would spend the whole budget on its own.
*/
export default function MDawarichConnectionSection(): React.ReactElement {
const { t, locale } = useTranslation()
const S = useDawarichConnection()
return (
<MSetCard title={t('dawarich.title')} icon={Plug} className="mt-3">
<MSetHint className="mt-0">{t('dawarich.intro')}</MSetHint>
<div className="mt-3 space-y-3">
<div>
<MSetInput
type="url"
inputMode="url"
value={S.url}
onChange={e => S.setUrl(e.target.value)}
placeholder="https://dawarich.example.com"
aria-label={t('dawarich.url')}
/>
</div>
<div>
<MSetInput
type="password"
value={S.apiKey}
onChange={e => S.setApiKey(e.target.value)}
autoComplete="off"
placeholder={S.connected && !S.apiKey ? '••••••••' : t('dawarich.apiKeyPlaceholder')}
aria-label={t('dawarich.apiKey')}
/>
<MSetHint>{t('dawarich.apiKeyHint')}</MSetHint>
</div>
</div>
<div className="mt-1">
<MSetRow
first
label={t('dawarich.syncEnabled')}
sub={t('dawarich.syncEnabledHint')}
trailing={
<MToggle checked={S.syncEnabled} onChange={S.toggleSync} ariaLabel={t('dawarich.syncEnabled')} />
}
/>
<MSetRow
label={t('dawarich.allowInsecureTls')}
sub={t('dawarich.allowInsecureTlsHint')}
trailing={
<MToggle
checked={S.allowInsecureTls}
onChange={S.toggleInsecureTls}
ariaLabel={t('dawarich.allowInsecureTls')}
/>
}
/>
</div>
<div className="mt-3 flex flex-wrap items-center gap-2">
<MSetButton onClick={S.save} disabled={S.saving || S.loading || !S.canSave}>
<Save size={14} /> {t('common.save')}
</MSetButton>
<MSetButton variant="ghost" onClick={S.test} disabled={S.testing || S.loading || !S.url.trim()}>
<Plug size={14} /> {t('dawarich.test.button')}
</MSetButton>
{S.connected && (
<MSetButton variant="ghost" onClick={S.syncNow} disabled={S.syncing}>
<RefreshCw size={14} className={S.syncing ? 'animate-spin' : ''} /> {t('dawarich.syncNow')}
</MSetButton>
)}
</div>
<div className="mt-3 space-y-[4px]">
<p className="font-geist text-[0.6875rem] font-semibold text-m-ink">
{S.connected ? t('dawarich.connected') : t('dawarich.notConnected')}
</p>
{S.probeMessage && (
<p className="font-geist text-[0.625rem] leading-relaxed text-m-muted">{S.probeMessage}</p>
)}
{S.connected && (
<p className="font-geist text-[0.625rem] leading-relaxed text-m-muted">
{S.lastSyncAt
? t('dawarich.lastSync', { when: new Date(S.lastSyncAt).toLocaleString(locale) })
: t('dawarich.neverSynced')}
</p>
)}
{S.lastSyncError && (
<p className="font-geist text-[0.625rem] leading-relaxed text-[color:var(--m-st-danger)]">
{S.lastSyncError}
</p>
)}
{S.capabilities?.serverVersion && (
<p className="font-geist text-[0.625rem] leading-relaxed text-m-faint">
{t('dawarich.serverVersion', { version: S.capabilities.serverVersion })}
</p>
)}
</div>
{S.connected && (
<div className="mt-3">
<MSetButton variant="danger" onClick={S.disconnect} disabled={S.saving}>
<Unplug size={14} /> {t('dawarich.disconnect')}
</MSetButton>
</div>
)}
</MSetCard>
)
}
@@ -2,6 +2,7 @@ import { useEffect } from 'react'
import { useAddonStore } from '../../../store/addonStore'
import MPhotoProvidersSection from './MPhotoProvidersSection'
import MAirTrailConnectionSection from './MAirTrailConnectionSection'
import MDawarichConnectionSection from './MDawarichConnectionSection'
import MLlmConnectionSection from './MLlmConnectionSection'
import MSettingsMcp from './MSettingsMcp'
import { useAuthStore } from '../../../store/authStore'
@@ -17,6 +18,7 @@ export default function MSettingsIntegrations() {
const mcpEnabled = addonEnabled('mcp')
const airtrailEnabled = addonEnabled('airtrail')
const llmEnabled = addonEnabled('llm_parsing')
const dawarichEnabled = addonEnabled('dawarich')
const managed = useAuthStore((s) => s.managed)
useEffect(() => {
@@ -27,6 +29,9 @@ export default function MSettingsIntegrations() {
<>
<MPhotoProvidersSection />
{airtrailEnabled && <MAirTrailConnectionSection />}
{/* Reaches a server the reader runs themselves, which a managed install has
no route to — the same gate the desktop shell puts on AirTrail. */}
{dawarichEnabled && !managed && <MDawarichConnectionSection />}
{/* Which model reads a booking, and what that costs, comes with the instance on
a managed install. The per-user fallback exists for people who supply their
own key, and there nobody does. */}