ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Form;
use Magento\Framework\View\Element\ComponentVisibilityInterface;
class CustomerHistoryFieldset extends \Magento\Ui\Component\Form\Fieldset implements ComponentVisibilityInterface
{
public function isComponentVisible(): bool
{
return $this->context->getRequestParam('id') !== null;
}
}
@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
use Amasty\AdminActionsLog\Model\OptionSource\LogEntryTypes;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
class LogEntryActions extends Column
{
/**
* @var LogEntryTypes
*/
private $logEntryTypes;
/**
* @var array
*/
private $availablePreviewTypes;
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
LogEntryTypes $logEntryTypes,
array $components = [],
array $data = [],
array $availablePreviewTypes = []
) {
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->logEntryTypes = $logEntryTypes;
$this->availablePreviewTypes = $availablePreviewTypes;
}
public function prepareDataSource(array $dataSource)
{
$previewTypes = array_filter(array_keys($this->logEntryTypes->toArray()), function ($type) {
return in_array($type, $this->availablePreviewTypes);
});
$dataSource = parent::prepareDataSource($dataSource);
if (empty($dataSource['data']['items'])) {
return $dataSource;
}
foreach ($dataSource['data']['items'] as &$item) {
$item[$this->getData('name')]['details'] = [
'href' => $this->context->getUrl(
'amaudit/actionslog/edit',
['id' => $item['id']]
),
'label' => __('View Details'),
'hidden' => false,
];
if (in_array($item['type'], $previewTypes)) {
$item[$this->getData('name')]['preview'] = [
'callback' => [
'provider' => 'index = preview-modal',
'target' => 'getPreviewData',
'id' => $item['id'],
],
'label' => __('Preview Details'),
'hidden' => false,
];
}
}
return $dataSource;
}
}
@@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
use Amasty\AdminActionsLog\Api\Data\LogEntryInterface;
use Amasty\AdminActionsLog\Api\Data\LogEntryInterfaceFactory;
use Magento\Backend\Model\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
class LogEntryItem extends Column
{
/**
* @var LogEntryInterfaceFactory
*/
private $logEntryFactory;
/**
* @var UrlInterface
*/
private $urlBuilder;
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
LogEntryInterfaceFactory $logEntryFactory,
UrlInterface $urlBuilder,
array $components = [],
array $data = []
) {
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->logEntryFactory = $logEntryFactory;
$this->urlBuilder = $urlBuilder;
}
public function prepareDataSource(array $dataSource)
{
if (empty($dataSource['data']['items'])) {
return $dataSource;
}
foreach ($dataSource['data']['items'] as &$item) {
if (isset($item['item'])) {
$logEntry = $this->logEntryFactory->create(['data' => $item]);
$item['view_url'] = $this->buildViewUrl($logEntry);
}
}
return $dataSource;
}
private function buildViewUrl(LogEntryInterface $logEntry): ?string
{
$category = (string)$logEntry->getCategory();
$categoryActionParts = explode('/', $category);
if (!$logEntry->getElementId() || count($categoryActionParts) < 3) {
return null;
}
return $this->urlBuilder->getUrl(
$category,
[
$logEntry->getParameterName() => $logEntry->getViewElementId() ?: $logEntry->getElementId()
]
);
}
}
@@ -0,0 +1,73 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
use Amasty\AdminActionsLog\Model\ActiveSession\ActiveSession;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
class RecentActivity extends Column
{
public const MINUTE = 60;
public const HOUR = 3600;
/**
* @var DateTime
*/
private $dateTime;
public function __construct(
DateTime $dateTime,
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
array $components = [],
array $data = []
) {
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->dateTime = $dateTime;
}
/**
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource): array
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as &$item) {
if (isset($item[ActiveSession::RECENT_ACTIVITY])) {
$item[ActiveSession::RECENT_ACTIVITY] = $this->decorateRecentActivity(
$item[ActiveSession::RECENT_ACTIVITY]
);
}
}
}
return $dataSource;
}
public function decorateRecentActivity(string $rowTime): string
{
$timeDifference = $this->dateTime->timestamp() - strtotime($rowTime);
if ($timeDifference < self::MINUTE) {
return __('Just Now')->render();
} elseif ($timeDifference < self::HOUR) {
$minutes = round($timeDifference / self::MINUTE);
return __($minutes . " minute(s) ago")->render();
} else {
$hours = round($timeDifference / self::HOUR);
return __($hours . " hour(s) ago")->render();
}
}
}
@@ -0,0 +1,38 @@
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
use Magento\Ui\Component\Listing\Columns\Column;
class ShowHistory extends Column
{
/**
* Prepare Data Source
*
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
$item[$this->getData('name')] = [
'history' => [
'callback' => [
'provider' => 'amaudit_visithistory_listing.amaudit_visithistory_listing.modal',
'target' => 'getHistory'
],
'label' => __('Show History')
]
];
}
}
return $dataSource;
}
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
use Magento\Store\Ui\Component\Listing\Column\Store;
class StoreView extends Store
{
public function prepareDataSource(array $dataSource)
{
if (empty($dataSource['data']['items'])) {
return $dataSource;
}
foreach ($dataSource['data']['items'] as &$item) {
if (isset($item['store_id'])) {
$storeId = (int)$item['store_id'];
$item['store_id'] = [];
$item['store_id'][] = $storeId;
}
}
$dataSource = parent::prepareDataSource($dataSource);
return $dataSource;
}
}
@@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Column;
use Amasty\AdminActionsLog\Model\ActiveSession\ActiveSession;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
class TerminateAction extends Column
{
/**
* @var UrlInterface
*/
protected $urlBuilder;
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
UrlInterface $urlBuilder,
array $components = [],
array $data = []
) {
$this->urlBuilder = $urlBuilder;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
/**
* @param array $dataSource
* @return array
*/
public function prepareDataSource(array $dataSource): array
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as &$item) {
if (isset($item[$this->getData('config/indexField')])) {
$urlEntityParamName = $this->getData('config/urlEntityParamName') ?: 'id';
$config = (array)$this->getData('config');
if ($config && isset($config['buttons'])) {
foreach ($config['buttons'] as $actionName => $button) {
$label = $button['itemLabel'];
$item[$this->getData('name')][$actionName] = [
'href' => $this->urlBuilder->getUrl(
$button['urlPath'],
[
$urlEntityParamName => $item[$this->getData('config/indexField')]
]
),
'label' => __($label)
];
}
}
}
}
}
return $dataSource;
}
}
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Filter;
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Customer\Customer;
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\Data\CollectionModifierInterface;
class FilterCustomerListing implements CollectionModifierInterface
{
/**
* @var RequestInterface
*/
private $request;
public function __construct(RequestInterface $request)
{
$this->request = $request;
}
public function apply(AbstractDb $collection)
{
$customerId = (int)$this->request->getParam('parent_id');
if (!$customerId) {
return;
}
$collection->getSelect()->where(sprintf(
'main_table.%s = \'%s\' AND main_table.%s = %s',
LogEntry::CATEGORY,
Customer::CATEGORY,
LogEntry::ELEMENT_ID,
$customerId
));
}
}
@@ -0,0 +1,113 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Filter;
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Sales\Creditmemo;
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Sales\Invoice;
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Sales\Order;
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Sales\OrderAddress;
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Sales\Shipment;
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\Data\CollectionModifierInterface;
use Magento\Sales\Api\Data\CreditmemoInterface;
use Magento\Sales\Api\Data\InvoiceInterface;
use Magento\Sales\Api\Data\OrderAddressInterface;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\Data\ShipmentInterface;
class FilterOrderListing implements CollectionModifierInterface
{
/**
* @var RequestInterface
*/
private $request;
/**
* @var array[]
*/
private $subEntityConditions = [
[
'alias' => 'order_table',
'table' => 'sales_order',
'join_field' => OrderInterface::ENTITY_ID,
'entity_field' => OrderInterface::ENTITY_ID,
'category' => Order::CATEGORY
],
[
'alias' => 'invoice_table',
'table' => 'sales_invoice',
'join_field' => InvoiceInterface::ENTITY_ID,
'entity_field' => InvoiceInterface::ORDER_ID,
'category' => Invoice::CATEGORY
],
[
'alias' => 'shipment_table',
'table' => 'sales_shipment',
'join_field' => ShipmentInterface::ENTITY_ID,
'entity_field' => ShipmentInterface::ORDER_ID,
'category' => Shipment::CATEGORY
],
[
'alias' => 'creditmemo_table',
'table' => 'sales_creditmemo',
'join_field' => CreditmemoInterface::ENTITY_ID,
'entity_field' => CreditmemoInterface::ORDER_ID,
'category' => Creditmemo::CATEGORY
],
[
'alias' => 'order_address_table',
'table' => 'sales_order_address',
'join_field' => OrderAddressInterface::ENTITY_ID,
'entity_field' => OrderAddressInterface::PARENT_ID,
'category' => OrderAddress::CATEGORY
]
];
public function __construct(RequestInterface $request)
{
$this->request = $request;
}
public function apply(AbstractDb $collection)
{
$sensitiveFields = [];
$orderId = (int)$this->request->getParam('order_id');
if (!$orderId) {
return;
}
foreach ($this->subEntityConditions as $conditionData) {
$sensitiveFields[] = $conditionData['alias'] . '.' . $conditionData['join_field'];
$collection->getSelect()->joinLeft(
[$conditionData['alias'] => $collection->getTable($conditionData['table'])],
sprintf(
'main_table.%s = %s.%s AND main_table.category = \'%s\' AND %s.%s = %s',
LogEntry::ELEMENT_ID,
$conditionData['alias'],
$conditionData['join_field'],
$conditionData['category'],
$conditionData['alias'],
$conditionData['entity_field'],
$orderId
),
[]
);
}
$collection->getSelect()->where(
new \Zend_Db_Expr(
sprintf('COALESCE (%s) IS NOT NULL', implode(',', $sensitiveFields))
)
);
}
}
@@ -0,0 +1,112 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Listing\Filter;
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Catalog\Product;
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Inventory\Model\SourceItem;
use Amasty\AdminActionsLog\Logging\Entity\SaveHandler\Adminhtml\Stock\Item as StockItem;
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
use Magento\Framework\DB\Select;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\Data\CollectionModifierInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Catalog\Api\ProductRepositoryInterface;
class FilterProductListing implements CollectionModifierInterface
{
/**
* @var RequestInterface
*/
private $request;
/**
* @var ProductRepositoryInterface
*/
private $productRepository;
public function __construct(
RequestInterface $request,
ProductRepositoryInterface $productRepository
) {
$this->request = $request;
$this->productRepository = $productRepository;
}
public function apply(AbstractDb $collection)
{
$productId = (int)$this->request->getParam('current_product_id');
if (!$productId) {
return;
}
$collection->getSelect()->where($this->getSqlCondition($productId));
}
private function getSqlCondition(int $productId): string
{
$sqlCondition = '';
try {
$product = $this->productRepository->getById($productId);
} catch (NoSuchEntityException $e) {
return 'null';
}
$elements = [
[
Product::CATEGORY,
LogEntry::ELEMENT_ID,
(string)$productId
], [
SourceItem::CATEGORY,
LogEntry::ITEM,
str_replace("'", "\'", $product->getSku())
]
];
if ($product->getExtensionAttributes()
&& $stockItem = $product->getExtensionAttributes()->getStockItem()
) {
$elements[] = [
StockItem::CATEGORY,
LogEntry::ELEMENT_ID,
(string)$stockItem->getItemId()
];
}
$lastIndex = count($elements) - 1;
foreach ($elements as $index => $element) {
$sqlCondition .= sprintf('(%s)', $this->prepareSql(...$element));
if ($index !== $lastIndex) {
$sqlCondition .= sprintf(' %s ', Select::SQL_OR);
}
}
return $sqlCondition;
}
private function prepareSql(
string $category,
string $identifierFieldName,
string $identifier
): string {
return sprintf(
'main_table.%s = \'%s\' AND main_table.%s = \'%s\'',
LogEntry::CATEGORY,
$category,
$identifierFieldName,
$identifier
);
}
}
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\Component\Listing\MassActions;
use Amasty\AdminActionsLog\Model\ConfigProvider;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Ui\Component\Action;
class Restore extends Action
{
/**
* @var ConfigProvider
*/
private $configProvider;
public function __construct(
ContextInterface $context,
ConfigProvider $configProvider,
array $components = [],
array $data = [],
$actions = null
) {
parent::__construct($context, $components, $data, $actions);
$this->configProvider = $configProvider;
}
public function getConfiguration()
{
$config = parent::getConfiguration();
$config['confirm']['message'] = $this->configProvider->getRestoreSettingsText()
. ' ' . __('Are you sure you want to restore selected items?');
return $config;
}
}
@@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\DataProvider\ActionsLog;
use Amasty\AdminActionsLog\Model\LogEntry\Frontend\LogDetailsFormatter;
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
use Amasty\AdminActionsLog\Model\LogEntry\ResourceModel\Grid\CollectionFactory;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Ui\DataProvider\AbstractDataProvider;
class Form extends AbstractDataProvider
{
/**
* @var LogDetailsFormatter
*/
private $logDetailsFormatter;
/**
* @var TimezoneInterface
*/
private $localeDate;
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $collectionFactory,
LogDetailsFormatter $logDetailsFormatter,
TimezoneInterface $localeDate,
array $meta = [],
array $data = []
) {
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
$this->collection = $collectionFactory->create();
$this->logDetailsFormatter = $logDetailsFormatter;
$this->localeDate = $localeDate;
}
public function getData()
{
$data = parent::getData();
if ($data['totalRecords'] > 0) {
$data['items'][0]['date'] = $this->localeDate->formatDateTime(
$data['items'][0]['date'],
\IntlDateFormatter::MEDIUM,
\IntlDateFormatter::MEDIUM
);
$logId = (int)$data['items'][0]['id'];
$data[$logId]['log_entry'] = $data['items'][0];
try {
$data[$logId]['log_entry'][LogEntry::LOG_DETAILS] = array_values(
$this->logDetailsFormatter->format($logId)
);
} catch (\RuntimeException $e) {
$data[$logId]['log_entry']['messages'] = [
'isError' => true,
'message' => $e->getMessage()
];
$data[$logId]['log_entry'][LogEntry::LOG_DETAILS] = [];
}
}
return $data;
}
}
@@ -0,0 +1,122 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\DataProvider\ActionsLog;
use Amasty\AdminActionsLog\Model\LogEntry\LogEntry;
use Amasty\AdminActionsLog\Model\LogEntry\ResourceModel\Grid\Collection;
use Magento\Framework\Api\Filter;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\Search\ReportingInterface;
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Data\CollectionModifierInterface;
use Magento\Framework\DataObject;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Magento\Framework\Stdlib\DateTime\Timezone;
use Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider;
class Listing extends DataProvider
{
/**
* @var CollectionModifierInterface[]
*/
private $collectionModifiers;
/**
* @var DateTime
*/
private $dateTime;
/**
* @var Timezone
*/
private $timezone;
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
ReportingInterface $reporting,
SearchCriteriaBuilder $searchCriteriaBuilder,
RequestInterface $request,
FilterBuilder $filterBuilder,
DateTime $dateTime,
Timezone $timezone,
array $collectionModifiers = [],
array $meta = [],
array $data = []
) {
parent::__construct(
$name,
$primaryFieldName,
$requestFieldName,
$reporting,
$searchCriteriaBuilder,
$request,
$filterBuilder,
$meta,
$data
);
$this->collectionModifiers = $collectionModifiers;
$this->dateTime = $dateTime;
$this->timezone = $timezone;
}
public function addFilter(Filter $filter)
{
if (isset($this->data['config']['filter_url_params'][$filter->getField()])) {
return;
}
switch ($filter->getField()) {
case LogEntry::DATE:
$value = $filter->getValue();
$date = new \DateTime(
$value,
new \DateTimeZone($this->timezone->getConfigTimezone())
);
$date = $this->dateTime->gmtDate('Y-m-d H:i:s', $date);
$filter->setValue($date);
break;
}
parent::addFilter($filter);
}
public function getSearchResult()
{
/** @var Collection $collection */
$collection = parent::getSearchResult();
$namespace = $this->request->getParam('namespace');
if (isset($this->collectionModifiers[$namespace])) {
$this->collectionModifiers[$namespace]->apply($collection);
}
return $collection;
}
protected function searchResultToOutput(SearchResultInterface $searchResult)
{
$logEntryItems = array_reduce($searchResult->getItems(), function (array $carry, DataObject $item): array {
$carry[] = $item->getData();
return $carry;
}, []);
return [
'items' => $logEntryItems,
'totalRecords' => $searchResult->getTotalCount()
];
}
}
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\DataProvider\ActiveSession;
use Amasty\AdminActionsLog\Model\ActiveSession\ResourceModel\CollectionFactory;
use Magento\Ui\DataProvider\AbstractDataProvider;
class Listing extends AbstractDataProvider
{
public function __construct(
CollectionFactory $collectionFactory,
$name,
$primaryFieldName,
$requestFieldName,
array $meta = [],
array $data = []
) {
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
$this->collection = $collectionFactory->create();
}
}
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\DataProvider\LoginAttempt;
use Amasty\AdminActionsLog\Model\LoginAttempt\ResourceModel\Grid\CollectionFactory;
use Magento\Framework\Api\Search\SearchCriteria;
use Magento\Framework\Api\Search\SearchCriteriaBuilder;
use Magento\Ui\DataProvider\AbstractDataProvider;
class Listing extends AbstractDataProvider
{
/**
* @var SearchCriteria
*/
private $searchCriteria;
public function __construct(
CollectionFactory $collectionFactory,
SearchCriteriaBuilder $searchCriteriaBuilder,
$name,
$primaryFieldName,
$requestFieldName,
array $meta = [],
array $data = []
) {
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
$this->collection = $collectionFactory->create();
$this->searchCriteria = $searchCriteriaBuilder->create()->setRequestName($name);
$this->collection->setSearchCriteria($this->searchCriteria);
}
/**
* @return SearchCriteria
*/
public function getSearchCriteria()
{
return $this->searchCriteria;
}
}
@@ -0,0 +1,110 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Model\Locator\LocatorInterface;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
use Magento\Framework\UrlInterface;
use Magento\Ui\Component\Form;
class History extends AbstractModifier
{
public const GROUP_HISTORY = 'history';
public const GROUP_CONTENT = 'content';
public const SORT_ORDER = 100;
public const LISTING_NS = 'amaudit_product_history_listing';
/**
* @var LocatorInterface
*/
protected $locator;
/**
* @var UrlInterface
*/
protected $urlBuilder;
/**
* @param LocatorInterface $locator
* @param UrlInterface $urlBuilder
*/
public function __construct(
LocatorInterface $locator,
UrlInterface $urlBuilder
) {
$this->locator = $locator;
$this->urlBuilder = $urlBuilder;
}
public function modifyData(array $data)
{
$productId = $this->locator->getProduct()->getId();
$data[$productId][self::DATA_SOURCE_DEFAULT]['current_product_id'] = $productId;
return $data;
}
public function modifyMeta(array $meta)
{
if (!$this->locator->getProduct()->getId()) {
return $meta;
}
$meta[static::GROUP_HISTORY] = [
'children' => [
self::LISTING_NS => [
'arguments' => [
'data' => [
'config' => [
'autoRender' => true,
'componentType' => 'insertListing',
'dataScope' => 'amaudit_product_history_listing',
'externalProvider' => self::LISTING_NS . '.amaudit_actionslog_listing_data_source',
'selectionsProvider' => self::LISTING_NS . '.' . self::LISTING_NS
. '.product_columns.ids',
'ns' => 'amaudit_product_history_listing',
'render_url' => $this->urlBuilder->getUrl('mui/index/render'),
'realTimeLink' => false,
'externalFilterMode' => true,
'imports' => [
'productId' => '${ $.provider }:data.product.current_product_id',
'__disableTmpl' => ['productId' => false]
],
'exports' => [
'productId' => '${ $.externalProvider }:params.current_product_id',
'__disableTmpl' => ['productId' => false]
],
],
],
],
],
],
'arguments' => [
'data' => [
'config' => [
'label' => __('History of Changes'),
'collapsible' => true,
'opened' => false,
'componentType' => Form\Fieldset::NAME,
'sortOrder' =>
$this->getNextGroupSortOrder(
$meta,
static::GROUP_CONTENT,
static::SORT_ORDER
),
],
],
],
];
return $meta;
}
}
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Admin Actions Log for Magento 2
*/
namespace Amasty\AdminActionsLog\Ui\DataProvider\VisitHistory;
use Amasty\AdminActionsLog\Model\VisitHistoryEntry\ResourceModel\CollectionFactory;
use Magento\Ui\DataProvider\AbstractDataProvider;
class Listing extends AbstractDataProvider
{
public function __construct(
CollectionFactory $collectionFactory,
$name,
$primaryFieldName,
$requestFieldName,
array $meta = [],
array $data = []
) {
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
$this->collection = $collectionFactory->create();
}
}