Skip to content

Commit 89aef44

Browse files
committed
Display error message in grid
1 parent d7b9c88 commit 89aef44

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace GhostUnicorns\WebapiLogs\Ui\Component\Listing\Column;
4+
5+
use IntlDateFormatter;
6+
use Magento\Framework\App\ObjectManager;
7+
use Magento\Framework\Locale\Bundle\DataBundle;
8+
use Magento\Framework\Locale\ResolverInterface;
9+
use Magento\Framework\Stdlib\BooleanUtils;
10+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
11+
use Magento\Framework\View\Element\UiComponent\ContextInterface;
12+
use Magento\Framework\View\Element\UiComponentFactory;
13+
use Magento\Ui\Component\Listing\Columns\Column;
14+
use ResourceBundle;
15+
16+
class ResponseBody extends Column
17+
{
18+
/**
19+
* @inheritdoc
20+
*/
21+
public function prepareDataSource(array $dataSource)
22+
{
23+
if (isset($dataSource['data']['items'])) {
24+
foreach ($dataSource['data']['items'] as & $item) {
25+
if (isset($item[$this->getData('name')]) && isset($item['response_code'])) {
26+
if ((int)$item['response_code'] === 200) {
27+
$item[$this->getData('name')] = '';
28+
}
29+
}
30+
}
31+
}
32+
33+
return $dataSource;
34+
}
35+
}

view/adminhtml/ui_component/webapi_logs_reports_index_listing.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@
143143
</item>
144144
</argument>
145145
</column>
146+
<column name="response_body" class="GhostUnicorns\WebapiLogs\Ui\Component\Listing\Column\ResponseBody">
147+
<argument name="data" xsi:type="array">
148+
<item name="config" xsi:type="array">
149+
<item name="filter" xsi:type="string">text</item>
150+
<item name="label" xsi:type="string" translate="true">Error</item>
151+
<item name="sortOrder" xsi:type="number">25</item>
152+
<item name="resizeDefaultWidth" xsi:type="string">100</item>
153+
</item>
154+
</argument>
155+
</column>
146156
<column name="request_method">
147157
<argument name="data" xsi:type="array">
148158
<item name="options" xsi:type="object">GhostUnicorns\WebapiLogs\Model\Config\Source\Methods</item>

0 commit comments

Comments
 (0)