Major refactoring of page and navigation

This commit is contained in:
Ziver Koc 2016-07-22 21:37:51 +02:00
parent bb546ce046
commit 3a0f40dab9
25 changed files with 353 additions and 669 deletions

View file

@ -27,9 +27,12 @@ import org.hyperic.sigar.FileSystemUsage;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.cmd.Shell;
import wa.server.plugin.WAStatus;
import wa.server.WAContext;
import wa.server.page.WAStatusPage;
import zutil.io.file.FileUtil;
import zutil.net.http.HttpHeader;
import zutil.parser.DataNode;
import zutil.parser.Templator;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@ -39,26 +42,35 @@ import java.util.Map;
/**
* Created by Ziver on 2015-04-17.
*/
public class HDDStatus implements WAStatus {
public class HDDStatus extends WAStatusPage {
private static final String TEMPLATE = "wa/server/plugin/hwstatus/HddStatus.tmpl";
private static final String NAVIGATION_NAME = "wa/server/plugin/hwstatus/HddStatus.tmpl";
private Templator tmpl;
private int nextId;
private HashMap<String,Integer> idMap = new HashMap<String,Integer>();
public HDDStatus() {
super("hdd", "Harddrives");
}
@Override
public String getName() {
return "Harddrives";
public Templator htmlResponse(WAContext context, HttpHeader client_info, Map<String, Object> session, Map<String, String> cookie, Map<String, String> request) throws IOException {
if (tmpl == null)
tmpl = new Templator(FileUtil.getContent(FileUtil.find(TEMPLATE)));
return tmpl;
}
@Override
public String html() {
try {
return FileUtil.getContent(FileUtil.findURL("wa/server/plugin/hwstatus/HddStatus.tmpl"));
} catch (IOException e) {
return e.getMessage();
}
}
@Override
public void jsonUpdate(Map<String, String> request, DataNode root) {
public DataNode jsonResponse(WAContext context,
HttpHeader client_info,
Map<String, Object> session,
Map<String, String> cookie,
Map<String, String> request) {
DataNode root = new DataNode(DataNode.DataType.Map);
if (request.containsKey("hdd")) {
DataNode hdd_root = new DataNode(DataNode.DataType.List);
root.set("hdd", hdd_root);
@ -95,5 +107,7 @@ public class HDDStatus implements WAStatus {
e.printStackTrace();
}
}
return root;
}
}