In Docker lasciare la pagina «Browser» o la vista remota di Collegamento mentre Alberto guida (un'altra pagina, la scheda chiusa, il collegamento perso) valeva «Annulla» e la sessione non si copiava. Ora è come chiudere la finestra del browser su Windows: `cancel` con `pageLeft` va a LeavePageAsync, la vista remota chiusa dalla sua pagina lo dice alla connessione, e se per 5 secondi non si apre un'altra vista né arriva un `begin` (una pagina ricaricata) il controllo del permesso copia la sessione con CopyOnLetGoAsync, solo da una pagina del sito che non sia di accesso o di verifica, poi rilascia il permesso e il motore rimette il browser a riposo. Il pulsante «Annulla» continua a non copiare; Windows non cambia. Prove nuove per la copia lasciando la pagina, la ricarica che non è lasciare, la pagina di accesso, la vista sostituita o chiusa da Febe; guida, protocollo e una riga in decisioni.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
2.7 KiB
JavaScript
52 lines
2.7 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. Leaving the page without «Ho finito»
|
|
// (another page, a reload, closing the tab) gives the browser back, like closing the window on Windows: the server copies
|
|
// the session if no view opens again within a moment (on Windows the window stays as it is until Alberto closes it). A browser at rest opens its start page; «?accesso=1» (the red strip of a disconnection)
|
|
// opens the login page, once: the parameter leaves the address straight away.
|
|
|
|
import { api } from '../core/api.js';
|
|
import { caps } from '../core/context.js';
|
|
import { h, icon, fill } from '../core/dom.js';
|
|
import { navigate, setQuery } from '../core/shell.js';
|
|
import { t } from '../core/text.js';
|
|
import { toast } from '../core/ui.js';
|
|
import { drivingLease, 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
|
|
}
|
|
if (page.signal.aborted) return;
|
|
const lease = drivingLease(page);
|
|
const login = new URLSearchParams(location.search).get('accesso') === '1';
|
|
lease.begin(login);
|
|
// Asked once: a reload of the page, or the tab restored later, must not open the login page again.
|
|
if (login) setQuery({ accesso: null });
|
|
const message = h('div', { 'aria-live': 'polite' });
|
|
const done = async () => {
|
|
const result = await finishDriving();
|
|
if (!result) return;
|
|
// «Ho finito» gives the browser back on the server whatever the answer.
|
|
lease.settled();
|
|
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: login || (status && status.state === 'notConnected') }).element,
|
|
passwordNote(windows)));
|
|
},
|
|
};
|