Felix Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 1 | <script type="text/javascript"> |
| 2 | // <![CDATA[ |
| 3 | |
| 4 | function 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 | |
| 15 | function 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 | |
| 55 | function 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 Meschberger | 2cc9787 | 2010-03-19 11:58:49 +0000 | [diff] [blame] | 66 | function 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 Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 89 | var __files__ = ${__files__}; |
| 90 | var __status__ = ${__status__}; |
| 91 | var __overall__ = ${__overall__}; |
Felix Meschberger | 2cc9787 | 2010-03-19 11:58:49 +0000 | [diff] [blame] | 92 | var __pools__ = ${__pools__}; |
Felix Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 93 | |
| 94 | $(document).ready(function() { |
| 95 | |
Felix Meschberger | 1da4bae | 2010-03-23 12:49:38 +0000 | [diff] [blame] | 96 | $(".statline").html("${dump.statline}".msgFormat(__status__.files, __status__.total)); |
Felix Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 97 | |
Felix Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 98 | renderOverall(__overall__); |
Felix Meschberger | 2cc9787 | 2010-03-19 11:58:49 +0000 | [diff] [blame] | 99 | 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 Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 120 | $("#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 Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 141 | }); |
| 142 | |
| 143 | |
| 144 | |
| 145 | // ]]> |
| 146 | </script> |
| 147 | |
| 148 | <!-- status line --> |
| 149 | <p class="statline"> </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 Meschberger | 2cc9787 | 2010-03-19 11:58:49 +0000 | [diff] [blame] | 158 | <table id="overview" class="nicetable"> |
Felix Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 159 | <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 Meschberger | c4fbef1 | 2010-08-01 10:01:37 +0000 | [diff] [blame] | 175 | <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 Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 185 | </tbody> |
| 186 | </table> |
| 187 | |
| 188 | <p> </p> |
| 189 | |
Felix Meschberger | 2cc9787 | 2010-03-19 11:58:49 +0000 | [diff] [blame] | 190 | <table id="pools" class="tablesorter nicetable noauto"> |
Felix Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 191 | <thead> |
| 192 | <tr> |
Felix Meschberger | 2cc9787 | 2010-03-19 11:58:49 +0000 | [diff] [blame] | 193 | <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"> </td></tr> |
| 204 | </tbody> |
| 205 | <tfoot class="ui-widget-header"> |
| 206 | <tr><td colspan="4"> </td></tr> |
| 207 | </tfoot> |
| 208 | </table> |
| 209 | |
| 210 | <p> </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 Meschberger | 9d86a26 | 2010-03-18 21:35:20 +0000 | [diff] [blame] | 219 | </tr> |
| 220 | </thead> |
| 221 | <tbody> |
| 222 | <tr><td colspan="4"> </td></tr> |
| 223 | </tbody> |
| 224 | </table> |