FELIX-1988 Apply 6.vmstat.patch by Valentin Valchev (thanks) with the following change: The WebConsoleUtil.getVariableResolver now presets the default resolver created with the appRoot and pluginRoot properties from the respective request attributes
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@910873 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
index ebd5908..273811f 100644
--- a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
+++ b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
@@ -23,9 +23,31 @@
# to translate the natively encoded files to ISO-8859-1 during bundle build
#
-#
-# There are no resources currently.
-#
-# In the future, this file will list the keys used in the Web Console bundle,
-# which may be translated by localization fragments.
-#
+
+# Common UI
+reload=Reload
+change=Change
+abort=Abort
+
+# VMStat plugin
+vmstat.stopped=Framework has been stopped.
+vmstat.restarting=Framework is restarting. stand by ...
+vmstat.reloading.in=Reloading in
+vmstat.running=System is up and running!
+vmstat.sl.title=Start Level Information:
+vmstat.sl.system=System Start Level
+vmstat.sl.bundle=Default Bundle Start Level
+vmstat.info.title=Server Information:
+vmstat.lastStarted=Last Started
+vmstat.framework=Framework
+vmstat.shutdown.in=Shutdown in
+vmstat.java.title=Java Information:
+vmstat.java.runtime=Java Runtime
+vmstat.java.jvm=Java Virtual Machine
+vmstat.mem.total=Total Memory
+vmstat.mem.used=Used Memory
+vmstat.mem.free=Free Memory
+vmstat.gc.title=Garbage Collection
+vmstat.gc.button=Run
+
+
diff --git a/webconsole/src/main/resources/res/ui/vmstat.js b/webconsole/src/main/resources/res/ui/vmstat.js
new file mode 100644
index 0000000..684b68a
--- /dev/null
+++ b/webconsole/src/main/resources/res/ui/vmstat.js
@@ -0,0 +1,42 @@
+/* shuts down server after [num] seconds */
+function shutdown(num, formname, elemid) {
+ var elem = $('#' + elemid);
+ var secs=" second";
+ var ellipsis="...";
+ if (num > 0) {
+ if (num != 1) {
+ secs+="s";
+ }
+ elem.html(num+secs+ellipsis);
+ setTimeout('shutdown('+(--num)+', "'+formname+'", "'+elemid+'")',1000);
+ } else {
+ $('#' + formname).submit();
+ }
+}
+
+/* aborts server shutdown and redirects to [target] */
+function abort(target) {
+ top.location.href=target;
+}
+
+/* displays a date in the user's local timezone */
+function localTm(time) {
+ return (time ? new Date(time) : new Date()).toLocaleString();
+}
+/* fill in the data */
+$(document).ready(function() {
+ if(typeof statData == 'undefined') return;
+ for(i in statData) {
+ var target = $('#' + i);
+ if (target.val()) {
+ target.val(statData[i]);
+ } else {
+ target.text(statData[i]);
+ }
+ }
+ $('#lastStarted').text(localTm(statData.lastStarted));
+ var st = statData.shutdownTimer;
+ $('#shutdownform').css('display', st ? 'none' : 'block');
+ $('#shutdownform2').css('display', st ? 'block' : 'none');
+ $('#shutdown_type').val(statData.shutdownType);
+});
\ No newline at end of file
diff --git a/webconsole/src/main/resources/templates/vmstat.html b/webconsole/src/main/resources/templates/vmstat.html
new file mode 100644
index 0000000..bf1d09a
--- /dev/null
+++ b/webconsole/src/main/resources/templates/vmstat.html
@@ -0,0 +1,108 @@
+<script type="text/javascript" src="res/ui/vmstat.js"></script>
+<script type="text/javascript">
+// <![CDATA[
+var statData = ${startData};
+// ]]>
+</script>
+
+<!-- status line -->
+<p class="statline">${vmstat.running}</p>
+
+<table class="nicetable">
+ <thead>
+ <tr>
+ <th colspan="2">${vmstat.sl.title}</th>
+ </tr>
+ </thead>
+
+ <tr>
+ <td>${vmstat.sl.system}</td>
+ <td>
+ <form method="post" action="${pluginRoot}">
+ <div>
+ <input type="hidden" name="action" value="setStartLevel"/>
+ <input type="text" size="3" name="systemStartLevel" id="systemStartLevel" value="-1"/>
+ <input type="submit" name="Set Start Level" value="${change}"/>
+ </div>
+ </form>
+ </td>
+ </tr>
+ <tr>
+ <td>${vmstat.sl.bundle}</td>
+ <td>
+ <form method="post" action="${pluginRoot}">
+ <div>
+ <input type="hidden" name="action" value="setStartLevel"/>
+ <input type="text" size="3" name="bundleStartLevel" id="bundleStartLevel" value="-1"/>
+ <input type="submit" name="Set Start Level" value="${change}"/>
+ </div>
+ </form>
+ </td>
+ </tr>
+
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <th colspan="2">${vmstat.info.title}</th>
+ </tr>
+ <tr>
+ <td>${vmstat.lastStarted}</td>
+ <td id="lastStarted">---</td>
+ </tr>
+ <tr>
+ <td>${vmstat.framework}</td>
+ <td>
+ <form id="shutdownform" method="post" action="${pluginRoot}">
+ <div>
+ <input type="hidden" name="shutdown_timer" value="shutdown_timer" />
+ <!-- NOTE: don't translate value="Restart" & value="Stop" - will break the operation type -->
+ <input class="ui-state-error" type="submit" name="shutdown_type" value="Restart" onclick="return confirm('This will stop and restart the framework and all bundles. Please confirm to continue.');" />
+ <input class="ui-state-error" type="submit" name="shutdown_type" value="Stop" onclick="return confirm('This will stop the framework and all bundles. Please confirm to continue.')" />
+ </div>
+ </form>
+ <form id="shutdownform2" method="post" action="${pluginRoot}">
+ <div>
+ <input type="hidden" name="shutdown_type" id="shutdown_type" value="" />
+ <input class="ui-state-error" type="button" value="${abort}" onclick="abort('${pluginRoot}')" />
+ ${vmstat.shutdown.in} <span id='countdowncell'> </span>
+ <script type="text/javascript">if(statData.shutdownTimer) shutdown(3, 'shutdownform2', 'countdowncell');</script>
+ </div>
+ </form>
+ </td>
+ </tr>
+
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <th colspan="2">${vmstat.java.title}</th>
+ </tr>
+ <tr>
+ <td>${vmstat.java.runtime}</td>
+ <td id="runtime">-</td>
+ </tr>
+ <tr>
+ <td>${vmstat.java.jvm}</td>
+ <td id="jvm">-</td>
+ </tr>
+ <tr>
+ <td>${vmstat.mem.total}</td>
+ <td id="mem_total">-</td>
+ </tr>
+ <tr>
+ <td>${vmstat.mem.used}</td>
+ <td id="mem_used">-</td>
+ </tr>
+ <tr>
+ <td>${vmstat.mem.free}</td>
+ <td id="mem_free">-</td>
+ </tr>
+ <tr>
+ <td>${vmstat.gc.title}</td>
+ <td>
+ <form method="post" action="${pluginRoot}">
+ <div>
+ <input type="hidden" name="action" value="gc" />
+ <input class="submit" type="submit" name="Collect Garbage" value="${vmstat.gc.button}" />
+ </div>
+ </form>
+ </td>
+ </tr>
+</table>
diff --git a/webconsole/src/main/resources/templates/vmstat_restart.html b/webconsole/src/main/resources/templates/vmstat_restart.html
new file mode 100644
index 0000000..bb1f933
--- /dev/null
+++ b/webconsole/src/main/resources/templates/vmstat_restart.html
@@ -0,0 +1,13 @@
+<script type="text/javascript" src="res/ui/vmstat.js"></script>
+
+<!-- status line -->
+<p class="statline">${vmstat.restarting}</p>
+
+<form id="reloadform" method="get" action="">
+ <div style="width:100%; text-align: center">
+ <input class="ui-state-error" type="submit" value="${reload}" />
+ ${vmstat.reloading.in} <span id="reloadcountdowncell"> </span>
+ <script type="text/javascript">shutdown(10, "reloadform", "reloadcountdowncell");</script>
+ </div>
+</form>
+
diff --git a/webconsole/src/main/resources/templates/vmstat_stop.html b/webconsole/src/main/resources/templates/vmstat_stop.html
new file mode 100644
index 0000000..ce054c2
--- /dev/null
+++ b/webconsole/src/main/resources/templates/vmstat_stop.html
@@ -0,0 +1,5 @@
+<script type="text/javascript" src="res/ui/vmstat.js"></script>
+
+<!-- status line -->
+<p class="statline">${vmstat.stopped}</p>
+