Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real-Time Log streaming fix #682 #684

Merged
merged 1 commit into from
Jan 30, 2024
Merged
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
15 changes: 10 additions & 5 deletions Controller/Adminhtml/FastlyCdn/Logging/CreateEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
use Magento\Framework\Controller\Result\JsonFactory;

/**
* Class CreateEndpoint
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Logging
* Class CreateEndpoint for Logging
*/
class CreateEndpoint extends Action
{
const ADMIN_RESOURCE = 'Magento_Config::config';
public const ADMIN_RESOURCE = 'Magento_Config::config';

/**
* @var Http
Expand Down Expand Up @@ -113,6 +112,11 @@ public function execute()
$this->getRequest()->getParam('condition_priority')
);

$selectedConditions = $this->getRequest()->getParam('conditions', '');
if (!$condition) {
$condition = $selectedConditions;
}

$params = array_merge(
$this->getRequest()->getParam('log_endpoint'),
['response_condition' => $condition]
Expand Down Expand Up @@ -152,17 +156,18 @@ public function execute()
}

/**
*
* @param $clone
* @param $conditionName
* @param $applyIf
* @param $conditionPriority
* @return string|null
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
private function createCondition($clone, $conditionName, $applyIf, $conditionPriority)
{
if (!$conditionName || !$applyIf || !$conditionPriority) {
return null;
return '';
}
$condition = [
'name' => $conditionName,
Expand Down
26 changes: 14 additions & 12 deletions Controller/Adminhtml/FastlyCdn/Logging/UpdateEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
use Magento\Framework\Controller\Result\JsonFactory;

/**
* Class UpdateEndpoint
* @package Fastly\Cdn\Controller\Adminhtml\FastlyCdn\Logging
* Class UpdateEndpoint for Logging
*/
class UpdateEndpoint extends Action
{
const ADMIN_RESOURCE = 'Magento_Config::config';
public const ADMIN_RESOURCE = 'Magento_Config::config';

/**
* @var Http
Expand Down Expand Up @@ -84,6 +83,7 @@ public function __construct(
}

/**
*
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\Result\Json|\Magento\Framework\Controller\ResultInterface
*/
public function execute()
Expand Down Expand Up @@ -114,14 +114,15 @@ public function execute()
$this->getRequest()->getParam('condition_priority')
);

$params = array_merge(
$this->getRequest()->getParam('log_endpoint'),
['response_condition' => $condition]
);

$selectedConditions = $this->getRequest()->getParam('conditions', '');
if (!$condition) {
$condition = $selectedConditions;
}
$params = $this->getRequest()->getParam('log_endpoint');
$params = array_filter($params);
//Array filter removes empty strings, but empty compression_codec param turns off compression formats
if (!isset($params['compression_codec'])){
$params['response_condition'] = $condition;

if (!isset($params['compression_codec'])) {
$params['compression_codec'] = "";
}
$endpoint = $this->api->updateLogEndpoint($clone->number, $endpointType, $params, $oldName);
Expand Down Expand Up @@ -157,17 +158,18 @@ public function execute()
}

/**
*
* @param $clone
* @param $conditionName
* @param $applyIf
* @param $conditionPriority
* @return string|null
* @return string
* @throws \Magento\Framework\Exception\LocalizedException
*/
private function createCondition($clone, $conditionName, $applyIf, $conditionPriority)
{
if (!$conditionName || !$applyIf || !$conditionPriority) {
return null;
return '';
}
$condition = [
'name' => $conditionName,
Expand Down
15 changes: 10 additions & 5 deletions view/adminhtml/web/js/log-endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,20 @@ define([
$('#condition_priority').val('');
return getResponseConditions(active_version, loaderVisibility)
.done(function (response) {
let html = '';
$('#attach_span').hide();
if (response !== false) {
let conditionElement = document.getElementById('conditions');
conditions = response.conditions;
html += '<option value="">no condition</option>';
let option = document.createElement("option");
option.text = 'no condition';
option.value = '';
conditionElement.add(option);
$.each(conditions, function (index, condition) {
if (condition.type === "REQUEST") {
html += '<option value="'+_.escape(condition.name)+'">'+_.escape(condition.name)+' ('+condition.type+') '+_.escape(condition.statement)+'</option>';
if (condition.type === "RESPONSE") {
let option = document.createElement("option");
option.text = _.escape(condition.name) +' ('+condition.type+') ' + _.escape(condition.statement);
option.value = _.escape(condition.name);
conditionElement.add(option);
}
});
}
Expand All @@ -112,7 +118,6 @@ define([
$('#detach').show();
$('#create-response-condition').show();
$('#sep').show();
$('#conditions').html(html);
})
}

Expand Down