mirror of
https://github.com/itdoginfo/podkop.git
synced 2026-01-06 08:38:52 +03:00
feat(podkop): add show config feature
- Add new button to show config with masked sensitive data - Update init script with new command `show_config` - Implement `show_config` function to mask sensitive data - Update version in config file to 0.3.3 - Update proxy check logic for better error handling
This commit is contained in:
@@ -7,10 +7,28 @@
|
||||
|
||||
return view.extend({
|
||||
async render() {
|
||||
document.getElementsByTagName('head')[0].insertAdjacentHTML('beforeend', `
|
||||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
`);
|
||||
|
||||
var m, s, o;
|
||||
|
||||
m = new form.Map('podkop', _('Podkop configuration'), null, ['main', 'second']);
|
||||
|
||||
m = new form.Map('podkop', _('Podkop'), null, ['main', 'second']);
|
||||
L.uci.load('podkop').then(() => {
|
||||
const version = L.uci.get('podkop', 'main', 'version') || '';
|
||||
if (version) {
|
||||
m.title = _('Podkop') + ' v' + version;
|
||||
if (!window.location.search.includes('v=')) {
|
||||
const newUrl = window.location.pathname + '?v=' + version;
|
||||
window.history.replaceState(null, '', newUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
s = m.section(form.TypedSection, 'main');
|
||||
s.anonymous = true;
|
||||
|
||||
@@ -552,6 +570,50 @@ return view.extend({
|
||||
});
|
||||
};
|
||||
|
||||
o = s.taboption('diagnostics', form.Button, '_show_config');
|
||||
o.title = _('Show Config');
|
||||
o.description = _('Show current podkop configuration with masked sensitive data');
|
||||
o.inputtitle = _('Show Config');
|
||||
o.inputstyle = 'apply';
|
||||
o.onclick = function () {
|
||||
return fs.exec('/etc/init.d/podkop', ['show_config'])
|
||||
.then(function (res) {
|
||||
const formattedOutput = formatDiagnosticOutput(res.stdout || _('No output'));
|
||||
|
||||
const modalElement = ui.showModal(_('Podkop Configuration'), [
|
||||
E('div', { class: 'cbi-section' }, [
|
||||
E('pre', { class: 'cbi-value-field' }, formattedOutput)
|
||||
]),
|
||||
E('div', { style: 'display: flex; justify-content: space-between; margin-top: 1em;' }, [
|
||||
E('button', {
|
||||
'class': 'btn cbi-button-save',
|
||||
'click': function () {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = '```\n' + formattedOutput + '\n```';
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
ui.hideModal();
|
||||
} catch (err) {
|
||||
ui.addNotification(null, E('p', {}, _('Failed to copy: ') + err.message));
|
||||
}
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
}, _('Copy to Clipboard')),
|
||||
E('button', {
|
||||
'class': 'btn cbi-button-neutral',
|
||||
'click': ui.hideModal
|
||||
}, _('Close'))
|
||||
])
|
||||
], 'large');
|
||||
|
||||
if (modalElement && modalElement.parentElement) {
|
||||
modalElement.parentElement.classList.add('modal-overlay-large');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
o = s.taboption('diagnostics', form.Button, '_list_update');
|
||||
o.title = _('Update lists');
|
||||
o.description = _('Update all lists in config');
|
||||
|
||||
Reference in New Issue
Block a user