From 3418aded7d7f170782c6ac1f5726ac615cb0ba2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D1=96=D0=B9=20=D0=A7=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= Date: Wed, 15 Jul 2026 14:42:36 +0200 Subject: [PATCH 1/8] 15453-Cli-Improvements --- view/adminhtml/templates/form.phtml | 147 +++++++++++++--------------- 1 file changed, 69 insertions(+), 78 deletions(-) diff --git a/view/adminhtml/templates/form.phtml b/view/adminhtml/templates/form.phtml index ac970f3..c616a32 100644 --- a/view/adminhtml/templates/form.phtml +++ b/view/adminhtml/templates/form.phtml @@ -48,8 +48,9 @@ $script = ''; #command-list ul{overflow:hidden;overflow-y:scroll;overflow-x:scroll;} #command-list li {padding-bottom: 10px} #command-list li .execute {padding-left: 10px} + .row:after {content:'';display:table;clear:both;} - .execute {cursor: pointer;} + .execute, .execute-label {cursor: pointer;}
@@ -154,23 +155,26 @@ $script = ''; } var loading = false; - $('#command').keydown(function(event) { - var el = $(this); - if(event.which == 40) { //up - commandLogIndex--; - if (commandLogIndex < 0) { - commandLogIndex = 0; - } - showCommand(); - } else if(event.which == 38) { //down - showCommand(); - commandLogIndex++; - if (commandLogIndex >= commandLog.length) { - commandLogIndex = commandLog.length-1; - } - } else if(event.which == 13) { //enter - if (loading) return; - loading = true; + $('#command').keydown(function(event) { + var el = $(this); + if(event.which == 40) { //up + event.preventDefault(); + commandLogIndex--; + if (commandLogIndex < 0) { + commandLogIndex = 0; + } + showCommand(); + } else if(event.which == 38) { //down + event.preventDefault(); + showCommand(); + commandLogIndex++; + if (commandLogIndex >= commandLog.length) { + commandLogIndex = commandLog.length-1; + } + } else if(event.which == 13) { //enter + event.preventDefault(); + if (loading) return; + loading = true; if (!$.trim(el.val())) { addContent('
'); @@ -179,69 +183,56 @@ $script = ''; } $.ajax({ - url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "', - data : {command:el.val(),current_password:$('#user_current_password').val()}, - type: 'POST', - dataType: 'json', - showLoader: true - }).done(function (data) { - loading = false; - if (data && data.message) { - addContent('$ ' + el.val() + '
'); - addContent(data.message); - } else { - alert('" . $block->escapeHtml(__('Unexpected error. Please refresh the page or try later.')) . "'); - } - }); + url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "', + data : {command:el.val(),current_password:$('#user_current_password').val(),form_key:$('input[name=\"form_key\"]').val()}, + type: 'POST', + dataType: 'json', + showLoader: true + }).done(function (data) { + loading = false; + if (data && data.message) { + addContent('$ ' + el.val() + '
'); + addContent(data.message); + } else { + alert('" . $block->escapeHtml(__('Unexpected error. Please refresh the page or try later.')) . "'); + } + if (data && data.newFormKey) { + $('input[name=\"form_key\"]').val(data.newFormKey); + } + }); } }); - $('.execute').click(function() { - var command = 'bin/magento ' + $(this).attr('data-name'); + $('.execute-label').click(function() { + var command = 'bin/magento ' + $(this).closest('li').find('.execute').attr('data-name'); + $('#command').val(command).focus(); + }); + + $('.execute').click(function() { + var command = 'bin/magento ' + $(this).closest('li').find('.execute').attr('data-name'); var loading = false; - confirmation({ - title: $.mage.__('Execute Command:') + ' ' + command, - content: $.mage.__('Are you sure you want to do this?'), - actions: { - confirm: function(){ - if (loading) return; - loading = true; - - $.ajax({ - url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "', - data : {command:'php ' + command,current_password:$('#user_current_password').val()}, - type: 'POST', - dataType: 'json', - showLoader: true - }).done(function (data) { - loading = false; - if (data && data.message) { - addContent('$ ' + command + '
'); - addContent(data.message); - } else { - alert('" . $block->escapeHtml(__('Unexpected error. Please refresh the page or try later.')) . "'); - } - - if (data && data.newFormKey) { - FORM_KEY = data.newFormKey; - document.querySelector('input[name=\"form_key\"]').value = FORM_KEY; - } - }); - } - }, - buttons: [{ - text: $.mage.__('Cancel'), - class: 'action-secondary dismiss', - click: function (event) { - this.closeModal(event); - } - }, { - text: $.mage.__('OK'), - class: 'action primary accept', - click: function (event) { - this.closeModal(event, true); - } - }] + + if (loading) return; + loading = true; + + $.ajax({ + url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "', + data : {command:'php ' + command, current_password:$('#user_current_password').val(),form_key:$('input[name=\"form_key\"]').val()}, type: 'POST', + dataType: 'json', + showLoader: true + }).done(function (data) { + loading = false; + if (data && data.message) { + addContent('$ ' + command + '
'); + addContent(data.message); + } else { + alert('" . $block->escapeHtml(__('Unexpected error. Please refresh the page or try later.')) . "'); + } + + if (data && data.newFormKey) { + FORM_KEY = data.newFormKey; + document.querySelector('input[name=\"form_key\"]').value = FORM_KEY; + } }); }) }); @@ -249,4 +240,4 @@ $script = ''; renderTag('script', [], $script, false) ?> - + \ No newline at end of file From 2bdab302e9596ddd3352936c64f841b8b45dd9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D1=96=D0=B9=20=D0=A7=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= Date: Thu, 16 Jul 2026 13:12:56 +0200 Subject: [PATCH 2/8] origin/15453-Cli-Improvements --- Block/Adminhtml/History.php | 38 ++++++++++++++++ Controller/Adminhtml/History/Index.php | 35 +++++++++++++++ etc/adminhtml/menu.xml | 23 +++++++++- etc/db_schema.xml | 26 +++++++++++ etc/module.xml | 1 + view/adminhtml/layout/mfcli_history_index.xml | 8 ++++ view/adminhtml/templates/history.phtml | 43 +++++++++++++++++++ 7 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 Block/Adminhtml/History.php create mode 100644 Controller/Adminhtml/History/Index.php create mode 100644 etc/db_schema.xml create mode 100644 view/adminhtml/layout/mfcli_history_index.xml create mode 100644 view/adminhtml/templates/history.phtml diff --git a/Block/Adminhtml/History.php b/Block/Adminhtml/History.php new file mode 100644 index 0000000..3bdbd4d --- /dev/null +++ b/Block/Adminhtml/History.php @@ -0,0 +1,38 @@ +resource = $resource; + parent::__construct($context, $data); + } + + /** + * Get recent logs + * @param int $limit + * @return array + */ + public function getLogs($limit = 100) + { + $connection = $this->resource->getConnection(); + $table = $this->resource->getTableName('magefan_cli_log'); + $select = $connection->select()->from($table)->order('executed_at DESC')->limit((int)$limit); + return $connection->fetchAll($select); + } +} \ No newline at end of file diff --git a/Controller/Adminhtml/History/Index.php b/Controller/Adminhtml/History/Index.php new file mode 100644 index 0000000..3c0cc47 --- /dev/null +++ b/Controller/Adminhtml/History/Index.php @@ -0,0 +1,35 @@ +resultPageFactory = $resultPageFactory; + parent::__construct($context); + } + + public function execute() + { + $resultPage = $this->resultPageFactory->create(); + $resultPage->setActiveMenu('Magefan_Cli::history'); + $resultPage->getConfig()->getTitle()->prepend(__('Command Line History')); + return $resultPage; + } +} \ No newline at end of file diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml index 4a8e5d6..dedbaab 100644 --- a/etc/adminhtml/menu.xml +++ b/etc/adminhtml/menu.xml @@ -7,6 +7,25 @@ --> - + + + - + \ No newline at end of file diff --git a/etc/db_schema.xml b/etc/db_schema.xml new file mode 100644 index 0000000..9d8f228 --- /dev/null +++ b/etc/db_schema.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml index c60d291..276733a 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -9,6 +9,7 @@ + diff --git a/view/adminhtml/layout/mfcli_history_index.xml b/view/adminhtml/layout/mfcli_history_index.xml new file mode 100644 index 0000000..91ddaf6 --- /dev/null +++ b/view/adminhtml/layout/mfcli_history_index.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/view/adminhtml/templates/history.phtml b/view/adminhtml/templates/history.phtml new file mode 100644 index 0000000..1d988a3 --- /dev/null +++ b/view/adminhtml/templates/history.phtml @@ -0,0 +1,43 @@ + + +getLogs(200); +?> +
+ + + + + + + + + + + + + + + + + + + + + +
escapeHtml(__('ID')) ?>escapeHtml(__('Command')) ?>escapeHtml(__('Result')) ?>escapeHtml(__('User ID')) ?>escapeHtml(__('Executed At')) ?>
escapeHtml($row['command']) ?>
escapeHtml($row['result']) ?>
escapeHtml($row['executed_at']) ?>
+
\ No newline at end of file From 502906e539432a0928a540db3e645d01c65f493e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D1=96=D0=B9=20=D0=A7=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= Date: Thu, 16 Jul 2026 13:29:18 +0200 Subject: [PATCH 3/8] origin/15453-Cli-Improvements --- Block/Adminhtml/History.php | 38 ---------------- Controller/Adminhtml/History/Index.php | 35 --------------- etc/adminhtml/menu.xml | 21 +-------- etc/db_schema.xml | 26 ----------- etc/module.xml | 1 - view/adminhtml/layout/mfcli_history_index.xml | 8 ---- view/adminhtml/templates/history.phtml | 43 ------------------- 7 files changed, 1 insertion(+), 171 deletions(-) delete mode 100644 Block/Adminhtml/History.php delete mode 100644 Controller/Adminhtml/History/Index.php delete mode 100644 etc/db_schema.xml delete mode 100644 view/adminhtml/layout/mfcli_history_index.xml delete mode 100644 view/adminhtml/templates/history.phtml diff --git a/Block/Adminhtml/History.php b/Block/Adminhtml/History.php deleted file mode 100644 index 3bdbd4d..0000000 --- a/Block/Adminhtml/History.php +++ /dev/null @@ -1,38 +0,0 @@ -resource = $resource; - parent::__construct($context, $data); - } - - /** - * Get recent logs - * @param int $limit - * @return array - */ - public function getLogs($limit = 100) - { - $connection = $this->resource->getConnection(); - $table = $this->resource->getTableName('magefan_cli_log'); - $select = $connection->select()->from($table)->order('executed_at DESC')->limit((int)$limit); - return $connection->fetchAll($select); - } -} \ No newline at end of file diff --git a/Controller/Adminhtml/History/Index.php b/Controller/Adminhtml/History/Index.php deleted file mode 100644 index 3c0cc47..0000000 --- a/Controller/Adminhtml/History/Index.php +++ /dev/null @@ -1,35 +0,0 @@ -resultPageFactory = $resultPageFactory; - parent::__construct($context); - } - - public function execute() - { - $resultPage = $this->resultPageFactory->create(); - $resultPage->setActiveMenu('Magefan_Cli::history'); - $resultPage->getConfig()->getTitle()->prepend(__('Command Line History')); - return $resultPage; - } -} \ No newline at end of file diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml index dedbaab..72fb81d 100644 --- a/etc/adminhtml/menu.xml +++ b/etc/adminhtml/menu.xml @@ -7,25 +7,6 @@ --> - - - + \ No newline at end of file diff --git a/etc/db_schema.xml b/etc/db_schema.xml deleted file mode 100644 index 9d8f228..0000000 --- a/etc/db_schema.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
-
\ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml index 276733a..c60d291 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -9,7 +9,6 @@ - diff --git a/view/adminhtml/layout/mfcli_history_index.xml b/view/adminhtml/layout/mfcli_history_index.xml deleted file mode 100644 index 91ddaf6..0000000 --- a/view/adminhtml/layout/mfcli_history_index.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/view/adminhtml/templates/history.phtml b/view/adminhtml/templates/history.phtml deleted file mode 100644 index 1d988a3..0000000 --- a/view/adminhtml/templates/history.phtml +++ /dev/null @@ -1,43 +0,0 @@ - - -getLogs(200); -?> -
- - - - - - - - - - - - - - - - - - - - - -
escapeHtml(__('ID')) ?>escapeHtml(__('Command')) ?>escapeHtml(__('Result')) ?>escapeHtml(__('User ID')) ?>escapeHtml(__('Executed At')) ?>
escapeHtml($row['command']) ?>
escapeHtml($row['result']) ?>
escapeHtml($row['executed_at']) ?>
-
\ No newline at end of file From cb0e33ae3b06bc79b681d7f24e905c99a7570b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D1=96=D0=B9=20=D0=A7=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= Date: Fri, 17 Jul 2026 13:40:39 +0200 Subject: [PATCH 4/8] 15453-Cli-Improvements --- view/adminhtml/templates/form.phtml | 59 +++++++++++++++++------------ 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/view/adminhtml/templates/form.phtml b/view/adminhtml/templates/form.phtml index c616a32..9e664e6 100644 --- a/view/adminhtml/templates/form.phtml +++ b/view/adminhtml/templates/form.phtml @@ -208,33 +208,44 @@ $script = ''; $('#command').val(command).focus(); }); - $('.execute').click(function() { + $('.execute').click(function () { var command = 'bin/magento ' + $(this).closest('li').find('.execute').attr('data-name'); - var loading = false; - - if (loading) return; - loading = true; - - $.ajax({ - url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "', - data : {command:'php ' + command, current_password:$('#user_current_password').val(),form_key:$('input[name=\"form_key\"]').val()}, type: 'POST', - dataType: 'json', - showLoader: true - }).done(function (data) { - loading = false; - if (data && data.message) { - addContent('$ ' + command + '
'); - addContent(data.message); - } else { - alert('" . $block->escapeHtml(__('Unexpected error. Please refresh the page or try later.')) . "'); - } - - if (data && data.newFormKey) { - FORM_KEY = data.newFormKey; - document.querySelector('input[name=\"form_key\"]').value = FORM_KEY; + + confirmation({ + title: 'Confirm Command', + content: 'Are you sure you want to execute:
' + command + '?', + actions: { + confirm: function () { + + $.ajax({ + url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "', + data: { + command: 'php ' + command, + current_password: $('#user_current_password').val(), + form_key: $('input[name=\"form_key\"]').val() + }, + type: 'POST', + dataType: 'json', + showLoader: true + }).done(function (data) { + + if (data && data.message) { + addContent('$ ' + command + '
'); + addContent(data.message); + } else { + alert('" . $block->escapeHtml(__('Unexpected error. Please refresh the page or try later.')) . "'); + } + + if (data && data.newFormKey) { + FORM_KEY = data.newFormKey; + $('input[name=\"form_key\"]').val(FORM_KEY); + } + }); + }, + cancel: function () {} } }); - }) + }); }); "; ?> From 7006c20d06b5ba9daf545e23ddcd2fd723a983ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D1=96=D0=B9=20=D0=A7=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= Date: Fri, 17 Jul 2026 13:44:49 +0200 Subject: [PATCH 5/8] 15453-Cli-Improvements --- view/adminhtml/templates/form.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view/adminhtml/templates/form.phtml b/view/adminhtml/templates/form.phtml index 9e664e6..bbcbc5d 100644 --- a/view/adminhtml/templates/form.phtml +++ b/view/adminhtml/templates/form.phtml @@ -208,14 +208,14 @@ $script = ''; $('#command').val(command).focus(); }); - $('.execute').click(function () { + $('.execute').click(function() { var command = 'bin/magento ' + $(this).closest('li').find('.execute').attr('data-name'); confirmation({ title: 'Confirm Command', content: 'Are you sure you want to execute:
' + command + '?', actions: { - confirm: function () { + confirm: function() { $.ajax({ url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "', @@ -242,7 +242,7 @@ $script = ''; } }); }, - cancel: function () {} + cancel: function() {} } }); }); From e1cd3b7897c3046b57b5413d761c8ed11db6f22f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D1=96=D0=B9=20=D0=A7=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= Date: Wed, 22 Jul 2026 13:07:10 +0200 Subject: [PATCH 6/8] 15453-Cli-Improvements --- view/adminhtml/templates/form.phtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/view/adminhtml/templates/form.phtml b/view/adminhtml/templates/form.phtml index bbcbc5d..74f9a8e 100644 --- a/view/adminhtml/templates/form.phtml +++ b/view/adminhtml/templates/form.phtml @@ -210,10 +210,11 @@ $script = ''; $('.execute').click(function() { var command = 'bin/magento ' + $(this).closest('li').find('.execute').attr('data-name'); + $('#command').val(command).focus(); confirmation({ - title: 'Confirm Command', - content: 'Are you sure you want to execute:
' + command + '?', + title: $.mage.__('Execute Command:') + ' ' + command, + content: $.mage.__('Are you sure you want to do this?'), actions: { confirm: function() { From 07c1dcad83ce8906624aa63964f591d3bccb711a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D1=96=D0=B9=20=D0=A7=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= Date: Wed, 22 Jul 2026 13:13:07 +0200 Subject: [PATCH 7/8] 15453-Cli-Improvements --- view/adminhtml/templates/form.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/adminhtml/templates/form.phtml b/view/adminhtml/templates/form.phtml index 74f9a8e..e2dc7e5 100644 --- a/view/adminhtml/templates/form.phtml +++ b/view/adminhtml/templates/form.phtml @@ -213,7 +213,7 @@ $script = ''; $('#command').val(command).focus(); confirmation({ - title: $.mage.__('Execute Command:') + ' ' + command, + title: $.mage.__('Execute Command:') + '
' + command, content: $.mage.__('Are you sure you want to do this?'), actions: { confirm: function() { From 467377d46c020f65354a502ac155c7af201a49f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D1=96=D0=B9=20=D0=A7=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= Date: Thu, 23 Jul 2026 14:35:59 +0200 Subject: [PATCH 8/8] 15453-Cli-Improvements --- view/adminhtml/templates/form.phtml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/view/adminhtml/templates/form.phtml b/view/adminhtml/templates/form.phtml index e2dc7e5..f938a20 100644 --- a/view/adminhtml/templates/form.phtml +++ b/view/adminhtml/templates/form.phtml @@ -137,15 +137,15 @@ $script = ''; } function addCommand() - { - var el = $('#command'); - v = $.trim(el.val()); - if (v) { - commandLog.push(v); - } - var commandLogIndex = 0; - el.val(''); - } + { + var el = $('#command'); + var v = $.trim(el.val()); + if (v) { + commandLog.push(v); + } + commandLogIndex = 0; + el.val(''); + } function addContent(c) {