]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecLoggerApplet.js
Splitted the LauncherApplet into two different applets. The first one is a generic...
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-lib / slc / class / org / argeo / slc / ria / SlcExecLoggerApplet.js
1 /**
2 * A simple Hello World applet for documentation purpose.
3 * The only associated command is the "Close" command.
4 */
5 qx.Class.define("org.argeo.slc.ria.SlcExecLoggerApplet",
6 {
7 extend : qx.ui.container.Composite,
8 implement : [org.argeo.ria.components.IView],
9
10 construct : function(){
11 this.base(arguments);
12 this.setLayout(new qx.ui.layout.Dock());
13 },
14
15 properties :
16 {
17 /**
18 * The viewPane inside which this applet is added.
19 */
20 view : {
21 init : null
22 },
23 /**
24 * Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions}
25 */
26 commands : {
27 init : {
28 "reloadlogs" : {
29 label : "Reload Logs",
30 icon : "resource/slc/view-refresh.png",
31 shortcut : "Control+r",
32 enabled : true,
33 menu : null,
34 toolbar : null,
35 callback : function(e){
36 this._reloadLogger();
37 },
38 command : null
39 }
40 }
41 }
42 },
43
44 members :
45 {
46 /**
47 * Called at applet creation. Just registers viewPane.
48 * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane.
49 */
50 init : function(viewPane){
51 this.setView(viewPane);
52 this._createLayout();
53 },
54
55 /**
56 *
57 */
58 load : function(){
59 this._reloadLogger();
60 this.timer = new qx.event.Timer(15000);
61 this.timer.addListener("interval", this._reloadLogger, this);
62 this.timer.start();
63 },
64
65 addScroll : function(){
66 return false;
67 },
68
69 close : function(){
70 this.timer.stop();
71 },
72
73 _createLayout : function(){
74 this.logModel = new qx.ui.table.model.Simple();
75 this.logModel.setColumns(["Date", "Agent Uuid", "Status"]);
76 this.logPane = new qx.ui.table.Table(this.logModel, {
77 tableColumnModel: function(obj){
78 return new qx.ui.table.columnmodel.Resize(obj)
79 }
80 });
81 this.logPane.setDecorator(null);
82 this._initLogger();
83 this.add(this.logPane, {edge:'center'});
84 },
85
86 _initLogger : function(){
87 this.logPane.set({
88 statusBarVisible: false,
89 showCellFocusIndicator:false
90 });
91 var columnModel = this.logPane.getTableColumnModel();
92 columnModel.getBehavior().setWidth(0, "30%");
93 columnModel.getBehavior().setWidth(2, "12%");
94 },
95
96 _reloadLogger : function(){
97 var request = org.argeo.slc.ria.SlcApi.getListSlcExecutionsService();
98 request.addListener("completed", function(response){
99 var messages = org.argeo.ria.util.Element.selectNodes(response.getContent(), "//slc:slc-execution");
100 this.logModel.setData([]);
101 for(var i=0;i<messages.length;i++){
102 var message = messages[i];
103 var slcExec = new org.argeo.slc.ria.SlcExecutionMessage(message.getAttribute("uuid"));
104 slcExec.fromXml(message);
105 this.logModel.addRows([
106 [slcExec.getDate(), slcExec.getHost()+' ('+slcExec.getUuid()+')', slcExec.getStatus()]
107 ]);
108 }
109 }, this);
110 request.send();
111 }
112
113 }
114 });