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=78715de0403652f23aad1095fc6ccf67ba59daa7;hb=065d36b85187201697a8ec79e92c39f0ccc3626e;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..78715de04 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 :
{
/**
@@ -22,9 +36,25 @@ 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){
+ this.executeBatchOnAgent(batchAgentId, prefValue);
+ 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
},
@@ -82,19 +112,27 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
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");
+ this.debug(confirmPref);
+ 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")
@@ -379,7 +417,7 @@ 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;
@@ -388,17 +426,27 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
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();
+ 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);
+ }
+ }catch(e){
+ this.error(e);
+ }
},
clearBatchForAgentId : function(agentId){