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=d3dc3f8cba4a6cad0534cbe16a567f7511be6702;hb=6e162ed05016679a19bf4da38b835d15684cb232;hp=4ca360b1b5ef1d6d138a1030bdb4f3ceb31c36e9;hpb=02e323ce2bac40ffb9d067788c61a3e41300a9fb;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 4ca360b1b..d3dc3f8cb 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 @@ -5,7 +5,21 @@ qx.Class.define("org.argeo.slc.ria.BatchView", { extend : qx.ui.container.Composite, implement : [org.argeo.ria.components.IView], - + include : [org.argeo.ria.session.MPrefHolder], + statics : { + riaPreferences : { + "slc.batch.delete.confirm" : { + label : "Confirm on batch deletion", + type : "boolean", + defaultValue : true + }, + "slc.batch.autoclear" : { + label : "Autoclear batch on execution", + type : "boolean", + defaultValue : false + } + } + }, properties : { /** @@ -16,85 +30,57 @@ qx.Class.define("org.argeo.slc.ria.BatchView", init : { "submitform" : { label : "Execute Batch", - icon : "org.argeo.slc.ria/media-playback-start.png", + icon : "org/argeo/slc/ria/media-playback-start.png", shortcut : null, enabled : false, menu : "Launcher", toolbar : "batch", callback : function(e) { - if (this.getBatchAgentId()) { - this.executeBatchOnAgent(this.getBatchAgentId()); + var batchAgentId = this.getBatchAgentId(); + if (!batchAgentId) { + return; } - }, - command : null - }, - /* - "toggleopenonadd" : { - label : "Auto edit on Add", - icon : "org.argeo.slc.ria/document-open.png", - shortcut : null, - enabled : true, - toggle : true, - toggleInitialState : true, - menu : "Launcher", - toolbar : "launcher", - callback : function(event) { - var state = event.getTarget().getUserData("slc.command.toggleState"); - this.setAutoOpen(state); - }, - command : null - }, - "editexecutionspecs" : { - label : "Edit Execution Specs", - icon : "org.argeo.slc.ria/document-open.png", - shortcut : null, - enabled : false, - menu : "Launcher", - toolbar : "batch", - callback : function(e) { - var sel = this.list.getSortedSelection(); - var spec = sel[0].getUserData("batchEntrySpec"); - if (spec.hasEditableValues()) { - var specEditor = new org.argeo.slc.ria.execution.SpecEditor(spec); - specEditor.attachAndShow(); - } - }, - selectionChange : function(viewId, selection) { - if (viewId != "batch:list") - return; - this.setEnabled(false); - if ((selection && selection.length == 1)) { - var selectedItemSpec = selection[0].getUserData("batchEntrySpec"); - if (selectedItemSpec.hasEditableValues()) { - this.setEnabled(true); - } + var prefName = "slc.batch.autoclear"; + var prefValue = this.getRiaPreferenceValue(prefName); + if(( prefValue !== null && prefValue === true ) || this.getForceClearPreference()){ + this.executeBatchOnAgent(batchAgentId, true); + }else{ + this.executeBatchOnAgent(batchAgentId, false); } + this.setForceClearPreference(false); + return; }, command : null }, - */ "removefrombatch" : { label : "Remove from batch", - icon : "org.argeo.slc.ria/edit-delete.png", + icon : "org/argeo/slc/ria/edit-delete.png", shortcut : null, enabled : false, menu : "Launcher", toolbar : "batch", callback : function(e) { var sel = this.list.getSortedSelection(); - var modal = new org.argeo.ria.components.Modal("Confirm", null); - modal.addConfirm("Are you sure you want to remove
the selected test" - + (sel.length > 1 ? "s" : "") - + " from the Batch?"); - modal.addListener("ok", function() { - for (var i = 0; i < sel.length; i++) { - this.list.remove(sel[i]); - } - if (!this.list.hasChildren()) { - this.setBatchAgentId(null); - } - }, this); - modal.attachAndShow(); + var confirmPref = this.getRiaPreferenceValue("slc.batch.delete.confirm"); + var execution = function() { + for (var i = 0; i < sel.length; i++) { + this.list.remove(sel[i]); + } + if (!this.list.hasChildren()) { + this.setBatchAgentId(null); + } + } + if(confirmPref){ + var modal = new org.argeo.ria.components.Modal("Confirm", null); + modal.addConfirm("Are you sure you want to remove
the selected test" + + (sel.length > 1 ? "s" : "") + + " from the Batch?"); + modal.addListener("ok", execution, this); + modal.attachAndShow(); + }else{ + execution = qx.lang.Function.bind(execution, this); + execution(); + } }, selectionChange : function(viewId, selection) { if (viewId != "batch:list") @@ -107,7 +93,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView", }, "clearbatch" : { label : "Clear batch", - icon : "org.argeo.slc.ria/user-trash-full.png", + icon : "org/argeo/slc/ria/user-trash-full.png", shortcut : null, enabled : true, menu : "Launcher", @@ -145,7 +131,11 @@ qx.Class.define("org.argeo.slc.ria.BatchView", nullable : true, check : "String", event : "changeBatchAgentId" - } + }, + forceClearPreference : { + init : false, + check : "Boolean" + } }, construct : function(){ @@ -269,7 +259,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView", this.dropDecorator = new qx.ui.decoration.Background(); this.dropDecorator.set({ - backgroundImage : "org.argeo.slc.ria/drophere.gif", + backgroundImage : "org/argeo/slc/ria/drophere.gif", backgroundRepeat : "no-repeat" }); @@ -345,16 +335,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) { @@ -365,12 +353,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]); + }, /** @@ -379,26 +363,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){