Restore console config values only when necessary
This reduces the need of unnecessary HTTP requests. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
f9600ddcd8
commit
e299aef4b4
@ -176,13 +176,35 @@ var Console = {
|
||||
consoleContent.classList.toggle('console_dark_theme', isDarkTheme);
|
||||
});
|
||||
|
||||
$('#pma_console_options').find('.button.default').on('click', function () {
|
||||
(document.getElementById('consoleOptionsAlwaysExpandCheckbox') as HTMLInputElement).checked = false;
|
||||
(document.getElementById('consoleOptionsStartHistoryCheckbox') as HTMLInputElement).checked = false;
|
||||
(document.getElementById('consoleOptionsCurrentQueryCheckbox') as HTMLInputElement).checked = true;
|
||||
(document.getElementById('consoleOptionsEnterExecutesCheckbox') as HTMLInputElement).checked = false;
|
||||
(document.getElementById('consoleOptionsDarkThemeCheckbox') as HTMLInputElement).checked = false;
|
||||
Config.update();
|
||||
const restoreConsoleOptionsButton = document.getElementById('pma_console_options').querySelector('.button.default');
|
||||
restoreConsoleOptionsButton?.addEventListener('click', function (): void {
|
||||
if (consoleOptionsAlwaysExpandCheckbox.checked) {
|
||||
consoleOptionsAlwaysExpandCheckbox.checked = false;
|
||||
Config.set('AlwaysExpand', false);
|
||||
}
|
||||
|
||||
if (consoleOptionsStartHistoryCheckbox.checked) {
|
||||
consoleOptionsStartHistoryCheckbox.checked = false;
|
||||
Config.set('StartHistory', false);
|
||||
}
|
||||
|
||||
if (! consoleOptionsCurrentQueryCheckbox.checked) {
|
||||
consoleOptionsCurrentQueryCheckbox.checked = true;
|
||||
Config.set('CurrentQuery', true);
|
||||
}
|
||||
|
||||
if (consoleOptionsEnterExecutesCheckbox.checked) {
|
||||
consoleOptionsEnterExecutesCheckbox.checked = false;
|
||||
Config.set('EnterExecutes', false);
|
||||
ConsoleMessages.showInstructions(false);
|
||||
}
|
||||
|
||||
if (consoleOptionsDarkThemeCheckbox.checked) {
|
||||
consoleOptionsDarkThemeCheckbox.checked = false;
|
||||
Config.set('DarkTheme', false);
|
||||
const consoleContent = document.getElementById('pma_console').querySelector('.content');
|
||||
consoleContent.classList.remove('console_dark_theme');
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('ajaxComplete', function (event, xhr, ajaxOptions) {
|
||||
|
||||
@ -69,24 +69,6 @@ export const Config = {
|
||||
this[key] = value;
|
||||
setConfigValue(key, value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Used for update console config
|
||||
*/
|
||||
update: function (): void {
|
||||
this.set('AlwaysExpand', !! (document.getElementById('consoleOptionsAlwaysExpandCheckbox') as HTMLInputElement).checked);
|
||||
this.set('StartHistory', !! (document.getElementById('consoleOptionsStartHistoryCheckbox') as HTMLInputElement).checked);
|
||||
this.set('CurrentQuery', !! (document.getElementById('consoleOptionsCurrentQueryCheckbox') as HTMLInputElement).checked);
|
||||
this.set('EnterExecutes', !! (document.getElementById('consoleOptionsEnterExecutesCheckbox') as HTMLInputElement).checked);
|
||||
this.set('DarkTheme', !! (document.getElementById('consoleOptionsDarkThemeCheckbox') as HTMLInputElement).checked);
|
||||
/* Setting the dark theme of the console*/
|
||||
const consoleContent = document.getElementById('pma_console').querySelector('.content');
|
||||
if (this.DarkTheme) {
|
||||
consoleContent.classList.add('console_dark_theme');
|
||||
} else {
|
||||
consoleContent.classList.remove('console_dark_theme');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -175,7 +175,7 @@
|
||||
<span>{{ 'Options'|trans }}</span>
|
||||
</div>
|
||||
<div class="button default">
|
||||
<span>{{ 'Set default'|trans }}</span>
|
||||
<span>{{ 'Restore default values'|trans }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user