Fixed zutil changes

This commit is contained in:
Ziver Koc 2016-04-02 01:17:13 +02:00
parent 7bf6896473
commit 6ad7c2ed58
9 changed files with 144 additions and 56 deletions

View file

@ -12,7 +12,8 @@
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" exported=""> <orderEntry type="module" module-name="Zutil" exported="" />
<orderEntry type="module-library">
<library name="lib"> <library name="lib">
<CLASSES> <CLASSES>
<root url="file://$MODULE_DIR$/lib" /> <root url="file://$MODULE_DIR$/lib" />
@ -25,6 +26,5 @@
<jarDirectory url="file://$MODULE_DIR$/lib" recursive="false" /> <jarDirectory url="file://$MODULE_DIR$/lib" recursive="false" />
</library> </library>
</orderEntry> </orderEntry>
<orderEntry type="module" module-name="Zutil" exported="" />
</component> </component>
</module> </module>

40
resources/WebContent/page/index.tmpl Normal file → Executable file
View file

@ -30,21 +30,21 @@
<a class="navbar-brand" href="#">{{title}}</a> <a class="navbar-brand" href="#">{{title}}</a>
<ul class="nav navbar-nav navbar-left"> <ul class="nav navbar-nav navbar-left">
{{#top-nav}} {{#top-nav}}
{{^.subNav.length}} {{^.getSubNavs().length}}
<li><a href="{{.url}}">{{.name}}</a></li> <li><a href="{{.getUrl()}}">{{.getName()}}</a></li>
{{/.subNav.length}} {{/.getSubNavs().length}}
{{#.subNav.length}} {{#.getSubNavs().length}}
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
{{.name}} <b class="caret"></b> {{.getName()}} <b class="caret"></b>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
{{#.subNav}} {{#.getSubNavs()}}
<li><a href="{{.url}}">{{.name}}</a></li> <li><a href="{{.getUrl()}}">{{.getName()}}</a></li>
{{/.subNav}} {{/.getSubNavs()}}
</ul> </ul>
</li> </li>
{{/.subNav.length}} {{/.getSubNavs().length}}
{{/top-nav}} {{/top-nav}}
</ul> </ul>
<!-- Top-Left nav --> <!-- Top-Left nav -->
@ -94,21 +94,21 @@
<div id="side-bar" class="col-md-2"> <div id="side-bar" class="col-md-2">
<ul class="side-menu nav nav-pills nav-stacked"> <ul class="side-menu nav nav-pills nav-stacked">
{{#side-nav}} {{#side-nav}}
{{^.subNav.length}} {{^.getSubNavs().length}}
<li><a href="{{.url}}">{{.name}}</a></li> <li><a href="{{.getUrl()}}">{{.getName()}}</a></li>
{{/.subNav.length}} {{/.getSubNavs().length}}
{{#.subNav.length}} {{#.getSubNavs().length}}
<li class=""> <li class="">
<a data-toggle="collapse" data-parent="#side-bar" href="#{{.name}}_collapse"> <a data-toggle="collapse" data-parent="#side-bar" href="#{{.getName()}}_collapse">
{{.name}} <b class="caret"></b> {{.getName()}} <b class="caret"></b>
</a> </a>
<ul id="{{.name}}_collapse" class="side-sub-menu collapse nav nav-pills nav-stacked "> <ul id="{{.name}}_collapse" class="side-sub-menu collapse nav nav-pills nav-stacked ">
{{#.subNav}} {{#.getSubNavs()}}
<li><a href="{{.url}}">{{.name}}</a></li> <li><a href="{{.url}}">{{.getName()}}</a></li>
{{/.subNav}} {{/.getSubNavs()}}
</ul> </ul>
</li> </li>
{{/.subNav.length}} {{/.getSubNavs().length}}
{{/side-nav}} {{/side-nav}}
</ul> </ul>
</div> </div>
@ -120,7 +120,7 @@
<div class="row"> <div class="row">
<ol class="breadcrumb"> <ol class="breadcrumb">
{{#breadcrumb}} {{#breadcrumb}}
<li><a href="{{.url}}">{{.name}}</a></li> <li><a href="{{.getUrl()}}">{{.getName()}}</a></li>
{{/breadcrumb}} {{/breadcrumb}}
</ol> </ol>
</div> </div>

View file

@ -0,0 +1,85 @@
/*
* Copyright (c) 2015 ezivkoc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package wa.server.page;
import zutil.net.http.HttpHeader;
import zutil.net.http.HttpHeaderParser;
import zutil.net.http.HttpPage;
import zutil.net.http.HttpPrintStream;
import zutil.parser.DataNode;
import zutil.parser.json.JSONWriter;
import zutil.struct.CircularBuffer;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
/**
* Created by Ziver on 2015-09-22.
*/
public class WALogPage extends Handler implements HttpPage {
private CircularBuffer<LogRecord> logBuffer;
@Override
public void publish(LogRecord record) {
if(super.isLoggable(record)){
logBuffer.add(record);
}
}
@Override
public void flush() {}
@Override
public void close() throws SecurityException {
throw new UnsupportedOperationException ();
}
@Override
public void respond(HttpPrintStream out,
HttpHeader client_info,
Map<String, Object> session,
Map<String, String> cookie,
Map<String, String> request) throws IOException {
DataNode logNode = new DataNode(DataNode.DataType.List);
Iterator<LogRecord> it = logBuffer.iterator();
for(int i=0; i<20 && it.hasNext(); ++i){
LogRecord record = it.next();
DataNode node = new DataNode(DataNode.DataType.Map);
node.set("timestamp", record.getMillis());
node.set("source", record.getLoggerName());
node.set("msg", record.getMessage());
logNode.add(node);
}
DataNode root = new DataNode(DataNode.DataType.Map);
root.add(logNode);
JSONWriter writer = new JSONWriter(out);
writer.write(root);
writer.close();
}
}

3
src/wa/server/page/struct/WANavigation.java Normal file → Executable file
View file

@ -80,6 +80,9 @@ public class WANavigation implements Iterable{
public String getName(){ public String getName(){
return name; return name;
} }
public String getUrl(){
return url;
}
public Object getResource(){ public Object getResource(){
return resource; return resource;
} }

8
src/wa/server/plugin/apache/plugin.json Normal file → Executable file
View file

@ -1,8 +1,8 @@
{ {
"version": "1.0", "version": "1.0",
"name": "Apache Web Server", "name": "Apache Web Server",
"interfaces": { "interfaces": [
"wa.server.plugin.WAService": "wa.server.plugin.apache.ApacheService", {"wa.server.plugin.WAService": "wa.server.plugin.apache.ApacheService"},
"wa.server.plugin.WAServiceStatus": "wa.server.plugin.apache.ApacheStatus" {"wa.server.plugin.WAServiceStatus": "wa.server.plugin.apache.ApacheStatus"}
} ]
} }

50
src/wa/server/plugin/hwstatus/HDDStatus.tmpl Normal file → Executable file
View file

@ -8,30 +8,6 @@
<div id="hdd-container"></div> <div id="hdd-container"></div>
<div id="template" class="hidden">
<div id="" class="col-md-4"><div class="panel panel-default">
<div class="panel-heading hdd-title">HDD: {{.mount}} ({{.size_total}})</div>
<div class="panel-body">
<center><img src="img/hdd_ok.png" /></center><br>
<div class="progress">
<div class="progress-bar hdd-used" role="progressbar"></div>
<center class="hdd-free">{{.size_free}}</center>
</div>
<table class="table small hdd-detail">
<thead><tr>
<th data-field="mount">Mount</th>
<th data-field="type" >Type</th>
</tr></thead>
<tr>
<td class="hdd-mount"></td>
<td class="hdd-filesystem"></td>
</tr>
</table>
<!--<div><canvas id="hdd-io" height="400"></canvas></div>-->
</div>
</div></div>
</div>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
@ -40,7 +16,7 @@ $(function() {
}); });
function updateHdd(){ function updateHdd(){
$.getJSON("{{nav.url}}&json&hdd", function( data ) { $.getJSON("{{nav.getUrl()}}&json&hdd", function( data ) {
$.each(data['hdd'], function( index, hdd ){ $.each(data['hdd'], function( index, hdd ){
var element = null; var element = null;
var html_id = "hdd-id-" + hdd.id; var html_id = "hdd-id-" + hdd.id;
@ -78,3 +54,27 @@ function byteToString(value){
return value+" "+sizes[total]; return value+" "+sizes[total];
} }
</script> </script>
<div id="template" class="hidden">
<div id="" class="col-md-4"><div class="panel panel-default">
<div class="panel-heading hdd-title">HDD: {{.mount}} ({{.size_total}})</div>
<div class="panel-body">
<center><img src="img/hdd_ok.png" /></center><br>
<div class="progress">
<div class="progress-bar hdd-used" role="progressbar"></div>
<center class="hdd-free">{{.size_free}}</center>
</div>
<table class="table small hdd-detail">
<thead><tr>
<th data-field="mount">Mount</th>
<th data-field="type" >Type</th>
</tr></thead>
<tr>
<td class="hdd-mount"></td>
<td class="hdd-filesystem"></td>
</tr>
</table>
<!--<div><canvas id="hdd-io" height="400"></canvas></div>-->
</div>
</div></div>
</div>

6
src/wa/server/plugin/hwstatus/HwStatus.tmpl Normal file → Executable file
View file

@ -54,7 +54,7 @@ var cpu_data = {
}; };
function updateCpuChart(){ function updateCpuChart(){
$.getJSON("{{nav.url}}&json&cpu", function( data ) { $.getJSON("{{nav.getUrl()}}&json&cpu", function( data ) {
// Setup graph // Setup graph
if(cpu_chart == null){ if(cpu_chart == null){
// Fill in cpus // Fill in cpus
@ -102,7 +102,7 @@ var mem_data = [
]; ];
function updateMemChart(){ function updateMemChart(){
$.getJSON("{{nav.url}}&json&memory", function( data ) { $.getJSON("{{nav.getUrl()}}&json&memory", function( data ) {
if(mem_chart == null){ if(mem_chart == null){
var ctx = $("#mem-chart").get(0).getContext("2d"); var ctx = $("#mem-chart").get(0).getContext("2d");
mem_chart = new Chart(ctx).Doughnut(mem_data, { mem_chart = new Chart(ctx).Doughnut(mem_data, {
@ -123,7 +123,7 @@ function updateMemChart(){
function updateProcTable(){ function updateProcTable(){
$.getJSON("{{nav.url}}&json&proc", function( data ) { $.getJSON("{{nav.getUrl()}}&json&proc", function( data ) {
$('#proc-list').bootstrapTable({ $('#proc-list').bootstrapTable({
data: data['proc'] data: data['proc']
}); });

2
src/wa/server/plugin/hwstatus/NetStatus.tmpl Normal file → Executable file
View file

@ -73,7 +73,7 @@ var net_chart_data = {
}; };
function updateNet(){ function updateNet(){
$.getJSON("{{nav.url}}&json&net", function( data ) { $.getJSON("{{nav.getUrl()}}&json&net", function( data ) {
$.each(data['net'], function( index, net ){ $.each(data['net'], function( index, net ){
var element = null; var element = null;
var html_id = "net-" + net.id; var html_id = "net-" + net.id;

2
src/wa/server/plugin/tomcat/plugin.json Normal file → Executable file
View file

@ -1,6 +1,6 @@
{ {
"version": "1.0", "version": "1.0",
"name": "Apache Tomcat", "name": "Tomcat",
"interfaces": { "interfaces": {
"wa.server.plugin.WAService": "wa.server.plugin.apache.TomcatService", "wa.server.plugin.WAService": "wa.server.plugin.apache.TomcatService",
"wa.server.plugin.WAServiceStatus": "wa.server.plugin.tomcat.TomcatStatus" "wa.server.plugin.WAServiceStatus": "wa.server.plugin.tomcat.TomcatStatus"