mirror of
https://github.com/spartanz51/tutabridge.git
synced 2026-06-24 10:54:32 +02:00
Restructure into Cargo workspace with Tauri desktop GUI (#1)
Split the bridge into a tutabridge-core crate, a Tauri v2 desktop app (src-tauri) and a React/TS UI (ui), keeping the CLI entrypoint at the workspace root. Add encrypted local storage (SQLCipher metadata index + encrypted .eml files) so mail persists across launches and only the delta is fetched. Wire the bridge to the Tuta Rust SDK via the tuta-repo submodule (batch loading, MailDetailsBlob reading, interactive 2FA login). Implement SMTP sending: build the draft and send it through Tuta's DraftService/SendDraftService, mirroring the web client (body in compressedBodyText, non-empty sender/recipient names, populated SendDraftParameters). Add unit tests for the draft/send payload building.
This commit is contained in:
+515
@@ -0,0 +1,515 @@
|
||||
.app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
/* ── Header ── */
|
||||
.app-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 16px;
|
||||
background: var(--surface-container);
|
||||
border-bottom: 1px solid var(--outline-variant);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.app-header h1 {
|
||||
font-family: var(--brand);
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
color: var(--on-surface);
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
|
||||
.header-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 3px 10px 3px 8px;
|
||||
background: var(--surface-container-high);
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.header-status-text {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
color: var(--on-surface-variant);
|
||||
}
|
||||
|
||||
/* ── Tabs ── */
|
||||
.tabs {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.tabs button {
|
||||
background: none;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
padding: 5px 12px;
|
||||
font-size: 13px;
|
||||
color: var(--on-surface-variant);
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
font-family: var(--sans);
|
||||
}
|
||||
|
||||
.tabs button:hover {
|
||||
background: var(--surface-container-high);
|
||||
}
|
||||
|
||||
.tabs button.active {
|
||||
background: var(--primary-container);
|
||||
color: var(--on-primary-container);
|
||||
border-color: transparent;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* ── Content ── */
|
||||
.app-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
/* ── Shared ── */
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: var(--on-surface-variant);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.error-text {
|
||||
font-size: 13px;
|
||||
color: var(--error);
|
||||
margin: 0;
|
||||
padding: 10px 12px;
|
||||
background: color-mix(in srgb, var(--error) 8%, transparent);
|
||||
border-radius: 8px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* ── Dashboard ── */
|
||||
.dashboard {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.status-hero {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 18px 20px;
|
||||
border-radius: 14px;
|
||||
border: 1px solid var(--outline-variant);
|
||||
background: var(--surface-container);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.status-hero.running {
|
||||
border-color: color-mix(in srgb, var(--green) 40%, transparent);
|
||||
background: color-mix(in srgb, var(--success-container) 30%, var(--surface-container));
|
||||
}
|
||||
|
||||
.status-hero.starting {
|
||||
border-color: color-mix(in srgb, var(--orange) 40%, transparent);
|
||||
}
|
||||
|
||||
.hero-indicator {
|
||||
position: relative;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.pulse-ring {
|
||||
position: absolute;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid var(--green);
|
||||
opacity: 0;
|
||||
animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
|
||||
}
|
||||
|
||||
.pulse-ring.orange {
|
||||
border-color: var(--orange);
|
||||
}
|
||||
|
||||
.pulse-dot {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
background: var(--green);
|
||||
animation: breathe 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.pulse-dot.orange {
|
||||
background: var(--orange);
|
||||
}
|
||||
|
||||
.static-dot {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
@keyframes ping {
|
||||
0% { transform: scale(0.8); opacity: 0.6; }
|
||||
75%, 100% { transform: scale(1.4); opacity: 0; }
|
||||
}
|
||||
|
||||
@keyframes breathe {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.5; }
|
||||
}
|
||||
|
||||
.hero-text {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.hero-text strong {
|
||||
font-size: 15px;
|
||||
color: var(--on-surface);
|
||||
}
|
||||
|
||||
.hero-uptime {
|
||||
font-size: 12px;
|
||||
color: var(--on-surface-variant);
|
||||
}
|
||||
|
||||
.hero-action {
|
||||
padding: 6px 16px;
|
||||
font-size: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.start-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.start-btn {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 20px 16px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--outline-variant);
|
||||
background: var(--surface-container);
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
border-color: color-mix(in srgb, var(--primary) 30%, var(--outline-variant));
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
color: var(--on-surface);
|
||||
font-family: var(--brand);
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--on-surface-variant);
|
||||
}
|
||||
|
||||
/* ── Connection Panel ── */
|
||||
.connection-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.panel-subtitle {
|
||||
font-size: 13px;
|
||||
color: var(--on-surface-variant);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.settings-card {
|
||||
border: 1px solid var(--outline-variant);
|
||||
border-radius: 14px;
|
||||
background: var(--surface-container);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.settings-section {
|
||||
padding: 16px 20px;
|
||||
}
|
||||
|
||||
.settings-section h3 {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--on-surface-variant);
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
|
||||
.settings-divider {
|
||||
height: 1px;
|
||||
background: var(--outline-variant);
|
||||
}
|
||||
|
||||
.settings-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 72px 1fr;
|
||||
gap: 6px 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.setting-key {
|
||||
font-size: 12px;
|
||||
color: var(--on-surface-variant);
|
||||
}
|
||||
|
||||
.setting-val {
|
||||
font-size: 14px;
|
||||
font-family: var(--mono);
|
||||
color: var(--on-surface);
|
||||
background: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.setting-val.copyable {
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.setting-val.copyable:hover {
|
||||
background: var(--surface-container-high);
|
||||
}
|
||||
|
||||
.password-field-inline {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.password-mono {
|
||||
font-size: 13px;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
|
||||
.inline-btn {
|
||||
padding: 2px 8px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
border: 1px solid var(--outline-variant);
|
||||
border-radius: 6px;
|
||||
background: var(--surface-container-high);
|
||||
color: var(--on-surface-variant);
|
||||
cursor: pointer;
|
||||
font-family: var(--sans);
|
||||
transition: all 0.15s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.inline-btn:hover {
|
||||
background: var(--surface-container-highest);
|
||||
color: var(--on-surface);
|
||||
}
|
||||
|
||||
.regen-btn {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.settings-note {
|
||||
font-size: 12px;
|
||||
color: var(--on-surface-variant);
|
||||
padding: 10px 14px;
|
||||
background: color-mix(in srgb, var(--orange) 8%, transparent);
|
||||
border-radius: 8px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.settings-note strong {
|
||||
color: var(--on-surface);
|
||||
}
|
||||
|
||||
/* ── Config Panel ── */
|
||||
.panel {
|
||||
}
|
||||
|
||||
.panel h2 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
margin: 0 0 16px;
|
||||
color: var(--on-surface);
|
||||
}
|
||||
|
||||
/* ── Forms ── */
|
||||
.form-group {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--on-surface-variant);
|
||||
margin-bottom: 4px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.form-group input {
|
||||
width: 100%;
|
||||
padding: 9px 12px;
|
||||
font-size: 14px;
|
||||
border: 1px solid var(--outline-variant);
|
||||
border-radius: 8px;
|
||||
background: var(--surface);
|
||||
color: var(--on-surface);
|
||||
box-sizing: border-box;
|
||||
font-family: var(--sans);
|
||||
transition: border-color 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
|
||||
.form-group input:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 15%, transparent);
|
||||
}
|
||||
|
||||
.form-group input:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.form-group input::placeholder {
|
||||
color: var(--outline);
|
||||
}
|
||||
|
||||
.form-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.form-row .form-group {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* ── Buttons ── */
|
||||
button {
|
||||
padding: 9px 18px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
border: 1px solid var(--outline-variant);
|
||||
border-radius: 8px;
|
||||
background: var(--surface-container-high);
|
||||
color: var(--on-surface);
|
||||
cursor: pointer;
|
||||
font-family: var(--sans);
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
button:hover:not(:disabled) {
|
||||
background: var(--surface-container-highest);
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
button.primary {
|
||||
background: var(--primary);
|
||||
color: var(--on-primary);
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
button.primary:hover:not(:disabled) {
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
button.small {
|
||||
padding: 4px 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* ── Logs ── */
|
||||
.logs-panel {
|
||||
max-width: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: calc(100vh - 120px);
|
||||
}
|
||||
|
||||
.logs-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.logs-header h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.logs-container {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
background: var(--surface-container);
|
||||
border: 1px solid var(--outline-variant);
|
||||
border-radius: 10px;
|
||||
padding: 12px;
|
||||
font-family: var(--mono);
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.logs-empty {
|
||||
color: var(--outline);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.log-line {
|
||||
color: var(--on-surface);
|
||||
word-break: break-all;
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
import { useState } from "react";
|
||||
import { useBridge } from "./hooks/useBridge";
|
||||
import { Dashboard } from "./components/Dashboard";
|
||||
import { ConnectionPanel } from "./components/ConnectionPanel";
|
||||
import { ConfigPanel } from "./components/ConfigPanel";
|
||||
import { LogsPanel } from "./components/LogsPanel";
|
||||
import { statusLabel, isError } from "./types";
|
||||
import "./App.css";
|
||||
|
||||
type Tab = "dashboard" | "connection" | "config" | "logs";
|
||||
|
||||
function App() {
|
||||
const [tab, setTab] = useState<Tab>("dashboard");
|
||||
const bridge = useBridge();
|
||||
|
||||
const status = bridge.status;
|
||||
const isRunning = status === "Running";
|
||||
const isStarting = status === "Starting";
|
||||
const statusColor = isRunning
|
||||
? "var(--green)"
|
||||
: isStarting
|
||||
? "var(--orange)"
|
||||
: status && isError(status)
|
||||
? "var(--red)"
|
||||
: "var(--gray)";
|
||||
|
||||
return (
|
||||
<div className="app">
|
||||
<header className="app-header">
|
||||
<div className="header-left">
|
||||
<h1>TutaBridge</h1>
|
||||
<div className="header-status">
|
||||
<span className="status-dot" style={{ background: statusColor }} />
|
||||
<span className="header-status-text">
|
||||
{status ? statusLabel(status) : "Loading..."}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<nav className="tabs">
|
||||
<button
|
||||
className={tab === "dashboard" ? "active" : ""}
|
||||
onClick={() => setTab("dashboard")}
|
||||
>
|
||||
Dashboard
|
||||
</button>
|
||||
<button
|
||||
className={tab === "connection" ? "active" : ""}
|
||||
onClick={() => setTab("connection")}
|
||||
>
|
||||
Connection
|
||||
</button>
|
||||
<button
|
||||
className={tab === "config" ? "active" : ""}
|
||||
onClick={() => setTab("config")}
|
||||
>
|
||||
Config
|
||||
</button>
|
||||
<button
|
||||
className={tab === "logs" ? "active" : ""}
|
||||
onClick={() => setTab("logs")}
|
||||
>
|
||||
Logs{bridge.logs.length > 0 ? ` (${bridge.logs.length})` : ""}
|
||||
</button>
|
||||
</nav>
|
||||
</header>
|
||||
<main className="app-content">
|
||||
{tab === "dashboard" && (
|
||||
<Dashboard
|
||||
status={bridge.status}
|
||||
stats={bridge.stats}
|
||||
hasSavedSession={bridge.hasSavedSession}
|
||||
loading={bridge.loading}
|
||||
onStart={bridge.startBridge}
|
||||
onStop={bridge.stopBridge}
|
||||
/>
|
||||
)}
|
||||
{tab === "connection" && (
|
||||
<ConnectionPanel
|
||||
config={bridge.config}
|
||||
status={bridge.status}
|
||||
bridgePassword={bridge.bridgePassword}
|
||||
onRegeneratePassword={bridge.regenerateBridgePassword}
|
||||
/>
|
||||
)}
|
||||
{tab === "config" && (
|
||||
<ConfigPanel
|
||||
config={bridge.config}
|
||||
status={bridge.status}
|
||||
onSave={bridge.saveConfig}
|
||||
/>
|
||||
)}
|
||||
{tab === "logs" && (
|
||||
<LogsPanel logs={bridge.logs} onClear={bridge.clearLogs} />
|
||||
)}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 8.5 KiB |
@@ -0,0 +1,86 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import type { Config, BridgeStatus } from "../types";
|
||||
|
||||
interface Props {
|
||||
config: Config | null;
|
||||
status: BridgeStatus | null;
|
||||
onSave: (config: Config) => Promise<void>;
|
||||
}
|
||||
|
||||
export function ConfigPanel({ config, status, onSave }: Props) {
|
||||
const [email, setEmail] = useState("");
|
||||
const [imapPort, setImapPort] = useState(1143);
|
||||
const [smtpPort, setSmtpPort] = useState(1025);
|
||||
const [apiUrl, setApiUrl] = useState("https://app.tuta.com");
|
||||
const [saved, setSaved] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (config) {
|
||||
setEmail(config.email);
|
||||
setImapPort(config.imap_port);
|
||||
setSmtpPort(config.smtp_port);
|
||||
setApiUrl(config.api_url);
|
||||
}
|
||||
}, [config]);
|
||||
|
||||
const isRunning = status === "Running" || status === "Starting";
|
||||
|
||||
const handleSave = async () => {
|
||||
await onSave({
|
||||
email,
|
||||
imap_port: imapPort,
|
||||
smtp_port: smtpPort,
|
||||
api_url: apiUrl,
|
||||
});
|
||||
setSaved(true);
|
||||
setTimeout(() => setSaved(false), 2000);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="panel">
|
||||
<h2>Configuration</h2>
|
||||
<div className="form-group">
|
||||
<label>Email</label>
|
||||
<input
|
||||
type="email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
disabled={isRunning}
|
||||
placeholder="your@tuta.com"
|
||||
/>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<div className="form-group">
|
||||
<label>IMAP Port</label>
|
||||
<input
|
||||
type="number"
|
||||
value={imapPort}
|
||||
onChange={(e) => setImapPort(Number(e.target.value))}
|
||||
disabled={isRunning}
|
||||
/>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label>SMTP Port</label>
|
||||
<input
|
||||
type="number"
|
||||
value={smtpPort}
|
||||
onChange={(e) => setSmtpPort(Number(e.target.value))}
|
||||
disabled={isRunning}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label>API URL</label>
|
||||
<input
|
||||
type="url"
|
||||
value={apiUrl}
|
||||
onChange={(e) => setApiUrl(e.target.value)}
|
||||
disabled={isRunning}
|
||||
/>
|
||||
</div>
|
||||
<button onClick={handleSave} disabled={isRunning || !email}>
|
||||
{saved ? "Saved!" : "Save"}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { useState } from "react";
|
||||
import type { Config, BridgeStatus } from "../types";
|
||||
|
||||
interface Props {
|
||||
config: Config | null;
|
||||
status: BridgeStatus | null;
|
||||
bridgePassword: string | null;
|
||||
onRegeneratePassword: () => Promise<string>;
|
||||
}
|
||||
|
||||
export function ConnectionPanel({ config, status, bridgePassword, onRegeneratePassword }: Props) {
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const isRunning = status === "Running" || status === "Starting";
|
||||
|
||||
const copyToClipboard = (text: string) => {
|
||||
navigator.clipboard.writeText(text);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
if (!config) {
|
||||
return <div className="connection-panel"><p className="muted">Loading...</p></div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="connection-panel">
|
||||
<p className="panel-subtitle">Configure your mail client with these settings</p>
|
||||
|
||||
<div className="settings-card">
|
||||
<div className="settings-section">
|
||||
<h3>Incoming Mail (IMAP)</h3>
|
||||
<div className="settings-grid">
|
||||
<span className="setting-key">Server</span>
|
||||
<code className="setting-val">127.0.0.1</code>
|
||||
<span className="setting-key">Port</span>
|
||||
<code className="setting-val">{config.imap_port}</code>
|
||||
<span className="setting-key">Security</span>
|
||||
<code className="setting-val">SSL/TLS</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="settings-divider" />
|
||||
|
||||
<div className="settings-section">
|
||||
<h3>Outgoing Mail (SMTP)</h3>
|
||||
<div className="settings-grid">
|
||||
<span className="setting-key">Server</span>
|
||||
<code className="setting-val">127.0.0.1</code>
|
||||
<span className="setting-key">Port</span>
|
||||
<code className="setting-val">{config.smtp_port}</code>
|
||||
<span className="setting-key">Security</span>
|
||||
<code className="setting-val">SSL/TLS</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="settings-divider" />
|
||||
|
||||
<div className="settings-section">
|
||||
<h3>Authentication</h3>
|
||||
<div className="settings-grid">
|
||||
<span className="setting-key">Username</span>
|
||||
<code className="setting-val copyable" onClick={() => copyToClipboard(config.email)}>
|
||||
{config.email || "—"}
|
||||
</code>
|
||||
<span className="setting-key">Password</span>
|
||||
<div className="password-field-inline">
|
||||
{bridgePassword ? (
|
||||
<>
|
||||
<code className="setting-val password-mono">
|
||||
{showPassword ? bridgePassword : "•".repeat(23)}
|
||||
</code>
|
||||
<button
|
||||
className="inline-btn"
|
||||
onClick={() => setShowPassword(!showPassword)}
|
||||
>
|
||||
{showPassword ? "Hide" : "Show"}
|
||||
</button>
|
||||
<button
|
||||
className="inline-btn"
|
||||
onClick={() => copyToClipboard(bridgePassword)}
|
||||
>
|
||||
{copied ? "Copied!" : "Copy"}
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<span className="muted">Start the bridge to generate</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{bridgePassword && (
|
||||
<button
|
||||
className="small regen-btn"
|
||||
onClick={onRegeneratePassword}
|
||||
disabled={isRunning}
|
||||
title={isRunning ? "Stop the bridge first" : "Generate a new password"}
|
||||
>
|
||||
Regenerate password
|
||||
</button>
|
||||
)}
|
||||
|
||||
<div className="settings-note">
|
||||
<strong>Note:</strong> Accept the self-signed certificate when your mail client prompts.
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
import { useState } from "react";
|
||||
import type { BridgeStatus, BridgeStats } from "../types";
|
||||
import { isError } from "../types";
|
||||
|
||||
interface Props {
|
||||
status: BridgeStatus | null;
|
||||
stats: BridgeStats;
|
||||
hasSavedSession: boolean;
|
||||
loading: boolean;
|
||||
onStart: (password?: string) => Promise<void>;
|
||||
onStop: () => Promise<void>;
|
||||
}
|
||||
|
||||
function formatUptime(secs: number): string {
|
||||
if (secs < 60) return `${secs}s`;
|
||||
if (secs < 3600) return `${Math.floor(secs / 60)}m ${secs % 60}s`;
|
||||
const h = Math.floor(secs / 3600);
|
||||
const m = Math.floor((secs % 3600) / 60);
|
||||
return `${h}h ${m}m`;
|
||||
}
|
||||
|
||||
export function Dashboard({ status, stats, hasSavedSession, loading, onStart, onStop }: Props) {
|
||||
const [password, setPassword] = useState("");
|
||||
|
||||
if (!status) {
|
||||
return <div className="dashboard"><p className="muted">Connecting...</p></div>;
|
||||
}
|
||||
|
||||
const isRunning = status === "Running";
|
||||
const isStarting = status === "Starting";
|
||||
const isStopped = status === "Stopped" || isError(status);
|
||||
const needsPassword = isStopped && !hasSavedSession;
|
||||
|
||||
const handleStart = async () => {
|
||||
if (needsPassword) {
|
||||
await onStart(password);
|
||||
setPassword("");
|
||||
} else {
|
||||
await onStart();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="dashboard">
|
||||
{isRunning && (
|
||||
<div className="status-hero running">
|
||||
<div className="hero-indicator">
|
||||
<span className="pulse-ring" />
|
||||
<span className="pulse-dot" />
|
||||
</div>
|
||||
<div className="hero-text">
|
||||
<strong>Bridge is running</strong>
|
||||
{stats.uptime_secs != null && (
|
||||
<span className="hero-uptime">Up {formatUptime(stats.uptime_secs)}</span>
|
||||
)}
|
||||
</div>
|
||||
<button className="hero-action" onClick={onStop} disabled={loading}>
|
||||
{loading ? "Stopping..." : "Stop"}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isStarting && (
|
||||
<div className="status-hero starting">
|
||||
<div className="hero-indicator">
|
||||
<span className="pulse-ring orange" />
|
||||
<span className="pulse-dot orange" />
|
||||
</div>
|
||||
<div className="hero-text">
|
||||
<strong>Connecting...</strong>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isStopped && (
|
||||
<div className="status-hero stopped">
|
||||
<div className="hero-indicator">
|
||||
<span className="static-dot" style={{ background: isError(status) ? "var(--red)" : "var(--gray)" }} />
|
||||
</div>
|
||||
<div className="hero-text">
|
||||
<strong>{isError(status) ? "Connection failed" : "Bridge is stopped"}</strong>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isError(status) && (
|
||||
<p className="error-text">{status.Error}</p>
|
||||
)}
|
||||
|
||||
{isStopped && (
|
||||
<div className="start-section">
|
||||
{needsPassword && (
|
||||
<div className="form-group">
|
||||
<label>Tuta Password</label>
|
||||
<input
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
placeholder="Enter your Tuta password"
|
||||
onKeyDown={(e) => e.key === "Enter" && password && handleStart()}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<button
|
||||
className="primary start-btn"
|
||||
onClick={handleStart}
|
||||
disabled={loading || (needsPassword && !password)}
|
||||
>
|
||||
{loading ? "Connecting..." : "Start Bridge"}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="stats-grid">
|
||||
<div className="stat-card">
|
||||
<span className="stat-value">{stats.mails_synced}</span>
|
||||
<span className="stat-label">Emails synced</span>
|
||||
</div>
|
||||
<div className="stat-card">
|
||||
<span className="stat-value">
|
||||
{stats.uptime_secs != null ? formatUptime(stats.uptime_secs) : "--"}
|
||||
</span>
|
||||
<span className="stat-label">Uptime</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
interface Props {
|
||||
logs: string[];
|
||||
onClear: () => void;
|
||||
}
|
||||
|
||||
export function LogsPanel({ logs, onClear }: Props) {
|
||||
const endRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
endRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||
}, [logs]);
|
||||
|
||||
return (
|
||||
<div className="panel logs-panel">
|
||||
<div className="logs-header">
|
||||
<h2>Logs</h2>
|
||||
<button className="small" onClick={onClear}>
|
||||
Clear
|
||||
</button>
|
||||
</div>
|
||||
<div className="logs-container">
|
||||
{logs.length === 0 ? (
|
||||
<span className="logs-empty">No logs yet</span>
|
||||
) : (
|
||||
logs.map((line, i) => (
|
||||
<div key={i} className="log-line">
|
||||
{line}
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
<div ref={endRef} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,100 @@
|
||||
import { useState, useEffect, useCallback, useRef } from "react";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import type { Config, BridgeStatus, BridgeStats } from "../types";
|
||||
|
||||
const MAX_LOG_LINES = 500;
|
||||
const POLL_INTERVAL = 1000;
|
||||
|
||||
export function useBridge() {
|
||||
const [config, setConfig] = useState<Config | null>(null);
|
||||
const [status, setStatus] = useState<BridgeStatus | null>(null);
|
||||
const [stats, setStats] = useState<BridgeStats>({ uptime_secs: null, mails_synced: 0 });
|
||||
const [hasSavedSession, setHasSavedSession] = useState(false);
|
||||
const [bridgePassword, setBridgePassword] = useState<string | null>(null);
|
||||
const [logs, setLogs] = useState<string[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
invoke<BridgeStatus>("get_status").then(setStatus);
|
||||
invoke<BridgeStats>("get_stats").then(setStats);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
invoke<Config>("get_config").then(setConfig);
|
||||
invoke<boolean>("has_saved_session").then(setHasSavedSession);
|
||||
invoke<string | null>("get_bridge_password").then(setBridgePassword);
|
||||
refresh();
|
||||
|
||||
pollRef.current = setInterval(refresh, POLL_INTERVAL);
|
||||
return () => {
|
||||
if (pollRef.current) clearInterval(pollRef.current);
|
||||
};
|
||||
}, [refresh]);
|
||||
|
||||
useEffect(() => {
|
||||
const unlisten = listen<string>("bridge://log", (event) => {
|
||||
setLogs((prev) => {
|
||||
const next = [...prev, event.payload];
|
||||
return next.length > MAX_LOG_LINES ? next.slice(-MAX_LOG_LINES) : next;
|
||||
});
|
||||
});
|
||||
return () => {
|
||||
unlisten.then((fn) => fn());
|
||||
};
|
||||
}, []);
|
||||
|
||||
const saveConfig = useCallback(async (cfg: Config) => {
|
||||
await invoke("save_config", { config: cfg });
|
||||
setConfig(cfg);
|
||||
}, []);
|
||||
|
||||
const startBridge = useCallback(async (password?: string) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
await invoke("start_bridge", { password: password || null });
|
||||
refresh();
|
||||
invoke<string | null>("get_bridge_password").then(setBridgePassword);
|
||||
} catch (e) {
|
||||
setStatus({ Error: String(e) });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [refresh]);
|
||||
|
||||
const stopBridge = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
await invoke("stop_bridge");
|
||||
refresh();
|
||||
} catch (e) {
|
||||
setStatus({ Error: String(e) });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [refresh]);
|
||||
|
||||
const clearLogs = useCallback(() => setLogs([]), []);
|
||||
|
||||
const regenerateBridgePassword = useCallback(async () => {
|
||||
const newPassword = await invoke<string>("regenerate_bridge_password");
|
||||
setBridgePassword(newPassword);
|
||||
return newPassword;
|
||||
}, []);
|
||||
|
||||
return {
|
||||
config,
|
||||
status,
|
||||
stats,
|
||||
hasSavedSession,
|
||||
bridgePassword,
|
||||
logs,
|
||||
loading,
|
||||
saveConfig,
|
||||
startBridge,
|
||||
stopBridge,
|
||||
clearLogs,
|
||||
regenerateBridgePassword,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
@font-face {
|
||||
font-family: 'MDIO';
|
||||
src: url('./fonts/MDIO-Semibold.woff2') format('woff2');
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
:root {
|
||||
/* Tuta light red theme */
|
||||
--primary: #8F4A4E;
|
||||
--on-primary: #FFFFFF;
|
||||
--primary-container: #F4D2D2;
|
||||
--on-primary-container: #733337;
|
||||
--secondary: #87521B;
|
||||
--tertiary: #63568F;
|
||||
--surface: #FFFFFF;
|
||||
--surface-container: #FCF9F6;
|
||||
--surface-container-high: #F5EEEA;
|
||||
--surface-container-highest: #e7e2de;
|
||||
--on-surface: #221A14;
|
||||
--on-surface-variant: #4e4545;
|
||||
--outline: #7f7575;
|
||||
--outline-variant: #d0c4c4;
|
||||
--scrim: #000000;
|
||||
--error: #BA1A1A;
|
||||
--on-error: #FFFFFF;
|
||||
--success: #44845E;
|
||||
--success-container: #E9FFED;
|
||||
--warning: #8D7426;
|
||||
--tuta-nota: #D93951;
|
||||
|
||||
--green: #44845E;
|
||||
--orange: #8D7426;
|
||||
--red: #BA1A1A;
|
||||
--gray: #7f7575;
|
||||
|
||||
--sans: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
--mono: ui-monospace, "SF Mono", Consolas, monospace;
|
||||
--brand: 'MDIO', var(--sans);
|
||||
|
||||
font: 16px/1.4286 var(--sans);
|
||||
color-scheme: light dark;
|
||||
color: var(--on-surface-variant);
|
||||
background: var(--surface);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--primary: #FFB3B5;
|
||||
--on-primary: #561D22;
|
||||
--primary-container: #733337;
|
||||
--on-primary-container: #FFDADA;
|
||||
--secondary: #F3BD6E;
|
||||
--tertiary: #CDBDFF;
|
||||
--surface: #181212;
|
||||
--surface-container: #241e1e;
|
||||
--surface-container-high: #2f2828;
|
||||
--surface-container-highest: #3d3434;
|
||||
--on-surface: #f3ecec;
|
||||
--on-surface-variant: #d0c4c4;
|
||||
--outline: #998e8e;
|
||||
--outline-variant: #4e4545;
|
||||
--scrim: #000000;
|
||||
--error: #FFB4AB;
|
||||
--on-error: #690005;
|
||||
--success: #5E9E77;
|
||||
--success-container: #003920;
|
||||
--warning: #FFE089;
|
||||
--tuta-nota: #D93951;
|
||||
|
||||
--green: #5E9E77;
|
||||
--orange: #FFE089;
|
||||
--red: #FFB4AB;
|
||||
--gray: #998e8e;
|
||||
}
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#root {
|
||||
height: 100vh;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App.tsx'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
export interface Config {
|
||||
email: string;
|
||||
imap_port: number;
|
||||
smtp_port: number;
|
||||
api_url: string;
|
||||
}
|
||||
|
||||
export type BridgeStatus = "Stopped" | "Starting" | "Running" | { Error: string };
|
||||
|
||||
export interface BridgeStats {
|
||||
uptime_secs: number | null;
|
||||
mails_synced: number;
|
||||
}
|
||||
|
||||
export function statusLabel(status: BridgeStatus): string {
|
||||
if (typeof status === "string") return status;
|
||||
return `Error: ${status.Error}`;
|
||||
}
|
||||
|
||||
export function isError(status: BridgeStatus): status is { Error: string } {
|
||||
return typeof status !== "string";
|
||||
}
|
||||
Reference in New Issue
Block a user