X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=server%2Forg.argeo.slc.ria%2Fsrc%2Fargeo-ria-lib%2Fslc%2Fclass%2Forg%2Fargeo%2Fslc%2Fria%2FBatchView.js;h=5f68b2cf6eeca1f9a525e554eb999193d8d288dd;hb=d4d0578c8c9dd7428cd04b2164bb1338cf0e04cd;hp=03f27df4399aa9aa81f40f6eb696b1782fb8ab17;hpb=8bc2ba14777b2d0bcfe1e45aaa96424dc0d0bbcd;p=gpl%2Fargeo-slc.git diff --git a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/BatchView.js b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/BatchView.js index 03f27df43..5f68b2cf6 100644 --- a/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/BatchView.js +++ b/server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/BatchView.js @@ -12,6 +12,11 @@ qx.Class.define("org.argeo.slc.ria.BatchView", label : "Confirm on batch deletion", type : "boolean", defaultValue : true + }, + "slc.batch.autoclear" : { + label : "Autoclear batch on execution", + type : "boolean", + defaultValue : false } } }, @@ -31,9 +36,27 @@ qx.Class.define("org.argeo.slc.ria.BatchView", menu : "Launcher", toolbar : "batch", callback : function(e) { - if (this.getBatchAgentId()) { - this.executeBatchOnAgent(this.getBatchAgentId()); + var batchAgentId = this.getBatchAgentId(); + if (!batchAgentId) { + return; } + var prefName = "slc.batch.autoclear"; + var prefValue = this.getRiaPreferenceValue(prefName); + if(prefValue !== null && prefValue === true){ + this.executeBatchOnAgent(batchAgentId, true); + }else{ + this.executeBatchOnAgent(batchAgentId, false); + } + return; + var modal = new org.argeo.ria.components.Modal("Clear?", null); + modal.addYesNoReminder("Do you want to clear the batch automatically after execution?", prefName); + modal.addListener("cancel", function(e){ + this.executeBatchOnAgent(batchAgentId, false); + }, this); + modal.addListener("ok", function(e){ + this.executeBatchOnAgent(batchAgentId, true); + }, this); + modal.attachAndShow(); }, command : null }, @@ -91,8 +114,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView", toolbar : "batch", callback : function(e) { var sel = this.list.getSortedSelection(); - var confirmPref = this.getRiaPreferenceValue("slc.batch.delete.confirm"); - this.debug(confirmPref); + var confirmPref = this.getRiaPreferenceValue("slc.batch.delete.confirm"); var execution = function() { for (var i = 0; i < sel.length; i++) { this.list.remove(sel[i]); @@ -362,16 +384,14 @@ qx.Class.define("org.argeo.slc.ria.BatchView", var executionFlow = target.getUserData("executionFlow"); var batchEntry = new org.argeo.slc.ria.execution.BatchEntrySpec( executionModule, executionFlow); - var label = batchEntry.getLabel(); - var icon = target.getIcon() || "org.argeo.slc.ria/office-document.png"; - var item = new qx.ui.form.ListItem(label, icon); - /* - item.addListener("dblclick", function(e) { - this.getCommands()["editexecutionspecs"].command - .execute(); - }, this); - */ - item.setUserData("batchEntrySpec", batchEntry); + + this.appendBatchEntrySpec(batchEntry, target.getIcon(), after); + }, + + appendBatchEntrySpec: function(batchEntrySpec, icon, after){ + + var item = new qx.ui.form.ListItem(batchEntrySpec.getLabel(), icon || "org.argeo.slc.ria/system.png"); + item.setUserData("batchEntrySpec", batchEntrySpec); item.setPaddingTop(1); item.setPaddingBottom(2); if (after) { @@ -382,12 +402,8 @@ qx.Class.define("org.argeo.slc.ria.BatchView", } else { this.list.add(item); } - this.list.select(item); - /* - if (this.getAutoOpen() && !skipAutoOpen) { - this.getCommands()["editexecutionspecs"].command.execute(); - } - */ + this.list.setSelection([item]); + }, /** @@ -396,26 +412,45 @@ qx.Class.define("org.argeo.slc.ria.BatchView", * @param agentUuid * {String} The id of the target agent */ - executeBatchOnAgent : function(agentUuid) { + executeBatchOnAgent : function(agentUuid, clearBatch) { var selection = this.list.getChildren(); if (!selection.length) return; + // Get Host + var agentsMap = org.argeo.ria.components.ViewsManager.getInstance().getViewPaneById("selector").getContent().getAgentsMap(); + var host = agentsMap[agentUuid]; var slcExecMessage = new org.argeo.slc.ria.execution.Message(); + slcExecMessage.setHost(host); for (var i = 0; i < selection.length; i++) { var batchEntrySpec = selection[i].getUserData("batchEntrySpec"); slcExecMessage.addBatchEntrySpec(batchEntrySpec); } - var req = org.argeo.slc.ria.SlcApi.getNewSlcExecutionService( - agentUuid, slcExecMessage.toXml()); - req.send(); - // Force logs refresh right now! - qx.event.Timer.once(function() { - var command = org.argeo.ria.event.CommandsManager - .getInstance().getCommandById("reloadlogs"); - if (command) { - command.execute(); - } - }, this, 2000); + try{ + var xmlMessage = slcExecMessage.toXml(); + if(!window.xmlExecStub){ + window.xmlExecStub = {}; + } + window.xmlExecStub[slcExecMessage.getUuid()] = qx.xml.Document.fromString(xmlMessage); + var req = org.argeo.slc.ria.SlcApi.getNewSlcExecutionService( + agentUuid, xmlMessage); + req.send(); + // Force logs refresh right now! + qx.event.Timer.once(function() { + var command = org.argeo.ria.event.CommandsManager + .getInstance().getCommandById("reloadlogs"); + if (command) { + command.execute(); + } + }, this, 2000); + if(clearBatch){ + req.addListener("completed", function(e){ + this.list.removeAll(); + this.setBatchAgentId(null); + }, this); + } + }catch(e){ + this.error(e); + } }, clearBatchForAgentId : function(agentId){