Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions etc/adminhtml/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Magefan_Cli::elements" title="Command Line" translate="title" module="Magefan_Cli" parent="Magento_Backend::system_tools" action="mfcli/index" sortOrder="60" resource="Magefan_Cli::elements"/>
<add id="Magefan_Cli::elements" title="Command Line" translate="title" module="Magefan_Cli" parent="Magento_Backend::system_tools" action="mfcli/index" sortOrder="60" resource="Magefan_Cli::elements"/>
</menu>
</config>
</config>
121 changes: 62 additions & 59 deletions view/adminhtml/templates/form.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
</style>

<div class="admin__scope-old">
Expand Down Expand Up @@ -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('<br/>');
Expand All @@ -179,42 +183,53 @@ $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('<strong>$ </strong>' + el.val() + '<br/>');
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('<strong>$ </strong>' + el.val() + '<br/>');
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');
var loading = false;
$('.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');
$('#command').val(command).focus();

confirmation({
title: $.mage.__('Execute Command:') + ' ' + command,
title: $.mage.__('Execute Command:') + '<br>' + command,
content: $.mage.__('Are you sure you want to do this?'),
actions: {
confirm: function(){
if (loading) return;
loading = true;
confirm: function() {

$.ajax({
url: '" . $block->escapeUrl($block->getUrl('*/*/cli')) . "',
data : {command:'php ' + command,current_password:$('#user_current_password').val()},
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('<strong>$ </strong>' + command + '<br/>');
addContent(data.message);
Expand All @@ -224,29 +239,17 @@ $script = '';

if (data && data.newFormKey) {
FORM_KEY = data.newFormKey;
document.querySelector('input[name=\"form_key\"]').value = FORM_KEY;
$('input[name=\"form_key\"]').val(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);
}
}]
},
cancel: function() {}
}
});
})
});
});
"; ?>

<?= /* @noEscape */ $mfSecureRenderer->renderTag('script', [], $script, false) ?>
<?php } ?>
<?php } ?>
<?php } ?>