Implemented navigation
This commit is contained in:
parent
846ed78252
commit
b3e0757b29
11 changed files with 203 additions and 90 deletions
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
package wa.server.page;
|
||||
|
||||
import wa.server.WAAbstractPage;
|
||||
import wa.server.WAContext;
|
||||
import wa.server.page.struct.WANavigation;
|
||||
import wa.server.plugin.WAStatus;
|
||||
|
|
@ -30,23 +31,22 @@ import zutil.parser.DataNode;
|
|||
import zutil.parser.Templator;
|
||||
import zutil.plugin.PluginManager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-04-06.
|
||||
*/
|
||||
public class StatusPage extends AbstractPage{
|
||||
public class StatusPage implements WAPage {
|
||||
private ArrayList<WAStatus> plugins;
|
||||
|
||||
public StatusPage(PluginManager pluginManager){
|
||||
this.plugins = pluginManager.toArray(WAStatus.class);
|
||||
|
||||
WANavigation nav = new WANavigation("Status");
|
||||
WANavigation nav = new WANavigation("Status", this);
|
||||
for(WAStatus plugin : plugins)
|
||||
nav.addSubNav(new WANavigation(plugin.getName()));
|
||||
WANavigation.getRootNav().addSubNav(nav);
|
||||
nav.addSubNav(new WANavigation(plugin.getName(), plugin));
|
||||
WANavigation.addRootNav(nav);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -56,14 +56,14 @@ public class StatusPage extends AbstractPage{
|
|||
Map<String, Object> session,
|
||||
Map<String, String> cookie,
|
||||
Map<String, String> request) {
|
||||
WAStatus obj = null;
|
||||
if(request.containsKey("i"))
|
||||
obj = getPlugin(Integer.parseInt(request.get("i")));
|
||||
else
|
||||
obj = getPlugin(0);
|
||||
|
||||
if(obj != null)
|
||||
return new Templator(obj.html());
|
||||
WAStatus obj = getPlugin(context);
|
||||
|
||||
if(obj != null) {
|
||||
Templator tmpl = new Templator(obj.html());
|
||||
tmpl.set("nav", context.getBreadcrumb().get(1));
|
||||
return tmpl;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ public class StatusPage extends AbstractPage{
|
|||
Map<String, String> request){
|
||||
|
||||
if(request.containsKey("i")) {
|
||||
WAStatus obj = getPlugin(Integer.parseInt(request.get("i")));
|
||||
WAStatus obj = getPlugin(context);
|
||||
DataNode root = new DataNode(DataNode.DataType.Map);
|
||||
obj.jsonUpdate(request, root);
|
||||
return root;
|
||||
|
|
@ -82,9 +82,14 @@ public class StatusPage extends AbstractPage{
|
|||
return null;
|
||||
}
|
||||
|
||||
private WAStatus getPlugin(int i){
|
||||
if(0 >= i && i < plugins.size())
|
||||
return plugins.get(i);
|
||||
|
||||
private WAStatus getPlugin(WAContext context){
|
||||
if(context.getBreadcrumb().size() >= 2){
|
||||
int i = plugins.indexOf(context.getBreadcrumb().get(1).getResource());
|
||||
if(i >= 0)
|
||||
return plugins.get(i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue