Files
Febe/src/Febe.Web/wwwroot/js/pages/browser.js
T

42 lines
1.8 KiB
JavaScript

// Browser (spec §10.3 «Apri il browser»; mockup 10 without the steps column): in Docker the remote view of the
// server's browser and «Ho finito»; on Windows the browser is its own window. While Alberto uses the browser the
// engine is still; «Ho finito» lets «Riprendi» become active after a verification.
import { api } from '../core/api.js';
import { caps } from '../core/context.js';
import { h, icon, fill } from '../core/dom.js';
import { navigate } from '../core/shell.js';
import { t } from '../core/text.js';
import { toast } from '../core/ui.js';
import { beginDriving, finishDriving, passwordNote, windowPanel } from './connection.js';
import { remoteView } from './remote-view.js';
export default {
async mount(page) {
page.title(t('browser.titolo'));
const windows = caps().browserWindow;
let status = null;
try {
status = await api('/api/connection', { signal: page.signal });
} catch {
// the view says whether the browser answers
}
beginDriving(false);
const message = h('div', { 'aria-live': 'polite' });
const done = async () => {
const result = await finishDriving();
if (!result) return;
toast(result.message, result.connected ? '' : 'errore');
if (result.connected) navigate('/attivita');
else fill(message, h('div.avviso.rosso', icon('octagon-alert', 's'), h('span', result.message)));
};
page.saveBar(h('div', { style: { display: 'contents' } },
h('span.nota', t('browser.aiuto')),
h('div.destra', h('button.btn.primo.grande', { type: 'button', onclick: done }, t('impostazioni.collegamento.hoFinito')))));
fill(page.body, h('div.pagina-browser',
message,
windows ? windowPanel() : remoteView(page, { url: status && status.currentUrl, login: status && status.state === 'notConnected' }).element,
passwordNote(windows)));
},
};