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">
|
||||
<table class="table table-hover">
|
||||
<thead><tr>
|
||||
<th data-field="service">Service</th>
|
||||
<th data-field="desc">Description</th>
|
||||
<th data-field="action" class="text-right">Actions</th>
|
||||
{{#headers}}<th>Service</th>{{#headers}}
|
||||
</tr></thead>
|
||||
{{! #data}}
|
||||
{{#data}}
|
||||
<tr {{^.enabled}}class="active"{{/.enabled}}>
|
||||
<td>{{.getName()}}</td>
|
||||
<td>{{.getValue()}}</td>
|
||||
{{#params}}
|
||||
<td>
|
||||
{{#.isTypeBoolean()}}
|
||||
<input type="checkbox" {{#.getValue()}}checked{{/.getValue()}} disabled />
|
||||
{{/.isTypeBoolean()}}
|
||||
{{^.isTypeBoolean()}}{{.getValue()}}{{/.isTypeBoolean()}}
|
||||
</td>
|
||||
{{/params}}
|
||||
<td class="text-right">
|
||||
<button type="button" class="btn btn-primary btn-xs">Edit</button>
|
||||
{{^.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>
|
||||
</td>
|
||||
</tr>
|
||||
{{! /data}}
|
||||
{{/data}}
|
||||
</table>
|
||||
</div>
|
||||
<div class="panel-footer text-right">
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ public class ConfigPage implements WAPage{
|
|||
Map<String, String> request) {
|
||||
try {
|
||||
Templator tmpl = new Templator(FileUtil.find(TMPL_FILE));
|
||||
tmpl.set("headers", null);
|
||||
tmpl.set("data", null);
|
||||
return tmpl;
|
||||
} catch (IOException e) {
|
||||
log.log(Level.SEVERE, null, e);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,24 @@
|
|||
package wa.server.plugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import zutil.db.DBConnection;
|
||||
|
||||
public interface WAServiceConfig {
|
||||
/**
|
||||
* @return the String name of this configuration type
|
||||
*/
|
||||
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";
|
||||
|
||||
// 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 {
|
||||
|
|
@ -47,7 +38,7 @@ public class ApacheConfig{
|
|||
out.println(FileUtil.getContent(new File(STATIC_PRE_CONF)));
|
||||
out.println("######################################");
|
||||
out.println("# vhost.php");
|
||||
for(ApacheConfigVirtualHost vhost : vhosts){
|
||||
for(ApacheConfigVirtualHost.VirtualHostData vhost : vhosts){
|
||||
if(vhost.isSSL())
|
||||
writeSSLVhost(out, vhost);
|
||||
else
|
||||
|
|
@ -57,7 +48,7 @@ public class ApacheConfig{
|
|||
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(" ServerName "+conf.getDomain()+":80");
|
||||
out.println(" DocumentRoot "+conf.getPath());
|
||||
|
|
@ -65,7 +56,7 @@ public class ApacheConfig{
|
|||
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(" ServerName "+conf.getDomain()+":80");
|
||||
out.println(" RewriteEngine On");
|
||||
|
|
@ -83,7 +74,7 @@ public class ApacheConfig{
|
|||
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(" ServerName "+conf.getDomain()+":80");
|
||||
out.println(" ");
|
||||
|
|
|
|||
|
|
@ -2,38 +2,19 @@ package wa.server.plugin.apache;
|
|||
|
||||
import wa.server.WAConstants;
|
||||
import wa.server.plugin.WAServiceConfig;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.db.bean.DBBean;
|
||||
import zutil.db.bean.DBBean.DBTable;;import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import zutil.db.bean.DBBean.DBTable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@DBTable(WAConstants.DB_TABLE_PREFIX+"_apache_vhost")
|
||||
public class ApacheConfigVirtualHost implements WAServiceConfig{
|
||||
public static final String CONFIG_NAME = "Apache Virtual Host";
|
||||
|
||||
protected String domain;
|
||||
protected String path;
|
||||
protected boolean ssl;
|
||||
private List<VirtualHostData> vhosts = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
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
|
||||
public String getName() {
|
||||
|
|
@ -41,12 +22,47 @@ public class ApacheConfigVirtualHost implements WAServiceConfig{
|
|||
}
|
||||
|
||||
@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
|
||||
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