Skip to content

Commit

Permalink
Merge pull request #39 from mzeis/dev
Browse files Browse the repository at this point in the history
Fixes for #33, #34 and #38
  • Loading branch information
fbrnc committed Sep 28, 2015
2 parents 4ecc104 + f2be115 commit 2903fb1
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 4 deletions.
Expand Up @@ -20,6 +20,17 @@ public function __construct()
$this->setUseAjax(true);
}

protected function _prepareMassaction() {
$this->setMassactionIdField('stack_id');
$this->getMassactionBlock()->setFormFieldName('stack');

$this->getMassactionBlock()->addItem('delete', array(
'label' => Mage::helper('aoe_profiler')->__('Delete'),
'url' => $this->getUrl('*/*/massDelete'),
'confirm' => Mage::helper('aoe_profiler')->__('Are you sure?')
) );
}

/**
* Prepare grid collection object
*
Expand Down Expand Up @@ -108,4 +119,4 @@ public function getGridUrl()
{
return $this->getUrl('*/*/grid', array('_current'=>true));
}
}
}
Expand Up @@ -9,4 +9,48 @@ class Aoe_Profiler_Block_Adminhtml_Profiler_View extends Mage_Adminhtml_Block_Wi
{

protected $_template = 'aoe_profiler/view.phtml';
}

protected function _construct()
{
parent::_construct();

$this->_addButton('back', array(
'label' => Mage::helper('aoe_profiler')->__('Back'),
'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
'class' => 'back',
), -1);

if ($this->getStack()->getId()) {
$this->_addButton('delete', array(
'label' => Mage::helper('aoe_profiler')->__('Delete'),
'class' => 'delete',
'onclick' => 'deleteConfirm(\''. Mage::helper('aoe_profiler')->__('Are you sure you want to do this?')
.'\', \'' . $this->getDeleteUrl() . '\')',
));
}
}

/**
* @return string
*/
public function getBackUrl()
{
return $this->getUrl('*/*/');
}

/**
* @return string
*/
public function getDeleteUrl()
{
return $this->getUrl('*/*/delete', array('stack_id' => $this->getStack()->getId()));
}

/**
* @return Aoe_Profiler_Model_Run
*/
public function getStack()
{
return Mage::registry('current_stack_instance');
}
}
12 changes: 12 additions & 0 deletions app/code/community/Aoe/Profiler/Block/Info.php
@@ -0,0 +1,12 @@
<?php

class Aoe_Profiler_Block_Info extends Mage_Adminhtml_Block_Template
{
/**
* @return Aoe_Profiler_Model_Run
*/
public function getStack()
{
return Mage::registry('current_stack_instance');
}
}
Expand Up @@ -48,6 +48,27 @@ protected function _initStackInstance()
return false;
}


/**
* Delete the selected stack instance.
*
* @return void
*/
public function deleteAction()
{
try {
$stack = $this->_initStackInstance();
if ($stack) {
$stack->delete();
$this->_getSession()->addSuccess( $this->__( 'The entry has been deleted.' ) );
}
} catch (Exception $e) {
$this->_getSession()->addError($e->getMessage());
}

$this->_redirect('*/*/');
}

/**
* Layout Grid
*/
Expand All @@ -68,6 +89,32 @@ public function gridAction()
$this->renderLayout();
}

/**
* @return void
*/
public function massDeleteAction()
{
$ids = $this->getRequest()->getParam('stack');
if (!is_array($ids)) {
$this->_getSession()->addError($this->__('Please select stack(s).'));
} else {
if (!empty($ids)) {
try {
foreach ($ids as $id) {
$stack = Mage::getSingleton('aoe_profiler/run')->load($id);
$stack->delete();
}
$this->_getSession()->addSuccess(
$this->__('Total of %d record(s) have been deleted.', count($ids))
);
} catch (Exception $e) {
$this->_getSession()->addError($e->getMessage());
}
}
}
$this->_redirect('*/*/index');
}

/**
* Edit layout instance action
*
Expand All @@ -93,4 +140,4 @@ protected function _isAllowed()
return Mage::getSingleton('admin/session')->isAllowed('system/aoe_profiler');
}

}
}
Expand Up @@ -20,10 +20,11 @@
</reference>
<reference name="content">
<block type="aoe_profiler/adminhtml_profiler_view" name="aoe_profiler_view">
<block type="aoe_profiler/info" name="aoe_profiler_info" template="aoe_profiler/view/info.phtml" />
<block type="aoe_profiler/tree" name="aoe_profiler_tree" />
<block type="aoe_profiler/filter" name="aoe_profiler_filter" />
</block>
</reference>
</adminhtml_profiler_view>

</profiler>
</profiler>
Expand Up @@ -13,6 +13,7 @@
</tr>
</table>
</div>
<?php echo $this->getChildHtml('aoe_profiler_info') ?>
<?php echo $this->getChildHtml('aoe_profiler_filter') ?>
<div>
<?php echo $this->getChildHtml('aoe_profiler_tree') ?>
Expand Down
@@ -0,0 +1,37 @@
<?php
/**
* @var $this Aoe_Profiler_Block_Info
*/
$_stack = $this->getStack();
?>
<div class="entry-edit">
<div class="entry-edit-head"><h4 class="icon-head"><?php echo $this->__('Run Details') ?></h4></div>
<fieldset>
<table cellspacing="2" class="box-left">
<tr>
<td><strong><?php echo $this->__('Created:') ?></strong></td>
<td><?php echo $this->formatDate($_stack->getCreatedAt(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true); ?></td>
</tr>
<tr>
<td><strong><?php echo $this->__('Route:') ?></strong></td>
<td><?php echo $this->escapeHtml($_stack->getRoute()); ?></td>
</tr>
<tr>
<td><strong><?php echo $this->__('URL:') ?></strong></td>
<td><?php echo $this->escapeHtml($_stack->getUrl()); ?></td>
</tr>
<tr>
<td><strong><?php echo $this->__('Session Id:') ?></strong></td>
<td><?php echo $this->escapeHtml($_stack->getSessionId()); ?></td>
</tr>
<tr>
<td><strong><?php echo $this->__('Time [sec]:') ?></strong></td>
<td><?php echo $this->escapeHtml($_stack->getTotalTime()); ?></td>
</tr>
<tr>
<td><strong><?php echo $this->__('Memory [MB]') ?></strong></td>
<td><?php echo $this->escapeHtml($_stack->getTotalMemory()); ?></td>
</tr>
</table>
</fieldset>
</div>

0 comments on commit 2903fb1

Please sign in to comment.