Skip to content

Commit

Permalink
Merge pull request #152 from Inchoo/bugfix/149-test-connection-issue
Browse files Browse the repository at this point in the history
Bugfix/149 test connection issue
  • Loading branch information
vvuksan authored Mar 6, 2018
2 parents e370c4e + 254af45 commit 9c99df5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 48 deletions.
28 changes: 14 additions & 14 deletions Model/Config/Backend/ListAcl.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@ public function __construct(
*/
public function toOptionArray()
{
$service = $this->api->checkServiceDetails();
$options = [];
if ($service === false) {
return $options;
} else {
try {
$service = $this->api->checkServiceDetails();
if ($service === false) {
return $options;
}

$currActiveVersion = $this->acl->determineVersions($service->versions);
$acls = $this->api->getAcls($currActiveVersion['active_version']);

try {
foreach ($acls as $value) {
$options[] = [
'value' => $value->name,
'label' => $value->name
];
}
return $options;
} catch (\Exception $e) {
return $options;
foreach ($acls as $value) {
$options[] = [
'value' => $value->name,
'label' => $value->name
];
}
return $options;
} catch (\Exception $e) {
return $options;
}
}
}
28 changes: 11 additions & 17 deletions view/adminhtml/web/js/testconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ define([
'mage/translate'
], function ($) {
return function (config) {
successBtnMsg = $('#fastly-test-success-button-msg');
errorBtnMsg = $('#fastly-test-error-button-msg');
warningBtnMsg = $('#fastly-test-warning-button-msg');
var testSuccessBtnMsg = $('#fastly-test-success-button-msg');
var testErrorBtnMsg = $('#fastly-test-error-button-msg');

$('#fastly_test_connection_button').on('click', function () {
resetAllMessages();

testSuccessBtnMsg.text();
testSuccessBtnMsg.hide();
testErrorBtnMsg.text();
testErrorBtnMsg.hide();

$.ajax({
type: "POST",
url: config.testServiceUrl,
Expand All @@ -22,25 +26,15 @@ define([
cache: false,
success: function (response) {
if (response.status == false) {
return errorBtnMsg.text($.mage.__('Please check your Service ID and API token and try again.')).show();
return testErrorBtnMsg.text($.mage.__('Please check your Service ID and API token and try again.')).show();
} else {
return successBtnMsg.text($.mage.__('Connection to service name ' + response.service_name + ' has been succesfully established. Please, save configuration and clear cache.')).show();
return testSuccessBtnMsg.text($.mage.__('Connection to service name ' + response.service_name + ' has been succesfully established. Please, save configuration and clear cache.')).show();
}
},
error: function (msg) {
return errorBtnMsg.text($.mage.__('An error occurred while processing your request. Please try again.')).show();
return testErrorBtnMsg.text($.mage.__('An error occurred while processing your request. Please try again.')).show();
}
});
});
};

function resetAllMessages()
{
successBtnMsg.text();
successBtnMsg.hide();
errorBtnMsg.text();
errorBtnMsg.hide();
warningBtnMsg.text();
warningBtnMsg.hide();
}
});
28 changes: 11 additions & 17 deletions view/adminhtml/web/js/updateblocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ define([
'mage/translate'
], function ($) {
return function (config) {
successBtnMsg = $('#fastly-update-blocking-success-button-msg');
errorBtnMsg = $('#fastly-update-blocking-error-button-msg');
warningBtnMsg = $('#fastly-update-blocking-warning-button-msg');
var blockingSuccessBtnMsg = $('#fastly-update-blocking-success-button-msg');
var blockingErrorBtnMsg = $('#fastly-update-blocking-error-button-msg');

$('#fastly_update_blocking_button').on('click', function () {
resetAllMessages();

blockingSuccessBtnMsg.text();
blockingSuccessBtnMsg.hide();
blockingErrorBtnMsg.text();
blockingErrorBtnMsg.hide();

$.ajax({
type: "POST",
url: config.updateBlockingUrl,
Expand All @@ -24,25 +28,15 @@ define([
cache: false,
success: function (response) {
if (response.status == false) {
return errorBtnMsg.text($.mage.__('Please make sure that blocking is enabled.')).show();
return blockingErrorBtnMsg.text($.mage.__('Please make sure that blocking is enabled.')).show();
} else {
return successBtnMsg.text($.mage.__('Blocking snippet has been updated successfully.')).show();
return blockingSuccessBtnMsg.text($.mage.__('Blocking snippet has been updated successfully.')).show();
}
},
error: function (msg) {
return errorBtnMsg.text($.mage.__('An error occurred while processing your request. Please try again.')).show();
return blockingErrorBtnMsg.text($.mage.__('An error occurred while processing your request. Please try again.')).show();
}
});
});
};

function resetAllMessages()
{
successBtnMsg.text();
successBtnMsg.hide();
errorBtnMsg.text();
errorBtnMsg.hide();
warningBtnMsg.text();
warningBtnMsg.hide();
}
});

0 comments on commit 9c99df5

Please sign in to comment.