diff --git a/resources/js/src/modules/console.ts b/resources/js/src/modules/console.ts index 645a184485..069becfa98 100644 --- a/resources/js/src/modules/console.ts +++ b/resources/js/src/modules/console.ts @@ -5,7 +5,6 @@ import { Functions } from './functions.ts'; import { CommonParams } from './common.ts'; import { Navigation } from './navigation.ts'; import { Config } from './console/config.ts'; -import { getConfigValue } from './functions/config.ts'; import { escapeHtml } from './functions/escape.ts'; /** @@ -58,18 +57,13 @@ var Console = { * Used for console initialize, reinit is ok, just some variable assignment */ initialize: function (): void { - if ($('#pma_console').length === 0) { + const consoleElement = document.getElementById('pma_console'); + if (consoleElement === null) { return; } - getConfigValue('Console', false, (data) => { - Config.init(data); - Console.setupAfterInit(); - }, () => { - Config.init({});// Avoid null pointers in setupAfterInit() - // Fetching data failed, still perform the console init - Console.setupAfterInit(); - }); + Config.init(consoleElement.dataset); + Console.setupAfterInit(); }, /** diff --git a/resources/js/src/modules/console/config.ts b/resources/js/src/modules/console/config.ts index 17b1f604d6..ebe56de2ea 100644 --- a/resources/js/src/modules/console/config.ts +++ b/resources/js/src/modules/console/config.ts @@ -45,20 +45,18 @@ export const Config = { */ Order: 'asc', - /** - * @param {Object} data - */ - init: function (data): void { - this.StartHistory = !! data.StartHistory; - this.AlwaysExpand = !! data.AlwaysExpand; - this.CurrentQuery = data.CurrentQuery !== undefined ? !! data.CurrentQuery : true; - this.EnterExecutes = !! data.EnterExecutes; - this.DarkTheme = !! data.DarkTheme; - this.Mode = data.Mode === 'show' || data.Mode === 'collapse' ? data.Mode : 'info'; - this.Height = data.Height > 0 ? Number(data.Height) : 92; - this.GroupQueries = !! data.GroupQueries; - this.OrderBy = data.OrderBy === 'time' || data.OrderBy === 'count' ? data.OrderBy : 'exec'; - this.Order = data.Order === 'desc' ? 'desc' : 'asc'; + init: function (dataset: DOMStringMap): void { + this.StartHistory = dataset.startHistory === 'true'; + this.AlwaysExpand = dataset.alwaysExpand === 'true'; + this.CurrentQuery = dataset.currentQuery !== undefined ? dataset.currentQuery === 'true' : true; + this.EnterExecutes = dataset.enterExecutes === 'true'; + this.DarkTheme = dataset.darkTheme === 'true'; + this.Mode = dataset.mode === 'show' || dataset.mode === 'collapse' ? dataset.mode : 'info'; + const height = Number(dataset.height); + this.Height = height > 0 ? height : 92; + this.GroupQueries = dataset.groupQueries === 'true'; + this.OrderBy = dataset.orderBy === 'time' || dataset.orderBy === 'count' ? dataset.orderBy : 'exec'; + this.Order = dataset.order === 'desc' ? 'desc' : 'asc'; }, /** diff --git a/resources/templates/console/display.twig b/resources/templates/console/display.twig index 25db37f536..45a66960a9 100644 --- a/resources/templates/console/display.twig +++ b/resources/templates/console/display.twig @@ -1,5 +1,15 @@
-
+