]> git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecLoggerApplet.js
Create Argeo SLC RIA project
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / 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 viewSelection : {
24 nullable:false,
25 check:"org.argeo.ria.components.ViewSelection"
26 },
27 instanceId : {init:""},
28 instanceLabel : {init:""},
29 /**
30 * Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions}
31 */
32 commands : {
33 init : {
34 "reloadlogs" : {
35 label : "Reload Logs",
36 icon : "resource/slc/view-refresh.png",
37 shortcut : "Control+r",
38 enabled : true,
39 menu : null,
40 toolbar : null,
41 callback : function(e){
42 this._reloadLogger();
43 },
44 command : null
45 }
46 }
47 }
48 },
49
50 members :
51 {
52 /**
53 * Called at applet creation. Just registers viewPane.
54 * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane.
55 */
56 init : function(viewPane){
57 this.setView(viewPane);
58 this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));
59 this._createLayout();
60 },
61
62 /**
63 *
64 */
65 load : function(){
66 this._reloadLogger();
67 this.timer = new qx.event.Timer(15000);
68 this.timer.addListener("interval", this._reloadLogger, this);
69 this.timer.start();
70 },
71
72 addScroll : function(){
73 return false;
74 },
75
76 close : function(){
77 this.timer.stop();
78 },
79
80 /**
81 * Creates the applet layout
82 */
83 _createLayout : function(){
84 this.logModel = new qx.ui.table.model.Simple();
85 this.logModel.setColumns(["Date", "Host", "Id", "Status"]);
86 this.logPane = new qx.ui.table.Table(this.logModel, {
87 tableColumnModel: function(obj){
88 return new qx.ui.table.columnmodel.Resize(obj)
89 }
90 });
91 this.logPane.setDecorator(null);
92 this._initLogger();
93 this.add(this.logPane, {edge:'center'});
94 },
95
96 /**
97 * Initialize the log table.
98 */
99 _initLogger : function(){
100 this.logPane.set({
101 statusBarVisible: false,
102 showCellFocusIndicator:false
103 });
104 var columnModel = this.logPane.getTableColumnModel();
105 columnModel.getBehavior().setWidth(0, "30%");
106 columnModel.getBehavior().setWidth(1, "15%");
107 columnModel.getBehavior().setWidth(3, "12%");
108 },
109
110 /**
111 * Refresh the data model.
112 */
113 _reloadLogger : function(){
114 var request = org.argeo.slc.ria.SlcApi.getListSlcExecutionsService();
115 request.addListener("completed", function(response){
116 var messages = org.argeo.ria.util.Element.selectNodes(response.getContent(), "//slc:slc-execution");
117 this.logModel.setData([]);
118 for(var i=0;i<messages.length;i++){
119 var message = messages[i];
120 var slcExec = new org.argeo.slc.ria.SlcExecutionMessage(message.getAttribute("uuid"));
121 slcExec.fromXml(message);
122 this.logModel.addRows([
123 [slcExec.getDate(), slcExec.getHost(), slcExec.getUuid(), slcExec.getStatus()]
124 ]);
125 }
126 }, this);
127 request.send();
128 }
129
130 }
131 });