luci: handle oversized peer config QR generation gracefully (#118)
Catch QR rendering failures when exporting peer configurations and show a user-facing message instead of failing silently (for example when large I1-I5 values present).
This commit is contained in:
@@ -72,9 +72,25 @@ function buildSVGQRCode(data, code) {
|
|||||||
whiteColor: 'white',
|
whiteColor: 'white',
|
||||||
blackColor: 'black'
|
blackColor: 'black'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
const svg = uqr.renderSVG(data, options);
|
const svg = uqr.renderSVG(data, options);
|
||||||
code.style.opacity = '';
|
code.style.opacity = '';
|
||||||
dom.content(code, Object.assign(E(svg), { style: 'width:100%;height:auto' }));
|
dom.content(code, Object.assign(E(svg), {
|
||||||
|
style: 'width:100%;height:auto'
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.warn('QR generation failed:', e);
|
||||||
|
|
||||||
|
code.style.opacity = '';
|
||||||
|
dom.content(code, E('div', {
|
||||||
|
'class': 'alert-message warning',
|
||||||
|
'style': 'margin:0;text-align:center'
|
||||||
|
}, [
|
||||||
|
_('QR code generation failed. The configuration may be too large.')
|
||||||
|
]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var cbiKeyPairGenerate = form.DummyValue.extend({
|
var cbiKeyPairGenerate = form.DummyValue.extend({
|
||||||
|
|||||||
Reference in New Issue
Block a user