[vlma-devel] commit: Make the configuration editable online. (Adrien Grand )
git version control
git at videolan.org
Sat May 3 11:50:50 CEST 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sat May 3 11:51:41 2008 +0200| [43e684148ef06f1cdfb9038b78d5c4a55a8e2319]
Make the configuration editable online.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=43e684148ef06f1cdfb9038b78d5c4a55a8e2319
---
.../main/java/org/videolan/vlma/common/VLMa.java | 1 +
.../videolan/vlma/web/dwr/RemoteController.java | 29 +++++++++
web/src/main/resources/messages.properties | 5 ++
web/src/main/resources/messages_fr.properties | 5 ++
web/src/main/webapp/WEB-INF/applicationContext.xml | 3 +
.../jsp/configuration/configurationview_right.jsp | 64 ++++++++++++++++++--
6 files changed, 101 insertions(+), 6 deletions(-)
diff --git a/core/src/main/java/org/videolan/vlma/common/VLMa.java b/core/src/main/java/org/videolan/vlma/common/VLMa.java
index 6d7d22e..87f24d4 100644
--- a/core/src/main/java/org/videolan/vlma/common/VLMa.java
+++ b/core/src/main/java/org/videolan/vlma/common/VLMa.java
@@ -95,6 +95,7 @@ public class VLMa extends CompositeConfiguration implements Configuration {
private VLMa(File f) throws ConfigurationException {
super(new PropertiesConfiguration(f));
+ ((PropertiesConfiguration) this.getInMemoryConfiguration()).setAutoSave(true);
}
private VLMa() {
diff --git a/web/src/main/java/org/videolan/vlma/web/dwr/RemoteController.java b/web/src/main/java/org/videolan/vlma/web/dwr/RemoteController.java
index d2dd243..2508193 100644
--- a/web/src/main/java/org/videolan/vlma/web/dwr/RemoteController.java
+++ b/web/src/main/java/org/videolan/vlma/web/dwr/RemoteController.java
@@ -25,6 +25,7 @@ import javax.servlet.ServletException;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
+import org.videolan.vlma.common.Data;
/**
* A remote ajax controller.
@@ -36,6 +37,12 @@ import org.directwebremoting.WebContextFactory;
*/
public class RemoteController {
+ private Data data;
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
/**
* Gets the HTML table containing orders which have been sent to VLM
* instances.
@@ -49,4 +56,26 @@ public class RemoteController {
return wctx.forwardToString("/orderscommands.htm");
}
+ /**
+ * Gets a configuration property.
+ *
+ * @param key the property key
+ * @return the property value
+ * @see Data#getConfigurationProperty(String)
+ */
+ public String getConfigurationProperty(String key) {
+ return data.getConfigurationProperty(key);
+ }
+
+ /**
+ * Sets a configuration property.
+ *
+ * @param key the property key
+ * @param value the value to set
+ * @see Data#setConfigurationProperty()
+ */
+ public void setConfigurationProperty(String key, String value) {
+ data.setConfigurationProperty(key, value);
+ }
+
}
diff --git a/web/src/main/resources/messages.properties b/web/src/main/resources/messages.properties
index 50a86c7..76dea8f 100644
--- a/web/src/main/resources/messages.properties
+++ b/web/src/main/resources/messages.properties
@@ -44,6 +44,11 @@ welcome.servers.unreachable = <b>{0}</b> is not accessible!
configuration.title = Configuration
configuration.page = Configuration
configuration.view = View configuration
+configuration.edit = Edit configuration
+configuration.edit.button = Edit
+configuration.key = Property
+configuration.value = Value
+configuration.save.button = Save
vlc.snmp.community = SNMP community
vlc.snmp.oid.cpu_load = CPU load OID
vlc.snmp.oid.vlc_cpu = CPU resources used by VLC OID
diff --git a/web/src/main/resources/messages_fr.properties b/web/src/main/resources/messages_fr.properties
index b3ae53e..5431058 100644
--- a/web/src/main/resources/messages_fr.properties
+++ b/web/src/main/resources/messages_fr.properties
@@ -44,6 +44,11 @@ welcome.servers.unreachable = <b>{0}</b> n''est pas accessible !
configuration.title = Configuration
configuration.page = Configuration
configuration.view = Voir la configuration
+configuration.edit = Modifier la configuration
+configuration.edit.button = Modifier
+configuration.key = Propriété
+configuration.value = Valeur
+configuration.save.button = Sauvegarder
vlc.snmp.community = Communauté SNMP
vlc.snmp.oid.cpu_load = OID de la charge processeur
vlc.snmp.oid.vlc_cpu = OID de la charge processeur consommée par VLC
diff --git a/web/src/main/webapp/WEB-INF/applicationContext.xml b/web/src/main/webapp/WEB-INF/applicationContext.xml
index e246acb..422a56e 100644
--- a/web/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/web/src/main/webapp/WEB-INF/applicationContext.xml
@@ -29,7 +29,10 @@
<bean id="remoteController" class="org.videolan.vlma.web.dwr.RemoteController">
<dwr:remote javascript="AjaxData">
<dwr:include method="getOrdersCommands" />
+ <dwr:include method="getConfigurationProperty" />
+ <dwr:include method="setConfigurationProperty" />
</dwr:remote>
+ <property name="data" ref="dataImporter" />
</bean>
</beans>
diff --git a/web/src/main/webapp/WEB-INF/jsp/configuration/configurationview_right.jsp b/web/src/main/webapp/WEB-INF/jsp/configuration/configurationview_right.jsp
index 55a910f..b2523de 100644
--- a/web/src/main/webapp/WEB-INF/jsp/configuration/configurationview_right.jsp
+++ b/web/src/main/webapp/WEB-INF/jsp/configuration/configurationview_right.jsp
@@ -1,15 +1,67 @@
<%@ include file="/WEB-INF/jsp/include.jsp" %>
-<%@ page import="java.util.Map"%>
<h1><fmt:message key="configuration.page" /></h1>
<table>
- <c:forEach items="${variables}" var="variable">
- <tr>
- <td><fmt:message key="${variable.key}" /></td>
- <td>${variable.key}</td>
- <td>${variable.value}</td>
+ <c:forEach items="${variables}" var="variable" varStatus="status">
+ <c:choose>
+ <c:when test='${(status.index)%2 eq 0}'>
+ <c:set var="rowColor" value="even" scope="page"/>
+ </c:when>
+ <c:otherwise>
+ <c:set var="rowColor" value="odd" scope="page"/>
+ </c:otherwise>
+ </c:choose>
+ <tr class="${rowColor}">
+ <td><fmt:message key="${variable.key}" /></td>
+ <td>${variable.key}</td>
+ <td id="${variable.key}">${variable.value}</td>
+ <td>
+ <input id="edit-${variable.key}" type="button" onclick="editClicked(this.id)" value="<fmt:message key="configuration.edit.button" />" />
+ </td>
</tr>
</c:forEach>
</table>
+<h2><fmt:message key="configuration.edit" /></h2>
+
+<table>
+ <tr>
+ <td><fmt:message key="configuration.key" /></td>
+ <td><span id="key" /></td>
+ </tr>
+ <tr>
+ <td><fmt:message key="configuration.value" /></td>
+ <td><input id="value" type="text" /></td>
+ </tr>
+ <tr>
+ <td />
+ <td><input type="button" onclick="saveClicked()" value="<fmt:message key="configuration.save.button" />" /></td>
+ </tr>
+</table>
+
+<script type="text/javascript">
+var selectedId;
+
+function updateValue(id) {
+ AjaxData.getConfigurationProperty(selectedId, function(data) {
+ dwr.util.setValue(id, data);
+ });
+}
+
+function editClicked(eleid) {
+ selectedId = eleid.substring(5);
+ dwr.util.setValue("key", selectedId);
+ AjaxData.getConfigurationProperty(selectedId, function(data) {
+ dwr.util.setValue("value", data);
+ });
+}
+
+function saveClicked() {
+ id = dwr.util.getValue("key");
+ if (id != "") {
+ AjaxData.setConfigurationProperty(id, dwr.util.getValue("value"));
+ updateValue(id);
+ }
+}
+</script>
\ No newline at end of file
More information about the vlma-devel
mailing list