blob: 8a8c2fd8ffc56e8c8d2819f43dcd3f4ff5f7d3c1 [file] [log] [blame]
Felix Meschberger9d86a262010-03-18 21:35:20 +00001<script type="text/javascript">
2// <![CDATA[
3
4function renderData(/* Object[] */ files) {
5 $("#plugin_table > tbody > tr").remove();
6 var tbody = $("#plugin_table > tbody");
7 for ( var idx in files ) {
8 var dumpFile = files[idx];
9 var trElement = tr( null, { id: "entry" + dumpFile.name } );
10 entryInternal( trElement, dumpFile );
11 tbody.append(trElement);
12 }
13}
14
15function entryInternal( /* Element */ parent, /* Object */ dumpFile ) {
16 var name = dumpFile.name;
17 var date = new Date(dumpFile.date).toLocaleString();
18 var size = dumpFile.size.toLocaleString();
19
20 var titleElement = createElement ("a", null, {
21 href: window.location.pathname + "/" + name
22 });
23 titleElement.appendChild(text(name));
24
25 var zipDL = createElement ("a", null, {
26 href: window.location.pathname + "/" + name + ".zip"
27 });
28 zipDL.appendChild(text("(zipped)"));
29
30 var liElement = createElement( "li", "dynhover ui-state-default ui-corner-all", {
31 title: "${dump.remove}"
32 });
33 var ulElement = createElement( "ul", "icons ui-widget", null, [
34 liElement
35 ]);
36
37 parent.appendChild( td( null, null, [ titleElement, text(" "), zipDL ] ) );
38 parent.appendChild( td( null, null, [ text( date ) ] ) );
39 parent.appendChild( td( null, null, [ text( size ) ] ) );
40 parent.appendChild( td( null, null, [ ulElement ] ) );
41
42 $(liElement)
43 .html('<span class="ui-icon ui-icon-trash"></span>')
44 .click(function() {
45 $.post(window.location.pathname + "/" + name,
46 { "X-Request-Method": "DELETE" },
47 function(data) {
48 Xalert( data, "${dump.remove}" );
49 window.location = window.location;
50 }
51 );
52 });
53}
54
55function renderOverall(/* Object */ overall) {
56 var tbody = $("#overview > tbody");
57 for ( var idx in overall ) {
58 var trElement = tr( null, null, [
59 td( null, null, [ text( idx ) ] ),
60 td( null, null, [ text( overall[idx] ) ] )
61 ]);
62 tbody.append(trElement);
63 }
64}
65
Felix Meschberger2cc97872010-03-19 11:58:49 +000066function renderPools(/* Object[] */ pools) {
67 var tbody = $("#pools > tbody").empty();
68 for ( var idx = 0; idx < pools.length; idx++ ) {
69 var pool = pools[idx];
70 var trElement = tr( null, null, [
71 td( null, null, [ text( pool.name ) ] ),
72 td( null, null, [ text( pool.score ) ] ),
73 td( null, null, [ text( pool.used ) ] ),
74 td( null, null, [ text( pool.committed ) ] ),
75 td( null, null, [ text( pool.max ) ] ),
76 td( null, null, [ text( pool.init ) ] ),
77 td( null, null, [ text( pool.type ) ] ),
78 ]);
79
80 // append to body (unless last row append to tfoot)
81 if (idx < pools.length - 1) {
82 tbody.append(trElement);
83 } else {
84 $("#pools > tfoot").empty().append(trElement);
85 }
86 }
87}
88
Felix Meschberger9d86a262010-03-18 21:35:20 +000089var __files__ = ${__files__};
90var __status__ = ${__status__};
91var __overall__ = ${__overall__};
Felix Meschberger2cc97872010-03-19 11:58:49 +000092var __pools__ = ${__pools__};
Felix Meschberger9d86a262010-03-18 21:35:20 +000093
94$(document).ready(function() {
95
Felix Meschberger1da4bae2010-03-23 12:49:38 +000096 $(".statline").html("${dump.statline}".msgFormat(__status__.files, __status__.total));
Felix Meschberger9d86a262010-03-18 21:35:20 +000097
Felix Meschberger9d86a262010-03-18 21:35:20 +000098 renderOverall(__overall__);
Felix Meschberger2cc97872010-03-19 11:58:49 +000099 renderPools(__pools__);
100 renderData(__files__);
101
102 // check for cookie
103 var cv = $.cookies.get("webconsole.memusage");
104 var lo = (cv ? cv.split(",") : [1,0]);
105 var poolsTable = $("#pools").tablesorter({
106 headers: {
107 1: { sorter:"digit" },
108 2: { sorter:"digit" },
109 3: { sorter:"digit" },
110 4: { sorter:"digit" },
111 5: { sorter:"digit" },
112 },
113 // textExtraction:mixedLinksExtraction,
114 sortList: cv ? [lo] : false
115 }).bind("sortEnd", function() {
116 poolsTable.eq(0).attr("config");
117 $.cookies.set("webconsole.memusage", poolsTable.sortList.toString());
118 });
119
Felix Meschberger9d86a262010-03-18 21:35:20 +0000120 $("#dumpButton")
121 .click(function() {
122 $.post(window.location.pathname,
123 { "command": "dump" },
124 function(data) {
125 Xalert( data, "${dump.dump}" );
126 window.location = window.location;
127 }
128 );
129 });
130
131 $("#gcButton")
132 .click(function() {
133 $.post(window.location.pathname,
134 { "command": "gc" },
135 function(data) {
136 Xalert( data, "${dump.gc}" );
137 window.location = window.location;
138 }
139 );
140 });
Felix Meschberger9d86a262010-03-18 21:35:20 +0000141});
142
143
144
145// ]]>
146</script>
147
148<!-- status line -->
149<p class="statline">&nbsp;</p>
150
151<!-- top header -->
152<div class="ui-widget-header ui-corner-top buttonGroup">
153 <button type="button" id="dumpButton">${dump.dump}</button>
154 <button type="button" id="gcButton">${dump.gc}</button>
155</div>
156
157
Felix Meschberger2cc97872010-03-19 11:58:49 +0000158<table id="overview" class="nicetable">
Felix Meschberger9d86a262010-03-18 21:35:20 +0000159 <thead>
160 <tr>
161 <th colspan="2">${dump.overview}</th>
162 </tr>
163 </thead>
164 <tbody>
165 <tr>
166 <td>${dump.threshold}</td>
167 <td>
168 <form method="post" action="">
169 <input type="hidden" name="command" value="threshold" />
170 <input type="text" name="threshold" value="${__threshold__}" />
171 <input type="submit" name="submit" value="${dump.threshold.set}" />
172 </form>
173 </td>
174 </tr>
Felix Meschbergerc4fbef12010-08-01 10:01:37 +0000175 <tr>
176 <td>${dump.interval}</td>
177 <td>
178 <form method="post" action="">
179 <input type="hidden" name="command" value="interval" />
180 <input type="text" name="interval" value="${__interval__}" />
181 <input type="submit" name="submit" value="${dump.interval.set}" />
182 </form>
183 </td>
184 </tr>
Felix Meschberger9d86a262010-03-18 21:35:20 +0000185 </tbody>
186</table>
187
188<p>&nbsp;</p>
189
Felix Meschberger2cc97872010-03-19 11:58:49 +0000190<table id="pools" class="tablesorter nicetable noauto">
Felix Meschberger9d86a262010-03-18 21:35:20 +0000191 <thead>
192 <tr>
Felix Meschberger2cc97872010-03-19 11:58:49 +0000193 <th class="col_pool_name">${dump.pools.name}</th>
194 <th class="col_pool_score">${dump.pools.score}</th>
195 <th class="col_pool_used">${dump.pools.used}</th>
196 <th class="col_pool_committed">${dump.pools.committed}</th>
197 <th class="col_pool_max">${dump.pools.max}</th>
198 <th class="col_pool_init">${dump.pools.init}</th>
199 <th class="col_pool_type">${dump.pools.type}</th>
200 </tr>
201 </thead>
202 <tbody>
203 <tr><td colspan="7">&nbsp;</td></tr>
204 </tbody>
205 <tfoot class="ui-widget-header">
206 <tr><td colspan="4">&nbsp;</td></tr>
207 </tfoot>
208</table>
209
210<p>&nbsp;</p>
211
212<table id="plugin_table" class="nicetable">
213 <thead>
214 <tr>
215 <th>${dump.name}</th>
216 <th>${dump.date}</th>
217 <th>${dump.size}</th>
218 <th>${dump.action}</th>
Felix Meschberger9d86a262010-03-18 21:35:20 +0000219 </tr>
220 </thead>
221 <tbody>
222 <tr><td colspan="4">&nbsp;</td></tr>
223 </tbody>
224</table>