From d4f54d06050a8967c439094eba74c01898794d77 Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Wed, 6 May 2015 17:06:58 +0200
Subject: [PATCH 1/2] Fixed: transmit status update url to javascript object
instead of using constant
---
.../Adminhtml/ProcessController.php | 6 ++--
.../default/layout/hackathon_indexerstats.xml | 3 ++
.../hackathon/indexerstats/process/js.phtml | 26 ++++++++++++++++
js/hackathon_indexerstats/index_progress.js | 31 +++----------------
4 files changed, 37 insertions(+), 29 deletions(-)
rename app/design/adminhtml/{base => default}/default/layout/hackathon_indexerstats.xml (81%)
create mode 100644 app/design/adminhtml/default/default/template/hackathon/indexerstats/process/js.phtml
diff --git a/app/code/community/Hackathon/IndexerStats/controllers/Adminhtml/ProcessController.php b/app/code/community/Hackathon/IndexerStats/controllers/Adminhtml/ProcessController.php
index 66667ec..bdd5622 100644
--- a/app/code/community/Hackathon/IndexerStats/controllers/Adminhtml/ProcessController.php
+++ b/app/code/community/Hackathon/IndexerStats/controllers/Adminhtml/ProcessController.php
@@ -43,11 +43,13 @@ public function statusAjaxAction()
$gridBlock = $this->getLayout()->createBlock('index/adminhtml_process_grid');
foreach ($indexer->getProcessesCollection()->clear() as $process) {
/* @var $process Mage_Index_Model_Process */
+ $updateRequiredOptions = $process->getUpdateRequiredOptions();
$updateRequiredDisplay = $gridBlock->decorateUpdateRequired(
- $process->getUpdateRequiredOptions()[intval($process->getUnprocessedEventsCollection()->count() > 0)],
+ $updateRequiredOptions[intval($process->getUnprocessedEventsCollection()->count() > 0)],
$process, null, false);
+ $statusesOptions = $process->getStatusesOptions();
$statusDisplay = $gridBlock->decorateStatus(
- $process->getStatusesOptions()[$process->getStatus()],
+ $statusesOptions[$process->getStatus()],
$process, null, false);
$endedAtDisplay = $process->getEndedAt()
? Mage::helper('core')->formatDate($process->getEndedAt(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true)
diff --git a/app/design/adminhtml/base/default/layout/hackathon_indexerstats.xml b/app/design/adminhtml/default/default/layout/hackathon_indexerstats.xml
similarity index 81%
rename from app/design/adminhtml/base/default/layout/hackathon_indexerstats.xml
rename to app/design/adminhtml/default/default/layout/hackathon_indexerstats.xml
index e6a7860..fbc3f96 100644
--- a/app/design/adminhtml/base/default/layout/hackathon_indexerstats.xml
+++ b/app/design/adminhtml/default/default/layout/hackathon_indexerstats.xml
@@ -20,5 +20,8 @@
hackathon_indexerstats/index_progress.js
+
+
+
\ No newline at end of file
diff --git a/app/design/adminhtml/default/default/template/hackathon/indexerstats/process/js.phtml b/app/design/adminhtml/default/default/template/hackathon/indexerstats/process/js.phtml
new file mode 100644
index 0000000..c6b2443
--- /dev/null
+++ b/app/design/adminhtml/default/default/template/hackathon/indexerstats/process/js.phtml
@@ -0,0 +1,26 @@
+
+
\ No newline at end of file
diff --git a/js/hackathon_indexerstats/index_progress.js b/js/hackathon_indexerstats/index_progress.js
index a1bccfc..aef8b3b 100644
--- a/js/hackathon_indexerstats/index_progress.js
+++ b/js/hackathon_indexerstats/index_progress.js
@@ -53,14 +53,15 @@ IndexerStats.Status.prototype = {
*/
UPDATE_BEFORE_ESTIMATE : 5,
- initialize : function() {
+ initialize : function(statusUpdateUrl) {
this.isUpdating = false;
this.timeoutId = null;
+ this.statusUpdateUrl = statusUpdateUrl;
},
update : function() {
if (this.isUpdating) return;
this.isUpdating = true;
- new Ajax.Request('/admin/process/statusAjax', {
+ new Ajax.Request(this.statusUpdateUrl, {
loaderArea : false,
onSuccess : this.onSuccess.bind(this),
onFailure : this.onFailure.bind(this)
@@ -169,28 +170,4 @@ IndexerStats.Progress.prototype = {
this.timeDisplayElement.update(remainingTimeDisplay);
this.progressBarElement.style.width = percentDone + '%';
}
-};
-
-document.observe("dom:loaded", function() {
- $$('.hackathon_indexerstats_progress').each(function (progressbar) {
- progressbar.progress = new IndexerStats.Progress(progressbar);
- });
- indexer_processes_grid_massactionJsObject.apply = indexer_processes_grid_massactionJsObject.apply.wrap(
- function(parent) {
- if (this.select.value == 'reindex') {
- var firstProcessId = this.checkedString.split(',', 1);
- var progressbar = $('indexer_processes_grid_table')
- .select('input[name=process][value=' + firstProcessId + ']')[0]
- .parentNode.parentNode
- .select('.hackathon_indexerstats_info')[0];
- progressbar.addClassName('hackathon_indexerstats_progress');
- progressbar.parentNode.removeClassName('hackathon_indexerstats_finished');
- progressbar.progress = new IndexerStats.Progress(progressbar);
- }
- parent();
- if (this.select.value == 'reindex') {
- IndexerStats.status.update();
- }
- });
- IndexerStats.status = new IndexerStats.Status();
-});
\ No newline at end of file
+};
\ No newline at end of file
From 37d2372e214ba6df89b05233432be08e3c75f885 Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Wed, 6 May 2015 17:19:36 +0200
Subject: [PATCH 2/2] Fixed: transmit status update url to javascript object
instead of using constant
---
.../default/default/layout/hackathon_indexerstats.xml | 4 ++--
.../default/template/hackathon/indexerstats/process/js.phtml | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/design/adminhtml/default/default/layout/hackathon_indexerstats.xml b/app/design/adminhtml/default/default/layout/hackathon_indexerstats.xml
index fbc3f96..8d835fe 100644
--- a/app/design/adminhtml/default/default/layout/hackathon_indexerstats.xml
+++ b/app/design/adminhtml/default/default/layout/hackathon_indexerstats.xml
@@ -20,8 +20,8 @@
hackathon_indexerstats/index_progress.js
-
-
+
+
\ No newline at end of file
diff --git a/app/design/adminhtml/default/default/template/hackathon/indexerstats/process/js.phtml b/app/design/adminhtml/default/default/template/hackathon/indexerstats/process/js.phtml
index c6b2443..5c34cb5 100644
--- a/app/design/adminhtml/default/default/template/hackathon/indexerstats/process/js.phtml
+++ b/app/design/adminhtml/default/default/template/hackathon/indexerstats/process/js.phtml
@@ -21,6 +21,6 @@ document.observe("dom:loaded", function() {
IndexerStats.status.update();
}
});
- IndexerStats.status = new IndexerStats.Status('getUrl('process/statusAjax') ?>');
+ IndexerStats.status = new IndexerStats.Status('getUrl('adminhtml/process/statusAjax') ?>');
});
\ No newline at end of file