- Rebrand: new app/agent icons, SKALD.md, warm "paper" CSS palette (terracotta accent, --radius tokens, WCAG contrast, reduced-motion), updated favicon, tray icon, skaldkonur asset - i18n: backend crate (i18n.rs, locale column, ui_locale config), frontend library (web/lib/i18n.js, I18nMixin, t(key)), translation files (web/i18n/), every component wired - Dashboard: <dashboard-page> replaces old home-page content; <app-copilot> becomes the landing page (full/dock layout modes) - Shared folders: API endpoints (shared_folders.rs), frontend page, can_write membership, container mount topology, user_fs routing - Role capabilities: new db table & authorization seam (data not enums), roles.attrs JSON for ui_mode / interface select - Setup: skald-setup prompts for language + password, sets ui_locale - General: components migrated to CSS variables, Lit conventions cleanup, connectors/catalog/marketplace/approval refactoring
79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
import { html, nothing } from 'lit';
|
|
import { t } from '../lib/i18n.js';
|
|
import { FileViewerBase } from './shared/file-viewer-base.js';
|
|
|
|
const PAGE_ID = 'file_viewer';
|
|
|
|
function pathFromHash() {
|
|
const h = location.hash;
|
|
const prefix = `#${PAGE_ID}?path=`;
|
|
if (!h.startsWith(prefix)) return null;
|
|
try {
|
|
return decodeURIComponent(h.slice(prefix.length));
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Desktop file-viewer page. Self-routes off the hash (`#file_viewer?path=...`):
|
|
* the sidebar's `llm-page-change` event toggles visibility and `hashchange`
|
|
* re-loads. All fetch/render/watch logic lives in `FileViewerBase`; this
|
|
* subclass only adds the desktop chrome and the hash wiring.
|
|
*/
|
|
export class FileViewerPage extends FileViewerBase {
|
|
static properties = {
|
|
_open: { state: true },
|
|
};
|
|
|
|
constructor() {
|
|
super();
|
|
this._open = false;
|
|
}
|
|
|
|
connectedCallback() {
|
|
super.connectedCallback();
|
|
window.addEventListener('llm-page-change', (e) => {
|
|
this._open = e.detail.page === PAGE_ID;
|
|
this.style.display = this._open ? 'flex' : 'none';
|
|
if (this._open) this._loadFromHash();
|
|
else this._hide();
|
|
});
|
|
window.addEventListener('hashchange', () => {
|
|
if (this._open) this._loadFromHash();
|
|
});
|
|
}
|
|
|
|
_loadFromHash() {
|
|
const path = pathFromHash();
|
|
if (path) this._show(path);
|
|
}
|
|
|
|
_back() {
|
|
history.back();
|
|
}
|
|
|
|
render() {
|
|
if (!this._open) return nothing;
|
|
return html`
|
|
<div class="llm-page fv-page">
|
|
<div class="llm-page-header">
|
|
<div class="llm-header-left">
|
|
<button class="btn btn-sm btn-outline-secondary back-btn" title=${t('fv.back')} @click=${() => this._back()}>
|
|
<i class="bi bi-arrow-left"></i>
|
|
</button>
|
|
<h2 class="llm-page-title fv-title" title=${this._path ?? ''}><bdi>${this._path ?? ''}</bdi></h2>
|
|
</div>
|
|
<div class="fv-header-actions">
|
|
${this._renderModeToggle('btn btn-sm btn-outline-secondary fv-download-btn')}
|
|
<button class="btn btn-sm btn-outline-secondary fv-download-btn" title=${t('fv.download')} @click=${() => this._download()}>
|
|
<i class="bi bi-download"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="fv-body">${this._renderBody()}</div>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|