diff --git a/Api/AbuseapiManagementInterface.php b/Api/AbuseapiManagementInterface.php new file mode 100644 index 0000000..3efac23 --- /dev/null +++ b/Api/AbuseapiManagementInterface.php @@ -0,0 +1,27 @@ + __('Back'), + 'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()), + 'class' => 'back', + 'sort_order' => 10 + ]; + } + + /** + * Get URL for back (reset) button + * + * @return string + */ + public function getBackUrl() + { + return $this->getUrl('*/*/'); + } +} + diff --git a/Block/Adminhtml/Check/Edit/DeleteButton.php b/Block/Adminhtml/Check/Edit/DeleteButton.php new file mode 100644 index 0000000..4a6c0fd --- /dev/null +++ b/Block/Adminhtml/Check/Edit/DeleteButton.php @@ -0,0 +1,44 @@ +getModelId()) { + $data = [ + 'label' => __('Delete Check'), + 'class' => 'delete', + 'on_click' => 'deleteConfirm(\'' . __( + 'Are you sure you want to do this?' + ) . '\', \'' . $this->getDeleteUrl() . '\')', + 'sort_order' => 20, + ]; + } + return $data; + } + + /** + * Get URL for delete button + * + * @return string + */ + public function getDeleteUrl() + { + return $this->getUrl('*/*/delete', ['check_id' => $this->getModelId()]); + } +} + diff --git a/Block/Adminhtml/Check/Edit/GenericButton.php b/Block/Adminhtml/Check/Edit/GenericButton.php new file mode 100644 index 0000000..3bf9c12 --- /dev/null +++ b/Block/Adminhtml/Check/Edit/GenericButton.php @@ -0,0 +1,47 @@ +context = $context; + } + + /** + * Return model ID + * + * @return int|null + */ + public function getModelId() + { + return $this->context->getRequest()->getParam('check_id'); + } + + /** + * Generate url by route and parameters + * + * @param string $route + * @param array $params + * @return string + */ + public function getUrl($route = '', $params = []) + { + return $this->context->getUrlBuilder()->getUrl($route, $params); + } +} + diff --git a/Block/Adminhtml/Check/Edit/SaveAndContinueButton.php b/Block/Adminhtml/Check/Edit/SaveAndContinueButton.php new file mode 100644 index 0000000..dc0a0d1 --- /dev/null +++ b/Block/Adminhtml/Check/Edit/SaveAndContinueButton.php @@ -0,0 +1,32 @@ + __('Save and Continue Edit'), + 'class' => 'save', + 'data_attribute' => [ + 'mage-init' => [ + 'button' => ['event' => 'saveAndContinueEdit'], + ], + ], + 'sort_order' => 80, + ]; + } +} + diff --git a/Block/Adminhtml/Check/Edit/SaveButton.php b/Block/Adminhtml/Check/Edit/SaveButton.php new file mode 100644 index 0000000..46d82f0 --- /dev/null +++ b/Block/Adminhtml/Check/Edit/SaveButton.php @@ -0,0 +1,31 @@ + __('Save Check'), + 'class' => 'save primary', + 'data_attribute' => [ + 'mage-init' => ['button' => ['event' => 'save']], + 'form-role' => 'save', + ], + 'sort_order' => 90, + ]; + } +} + diff --git a/Controller/Adminhtml/Check.php b/Controller/Adminhtml/Check.php new file mode 100644 index 0000000..0c3b787 --- /dev/null +++ b/Controller/Adminhtml/Check.php @@ -0,0 +1,42 @@ +_coreRegistry = $coreRegistry; + parent::__construct($context); + } + + /** + * Init page + * + * @param \Magento\Backend\Model\View\Result\Page $resultPage + * @return \Magento\Backend\Model\View\Result\Page + */ + public function initPage($resultPage) + { + $resultPage->setActiveMenu(self::ADMIN_RESOURCE) + ->addBreadcrumb(__('Cs'), __('Cs')) + ->addBreadcrumb(__('Check'), __('Check')); + return $resultPage; + } +} + diff --git a/Controller/Adminhtml/Check/Delete.php b/Controller/Adminhtml/Check/Delete.php new file mode 100644 index 0000000..d891252 --- /dev/null +++ b/Controller/Adminhtml/Check/Delete.php @@ -0,0 +1,47 @@ +resultRedirectFactory->create(); + // check if we know what should be deleted + $id = $this->getRequest()->getParam('check_id'); + if ($id) { + try { + // init model and delete + $model = $this->_objectManager->create(\Cs\AbuseApi\Model\Check::class); + $model->load($id); + $model->delete(); + // display success message + $this->messageManager->addSuccessMessage(__('You deleted the Check.')); + // go to grid + return $resultRedirect->setPath('*/*/'); + } catch (\Exception $e) { + // display error message + $this->messageManager->addErrorMessage($e->getMessage()); + // go back to edit form + return $resultRedirect->setPath('*/*/edit', ['check_id' => $id]); + } + } + // display error message + $this->messageManager->addErrorMessage(__('We can\'t find a Check to delete.')); + // go to grid + return $resultRedirect->setPath('*/*/'); + } +} + diff --git a/Controller/Adminhtml/Check/Edit.php b/Controller/Adminhtml/Check/Edit.php new file mode 100644 index 0000000..a0ecab1 --- /dev/null +++ b/Controller/Adminhtml/Check/Edit.php @@ -0,0 +1,64 @@ +resultPageFactory = $resultPageFactory; + parent::__construct($context, $coreRegistry); + } + + /** + * Edit action + * + * @return \Magento\Framework\Controller\ResultInterface + */ + public function execute() + { + // 1. Get ID and create model + $id = $this->getRequest()->getParam('check_id'); + $model = $this->_objectManager->create(\Cs\AbuseApi\Model\Check::class); + + // 2. Initial checking + if ($id) { + $model->load($id); + if (!$model->getId()) { + $this->messageManager->addErrorMessage(__('This Check no longer exists.')); + /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + $resultRedirect = $this->resultRedirectFactory->create(); + return $resultRedirect->setPath('*/*/'); + } + } + $this->_coreRegistry->register('cs_abuseapi_check', $model); + + // 3. Build edit form + /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ + $resultPage = $this->resultPageFactory->create(); + $this->initPage($resultPage)->addBreadcrumb( + $id ? __('Edit Check') : __('New Check'), + $id ? __('Edit Check') : __('New Check') + ); + $resultPage->getConfig()->getTitle()->prepend(__('Checks')); + $resultPage->getConfig()->getTitle()->prepend($model->getId() ? __('Edit Check %1', $model->getId()) : __('New Check')); + return $resultPage; + } +} + diff --git a/Controller/Adminhtml/Check/Index.php b/Controller/Adminhtml/Check/Index.php new file mode 100644 index 0000000..8069747 --- /dev/null +++ b/Controller/Adminhtml/Check/Index.php @@ -0,0 +1,41 @@ +resultPageFactory = $resultPageFactory; + parent::__construct($context); + } + + /** + * Index action + * + * @return \Magento\Framework\Controller\ResultInterface + */ + public function execute() + { + $resultPage = $this->resultPageFactory->create(); + $resultPage->getConfig()->getTitle()->prepend(__("Check")); + return $resultPage; + } +} + diff --git a/Controller/Adminhtml/Check/InlineEdit.php b/Controller/Adminhtml/Check/InlineEdit.php new file mode 100644 index 0000000..6ef5fdb --- /dev/null +++ b/Controller/Adminhtml/Check/InlineEdit.php @@ -0,0 +1,65 @@ +jsonFactory = $jsonFactory; + } + + /** + * Inline edit action + * + * @return \Magento\Framework\Controller\ResultInterface + */ + public function execute() + { + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ + $resultJson = $this->jsonFactory->create(); + $error = false; + $messages = []; + + if ($this->getRequest()->getParam('isAjax')) { + $postItems = $this->getRequest()->getParam('items', []); + if (!count($postItems)) { + $messages[] = __('Please correct the data sent.'); + $error = true; + } else { + foreach (array_keys($postItems) as $modelid) { + /** @var \Cs\AbuseApi\Model\Check $model */ + $model = $this->_objectManager->create(\Cs\AbuseApi\Model\Check::class)->load($modelid); + try { + $model->setData(array_merge($model->getData(), $postItems[$modelid])); + $model->save(); + } catch (\Exception $e) { + $messages[] = "[Check ID: {$modelid}] {$e->getMessage()}"; + $error = true; + } + } + } + } + + return $resultJson->setData([ + 'messages' => $messages, + 'error' => $error + ]); + } +} + diff --git a/Controller/Adminhtml/Check/NewAction.php b/Controller/Adminhtml/Check/NewAction.php new file mode 100644 index 0000000..576f297 --- /dev/null +++ b/Controller/Adminhtml/Check/NewAction.php @@ -0,0 +1,41 @@ +resultForwardFactory = $resultForwardFactory; + parent::__construct($context, $coreRegistry); + } + + /** + * New action + * + * @return \Magento\Framework\Controller\ResultInterface + */ + public function execute() + { + /** @var \Magento\Framework\Controller\Result\Forward $resultForward */ + $resultForward = $this->resultForwardFactory->create(); + return $resultForward->forward('edit'); + } +} + diff --git a/Controller/Adminhtml/Check/Save.php b/Controller/Adminhtml/Check/Save.php new file mode 100644 index 0000000..de13e00 --- /dev/null +++ b/Controller/Adminhtml/Check/Save.php @@ -0,0 +1,71 @@ +dataPersistor = $dataPersistor; + parent::__construct($context); + } + + /** + * Save action + * + * @return \Magento\Framework\Controller\ResultInterface + */ + public function execute() + { + /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ + $resultRedirect = $this->resultRedirectFactory->create(); + $data = $this->getRequest()->getPostValue(); + if ($data) { + $id = $this->getRequest()->getParam('check_id'); + + $model = $this->_objectManager->create(\Cs\AbuseApi\Model\Check::class)->load($id); + if (!$model->getId() && $id) { + $this->messageManager->addErrorMessage(__('This Check no longer exists.')); + return $resultRedirect->setPath('*/*/'); + } + + $model->setData($data); + + try { + $model->save(); + $this->messageManager->addSuccessMessage(__('You saved the Check.')); + $this->dataPersistor->clear('cs_abuseapi_check'); + + if ($this->getRequest()->getParam('back')) { + return $resultRedirect->setPath('*/*/edit', ['check_id' => $model->getId()]); + } + return $resultRedirect->setPath('*/*/'); + } catch (LocalizedException $e) { + $this->messageManager->addErrorMessage($e->getMessage()); + } catch (\Exception $e) { + $this->messageManager->addExceptionMessage($e, __('Something went wrong while saving the Check.')); + } + + $this->dataPersistor->set('cs_abuseapi_check', $data); + return $resultRedirect->setPath('*/*/edit', ['check_id' => $this->getRequest()->getParam('check_id')]); + } + return $resultRedirect->setPath('*/*/'); + } +} + diff --git a/Controller/Check/Index.php b/Controller/Check/Index.php new file mode 100644 index 0000000..10d352c --- /dev/null +++ b/Controller/Check/Index.php @@ -0,0 +1,89 @@ +resultPageFactory = $resultPageFactory; + $this->serializer = $json; + $this->logger = $logger; + $this->http = $http; + } + + /** + * Execute view action + * + * @return ResultInterface + */ + public function execute() + { + try { + return $this->jsonResponse('your response'); + } catch (LocalizedException $e) { + return $this->jsonResponse($e->getMessage()); + } catch (\Exception $e) { + $this->logger->critical($e); + return $this->jsonResponse($e->getMessage()); + } + } + + /** + * Create json response + * + * @return ResultInterface + */ + public function jsonResponse($response = '') + { + $this->http->getHeaders()->clearHeaders(); + $this->http->setHeader('Content-Type', 'application/json'); + return $this->http->setBody( + $this->serializer->serialize($response) + ); + } +} + diff --git a/Model/AbuseapiManagement.php b/Model/AbuseapiManagement.php new file mode 100644 index 0000000..d15c076 --- /dev/null +++ b/Model/AbuseapiManagement.php @@ -0,0 +1,29 @@ +_init(\Cs\AbuseApi\Model\ResourceModel\Check::class); + } + + /** + * @inheritDoc + */ + public function getCheckId() + { + return $this->getData(self::CHECK_ID); + } + + /** + * @inheritDoc + */ + public function setCheckId($checkId) + { + return $this->setData(self::CHECK_ID, $checkId); + } + + /** + * @inheritDoc + */ + public function getIpAddress() + { + return $this->getData(self::IP_ADDRESS); + } + + /** + * @inheritDoc + */ + public function setIpAddress($ipAddress) + { + return $this->setData(self::IP_ADDRESS, $ipAddress); + } + + /** + * @inheritDoc + */ + public function getIsPublic() + { + return $this->getData(self::IS_PUBLIC); + } + + /** + * @inheritDoc + */ + public function setIsPublic($isPublic) + { + return $this->setData(self::IS_PUBLIC, $isPublic); + } + + /** + * @inheritDoc + */ + public function getIpVersion() + { + return $this->getData(self::IP_VERSION); + } + + /** + * @inheritDoc + */ + public function setIpVersion($ipVersion) + { + return $this->setData(self::IP_VERSION, $ipVersion); + } + + /** + * @inheritDoc + */ + public function getAbuseConfidenceScore() + { + return $this->getData(self::ABUSE_CONFIDENCE_SCORE); + } + + /** + * @inheritDoc + */ + public function setAbuseConfidenceScore($abuseConfidenceScore) + { + return $this->setData(self::ABUSE_CONFIDENCE_SCORE, $abuseConfidenceScore); + } + + /** + * @inheritDoc + */ + public function getCountryCode() + { + return $this->getData(self::COUNTRY_CODE); + } + + /** + * @inheritDoc + */ + public function setCountryCode($countryCode) + { + return $this->setData(self::COUNTRY_CODE, $countryCode); + } + + /** + * @inheritDoc + */ + public function getIsWhitelisted() + { + return $this->getData(self::IS_WHITELISTED); + } + + /** + * @inheritDoc + */ + public function setIsWhitelisted($isWhitelisted) + { + return $this->setData(self::IS_WHITELISTED, $isWhitelisted); + } + + /** + * @inheritDoc + */ + public function getUsageType() + { + return $this->getData(self::USAGE_TYPE); + } + + /** + * @inheritDoc + */ + public function setUsageType($usageType) + { + return $this->setData(self::USAGE_TYPE, $usageType); + } + + /** + * @inheritDoc + */ + public function getIsp() + { + return $this->getData(self::ISP); + } + + /** + * @inheritDoc + */ + public function setIsp($isp) + { + return $this->setData(self::ISP, $isp); + } + + /** + * @inheritDoc + */ + public function getDomain() + { + return $this->getData(self::DOMAIN); + } + + /** + * @inheritDoc + */ + public function setDomain($domain) + { + return $this->setData(self::DOMAIN, $domain); + } + + /** + * @inheritDoc + */ + public function getTotalReports() + { + return $this->getData(self::TOTAL_REPORTS); + } + + /** + * @inheritDoc + */ + public function setTotalReports($totalReports) + { + return $this->setData(self::TOTAL_REPORTS, $totalReports); + } + + /** + * @inheritDoc + */ + public function getNumDistinctUsers() + { + return $this->getData(self::NUM_DISTINCT_USERS); + } + + /** + * @inheritDoc + */ + public function setNumDistinctUsers($numDistinctUsers) + { + return $this->setData(self::NUM_DISTINCT_USERS, $numDistinctUsers); + } + + /** + * @inheritDoc + */ + public function getLastReportedAt() + { + return $this->getData(self::LAST_REPORTED_AT); + } + + /** + * @inheritDoc + */ + public function setLastReportedAt($lastReportedAt) + { + return $this->setData(self::LAST_REPORTED_AT, $lastReportedAt); + } + + /** + * @inheritDoc + */ + public function getCreatedAt() + { + return $this->getData(self::CREATED_AT); + } + + /** + * @inheritDoc + */ + public function setCreatedAt($createdAt) + { + return $this->setData(self::CREATED_AT, $createdAt); + } + + /** + * @inheritDoc + */ + public function getUpdatedAt() + { + return $this->getData(self::UPDATED_AT); + } + + /** + * @inheritDoc + */ + public function setUpdatedAt($updatedAt) + { + return $this->setData(self::UPDATED_AT, $updatedAt); + } + + /** + * @inheritDoc + */ + public function getCheckDays() + { + return $this->getData(self::CHECK_DAYS); + } + + /** + * @inheritDoc + */ + public function setCheckDays($checkDays) + { + return $this->setData(self::CHECK_DAYS, $checkDays); + } + + /** + * @inheritDoc + */ + public function getHostnames(): ?array + { + return explode(',',$this->getData(self::HOSTNAMES)); + } + + /** + * @inheritDoc + */ + public function setHostnames(array $hostnames) + { + return $this->setData(self::HOSTNAMES, implode(',',$hostnames)); + } + + /** + * @inheritDoc + */ + public function getIsTor() + { + return $this->getData(self::IS_TOR); + } + + /** + * @inheritDoc + */ + public function setIsTor($isTor) + { + return $this->setData(self::IS_TOR, $isTor); + } +} + diff --git a/Model/Check/DataProvider.php b/Model/Check/DataProvider.php new file mode 100644 index 0000000..f85461e --- /dev/null +++ b/Model/Check/DataProvider.php @@ -0,0 +1,79 @@ +collection = $collectionFactory->create(); + $this->dataPersistor = $dataPersistor; + parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); + } + + /** + * @inheritDoc + */ + public function getData() + { + if (isset($this->loadedData)) { + return $this->loadedData; + } + $items = $this->collection->getItems(); + foreach ($items as $model) { + $this->loadedData[$model->getId()] = $model->getData(); + } + $data = $this->dataPersistor->get('cs_abuseapi_check'); + + if (!empty($data)) { + $model = $this->collection->getNewEmptyItem(); + $model->setData($data); + $this->loadedData[$model->getId()] = $model->getData(); + $this->dataPersistor->clear('cs_abuseapi_check'); + } + + return $this->loadedData; + } +} + diff --git a/Model/CheckRepository.php b/Model/CheckRepository.php new file mode 100644 index 0000000..63954bc --- /dev/null +++ b/Model/CheckRepository.php @@ -0,0 +1,149 @@ +resource = $resource; + $this->checkFactory = $checkFactory; + $this->checkCollectionFactory = $checkCollectionFactory; + $this->searchResultsFactory = $searchResultsFactory; + $this->collectionProcessor = $collectionProcessor; + } + + /** + * @inheritDoc + */ + public function save(CheckInterface $check) + { + try { + $this->resource->save($check); + } catch (\Exception $exception) { + throw new CouldNotSaveException(__( + 'Could not save the check: %1', + $exception->getMessage() + )); + } + return $check; + } + + /** + * @inheritDoc + */ + public function get($checkId) + { + $check = $this->checkFactory->create(); + $this->resource->load($check, $checkId); + if (!$check->getId()) { + throw new NoSuchEntityException(__('Check with id "%1" does not exist.', $checkId)); + } + return $check; + } + + /** + * @inheritDoc + */ + public function getList( + \Magento\Framework\Api\SearchCriteriaInterface $criteria + ) { + $collection = $this->checkCollectionFactory->create(); + + $this->collectionProcessor->process($criteria, $collection); + + $searchResults = $this->searchResultsFactory->create(); + $searchResults->setSearchCriteria($criteria); + + $items = []; + foreach ($collection as $model) { + $items[] = $model; + } + + $searchResults->setItems($items); + $searchResults->setTotalCount($collection->getSize()); + return $searchResults; + } + + /** + * @inheritDoc + */ + public function delete(CheckInterface $check) + { + try { + $checkModel = $this->checkFactory->create(); + $this->resource->load($checkModel, $check->getCheckId()); + $this->resource->delete($checkModel); + } catch (\Exception $exception) { + throw new CouldNotDeleteException(__( + 'Could not delete the Check: %1', + $exception->getMessage() + )); + } + return true; + } + + /** + * @inheritDoc + */ + public function deleteById($checkId) + { + return $this->delete($this->get($checkId)); + } +} + diff --git a/Model/Client/CheckResponse.php b/Model/Client/CheckResponse.php index d99fe46..24b63ff 100644 --- a/Model/Client/CheckResponse.php +++ b/Model/Client/CheckResponse.php @@ -21,7 +21,11 @@ class CheckResponse extends DataObject implements CheckResponseInterface public function __construct( array $data = [] ) { - parent::__construct($data); + $updata = []; + foreach ($data as $key => $value) { + $updata[\Magento\Framework\Api\SimpleDataObjectConverter::camelCaseToSnakeCase($key)] = $value; + } + parent::__construct($updata); } /** @@ -101,15 +105,20 @@ public function getDomain(): string */ public function getHostnames(): array { - return $this->getData(self::HOSTNAMES); + $hostnames = explode(',',$this->getData(self::HOSTNAMES)); + if (is_array($hostnames)) + { + return $hostnames; + } + return []; } /** * @inheritDoc */ - public function getTotalReports(): int + public function setHostnames(array $value): CheckResponse { - return $this->getData(self::TOTAL_REPORTS); + return $this->setData(self::HOSTNAMES, implode(',',$value)); } /** @@ -200,14 +209,6 @@ public function setDomain(string $value): void $this->setData(self::DOMAIN, $value); } - /** - * @inheritDoc - */ - public function setHostnames(array $value = []): void - { - $this->setData(self::HOSTNAMES, $value); - } - /** * @inheritDoc */ @@ -232,5 +233,10 @@ public function setLastReportedAt(string $value): void $this->setData(self::LAST_REPORTED_AT, $value); } + public function getTotalReports(): int + { + // TODO: Implement getTotalReports() method. + return $this->getData('total_reports'); + } } diff --git a/Model/PiresAbuseIpCheck.php b/Model/PiresAbuseIpCheck.php new file mode 100644 index 0000000..1e8976e --- /dev/null +++ b/Model/PiresAbuseIpCheck.php @@ -0,0 +1,14 @@ +_init(ResourceModel::class); // Initialize the resource model + } +} diff --git a/Model/ResourceModel/Check.php b/Model/ResourceModel/Check.php new file mode 100644 index 0000000..9ccc5b3 --- /dev/null +++ b/Model/ResourceModel/Check.php @@ -0,0 +1,23 @@ +_init('cs_abuseapi_check', 'check_id'); + } +} + diff --git a/Model/ResourceModel/Check/Collection.php b/Model/ResourceModel/Check/Collection.php new file mode 100644 index 0000000..328265a --- /dev/null +++ b/Model/ResourceModel/Check/Collection.php @@ -0,0 +1,31 @@ +_init( + \Cs\AbuseApi\Model\Check::class, + \Cs\AbuseApi\Model\ResourceModel\Check::class + ); + } +} + diff --git a/Model/ResourceModel/PiresAbuseIpCheck.php b/Model/ResourceModel/PiresAbuseIpCheck.php new file mode 100644 index 0000000..0b2a7e8 --- /dev/null +++ b/Model/ResourceModel/PiresAbuseIpCheck.php @@ -0,0 +1,15 @@ +_init('pires_abuseip_check', 'id'); // Define the table name and primary key + } +} + diff --git a/Model/ResourceModel/PiresAbuseIpCheck/Collection.php b/Model/ResourceModel/PiresAbuseIpCheck/Collection.php new file mode 100644 index 0000000..a07c610 --- /dev/null +++ b/Model/ResourceModel/PiresAbuseIpCheck/Collection.php @@ -0,0 +1,19 @@ +_init(Model::class, ResourceModel::class); + // Initialize the model and resource model + } +} diff --git a/Ui/Component/Listing/Column/CheckActions.php b/Ui/Component/Listing/Column/CheckActions.php new file mode 100644 index 0000000..1f0fa19 --- /dev/null +++ b/Ui/Component/Listing/Column/CheckActions.php @@ -0,0 +1,78 @@ +urlBuilder = $urlBuilder; + parent::__construct($context, $uiComponentFactory, $components, $data); + } + + /** + * Prepare Data Source + * + * @param array $dataSource + * @return array + */ + public function prepareDataSource(array $dataSource) + { + if (isset($dataSource['data']['items'])) { + foreach ($dataSource['data']['items'] as & $item) { + if (isset($item['check_id'])) { + $item[$this->getData('name')] = [ + 'edit' => [ + 'href' => $this->urlBuilder->getUrl( + static::URL_PATH_EDIT, + [ + 'check_id' => $item['check_id'] + ] + ), + 'label' => __('Edit') + ], + 'delete' => [ + 'href' => $this->urlBuilder->getUrl( + static::URL_PATH_DELETE, + [ + 'check_id' => $item['check_id'] + ] + ), + 'label' => __('Delete'), + 'confirm' => [ + 'title' => __('Delete "${ $.$data.title }"'), + 'message' => __('Are you sure you wan\'t to delete a "${ $.$data.title }" record?') + ] + ] + ]; + } + } + } + + return $dataSource; + } +} + diff --git a/composer.json b/composer.json index 0629541..73a78e5 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "description": "Abuse IP Database API Integration for Magento2", "homepage": "https://github.com/df2k2/abuse-api", "require": { - "php": "^7.1|^7.2|^7.3", + "php": "~7.0|^8.0|^8.1|^8.2", "magento/magento-composer-installer": "*" }, "authors": [ diff --git a/etc/acl.xml b/etc/acl.xml index 073e9ae..87e97d7 100644 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -8,6 +8,12 @@ + + + + + + diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml new file mode 100644 index 0000000..083c677 --- /dev/null +++ b/etc/adminhtml/menu.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml new file mode 100644 index 0000000..f625298 --- /dev/null +++ b/etc/adminhtml/routes.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/etc/db_schema.xml b/etc/db_schema.xml new file mode 100644 index 0000000..8559049 --- /dev/null +++ b/etc/db_schema.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/etc/di.xml b/etc/di.xml index 58f3008..366449b 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -17,4 +17,22 @@ + + + + + + + cs_abuseapi_check + Cs\AbuseApi\Model\ResourceModel\Check\Collection + + + + + + Cs\AbuseApi\Model\ResourceModel\Check\Grid\Collection + + + + diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml new file mode 100644 index 0000000..6f4795e --- /dev/null +++ b/etc/frontend/routes.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/etc/webapi.xml b/etc/webapi.xml new file mode 100644 index 0000000..ccd9ea7 --- /dev/null +++ b/etc/webapi.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/readme.md b/readme.md index 5fe3bba..d2d9296 100644 --- a/readme.md +++ b/readme.md @@ -117,7 +117,7 @@ Register for API Key. + + + + + + + + diff --git a/view/adminhtml/layout/cs_abuseapi_check_index.xml b/view/adminhtml/layout/cs_abuseapi_check_index.xml new file mode 100644 index 0000000..3379480 --- /dev/null +++ b/view/adminhtml/layout/cs_abuseapi_check_index.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/view/adminhtml/layout/cs_abuseapi_check_new.xml b/view/adminhtml/layout/cs_abuseapi_check_new.xml new file mode 100644 index 0000000..f422c35 --- /dev/null +++ b/view/adminhtml/layout/cs_abuseapi_check_new.xml @@ -0,0 +1,4 @@ + + + + diff --git a/view/adminhtml/ui_component/cs_abuseapi_check_form.xml b/view/adminhtml/ui_component/cs_abuseapi_check_form.xml new file mode 100644 index 0000000..e72d9cf --- /dev/null +++ b/view/adminhtml/ui_component/cs_abuseapi_check_form.xml @@ -0,0 +1,194 @@ + +
+ + + cs_abuseapi_check_form.check_form_data_source + + General Information + templates/form/collapsible + + + + + +
+ + + + check_id + + + + Cs_AbuseApi::Check + + + id + check_id + + + + + + true + + + + + + + + + + cs_abuseapi_check_listing.cs_abuseapi_check_listing.cs_abuseapi_check_columns.ids + true + check_id + + + false + + + + + cs_abuseapi_check_listing.cs_abuseapi_check_listing.cs_abuseapi_check_columns_editor + startEdit + + ${ $.$data.rowIndex } + true + + + + + + + check_id + + + + + text + asc + + + + + + text + + + text + + false + + + + + + + check_id + false + 107 + + + + + text + + + text + + false + + + + + + + text + + + text + + false + + + + + + + text + + + text + + false + + + + + + + text + + + text + + false + + + + + + + + text + + false + + + + + + + text + + + text + + false + + + + + + + text + + + text + + false + + + + + + + text + + + text + + false + + + + + + + + text + + false + + + + + + + text + + + + + + text + + + + + + text + + + + + + text + + + + +