Refactor: remove desktop/Tauri bundle, add i18n, CI/CD pipeline
Nightly Build / build (push) Failing after 6s

- Remove desktop (Tauri) bundle: docs/desktop.md, icons/, tauri.conf.json,
  src/desktop/mod.rs, gen/schemas/
- Remove build.rs (no longer needed)
- Add i18n system (crates/core-api, plugin-mobile-connector, web)
- Refactor config system (src/config.rs, boot_format.rs)
- Add mobile connector features (app, router, device pairing)
- Plugin system improvements (skald-core)
- Update dependencies (Cargo.lock, Cargo.toml)
- CI/CD: Gitea Actions workflows (nightly + release), package.sh,
  verify-version.sh, builds.skaldagent.net config
This commit is contained in:
2026-07-19 22:35:06 +01:00
parent ba911ae8cb
commit fb3eeeeec6
54 changed files with 823 additions and 8002 deletions
@@ -0,0 +1,6 @@
{
"plugin.mobile-connector.err.relay_not_connected": "Relay not connected. Set the connector's relay_url and make sure the relay is reachable, then try again.",
"plugin.mobile-connector.err.admin_only": "Admin only.",
"plugin.mobile-connector.err.user_id_empty": "The user must not be empty.",
"plugin.mobile-connector.err.pubkey_hex": "The device key must be 32-byte hex."
}
@@ -0,0 +1,6 @@
{
"plugin.mobile-connector.err.relay_not_connected": "Relais non connecté. Renseignez le relay_url du connecteur et assurez-vous que le relais est joignable, puis réessayez.",
"plugin.mobile-connector.err.admin_only": "Administrateur uniquement.",
"plugin.mobile-connector.err.user_id_empty": "L'utilisateur ne doit pas être vide.",
"plugin.mobile-connector.err.pubkey_hex": "La clé de l'appareil doit être en hexadécimal de 32 octets."
}
@@ -0,0 +1,6 @@
{
"plugin.mobile-connector.err.relay_not_connected": "Relay non connesso. Imposta il relay_url del connettore e assicurati che il relay sia raggiungibile, poi riprova.",
"plugin.mobile-connector.err.admin_only": "Solo amministratore.",
"plugin.mobile-connector.err.user_id_empty": "L'utente non può essere vuoto.",
"plugin.mobile-connector.err.pubkey_hex": "La chiave del dispositivo deve essere esadecimale di 32 byte."
}
+13
View File
@@ -24,6 +24,7 @@ use tokio_util::sync::CancellationToken;
use tracing::{debug, info, warn};
use core_api::config_api::ConfigApi;
use core_api::i18n::I18nApi;
use core_api::user_channel::UserChannelApi;
use skald_relay_client::{ClientState, RelayClient, RelayEvent};
@@ -39,6 +40,9 @@ pub struct RelayApp {
pub(crate) user_channel: Arc<dyn UserChannelApi>,
/// Config store — used to persist binding removals (logout/revoke).
config: Arc<dyn ConfigApi>,
/// Backend localization — turns a namespaced key into text in the caller's
/// language for the router's error/response strings.
i18n: Arc<dyn I18nApi>,
/// Device→user bindings, cached in memory; kept in sync by `auth::config_listener`.
pub(crate) bindings: RwLock<MobileConfig>,
/// When true, a freshly paired device stays Pending until an admin binds it
@@ -60,10 +64,12 @@ pub struct RelayApp {
}
impl RelayApp {
#[allow(clippy::too_many_arguments)]
pub fn new(
client: Arc<RelayClient>,
user_channel: Arc<dyn UserChannelApi>,
config: Arc<dyn ConfigApi>,
i18n: Arc<dyn I18nApi>,
bindings: MobileConfig,
require_device_confirmation: bool,
notify_delay: Duration,
@@ -73,6 +79,7 @@ impl RelayApp {
client,
user_channel,
config,
i18n,
bindings: RwLock::new(bindings),
require_device_confirmation,
notify_delay,
@@ -100,6 +107,12 @@ impl RelayApp {
&self.client
}
/// Backend localizer — the router resolves its error strings to the caller's
/// language through this (`app.i18n().for_user(user_id, key, &[])`).
pub(crate) fn i18n(&self) -> &Arc<dyn I18nApi> {
&self.i18n
}
/// Cancellation token for this run's spawned tasks.
pub(crate) fn cancel(&self) -> CancellationToken {
self.cancel.clone()
@@ -0,0 +1,35 @@
//! Backend translation bundles for the mobile-connector.
//!
//! These are the plugin's **backend** strings — the error/response text its
//! router returns, resolved to the caller's language via `PluginContext.i18n`
//! (see `core_api::i18n`). The frontend fragment's UI strings live separately in
//! `web/i18n.js` (registered client-side); the two sets barely overlap, so each
//! side owns its own table rather than sharing one over an endpoint.
//!
//! The tables ship as JSON embedded at compile time — one file per locale, keys
//! namespaced `plugin.mobile-connector.*`. A malformed file is skipped (its
//! locale simply falls back to English) rather than failing the build path.
use std::collections::HashMap;
use core_api::i18n::LocaleBundle;
/// Every locale bundle this plugin contributes, parsed from the embedded JSON.
pub fn bundles() -> Vec<LocaleBundle> {
[
("en", include_str!("../i18n/en.json")),
("it", include_str!("../i18n/it.json")),
("fr", include_str!("../i18n/fr.json")),
]
.into_iter()
.filter_map(|(locale, raw)| {
match serde_json::from_str::<HashMap<String, String>>(raw) {
Ok(strings) => Some(LocaleBundle::new(locale, strings)),
Err(e) => {
tracing::warn!(locale, error = %e, "mobile-connector i18n bundle failed to parse");
None
}
}
})
.collect()
}
@@ -31,6 +31,7 @@ mod agent;
mod app;
mod auth;
mod events;
mod i18n;
mod notifier;
mod payloads;
mod proxy;
@@ -140,6 +141,7 @@ impl MobileConnectorPlugin {
Arc::clone(&client),
Arc::clone(&ctx.user_channel),
Arc::clone(&ctx.config),
Arc::clone(&ctx.i18n),
bindings,
require_device_confirmation,
notify_delay,
@@ -339,6 +341,12 @@ impl Plugin for MobileConnectorPlugin {
crate::tools::mobile_tools(self)
}
/// Backend translation tables — the router's error/response strings,
/// namespaced `plugin.mobile-connector.*`. See `crate::i18n`.
fn i18n(&self) -> Vec<core_api::i18n::LocaleBundle> {
crate::i18n::bundles()
}
fn as_any(&self) -> &dyn std::any::Any { self }
fn as_arc_any(self: Arc<Self>) -> Arc<dyn std::any::Any + Send + Sync> { self }
}
+24 -12
View File
@@ -36,6 +36,14 @@ use crate::PLUGIN_ID;
/// Cloned cheaply and safely shared between the plugin and the router.
type StateCell = Arc<Mutex<Option<Arc<RelayApp>>>>;
// Namespaced i18n keys for the router's user-facing strings (backend tables in
// `../i18n/*.json`). Resolved to the caller's language via `app.i18n()`. Every
// use sits after `admin_app`, so the app — hence the localizer — is present.
const KEY_RELAY_NOT_CONNECTED: &str = "plugin.mobile-connector.err.relay_not_connected";
const KEY_ADMIN_ONLY: &str = "plugin.mobile-connector.err.admin_only";
const KEY_USER_ID_EMPTY: &str = "plugin.mobile-connector.err.user_id_empty";
const KEY_PUBKEY_HEX: &str = "plugin.mobile-connector.err.pubkey_hex";
/// Build the plugin's router. Takes the shared state cell so each request
/// resolves the *current* `RelayApp` — not a snapshot from startup.
pub fn build(state_cell: StateCell) -> Router {
@@ -45,6 +53,7 @@ pub fn build(state_cell: StateCell) -> Router {
.route("/web/pairing.js", get(|| async { serve_js(include_str!("../web/pairing.js")) }))
.route("/web/devices.js", get(|| async { serve_js(include_str!("../web/devices.js")) }))
.route("/web/common.js", get(|| async { serve_js(include_str!("../web/common.js")) }))
.route("/web/i18n.js", get(|| async { serve_js(include_str!("../web/i18n.js")) }))
// Admin pairing console API.
.route("/pairing", post(start_pairing).delete(stop_pairing))
.route("/devices", get(list_devices))
@@ -69,7 +78,8 @@ async fn require_admin(app: &RelayApp, caller: &Caller) -> Result<(), Response>
if app.user_channel.plugin_access(PLUGIN_ID, &caller.user_id).await {
Ok(())
} else {
Err((StatusCode::FORBIDDEN, "admin only").into_response())
let msg = app.i18n().for_user(&caller.user_id, KEY_ADMIN_ONLY, &[]).await;
Err((StatusCode::FORBIDDEN, msg).into_response())
}
}
@@ -84,9 +94,14 @@ fn bad_request(msg: impl Into<String>) -> Response {
(StatusCode::BAD_REQUEST, msg.into()).into_response()
}
fn decode_pubkey(hex: &str) -> Result<[u8; 32], Response> {
skald_relay_common::crypto::decode_hex::<32>(hex)
.ok_or_else(|| bad_request("`pubkey` must be 32-byte hex"))
async fn decode_pubkey(app: &RelayApp, caller: &Caller, hex: &str) -> Result<[u8; 32], Response> {
match skald_relay_common::crypto::decode_hex::<32>(hex) {
Some(pk) => Ok(pk),
None => {
let msg = app.i18n().for_user(&caller.user_id, KEY_PUBKEY_HEX, &[]).await;
Err(bad_request(msg))
}
}
}
// ── POST/DELETE /pairing ────────────────────────────────────────────────────────
@@ -110,11 +125,8 @@ async fn start_pairing(
// send `pairing_start` on ("WS outbound channel closed"). Fail with an
// actionable message instead of the transport-level one.
if !app.client().is_connected() {
return (
StatusCode::SERVICE_UNAVAILABLE,
"Relay not connected. Set the connector's relay_url and make sure the relay is reachable, then try again.",
)
.into_response();
let msg = app.i18n().for_user(&caller.user_id, KEY_RELAY_NOT_CONNECTED, &[]).await;
return (StatusCode::SERVICE_UNAVAILABLE, msg).into_response();
}
let ttl = body.ttl.unwrap_or(0).min(600);
app.set_pending_owner(Some(caller.user_id.clone())).await;
@@ -192,9 +204,9 @@ async fn bind_device(
Json(body): Json<BindBody>,
) -> Response {
let app = match admin_app(&cell, &caller).await { Ok(a) => a, Err(r) => return r };
let pk = match decode_pubkey(&body.pubkey) { Ok(p) => p, Err(r) => return r };
let pk = match decode_pubkey(&app, &caller, &body.pubkey).await { Ok(p) => p, Err(r) => return r };
if body.user_id.trim().is_empty() {
return bad_request("`user_id` must not be empty");
return bad_request(app.i18n().for_user(&caller.user_id, KEY_USER_ID_EMPTY, &[]).await);
}
match app.bind_device(pk, body.user_id, body.display).await {
Ok(()) => StatusCode::NO_CONTENT.into_response(),
@@ -214,7 +226,7 @@ async fn revoke_device(
Json(body): Json<RevokeBody>,
) -> Response {
let app = match admin_app(&cell, &caller).await { Ok(a) => a, Err(r) => return r };
let pk = match decode_pubkey(&body.pubkey) { Ok(p) => p, Err(r) => return r };
let pk = match decode_pubkey(&app, &caller, &body.pubkey).await { Ok(p) => p, Err(r) => return r };
match app.revoke_device(pk).await {
Ok(()) => StatusCode::NO_CONTENT.into_response(),
Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
+24 -11
View File
@@ -6,10 +6,23 @@
// `Plugin::web_pages` contract): they talk only to `/api/plugin/<id>/…` and,
// for the user directory used by the reassign dropdown, the host `/api/users`
// (the fragment runs with the logged-in admin's full session privileges).
//
// i18n: the plugin ships its own dictionary (`./i18n.js`) and registers it into
// the host's shared strings via `addStrings` (imported from the app root by the
// absolute `/lib/i18n.js` specifier — the same module the host app uses, so
// `t()` and `locale-changed` are shared). `MobileBase` mixes in `I18nMixin` so
// every fragment re-renders on a language switch. Register once, at module load.
import { LitElement } from 'lit';
import { t, addStrings, I18nMixin } from '/lib/i18n.js';
import STRINGS from './i18n.js';
addStrings(STRINGS);
export { t };
/// JSON fetch that throws the server's error text on non-2xx and tolerates an
/// empty (204) body.
/// empty (204) body. The server's error text is already localized (the backend
/// resolves the caller's locale), so it is safe to surface directly.
export async function jf(url, opts = {}) {
const res = await fetch(url, {
headers: { 'Content-Type': 'application/json', ...(opts.headers || {}) },
@@ -25,27 +38,27 @@ export async function jf(url, opts = {}) {
}
/// Base for the console fragments: renders into light DOM (so Bootstrap classes
/// and the app's theme CSS variables apply) and exposes the plugin's API root
/// from the host-set `plugin-id` attribute.
export class MobileBase extends LitElement {
/// and the app's theme CSS variables apply), re-renders on locale change, and
/// exposes the plugin's API root from the host-set `plugin-id` attribute.
export class MobileBase extends I18nMixin(LitElement) {
createRenderRoot() { return this; }
get api() { return `/api/plugin/${this.getAttribute('plugin-id') || 'mobile-connector'}`; }
}
/// Human-friendly "time ago" for a Unix-ms timestamp (or "—" when absent).
/// Human-friendly, localized "time ago" for a Unix-ms timestamp (or "—" when absent).
export function ago(ms) {
if (!ms) return '—';
if (!ms) return t('plugin.mobile-connector.time.never');
const s = Math.max(0, Math.floor((Date.now() - ms) / 1000));
if (s < 60) return `${s}s ago`;
if (s < 60) return t('plugin.mobile-connector.time.ago_s', { n: s });
const m = Math.floor(s / 60);
if (m < 60) return `${m}m ago`;
if (m < 60) return t('plugin.mobile-connector.time.ago_m', { n: m });
const h = Math.floor(m / 60);
if (h < 24) return `${h}h ago`;
return `${Math.floor(h / 24)}d ago`;
if (h < 24) return t('plugin.mobile-connector.time.ago_h', { n: h });
return t('plugin.mobile-connector.time.ago_d', { n: Math.floor(h / 24) });
}
/// Best-effort device label from the `device_info` JSON a phone sends on hello.
export function deviceLabel(d) {
const info = d.device_info || {};
return info.name || info.model || info.device || d.platform || 'Unknown device';
return info.name || info.model || info.device || d.platform || t('plugin.mobile-connector.devices.unknown');
}
+13 -11
View File
@@ -6,7 +6,9 @@
// from the host `/api/users` (the fragment runs with the admin's session).
// Default-exports the element class; the host registers it.
import { html, nothing } from 'lit';
import { MobileBase, jf, ago, deviceLabel } from './common.js';
import { MobileBase, jf, ago, deviceLabel, t } from './common.js';
const P = 'plugin.mobile-connector';
export default class MobileDevicesPage extends MobileBase {
static get properties() {
@@ -67,7 +69,7 @@ export default class MobileDevicesPage extends MobileBase {
}
async _revoke(pubkey) {
if (!confirm('Revoke this device? It loses access immediately.')) return;
if (!confirm(t(`${P}.devices.revoke_confirm`))) return;
try {
await jf(`${this.api}/devices/revoke`, { method: 'POST', body: JSON.stringify({ pubkey }) });
await this._load();
@@ -79,13 +81,13 @@ export default class MobileDevicesPage extends MobileBase {
return html`
<div class="um-page">
<div class="um-header d-flex justify-content-between align-items-center">
<h2 class="um-title"><i class="bi bi-phone me-2"></i>Mobile devices</h2>
<h2 class="um-title"><i class="bi bi-phone me-2"></i>${t(`${P}.devices.title`)}</h2>
<button class="btn btn-sm btn-outline-secondary" @click=${() => this._load()}>
<i class="bi bi-arrow-repeat me-1"></i>Refresh</button>
<i class="bi bi-arrow-repeat me-1"></i>${t(`${P}.devices.refresh`)}</button>
</div>
<div style="padding:0 1.25rem 1.5rem">
${this._error ? html`<div class="alert alert-danger py-2" style="font-size:.85rem">${this._error}</div>` : nothing}
${loading ? html`<div class="um-empty"><i class="bi bi-hourglass-split"></i> Loading…</div>` : this._renderList()}
${loading ? html`<div class="um-empty"><i class="bi bi-hourglass-split"></i> ${t(`${P}.devices.loading`)}</div>` : this._renderList()}
</div>
</div>`;
}
@@ -94,15 +96,15 @@ export default class MobileDevicesPage extends MobileBase {
const rows = this._devices || [];
if (!rows.length) {
return html`<div class="um-empty" style="padding:1rem">
<i class="bi bi-phone"></i><p>No paired devices yet.</p>
<p style="font-size:.8rem;opacity:.7">Use the <em>Pair a device</em> page to add one.</p>
<i class="bi bi-phone"></i><p>${t(`${P}.devices.empty`)}</p>
<p style="font-size:.8rem;opacity:.7">${t(`${P}.devices.empty_hint`)}</p>
</div>`;
}
return html`
<div class="table-responsive">
<table class="table align-middle" style="font-size:.88rem">
<thead><tr>
<th>Device</th><th>State</th><th>Bound to</th><th>Last seen</th><th class="text-end">Actions</th>
<th>${t(`${P}.devices.col_device`)}</th><th>${t(`${P}.devices.col_state`)}</th><th>${t(`${P}.devices.col_bound`)}</th><th>${t(`${P}.devices.col_last_seen`)}</th><th class="text-end">${t(`${P}.devices.col_actions`)}</th>
</tr></thead>
<tbody>${rows.map(d => this._renderRow(d))}</tbody>
</table>
@@ -119,7 +121,7 @@ export default class MobileDevicesPage extends MobileBase {
${d.pubkey.slice(0, 16)}…</div>
</td>
<td>
<span class="badge ${authorized ? 'text-bg-success' : 'text-bg-secondary'}">${d.state}</span>
<span class="badge ${authorized ? 'text-bg-success' : 'text-bg-secondary'}">${t(`${P}.devices.state_${d.state}`)}</span>
</td>
<td>${d.bound_user ? this._userName(d.bound_user) : html`<span class="text-body-secondary">—</span>`}</td>
<td class="text-body-secondary">${ago(d.last_seen)}</td>
@@ -128,12 +130,12 @@ export default class MobileDevicesPage extends MobileBase {
<select class="form-select form-select-sm" style="width:auto"
.value=${this._pick[d.pubkey] || d.bound_user || ''}
@change=${(e) => { this._pick = { ...this._pick, [d.pubkey]: e.target.value }; }}>
<option value="">Assign to…</option>
<option value="">${t(`${P}.devices.assign_to`)}</option>
${this._users.map(u => html`<option value=${u.id}>${u.display_name || u.username}</option>`)}
</select>
<button class="btn btn-sm btn-primary"
?disabled=${!this._pick[d.pubkey] || this._pick[d.pubkey] === d.bound_user}
@click=${() => this._bind(d.pubkey)}>Bind</button>
@click=${() => this._bind(d.pubkey)}>${t(`${P}.devices.bind`)}</button>
<button class="btn btn-sm btn-outline-danger" @click=${() => this._revoke(d.pubkey)}>
<i class="bi bi-trash"></i></button>
</div>
+116
View File
@@ -0,0 +1,116 @@
// Frontend translations for the mobile-connector page fragments.
//
// Served at `/api/plugin/mobile-connector/web/i18n.js` and imported by
// `common.js`, which registers it into the host's shared dictionaries via
// `addStrings` (see `web/lib/i18n.js`). Keys are namespaced `plugin.mobile-
// connector.*` so they never collide with core keys. These are the *frontend*
// UI strings; the plugin's backend error strings live in `../i18n/*.json` and
// reach the browser already translated as HTTP response text.
const P = 'plugin.mobile-connector';
export default {
en: {
[`${P}.pairing.title`]: 'Pair a device',
[`${P}.pairing.intro`]: 'Open a pairing window, then scan the QR code with the Skald mobile app. The device is linked to you and works immediately — you can reassign it to another user from the Mobile devices page.',
[`${P}.pairing.open`]: 'Open pairing window',
[`${P}.pairing.opening`]: 'Opening…',
[`${P}.pairing.qr_alt`]: 'Pairing QR',
[`${P}.pairing.expired`]: 'Window expired',
[`${P}.pairing.scan_within`]: 'Scan within {n}s',
[`${P}.pairing.new_code`]: 'New code',
[`${P}.pairing.close`]: 'Close',
[`${P}.devices.title`]: 'Mobile devices',
[`${P}.devices.refresh`]: 'Refresh',
[`${P}.devices.loading`]: 'Loading…',
[`${P}.devices.empty`]: 'No paired devices yet.',
[`${P}.devices.empty_hint`]: 'Use the Pair a device page to add one.',
[`${P}.devices.col_device`]: 'Device',
[`${P}.devices.col_state`]: 'State',
[`${P}.devices.col_bound`]: 'Bound to',
[`${P}.devices.col_last_seen`]: 'Last seen',
[`${P}.devices.col_actions`]: 'Actions',
[`${P}.devices.state_authorized`]: 'authorized',
[`${P}.devices.state_pending`]: 'pending',
[`${P}.devices.assign_to`]: 'Assign to…',
[`${P}.devices.bind`]: 'Bind',
[`${P}.devices.revoke_confirm`]: 'Revoke this device? It loses access immediately.',
[`${P}.devices.unknown`]: 'Unknown device',
[`${P}.time.never`]: '—',
[`${P}.time.ago_s`]: '{n}s ago',
[`${P}.time.ago_m`]: '{n}m ago',
[`${P}.time.ago_h`]: '{n}h ago',
[`${P}.time.ago_d`]: '{n}d ago',
},
it: {
[`${P}.pairing.title`]: 'Associa un dispositivo',
[`${P}.pairing.intro`]: 'Apri una finestra di associazione, poi scansiona il codice QR con lapp Skald sul telefono. Il dispositivo viene collegato a te e funziona subito — puoi riassegnarlo a un altro utente dalla pagina Dispositivi mobili.',
[`${P}.pairing.open`]: 'Apri finestra di associazione',
[`${P}.pairing.opening`]: 'Apertura…',
[`${P}.pairing.qr_alt`]: 'QR di associazione',
[`${P}.pairing.expired`]: 'Finestra scaduta',
[`${P}.pairing.scan_within`]: 'Scansiona entro {n}s',
[`${P}.pairing.new_code`]: 'Nuovo codice',
[`${P}.pairing.close`]: 'Chiudi',
[`${P}.devices.title`]: 'Dispositivi mobili',
[`${P}.devices.refresh`]: 'Aggiorna',
[`${P}.devices.loading`]: 'Caricamento…',
[`${P}.devices.empty`]: 'Nessun dispositivo associato.',
[`${P}.devices.empty_hint`]: 'Usa la pagina Associa un dispositivo per aggiungerne uno.',
[`${P}.devices.col_device`]: 'Dispositivo',
[`${P}.devices.col_state`]: 'Stato',
[`${P}.devices.col_bound`]: 'Assegnato a',
[`${P}.devices.col_last_seen`]: 'Ultimo accesso',
[`${P}.devices.col_actions`]: 'Azioni',
[`${P}.devices.state_authorized`]: 'autorizzato',
[`${P}.devices.state_pending`]: 'in attesa',
[`${P}.devices.assign_to`]: 'Assegna a…',
[`${P}.devices.bind`]: 'Associa',
[`${P}.devices.revoke_confirm`]: 'Revocare questo dispositivo? Perderà laccesso immediatamente.',
[`${P}.devices.unknown`]: 'Dispositivo sconosciuto',
[`${P}.time.never`]: '—',
[`${P}.time.ago_s`]: '{n}s fa',
[`${P}.time.ago_m`]: '{n}m fa',
[`${P}.time.ago_h`]: '{n}h fa',
[`${P}.time.ago_d`]: '{n}g fa',
},
fr: {
[`${P}.pairing.title`]: 'Associer un appareil',
[`${P}.pairing.intro`]: 'Ouvrez une fenêtre dassociation, puis scannez le QR code avec lapp mobile Skald. Lappareil est lié à vous et fonctionne immédiatement — vous pouvez le réassigner à un autre utilisateur depuis la page Appareils mobiles.',
[`${P}.pairing.open`]: 'Ouvrir la fenêtre dassociation',
[`${P}.pairing.opening`]: 'Ouverture…',
[`${P}.pairing.qr_alt`]: 'QR dassociation',
[`${P}.pairing.expired`]: 'Fenêtre expirée',
[`${P}.pairing.scan_within`]: 'Scannez sous {n}s',
[`${P}.pairing.new_code`]: 'Nouveau code',
[`${P}.pairing.close`]: 'Fermer',
[`${P}.devices.title`]: 'Appareils mobiles',
[`${P}.devices.refresh`]: 'Actualiser',
[`${P}.devices.loading`]: 'Chargement…',
[`${P}.devices.empty`]: 'Aucun appareil associé.',
[`${P}.devices.empty_hint`]: 'Utilisez la page Associer un appareil pour en ajouter un.',
[`${P}.devices.col_device`]: 'Appareil',
[`${P}.devices.col_state`]: 'État',
[`${P}.devices.col_bound`]: 'Assigné à',
[`${P}.devices.col_last_seen`]: 'Vu la dernière fois',
[`${P}.devices.col_actions`]: 'Actions',
[`${P}.devices.state_authorized`]: 'autorisé',
[`${P}.devices.state_pending`]: 'en attente',
[`${P}.devices.assign_to`]: 'Assigner à…',
[`${P}.devices.bind`]: 'Associer',
[`${P}.devices.revoke_confirm`]: 'Révoquer cet appareil ? Il perd laccès immédiatement.',
[`${P}.devices.unknown`]: 'Appareil inconnu',
[`${P}.time.never`]: '—',
[`${P}.time.ago_s`]: 'il y a {n}s',
[`${P}.time.ago_m`]: 'il y a {n}m',
[`${P}.time.ago_h`]: 'il y a {n}h',
[`${P}.time.ago_d`]: 'il y a {n}j',
},
};
+11 -11
View File
@@ -6,7 +6,9 @@
// is usable on the phone immediately and can be reassigned later from the
// Devices page. Default-exports the element class; the host registers it.
import { html, nothing } from 'lit';
import { MobileBase, jf } from './common.js';
import { MobileBase, jf, t } from './common.js';
const P = 'plugin.mobile-connector';
export default class MobilePairingPage extends MobileBase {
static get properties() {
@@ -73,36 +75,34 @@ export default class MobilePairingPage extends MobileBase {
return html`
<div class="um-page">
<div class="um-header">
<h2 class="um-title"><i class="bi bi-qr-code me-2"></i>Pair a device</h2>
<h2 class="um-title"><i class="bi bi-qr-code me-2"></i>${t(`${P}.pairing.title`)}</h2>
</div>
<div style="padding:0 1.25rem 1.5rem; max-width:640px">
${this._error ? html`<div class="alert alert-danger py-2" style="font-size:.85rem">${this._error}</div>` : nothing}
${!this._session ? html`
<p class="text-body-secondary" style="font-size:.9rem">
Open a pairing window, then scan the QR code with the Skald mobile app.
The device is linked to <strong>you</strong> and works immediately — you can
reassign it to another user from the <em>Mobile devices</em> page.
${t(`${P}.pairing.intro`)}
</p>
<button class="btn btn-primary" ?disabled=${this._busy} @click=${() => this._open()}>
<i class="bi bi-qr-code-scan me-1"></i>${this._busy ? 'Opening…' : 'Open pairing window'}
<i class="bi bi-qr-code-scan me-1"></i>${this._busy ? t(`${P}.pairing.opening`) : t(`${P}.pairing.open`)}
</button>
` : html`
<div class="d-flex flex-column align-items-center gap-3 p-3"
style="border:1px solid var(--border-color,#ddd); border-radius:var(--radius-md,12px)">
<img src=${this._session.url} alt="Pairing QR" width="256" height="256"
<img src=${this._session.url} alt=${t(`${P}.pairing.qr_alt`)} width="256" height="256"
style="image-rendering:pixelated; ${expired ? 'opacity:.25' : ''}" />
${expired
? html`<div class="text-danger" style="font-size:.9rem"><i class="bi bi-clock-history me-1"></i>Window expired</div>`
? html`<div class="text-danger" style="font-size:.9rem"><i class="bi bi-clock-history me-1"></i>${t(`${P}.pairing.expired`)}</div>`
: html`<div class="text-body-secondary" style="font-size:.9rem">
Scan within <strong>${this._remain}s</strong>
${t(`${P}.pairing.scan_within`, { n: this._remain })}
</div>`}
<div class="d-flex gap-2">
${expired
? html`<button class="btn btn-primary btn-sm" @click=${() => this._open()}>
<i class="bi bi-arrow-repeat me-1"></i>New code</button>`
<i class="bi bi-arrow-repeat me-1"></i>${t(`${P}.pairing.new_code`)}</button>`
: html`<button class="btn btn-outline-secondary btn-sm" @click=${() => this._stop()}>
<i class="bi bi-x-lg me-1"></i>Close</button>`}
<i class="bi bi-x-lg me-1"></i>${t(`${P}.pairing.close`)}</button>`}
</div>
</div>
`}