Some progress on service configuration
This commit is contained in:
parent
29def452b6
commit
ab7296198a
10 changed files with 138 additions and 84 deletions
|
|
@ -25,6 +25,7 @@ package wa.server.page;
|
|||
import wa.server.WAContext;
|
||||
import wa.server.page.struct.WANavigation;
|
||||
import wa.server.plugin.WAService;
|
||||
import wa.server.plugin.WAServiceStatus;
|
||||
import zutil.io.file.FileUtil;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.net.http.HttpHeaderParser;
|
||||
|
|
@ -43,16 +44,21 @@ import java.util.logging.Logger;
|
|||
*/
|
||||
public class ServicePage implements WAPage {
|
||||
private static final Logger log = LogUtil.getLogger();
|
||||
public static final String NAVIGATION_NAME = "Services";
|
||||
private static final String TMPL_FILE = "WebContent/page/ServicePage.tmpl";
|
||||
|
||||
private ArrayList<WAService> plugins;
|
||||
private ArrayList<WAService> services;
|
||||
private ArrayList<ServiceStatusPage> statuses;
|
||||
|
||||
public ServicePage(PluginManager pluginManager){
|
||||
this.plugins = pluginManager.toArray(WAService.class);
|
||||
this.services = pluginManager.toArray(WAService.class);
|
||||
this.statuses = new ArrayList<>();
|
||||
|
||||
WANavigation nav = new WANavigation("Services");
|
||||
for(WAService plugin : plugins)
|
||||
WANavigation nav = new WANavigation(NAVIGATION_NAME, this);
|
||||
for(WAService plugin : services) {
|
||||
nav.addSubNav(new WANavigation(plugin.getName()));
|
||||
statuses.add(new ServiceStatusPage(plugin.getStatus()));
|
||||
}
|
||||
WANavigation.addRootNav(nav);
|
||||
}
|
||||
|
||||
|
|
@ -65,13 +71,17 @@ public class ServicePage implements WAPage {
|
|||
Map<String, String> request) {
|
||||
|
||||
try {
|
||||
WAService obj = getPlugin(context);
|
||||
int index = services.indexOf(context.getBreadcrumb().get(1).getResource());
|
||||
if(index < 0)
|
||||
return null;
|
||||
WAService obj = services.get(index);
|
||||
ServiceStatusPage statusPage = statuses.get(index);
|
||||
|
||||
Templator tmpl = new Templator(FileUtil.find(TMPL_FILE));
|
||||
tmpl.set("service_status",
|
||||
statusPage.htmlResponse(context, client_info, session, cookie, request).compile());
|
||||
return tmpl;
|
||||
|
||||
if (obj != null) {
|
||||
Templator tmpl = new Templator(FileUtil.find(TMPL_FILE));
|
||||
tmpl.set("nav", context.getBreadcrumb().get(1));
|
||||
return tmpl;
|
||||
}
|
||||
}catch (IOException e){
|
||||
log.log(Level.SEVERE, null, e);
|
||||
}
|
||||
|
|
@ -88,13 +98,4 @@ public class ServicePage implements WAPage {
|
|||
}
|
||||
|
||||
|
||||
private WAService 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