summaryrefslogtreecommitdiff
path: root/swat/apps/plug-ins/nbt_stats.js
blob: f9de19004f7ac319d64bcec7bf39ba48957db994 (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

// This function takes the main pane widget and jams its widget in the right
// sub-pane.

function _asyncNBTStatsHandler(result, ex, id, paneWidget) {
	var statusTextArea = null;

	var listData = [];
	listData.push({
		server_status : { text : result.server_status },
		total_received : { text : result.total_received.toString() },
		total_sent : { text : result.total_sent.toString() },
		query_count : { text : result.query_count.toString() },
		release_count : { text : result.release_count.toString() },
		register_count : { text : result.register_count.toString() }
	});

	if (ex == null) {
		// We need to remove anything previously drawn in this area.
		paneWidget.removeAll();

		statusTextArea = new
			qx.ui.form.TextArea("Server Status: " +
				result.server_status.toString() + "\n" +
				"Total Received: " +
				result.total_received.toString() + "\n" +
				"Total Sent: " +
				result.total_sent.toString() + "\n" +
				"Query Count: " +
				result.query_count.toString() + "\n" +
				"Release Count: " +
				result.release_count.toString() + "\n" +
				"Register Count: " +
				result.register_count.toString() + "\n");
		statusTextArea.setWrap(true);
		statusTextArea.setWidth("100%");
		statusTextArea.setHeight("100%");
	} else {
		alert("Async(" + id + ") exception: " + ex);
	}
	paneWidget.add(statusTextArea);
}

function _NBTStatsPlugInDisplay(paneWidget) {
        var rpc = new qx.io.remote.Rpc();
        rpc.setTimeout(60000);
        rpc.setUrl("/services/");
        rpc.setServiceName("samba.adm");
        rpc.setCrossDomain(false);

        mycall = rpc.callAsync(
                function(result, ex, id) {
			_asyncNBTStatsHandler(result, ex, id, paneWidget);
                },
                "NBTPacketStats");
}

function NBTStatsPlugIn() {
	var o = new Object();
	o.display = _NBTStatsPlugInDisplay;
	return o;
}