-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1089 from algolia/develop
Develop
- Loading branch information
Showing
48 changed files
with
1,585 additions
and
99 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
app/code/community/Algolia/Algoliasearch/Block/Adminhtml/IndexingQueue.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue extends Mage_Adminhtml_Block_Widget_Grid_Container | ||
{ | ||
/** | ||
* Initialize Grid Container | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->_blockGroup = 'algoliasearch'; | ||
$this->_controller = 'adminhtml_indexingqueue'; | ||
|
||
parent::__construct(); | ||
|
||
$this->_removeButton('add'); | ||
$this->_addButton('clear_queue', array( | ||
'label' => Mage::helper('algoliasearch')->__('Clear Queue'), | ||
'onclick' => "if (confirm('Are you sure you want to clear the queue? This operation cannot be reverted.')) { | ||
location.href='" . $this->getUrl('*/*/clear') . "' };", | ||
'class' => 'cancel', | ||
)); | ||
} | ||
|
||
/** | ||
* Get header text. | ||
* | ||
* @return string | ||
*/ | ||
public function getHeaderText() | ||
{ | ||
return Mage::helper('algoliasearch')->__('Algolia Search - Indexing Queue'); | ||
} | ||
|
||
/** | ||
* Set custom Algolia icon class. | ||
* | ||
* @return string | ||
*/ | ||
public function getHeaderCssClass() | ||
{ | ||
return 'icon-head algoliasearch-head-icon'; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/code/community/Algolia/Algoliasearch/Block/Adminhtml/IndexingQueue/Edit.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Edit extends Mage_Adminhtml_Block_Widget_Form_Container | ||
{ | ||
/** | ||
* Internal constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->_objectId = 'job_id'; | ||
$this->_blockGroup = 'algoliasearch'; | ||
$this->_controller = 'adminhtml_indexingqueue'; | ||
|
||
$this->_removeButton('save'); | ||
$this->_removeButton('reset'); | ||
$this->_removeButton('delete'); | ||
} | ||
|
||
/** | ||
* Get header text. | ||
* | ||
* @return string | ||
*/ | ||
public function getHeaderText() | ||
{ | ||
return Mage::helper('algoliasearch')->__('Algolia Search - Indexing Queue Job #%s', | ||
Mage::registry('algoliasearch_current_job')->getJobId()); | ||
} | ||
|
||
/** | ||
* Set custom Algolia icon class. | ||
* | ||
* @return string | ||
*/ | ||
public function getHeaderCssClass() | ||
{ | ||
return 'icon-head algoliasearch-head-icon'; | ||
} | ||
} |
118 changes: 118 additions & 0 deletions
118
app/code/community/Algolia/Algoliasearch/Block/Adminhtml/IndexingQueue/Edit/Form.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php | ||
|
||
class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Edit_Form extends Mage_Adminhtml_Block_Widget_Form | ||
{ | ||
/** | ||
* @return Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Edit_Form | ||
*/ | ||
protected function _prepareForm() | ||
{ | ||
$model = Mage::registry('algoliasearch_current_job'); | ||
|
||
$form = new Varien_Data_Form(array( | ||
'id' => 'edit_form', | ||
'action' => $this->getUrl('*/*/updatePost'), | ||
'method' => 'post', | ||
)); | ||
|
||
$fieldset = $form->addFieldset('base_fieldset', array()); | ||
$readOnlyStyle = 'border: 0; background: none;'; | ||
|
||
$fieldset->addField('job_id', 'text', array( | ||
'name' => 'job_id', | ||
'label' => Mage::helper('algoliasearch')->__('Job ID'), | ||
'title' => Mage::helper('algoliasearch')->__('Job ID'), | ||
'readonly' => true, | ||
'style' => $readOnlyStyle, | ||
)); | ||
|
||
$fieldset->addField('created', 'text', array( | ||
'name' => 'created', | ||
'label' => Mage::helper('algoliasearch')->__('Created'), | ||
'title' => Mage::helper('algoliasearch')->__('Created'), | ||
'readonly' => true, | ||
'style' => $readOnlyStyle, | ||
)); | ||
|
||
$fieldset->addField('status', 'text', array( | ||
'name' => 'status', | ||
'label' => Mage::helper('algoliasearch')->__('Status'), | ||
'title' => Mage::helper('algoliasearch')->__('Status'), | ||
'readonly' => true, | ||
'style' => $readOnlyStyle, | ||
)); | ||
|
||
$fieldset->addField('pid', 'text', array( | ||
'name' => 'pid', | ||
'label' => Mage::helper('algoliasearch')->__('PID'), | ||
'title' => Mage::helper('algoliasearch')->__('PID'), | ||
'readonly' => true, | ||
'style' => $readOnlyStyle, | ||
)); | ||
|
||
$fieldset->addField('class', 'text', array( | ||
'name' => 'class', | ||
'label' => Mage::helper('algoliasearch')->__('Class'), | ||
'title' => Mage::helper('algoliasearch')->__('Class'), | ||
'readonly' => true, | ||
'style' => $readOnlyStyle, | ||
)); | ||
|
||
$fieldset->addField('method', 'text', array( | ||
'name' => 'method', | ||
'label' => Mage::helper('algoliasearch')->__('Method'), | ||
'title' => Mage::helper('algoliasearch')->__('Method'), | ||
'readonly' => true, | ||
'style' => $readOnlyStyle, | ||
)); | ||
|
||
$fieldset->addField('data', 'textarea', array( | ||
'name' => 'data', | ||
'label' => Mage::helper('algoliasearch')->__('Data'), | ||
'title' => Mage::helper('algoliasearch')->__('Data'), | ||
'readonly' => true, | ||
)); | ||
|
||
$fieldset->addField('max_retries', 'text', array( | ||
'name' => 'max_retries', | ||
'label' => Mage::helper('algoliasearch')->__('Max Retries'), | ||
'title' => Mage::helper('algoliasearch')->__('Max Retries'), | ||
'readonly' => true, | ||
'style' => $readOnlyStyle, | ||
)); | ||
|
||
$fieldset->addField('retries', 'text', array( | ||
'name' => 'retries', | ||
'label' => Mage::helper('algoliasearch')->__('Retries'), | ||
'title' => Mage::helper('algoliasearch')->__('Retries'), | ||
'readonly' => true, | ||
'style' => $readOnlyStyle, | ||
)); | ||
|
||
$fieldset->addField('data_size', 'text', array( | ||
'name' => 'data_size', | ||
'label' => Mage::helper('algoliasearch')->__('Data Size'), | ||
'title' => Mage::helper('algoliasearch')->__('Data Size'), | ||
'readonly' => true, | ||
'style' => $readOnlyStyle, | ||
)); | ||
|
||
$fieldset->addField('error_log', 'textarea', array( | ||
'name' => 'error_log', | ||
'label' => Mage::helper('algoliasearch')->__('Error Log'), | ||
'title' => Mage::helper('algoliasearch')->__('Error Log'), | ||
'readonly' => true, | ||
)); | ||
|
||
|
||
$form->setValues($model->getData()); | ||
$form->addValues(array( | ||
'status' => $model->getStatusLabel() | ||
)); | ||
$form->setUseContainer(true); | ||
|
||
$this->setForm($form); | ||
|
||
return parent::_prepareForm(); | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
app/code/community/Algolia/Algoliasearch/Block/Adminhtml/IndexingQueue/Grid.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Grid extends Mage_Adminhtml_Block_Widget_Grid | ||
{ | ||
/** | ||
* Initialize Grid Properties | ||
* | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->setId('job_id'); | ||
$this->setDefaultSort('job_id'); | ||
$this->setDefaultDir('acs'); | ||
} | ||
|
||
/** | ||
* Prepare Search Report collection for grid | ||
* | ||
* @return Mage_Adminhtml_Block_Report_Search_Grid | ||
*/ | ||
protected function _prepareCollection() | ||
{ | ||
$collection = Mage::getResourceModel('algoliasearch/job_collection'); | ||
$this->setCollection($collection); | ||
|
||
return parent::_prepareCollection(); | ||
} | ||
|
||
/** | ||
* Prepare Grid columns | ||
* | ||
* @return Mage_Adminhtml_Block_Report_Search_Grid | ||
*/ | ||
protected function _prepareColumns() | ||
{ | ||
$this->addColumn('job_id', array( | ||
'header' => Mage::helper('algoliasearch')->__('Job ID'), | ||
'width' => '50px', | ||
'filter' => false, | ||
'index' => 'job_id', | ||
'type' => 'number' | ||
)); | ||
|
||
$this->addColumn('created', array( | ||
'header' => Mage::helper('algoliasearch')->__('Created'), | ||
'index' => 'created', | ||
'type' => 'datetime', | ||
)); | ||
|
||
$this->addColumn('status', array( | ||
'header' => Mage::helper('algoliasearch')->__('Status'), | ||
'index' => 'status', | ||
'getter' => 'getStatusLabel', | ||
'filter' => false, | ||
)); | ||
|
||
$this->addColumn('method', array( | ||
'header' => Mage::helper('algoliasearch')->__('Method'), | ||
'index' => 'method', | ||
'type' => 'options', | ||
'options' => Mage::getModel('algoliasearch/source_jobMethods')->getMethods(), | ||
)); | ||
|
||
$this->addColumn('data', array( | ||
'header' => Mage::helper('algoliasearch')->__('Data'), | ||
'index' => 'data', | ||
'renderer' => 'Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Grid_Renderer_Json' | ||
)); | ||
|
||
$this->addColumn('max_retries', array( | ||
'header' => Mage::helper('algoliasearch')->__('Max Retries'), | ||
'width' => '40px', | ||
'filter' => false, | ||
'index' => 'max_retries', | ||
'type' => 'number' | ||
)); | ||
|
||
$this->addColumn('retries', array( | ||
'header' => Mage::helper('algoliasearch')->__('Retries'), | ||
'width' => '40px', | ||
'filter' => false, | ||
'index' => 'retries', | ||
'type' => 'number' | ||
)); | ||
|
||
$this->addColumn('action', | ||
array( | ||
'header' => Mage::helper('algoliasearch')->__('Action'), | ||
'width' => '50px', | ||
'type' => 'action', | ||
'getter' => 'getJobId', | ||
'actions' => array( | ||
array( | ||
'caption' => Mage::helper('algoliasearch')->__('View'), | ||
'url' => array('base'=>'*/*/view'), | ||
'field' => 'id' | ||
) | ||
), | ||
'filter' => false, | ||
'sortable' => false, | ||
)); | ||
|
||
return parent::_prepareColumns(); | ||
} | ||
|
||
/** | ||
* Retrieve Row Click callback URL | ||
* | ||
* @return string | ||
*/ | ||
public function getRowUrl($row) | ||
{ | ||
return $this->getUrl('*/*/view', array('id' => $row->getJobId())); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...code/community/Algolia/Algoliasearch/Block/Adminhtml/IndexingQueue/Grid/Renderer/Json.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
class Algolia_Algoliasearch_Block_Adminhtml_IndexingQueue_Grid_Renderer_Json extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract | ||
{ | ||
/** | ||
* @param Varien_Object $row | ||
* @return string | ||
*/ | ||
public function render(Varien_Object $row) | ||
{ | ||
$html = ''; | ||
if ($json = $row->getData('data')) { | ||
$json = json_decode($json, true); | ||
|
||
foreach ($json as $var => $value) { | ||
$html .= $var . ': ' . (is_array($value) ? implode(',', $value) : $value) . '<br/>'; | ||
} | ||
} | ||
return $html; | ||
} | ||
} |
Oops, something went wrong.