Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
826c471ed7 | ||
|
|
817fb743de |
+77
-4
@@ -3508,14 +3508,50 @@ function shareChoice() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function shareBase() {
|
/* This Mac on the church network. The operator page lives here and NOWHERE
|
||||||
|
else: it returns 404 to anything arriving through a proxy, by design. */
|
||||||
|
function lanBase() {
|
||||||
const c = shareChoice();
|
const c = shareChoice();
|
||||||
if (!c || c.none) return '';
|
if (!c || c.none) return '';
|
||||||
return 'http://' + c.addr.address + ':' + state.local.port;
|
return 'http://' + c.addr.address + ':' + state.local.port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* WHAT THE CONGREGATION OPENS.
|
||||||
|
*
|
||||||
|
* A church that has put this on a domain has said so in the operator page's
|
||||||
|
* Public address, and from that moment the LAN address is the wrong thing to
|
||||||
|
* print: it is not what is on the poster, not what the QR should encode, and
|
||||||
|
* not what someone off the building's wifi can reach. The app window went on
|
||||||
|
* showing the IP anyway, because this half of it never read that setting --
|
||||||
|
* the operator page honoured it and the main window did not, so the two
|
||||||
|
* disagreed about the one fact they both exist to display.
|
||||||
|
*/
|
||||||
|
function publicBaseConfigured() {
|
||||||
|
const u = opConfig && typeof opConfig.publicUrl === 'string' ? opConfig.publicUrl.trim() : '';
|
||||||
|
return u ? u.replace(/\/+$/, '') : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function shareBase() {
|
||||||
|
return publicBaseConfigured() || lanBase();
|
||||||
|
}
|
||||||
|
|
||||||
function renderQrWarning() {
|
function renderQrWarning() {
|
||||||
const el = $('qrWarn');
|
const el = $('qrWarn');
|
||||||
|
/*
|
||||||
|
* On a domain the warnings below are about an address nobody is being
|
||||||
|
* given any more. Saying "Wi-Fi is down, phones cannot reach the code"
|
||||||
|
* while the code points at a proxy would send the desk after the wrong
|
||||||
|
* thing entirely.
|
||||||
|
*/
|
||||||
|
const pub = publicBaseConfigured();
|
||||||
|
if (pub) {
|
||||||
|
el.hidden = false;
|
||||||
|
el.textContent = 'The code points at ' + pub + ', set as the public address. ' +
|
||||||
|
'This Mac still has to be reachable from there; its own address is ' +
|
||||||
|
(lanBase() || 'unavailable') + '.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
const c = shareChoice();
|
const c = shareChoice();
|
||||||
if (!c) { el.hidden = true; return; }
|
if (!c) { el.hidden = true; return; }
|
||||||
|
|
||||||
@@ -3566,6 +3602,26 @@ function renderShare() {
|
|||||||
const list = state.local.addresses || [];
|
const list = state.local.addresses || [];
|
||||||
const box = $('addrList');
|
const box = $('addrList');
|
||||||
box.textContent = '';
|
box.textContent = '';
|
||||||
|
/*
|
||||||
|
* WHICH INTERFACE THE QR USES IS A QUESTION ONLY A LAN SETUP HAS.
|
||||||
|
*
|
||||||
|
* These rows let the operator pick the address the code points at. Once a
|
||||||
|
* public address is configured the code points at the domain whatever they
|
||||||
|
* pick, so the list is a row of numbers that do nothing — and the one
|
||||||
|
* marked IN USE is not the address anyone is being given. Hide it.
|
||||||
|
*/
|
||||||
|
const addrBox = $('addrList');
|
||||||
|
addrBox.hidden = !!publicBaseConfigured();
|
||||||
|
if (addrBox.hidden) {
|
||||||
|
/* Still draw the code itself — it is the only thing left in this panel. */
|
||||||
|
const only = shareBase();
|
||||||
|
$('qr').src = only
|
||||||
|
? 'http://127.0.0.1:' + state.local.port + '/qr.svg?url=' + encodeURIComponent(only + '/')
|
||||||
|
: '';
|
||||||
|
renderQrWarning();
|
||||||
|
renderOperatorUrl();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Mark the row the QR is actually using, not the row that was saved — when
|
/* Mark the row the QR is actually using, not the row that was saved — when
|
||||||
a lease moves those are two different things and the saved one is gone. */
|
a lease moves those are two different things and the saved one is gone. */
|
||||||
@@ -3607,8 +3663,22 @@ $('copyAddr').addEventListener('click', () => {
|
|||||||
.catch((err) => log('could not copy: ' + err.message, 'err'));
|
.catch((err) => log('could not copy: ' + err.message, 'err'));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('openPoster').addEventListener('click', () => {
|
/*
|
||||||
window.open('http://127.0.0.1:' + state.local.port + '/poster', '_blank');
|
* The QR itself, saved as a file, because the poster people actually print
|
||||||
|
* is made in their own design tool. The built-in poster page is still there
|
||||||
|
* at /poster for anyone who wants it; it is just not what this button does.
|
||||||
|
*/
|
||||||
|
$('saveQr').addEventListener('click', () => {
|
||||||
|
const base = shareBase();
|
||||||
|
if (!base) { log('no address to encode yet', 'err'); return; }
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = 'http://127.0.0.1:' + state.local.port + '/qr.svg?url=' +
|
||||||
|
encodeURIComponent(base + '/');
|
||||||
|
a.download = 'church-translate-qr.svg';
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
a.remove();
|
||||||
|
log('saved the QR for ' + base + '/', 'ok');
|
||||||
});
|
});
|
||||||
$('openOperator').addEventListener('click', () => {
|
$('openOperator').addEventListener('click', () => {
|
||||||
window.open('http://127.0.0.1:' + state.local.port + '/operator', '_blank');
|
window.open('http://127.0.0.1:' + state.local.port + '/operator', '_blank');
|
||||||
@@ -3665,7 +3735,8 @@ function renderBuildTag() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderOperatorUrl() {
|
function renderOperatorUrl() {
|
||||||
const base = shareBase();
|
/* Deliberately lanBase, not shareBase: over a proxy /operator is a 404. */
|
||||||
|
const base = lanBase();
|
||||||
$('opPageUrl').textContent = base ? base + '/operator' : 'no network';
|
$('opPageUrl').textContent = base ? base + '/operator' : 'no network';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3968,6 +4039,7 @@ async function loadOperator() {
|
|||||||
try {
|
try {
|
||||||
const j = await opApi('/api/config');
|
const j = await opApi('/api/config');
|
||||||
opConfig = j.config;
|
opConfig = j.config;
|
||||||
|
renderShare(); /* publicUrl may have just arrived */
|
||||||
clearTimeout(opLoadTimer); opLoadTimer = null; // it answered; stop retrying
|
clearTimeout(opLoadTimer); opLoadTimer = null; // it answered; stop retrying
|
||||||
opRetryMs = 0;
|
opRetryMs = 0;
|
||||||
renderOpLanguages();
|
renderOpLanguages();
|
||||||
@@ -4022,6 +4094,7 @@ async function opSave(patch, okMsg) {
|
|||||||
try {
|
try {
|
||||||
const j = await opApi('/api/config', { method: 'POST', body: JSON.stringify(patch) });
|
const j = await opApi('/api/config', { method: 'POST', body: JSON.stringify(patch) });
|
||||||
opConfig = j.config;
|
opConfig = j.config;
|
||||||
|
renderShare(); /* publicUrl may have just arrived */
|
||||||
if (okMsg) log(okMsg, 'ok');
|
if (okMsg) log(okMsg, 'ok');
|
||||||
return j;
|
return j;
|
||||||
} catch (e) { log('could not save: ' + e.message, 'err'); throw e; }
|
} catch (e) { log('could not save: ' + e.message, 'err'); throw e; }
|
||||||
|
|||||||
+1
-1
@@ -433,7 +433,7 @@
|
|||||||
<div id="addrList" class="addrlist"></div>
|
<div id="addrList" class="addrlist"></div>
|
||||||
<div class="railbtns">
|
<div class="railbtns">
|
||||||
<button class="btn btn-primary" id="copyAddr">Copy address</button>
|
<button class="btn btn-primary" id="copyAddr">Copy address</button>
|
||||||
<button class="btn" id="openPoster">Printable poster</button>
|
<button class="btn" id="saveQr">Save QR image</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h3 class="subhead">Operator page</h3>
|
<h3 class="subhead">Operator page</h3>
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@
|
|||||||
"name": "church-translate-engine",
|
"name": "church-translate-engine",
|
||||||
"productName": "Church Translate",
|
"productName": "Church Translate",
|
||||||
"version": "3.23.2",
|
"version": "3.23.2",
|
||||||
"buildNumber": 121,
|
"buildNumber": 123,
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Live sermon translation — self-contained: captures audio, transcribes, translates, and serves the congregation page itself",
|
"description": "Live sermon translation — self-contained: captures audio, transcribes, translates, and serves the congregation page itself",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"asar": false,
|
"asar": false,
|
||||||
"buildVersion": "121",
|
"buildVersion": "123",
|
||||||
"win": {
|
"win": {
|
||||||
"target": [
|
"target": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user