Initial impl of configuration page
This commit is contained in:
parent
78cb41a39c
commit
813d48ca05
5 changed files with 80 additions and 55 deletions
|
|
@ -4,14 +4,18 @@
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<table class="table table-hover">
|
<table class="table table-hover">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th data-field="service">Service</th>
|
{{#headers}}<th>Service</th>{{#headers}}
|
||||||
<th data-field="desc">Description</th>
|
|
||||||
<th data-field="action" class="text-right">Actions</th>
|
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
{{! #data}}
|
{{#data}}
|
||||||
<tr {{^.enabled}}class="active"{{/.enabled}}>
|
<tr {{^.enabled}}class="active"{{/.enabled}}>
|
||||||
<td>{{.getName()}}</td>
|
{{#params}}
|
||||||
<td>{{.getValue()}}</td>
|
<td>
|
||||||
|
{{#.isTypeBoolean()}}
|
||||||
|
<input type="checkbox" {{#.getValue()}}checked{{/.getValue()}} disabled />
|
||||||
|
{{/.isTypeBoolean()}}
|
||||||
|
{{^.isTypeBoolean()}}{{.getValue()}}{{/.isTypeBoolean()}}
|
||||||
|
</td>
|
||||||
|
{{/params}}
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
<button type="button" class="btn btn-primary btn-xs">Edit</button>
|
<button type="button" class="btn btn-primary btn-xs">Edit</button>
|
||||||
{{^.enabled}}<button type="button" class="btn btn-default btn-xs">Disable</button>{{/.enabled}}
|
{{^.enabled}}<button type="button" class="btn btn-default btn-xs">Disable</button>{{/.enabled}}
|
||||||
|
|
@ -19,7 +23,7 @@
|
||||||
<button type="button" class="btn btn-danger btn-xs">Remove</button>
|
<button type="button" class="btn btn-danger btn-xs">Remove</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{! /data}}
|
{{/data}}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-footer text-right">
|
<div class="panel-footer text-right">
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ public class ConfigPage implements WAPage{
|
||||||
Map<String, String> request) {
|
Map<String, String> request) {
|
||||||
try {
|
try {
|
||||||
Templator tmpl = new Templator(FileUtil.find(TMPL_FILE));
|
Templator tmpl = new Templator(FileUtil.find(TMPL_FILE));
|
||||||
|
tmpl.set("headers", null);
|
||||||
|
tmpl.set("data", null);
|
||||||
return tmpl;
|
return tmpl;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.log(Level.SEVERE, null, e);
|
log.log(Level.SEVERE, null, e);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,24 @@
|
||||||
package wa.server.plugin;
|
package wa.server.plugin;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
import zutil.db.DBConnection;
|
|
||||||
|
|
||||||
public interface WAServiceConfig {
|
public interface WAServiceConfig {
|
||||||
|
/**
|
||||||
|
* @return the String name of this configuration type
|
||||||
|
*/
|
||||||
public String getName();
|
public String getName();
|
||||||
public void read() throws SQLException;
|
|
||||||
public void save() throws IOException;
|
/**
|
||||||
|
* Read in current configuration data
|
||||||
|
*/
|
||||||
|
public void read() throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save configured data to disk or database
|
||||||
|
*/
|
||||||
|
public void save() throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure service with current configuration data
|
||||||
|
*/
|
||||||
|
public void configure() throws Exception;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,9 @@ public class ApacheConfig{
|
||||||
private static final String STATIC_PRE_CONF = "wa/server/plugin/apache/apache_default.config";
|
private static final String STATIC_PRE_CONF = "wa/server/plugin/apache/apache_default.config";
|
||||||
|
|
||||||
// Configuration data
|
// Configuration data
|
||||||
List<ApacheConfigVirtualHost> vhosts;
|
List<ApacheConfigVirtualHost.VirtualHostData> vhosts;
|
||||||
|
|
||||||
|
|
||||||
public ApacheConfig(){
|
|
||||||
vhosts = new LinkedList<ApacheConfigVirtualHost>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void read() throws SQLException {
|
|
||||||
DBConnection db = WAConstants.getDB();
|
|
||||||
//vhosts = ApacheConfigVirtualHost.load(db, ApacheConfigVirtualHost.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void save() throws IOException {
|
public void save() throws IOException {
|
||||||
|
|
@ -47,7 +38,7 @@ public class ApacheConfig{
|
||||||
out.println(FileUtil.getContent(new File(STATIC_PRE_CONF)));
|
out.println(FileUtil.getContent(new File(STATIC_PRE_CONF)));
|
||||||
out.println("######################################");
|
out.println("######################################");
|
||||||
out.println("# vhost.php");
|
out.println("# vhost.php");
|
||||||
for(ApacheConfigVirtualHost vhost : vhosts){
|
for(ApacheConfigVirtualHost.VirtualHostData vhost : vhosts){
|
||||||
if(vhost.isSSL())
|
if(vhost.isSSL())
|
||||||
writeSSLVhost(out, vhost);
|
writeSSLVhost(out, vhost);
|
||||||
else
|
else
|
||||||
|
|
@ -57,7 +48,7 @@ public class ApacheConfig{
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeVhost(PrintStream out, ApacheConfigVirtualHost conf) throws IOException{
|
private void writeVhost(PrintStream out, ApacheConfigVirtualHost.VirtualHostData conf) throws IOException{
|
||||||
out.println("<VirtualHost *:80>");
|
out.println("<VirtualHost *:80>");
|
||||||
out.println(" ServerName "+conf.getDomain()+":80");
|
out.println(" ServerName "+conf.getDomain()+":80");
|
||||||
out.println(" DocumentRoot "+conf.getPath());
|
out.println(" DocumentRoot "+conf.getPath());
|
||||||
|
|
@ -65,7 +56,7 @@ public class ApacheConfig{
|
||||||
out.println("");
|
out.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeSSLVhost(PrintStream out, ApacheConfigVirtualHost conf) throws IOException{
|
private void writeSSLVhost(PrintStream out, ApacheConfigVirtualHost.VirtualHostData conf) throws IOException{
|
||||||
out.println("<VirtualHost *:80>");
|
out.println("<VirtualHost *:80>");
|
||||||
out.println(" ServerName "+conf.getDomain()+":80");
|
out.println(" ServerName "+conf.getDomain()+":80");
|
||||||
out.println(" RewriteEngine On");
|
out.println(" RewriteEngine On");
|
||||||
|
|
@ -83,7 +74,7 @@ public class ApacheConfig{
|
||||||
out.println("");
|
out.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeTomcatVhost(PrintStream out, ApacheConfigVirtualHost conf) throws IOException{
|
private void writeTomcatVhost(PrintStream out, ApacheConfigVirtualHost.VirtualHostData conf) throws IOException{
|
||||||
out.println("<VirtualHost *:80>");
|
out.println("<VirtualHost *:80>");
|
||||||
out.println(" ServerName "+conf.getDomain()+":80");
|
out.println(" ServerName "+conf.getDomain()+":80");
|
||||||
out.println(" ");
|
out.println(" ");
|
||||||
|
|
|
||||||
|
|
@ -2,51 +2,67 @@ package wa.server.plugin.apache;
|
||||||
|
|
||||||
import wa.server.WAConstants;
|
import wa.server.WAConstants;
|
||||||
import wa.server.plugin.WAServiceConfig;
|
import wa.server.plugin.WAServiceConfig;
|
||||||
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.bean.DBBean;
|
import zutil.db.bean.DBBean;
|
||||||
import zutil.db.bean.DBBean.DBTable;;import java.io.IOException;
|
import zutil.db.bean.DBBean.DBTable;
|
||||||
import java.sql.SQLException;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@DBTable(WAConstants.DB_TABLE_PREFIX+"_apache_vhost")
|
|
||||||
public class ApacheConfigVirtualHost implements WAServiceConfig{
|
public class ApacheConfigVirtualHost implements WAServiceConfig{
|
||||||
public static final String CONFIG_NAME = "Apache Virtual Host";
|
public static final String CONFIG_NAME = "Apache Virtual Host";
|
||||||
|
|
||||||
protected String domain;
|
private List<VirtualHostData> vhosts = new ArrayList<>();
|
||||||
protected String path;
|
|
||||||
protected boolean ssl;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getDomain() {
|
|
||||||
return domain;
|
|
||||||
}
|
|
||||||
public void setDomain(String domain) {
|
|
||||||
this.domain = domain;
|
|
||||||
}
|
|
||||||
public String getPath() {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
public void setPath(String path) {
|
|
||||||
this.path = path;
|
|
||||||
}
|
|
||||||
public boolean isSSL() {
|
|
||||||
return ssl;
|
|
||||||
}
|
|
||||||
public void setSSL(boolean ssl) {
|
|
||||||
this.ssl = ssl;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return CONFIG_NAME;
|
return CONFIG_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read() throws SQLException {
|
public void read() throws Exception {
|
||||||
|
DBConnection db = WAConstants.getDB();
|
||||||
|
vhosts = DBBean.load(db, VirtualHostData.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save() throws Exception {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save() throws IOException {
|
public void configure() throws Exception {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DBTable(WAConstants.DB_TABLE_PREFIX + "_apache_vhost")
|
||||||
|
public static class VirtualHostData extends DBBean{
|
||||||
|
protected String domain;
|
||||||
|
protected String path;
|
||||||
|
protected boolean ssl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getDomain() {
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
public void setDomain(String domain) {
|
||||||
|
this.domain = domain;
|
||||||
|
}
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
public void setPath(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
public boolean isSSL() {
|
||||||
|
return ssl;
|
||||||
|
}
|
||||||
|
public void setSSL(boolean ssl) {
|
||||||
|
this.ssl = ssl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue