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=a2a8ff9c8832427fea81b0ce43c548fc8cad9918;hb=f59509dd7a5d4aed1a1b4f8fae72883b3911b16b;hp=8769751bb82f4559a4d369ce5f6a38ad709d4f12;hpb=2dad63f97c21e34db947b740c7f728fd34ae11a5;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 8769751bb..a2a8ff9c8 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,21 +30,38 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
init : {
"submitform" : {
label : "Execute Batch",
- icon : "resource/slc/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;
+ }
+ 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
},
+ /*
"toggleopenonadd" : {
label : "Auto edit on Add",
- icon : "resource/slc/document-open.png",
+ icon : "org.argeo.slc.ria/document-open.png",
shortcut : null,
enabled : true,
toggle : true,
@@ -45,7 +76,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
},
"editexecutionspecs" : {
label : "Edit Execution Specs",
- icon : "resource/slc/document-open.png",
+ icon : "org.argeo.slc.ria/document-open.png",
shortcut : null,
enabled : false,
menu : "Launcher",
@@ -59,7 +90,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
}
},
selectionChange : function(viewId, selection) {
- if (viewId != "form:list")
+ if (viewId != "batch:list")
return;
this.setEnabled(false);
if ((selection && selection.length == 1)) {
@@ -71,38 +102,62 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
},
command : null
},
+ */
"removefrombatch" : {
label : "Remove from batch",
- icon : "resource/slc/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 != "form:list")
+ if (viewId != "batch:list")
return;
this.setEnabled(false);
if ((selection && selection.length > 0))
this.setEnabled(true);
},
command : null
- }
+ },
+ "clearbatch" : {
+ label : "Clear batch",
+ icon : "org.argeo.slc.ria/user-trash-full.png",
+ shortcut : null,
+ enabled : true,
+ menu : "Launcher",
+ toolbar : "batch",
+ callback : function(e) {
+ if(!this.list.hasChildren()) return;
+ this.list.selectAll();
+ this.getCommands()["removefrombatch"].command.execute();
+ },
+ selectionChange : function(viewId, selection) {
+ },
+ command : null
+ }
}
},
view : {
@@ -198,8 +253,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
this.list.setDroppable(true);
this.list.setDraggable(true);
this.list.setContextMenu(org.argeo.ria.event.CommandsManager
- .getInstance().createMenuFromIds(["editexecutionspecs",
- "removefrombatch"]));
+ .getInstance().createMenuFromIds(["removefrombatch"]));
this.list.addListener("dragstart", function(e) {
e.addType(["items"]);
@@ -242,7 +296,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
this.list.addListener("changeSelection", function(e) {
var viewSelection = this.getViewSelection();
- viewSelection.setViewId("form:list");
+ viewSelection.setViewId("batch:list");
viewSelection.clear();
var listSel = this.list.getSortedSelection();
for (var i = 0; i < listSel.length; i++) {
@@ -250,15 +304,27 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
}
}, this);
+ this.dropDecorator = new qx.ui.decoration.Background();
+ this.dropDecorator.set({
+ backgroundImage : "org.argeo.slc.ria/drophere.gif",
+ backgroundRepeat : "no-repeat"
+ });
+
+
listChangeListener = function() {
var command = org.argeo.ria.event.CommandsManager.getInstance()
.getCommandById("submitform");
command.setEnabled(this.list.hasChildren());
+ var command2 = org.argeo.ria.event.CommandsManager.getInstance()
+ .getCommandById("clearbatch");
+ command2.setEnabled(this.list.hasChildren());
+ this.list.setDecorator((this.list.hasChildren()?null:this.dropDecorator));
};
this.list.addListener("addItem", listChangeListener, this);
this.list.addListener("removeItem", listChangeListener, this);
-
-
+
+ this.list.setDecorator(this.dropDecorator);
+
this.add(this.listPane);
},
@@ -316,14 +382,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() || "resource/slc/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) {
@@ -335,9 +401,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
this.list.add(item);
}
this.list.select(item);
- if (this.getAutoOpen() && !skipAutoOpen) {
- this.getCommands()["editexecutionspecs"].command.execute();
- }
+
},
/**
@@ -346,7 +410,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;
@@ -355,17 +419,32 @@ 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();
+ 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){