Skip to content

Commit

Permalink
Merge pull request #205 from APochmann/master
Browse files Browse the repository at this point in the history
Wrong order of processes in popup when new jobs to be added
  • Loading branch information
ctippler committed Mar 5, 2024
2 parents 8f324e1 + 66fd96d commit 0958700
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/BundleConfiguration.php
Expand Up @@ -39,6 +39,11 @@ public function getProcessTimeoutMinutes(): int
return $this->config['processTimeoutMinutes'];
}

public function getRefreshIntervalSeconds() : int
{
return $this->config["refreshIntervalSeconds"] ?? 3;
}

/**
* @return array<mixed>
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/IndexController.php
Expand Up @@ -90,6 +90,8 @@ public function getPluginConfigAction(CommandsValidator $commandsValidator, Tran
$data['shortCutMenu'] = $shortCutMenu ?: false;
}

$data['refreshIntervalSeconds'] = $bundleConfig->getRefreshIntervalSeconds();

if($data['shortCutMenu'] ?? null) {
ksort($data['shortCutMenu'], SORT_LOCALE_STRING);
}
Expand Down
5 changes: 5 additions & 0 deletions src/DependencyInjection/Configuration.php
Expand Up @@ -41,6 +41,11 @@ public function getConfigTreeBuilder(): TreeBuilder
->min(0)
->info('If the MonitoringItem has not been save within X minutes it will be considered as hanging process')
->end()
->integerNode('refreshIntervalSeconds')
->defaultValue(3)
->min(1)
->info('Refresh interal of process list in seconds')
->end()
->booleanNode('disableShortcutMenu')
->defaultValue(false)
->info('Disable the shortcut menu on the left side in the Pimcore admin')
Expand Down
63 changes: 51 additions & 12 deletions src/Resources/public/js/window/activeProcesses.js
Expand Up @@ -3,14 +3,13 @@ pimcore.registerNS("pimcore.plugin.processmanager.window.activeProcesses");
pimcore.plugin.processmanager.window.activeProcesses = Class.create({
displayList : [],
toast : null,
refreshIntervalSeconds : 3,

initialize: function () {
let runner = new Ext.util.TaskRunner(), task;
this.refreshTask = runner.newTask({
run: this.requestServerData.bind(this),
fireOnStart : true,
interval: this.refreshIntervalSeconds * 1000
interval: processmanagerPlugin.config.refreshIntervalSeconds * 1000
});
},

Expand Down Expand Up @@ -198,12 +197,45 @@ pimcore.plugin.processmanager.window.activeProcesses = Class.create({
//button.setDisabled(item.isAlive);
},

_checkActionBtns: function(actionBtnsPanel, item) {

let needUpdate = false;
try {
if(item.actionItems.length != actionBtnsPanel.items.items.length){
needUpdate = true;
}else if(item.actionItems.length){
for(let i = 0; i < item.actionItems.length; i++){
let actionData = item.actionItems[i];
let panelData = actionBtnsPanel.items.items[i];

if(actionData.executeAtStates.includes(item.status)){
if(actionData.dynamicData && actionData.dynamicData.extJsClass){
if( (actionData.dynamicData.extJsClass == 'pimcore.plugin.processmanager.executor.action.download')
||(actionData.dynamicData.extJsClass == 'pimcore.plugin.processmanager.executor.action.openItem')){
if(actionData.dynamicData.fileExists && panelData.disabled){
needUpdate = true;
} else if(!actionData.dynamicData.fileExists && !panelData.disabled){
needUpdate = true;
}
}else{
needUpdate = true;
}
}
}
}
}
} catch (ex) {
needUpdate = true;
}
return needUpdate;
},

_updateActionBtns: function(actionBtnsPanel, item) {

actionBtnsPanel.items.removeAll(); //do not remove them as it causes flickering
actionBtnsPanel.update();
if(this._checkActionBtns(actionBtnsPanel, item)){
actionBtnsPanel.items.removeAll(); //do not remove them as it causes flickering
actionBtnsPanel.update();

if(item.actionItems.length){
for(let i = 0; i < item.actionItems.length; i++){
let actionData = item.actionItems[i];

Expand All @@ -216,10 +248,10 @@ pimcore.plugin.processmanager.window.activeProcesses = Class.create({
}

}
}

actionBtnsPanel.update();
actionBtnsPanel.updateLayout();
actionBtnsPanel.update();
actionBtnsPanel.updateLayout();
}
},

_updatePanelTitle : function(data){
Expand Down Expand Up @@ -253,11 +285,18 @@ pimcore.plugin.processmanager.window.activeProcesses = Class.create({

if (items.length > 0) {


// let activeItemIds = [];
let cachedItems = [];
for (itemKey in items) {
this._buildBar(items[itemKey]);
activeItemIds.push(items[itemKey].id);
if (this.toast && !this.getPanelByItemId(items[itemKey].id)) {
cachedItems.push(items[itemKey]);
} else {
this._buildBar(items[itemKey]);
activeItemIds.push(items[itemKey].id);
}
}
for (let idx = cachedItems.length; idx--; ){
this._buildBar(cachedItems[idx]);
activeItemIds.push(cachedItems[idx].id);
}

if(!this.toast){
Expand Down

0 comments on commit 0958700

Please sign in to comment.