Skip to content

Commit

Permalink
Merge pull request Smile-SA#3147 from rbayet/fix-analytics-dashboard-…
Browse files Browse the repository at this point in the history
…broken

[Analytics] Make the dashboard display handle long search terms
  • Loading branch information
rbayet authored Jan 11, 2024
2 parents 7bc0b3c + a230f4f commit 97efd19
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<referenceContainer name="content">
<container name="dashboard-container" htmlTag="div" htmlClass="dashboard-container row">
<block name="elasticsuite.analytics.search_usage.kpi" class="Smile\ElasticsuiteAnalytics\Block\Adminhtml\Search\Usage\Kpi" template="Smile_ElasticsuiteAnalytics::search/usage/kpi.phtml" />
<container name="dashboard-left-col" htmlTag="div" htmlClass="dashboard-secondary col-m-5">

<container name="dashboard-left-col" htmlTag="div" htmlClass="dashboard-secondary col-m-6">
<block name="elasticsuite.analytics.search_usage.popular_terms" class="Smile\ElasticsuiteAnalytics\Block\Adminhtml\Search\Usage\SearchTerms" template="Smile_ElasticsuiteAnalytics::search/usage/terms.phtml">
<arguments>
<argument name="report" xsi:type="object">Smile\ElasticsuiteAnalytics\Model\Search\Usage\Terms\PopularTerms\Report</argument>
Expand Down Expand Up @@ -60,8 +60,8 @@
</arguments>
</block>
</container>
<container name="dashboard-right-col" htmlTag="div" htmlClass="dashboard-main col-m-5">

<container name="dashboard-right-col" htmlTag="div" htmlClass="dashboard-main col-m-4 col-m-push-1">
<block name="elasticsuite.analytics.search_usage.sessions" class="Smile\ElasticsuiteAnalytics\Block\Adminhtml\Search\Usage\Chart\Sessions" template="Smile_ElasticsuiteAnalytics::search/usage/chart.phtml">
<arguments>
<argument name="title" xsi:type="string" translate="true">Sessions</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<?php
/**
* @var Smile\ElasticsuiteAnalytics\Block\Adminhtml\Search\Usage\SearchTerms $block
* @var \Magento\Framework\Escaper $escaper
*/
$maxVisibleTerms = $block->getMaxVisibleTerms();
$termsData = $block->getTermsData();
Expand Down Expand Up @@ -43,12 +44,12 @@ $hiddenTermsData = array_slice($termsData, $maxVisibleTerms);
<table class="admin__table-primary dashboard-data terms-report">
<thead>
<tr>
<th class="data-grid-th no-link"><span><?= __('Term');?></span></th>
<th class="data-grid-th no-link col-search-query"><span><?= __('Term');?></span></th>
<th class="data-grid-th no-link"><span><?= __('Sessions');?></span></th>
<th class="data-grid-th no-link"><span><?= __('Visitors');?></span></th>
<th class="data-grid-th no-link"><span><?= __('# Results (avg.)');?></span></th>
<th class="data-grid-th no-link <?php if (!$block->getShowConversionRate()) : ?>col-total<?php endif; ?>"><span><?= __('# Results (avg.)');?></span></th>
<?php if ($block->getShowConversionRate()) : ?>
<th class="data-grid-th no-link">
<th class="data-grid-th no-link col-total">
<span title="<?= $block->escapeHtml(__('Conversion rate for the term(s)')) ?>">
<?= __('Conv. rate');?>
</span>
Expand All @@ -67,35 +68,39 @@ $hiddenTermsData = array_slice($termsData, $maxVisibleTerms);
<tbody>
<?php foreach ($visibleTermsData as $termData) : ?>
<tr>
<td><?php if ($termData['url']) : ?>
<a href=<?= $termData['url']; ?> target="_blank"><?= $termData['term']; ?></a>
<td class="col-search-query"><?php if ($termData['url']) : ?>
<a href=<?= $termData['url']; ?> target="_blank">
<span title="<?= $escaper->escapeHtmlAttr($termData['term']); ?>"><?= $escaper->escapeHtml($termData['term']); ?></span>
</a>
<?php else : ?>
<?= $termData['term']; ?>
<span title="<?= $escaper->escapeHtmlAttr($termData['term']); ?>"><?= $escaper->escapeHtml($termData['term']); ?></span>
<?php endif; ?>
</td>
<td><?= $termData['sessions']; ?></td>
<td><?= $termData['visitors']; ?></td>
<td><?= $termData['result_count']; ?></td>
<td class="col-number"><?= $termData['sessions']; ?></td>
<td class="col-number"><?= $termData['visitors']; ?></td>
<td class="col-number"><?= $termData['result_count']; ?></td>
<?php if ($block->getShowConversionRate()) : ?>
<td><?= number_format($termData['conversion_rate'] * 100, 2); ?> %</td>
<td class="col-number"><?= number_format($termData['conversion_rate'] * 100, 2); ?> %</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
<tbody class="extra" id="<?php echo $block->getJsId() ?>_extra">
<?php foreach ($hiddenTermsData as $termData) : ?>
<tr>
<td><?php if ($termData['url']) : ?>
<a href=<?= $termData['url']; ?> target="_blank"><?= $termData['term']; ?></a>
<td class="col-search-query"><?php if ($termData['url']) : ?>
<a href=<?= $termData['url']; ?> target="_blank">
<span title="<?= $escaper->escapeHtmlAttr($termData['term']); ?>"><?= $escaper->escapeHtml($termData['term']); ?></span>
</a>
<?php else : ?>
<?= $termData['term']; ?>
<span title="<?= $escaper->escapeHtmlAttr($termData['term']); ?>"><?= $escaper->escapeHtml($termData['term']); ?></span>
<?php endif; ?>
</td>
<td><?= $termData['sessions']; ?></td>
<td><?= $termData['visitors']; ?></td>
<td><?= $termData['result_count']; ?></td>
<td class="col-number"><?= $termData['sessions']; ?></td>
<td class="col-number"><?= $termData['visitors']; ?></td>
<td class="col-number"><?= $termData['result_count']; ?></td>
<?php if ($block->getShowConversionRate()) : ?>
<td><?= number_format($termData['conversion_rate'] * 100, 2); ?> %</td>
<td class="col-number"><?= number_format($termData['conversion_rate'] * 100, 2); ?> %</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<?php
/**
* @var Smile\ElasticsuiteAnalytics\Block\Adminhtml\Search\Usage\SearchTerms $block
* @var \Magento\Framework\Escaper $escaper
*/
$maxVisibleTerms = $block->getMaxVisibleTerms();
$termsData = $block->getTermsData();
Expand Down Expand Up @@ -43,7 +44,7 @@ $hiddenTermsData = array_slice($termsData, $maxVisibleTerms);
<table class="admin__table-primary dashboard-data terms-report">
<thead>
<tr>
<th class="data-grid-th no-link"><span><?= __('Term');?></span></th>
<th class="data-grid-th no-link col-search-query"><span><?= __('Term');?></span></th>
<th class="data-grid-th no-link"><span><?= __('Sessions');?></span></th>
<th class="data-grid-th no-link"><span><?= __('Visitors');?></span></th>
</thead>
Expand All @@ -59,28 +60,32 @@ $hiddenTermsData = array_slice($termsData, $maxVisibleTerms);
<tbody>
<?php foreach ($visibleTermsData as $termData) : ?>
<tr>
<td><?php if ($termData['url']) : ?>
<a href=<?= $termData['url']; ?> target="_blank"><?= $termData['term']; ?></a>
<td class="col-search-query"><?php if ($termData['url']) : ?>
<a href=<?= $termData['url']; ?> target="_blank">
<span title="<?= $escaper->escapeHtmlAttr($termData['term']); ?>"><?= $escaper->escapeHtml($termData['term']); ?></span>
</a>
<?php else : ?>
<?= $termData['term']; ?>
<span title="<?= $escaper->escapeHtmlAttr($termData['term']); ?>"><?= $escaper->escapeHtml($termData['term']); ?></span>
<?php endif; ?>
</td>
<td><?= $termData['sessions']; ?></td>
<td><?= $termData['visitors']; ?></td>
<td class="col-number"><?= $termData['sessions']; ?></td>
<td class="col-number"><?= $termData['visitors']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tbody class="extra" id="<?php echo $block->getJsId() ?>_extra">
<?php foreach ($hiddenTermsData as $termData) : ?>
<tr>
<td><?php if ($termData['url']) : ?>
<a href=<?= $termData['url']; ?> target="_blank"><?= $termData['term']; ?></a>
<td class="col-search-query"><?php if ($termData['url']) : ?>
<a href=<?= $termData['url']; ?> target="_blank">
<span title="<?= $escaper->escapeHtmlAttr($termData['term']); ?>"><?= $escaper->escapeHtml($termData['term']); ?></span>
</a>
<?php else : ?>
<?= $termData['term']; ?>
<span title="<?= $escaper->escapeHtmlAttr($termData['term']); ?>"><?= $escaper->escapeHtml($termData['term']); ?></span>
<?php endif; ?>
</td>
<td><?= $termData['sessions']; ?></td>
<td><?= $termData['visitors']; ?></td>
<td class="col-number"><?= $termData['sessions']; ?></td>
<td class="col-number"><?= $termData['visitors']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@
border-bottom-color: @table-td__border-color;
}
}

.col-search-query {
text-overflow: ellipsis;
overflow: clip;
width: 90%;
max-width: 0;
white-space: nowrap;
}

.col-number {
text-align: right;
}
}

tfoot {
Expand Down

0 comments on commit 97efd19

Please sign in to comment.