summaryrefslogtreecommitdiffstats
path: root/web-gui/logging/source/class/logging/Application.js
blob: c715d5ee9ee52ad06d7f4e215ebe575545c5c1d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* ************************************************************************

	 Copyright:

	 License:

	 Authors:

************************************************************************ */

/* ************************************************************************

#asset(logging/*)

************************************************************************ */

/**
 * This is the main application class of your custom application "logging"
 */
qx.Class.define("logging.Application",
{
extend : qx.application.Standalone,



/*
*****************************************************************************
	 MEMBERS
*****************************************************************************
*/

members :
{
	__list: null,
	__rpc: null,
	__call: null,
	__last: 0,

	/**
	 * This method contains the initial application code and gets called 
	 * during startup of the application
	 * 
	 * @lint ignoreDeprecated(alert)
	 */
	main : function()
	{
		// Call super class
		this.base(arguments);

		// Enable logging in debug variant
		if (qx.core.Variant.isSet("qx.debug", "on"))
		{
			// support native logging capabilities, e.g. Firebug for Firefox
			qx.log.appender.Native;
			// support additional cross-browser console. Press F7 to toggle visibility
			qx.log.appender.Console;
		}

		/*
		-------------------------------------------------------------------------
			Below is your actual application code...
		-------------------------------------------------------------------------
		*/

		var doc = this.getRoot();
		doc.setBackgroundColor("#ffffff");

		var back = new qx.ui.basic.Image("logging/back.png");
		back.setScale(true);
		doc.add(back, {left:0, top: 0});

		this.__list = new logging.list.List();
		doc.add(this.__list, {left:"15%", top: "10%", width: "70%", height: "80%"});

		this.__rpc = new qx.io.remote.Rpc("http://localhost:8080/rpc", "com.pengutronix.jdb.systeminfo|/");

		var timer = new qx.event.Timer(2000);
		timer.addListener("interval", this.__tick, this);
		timer.start();
	},
	__tick: function() {
		if (this.__call != null) {
			this.__rpc.abort(this.__call);
		}
		this.__call = this.__rpc.callAsync(
			qx.lang.Function.bind(this.__callback, this),
			"com.pengutronix.jdb.SystemInfo.Syslog", "i", this.__last);
	},
	__callback: function(ret, err, id) {
		this.__call = null;
		if (err != null) {
			return;
		}
		this.__last = ret.last;
		for (var i = 0; i < ret.data.length; ++i) {
			this.__list.addLine(ret.data[i]);
		}
	}
}
});