dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16557
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6321: (mobile) GatewayConfig GUI - in process...
------------------------------------------------------------
revno: 6321
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-21 09:20:05 +0700
message:
(mobile) GatewayConfig GUI - in process...
removed:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowUpdateGateWayConfigFormAction.java
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/RemoveGatewayConfigAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SaveSmsConfigurationAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateClickatellGateWayConfigAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateGenericHTTPGateWayConfigAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateModemGateWayConfigAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java 2012-03-01 08:56:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfiguration.java 2012-03-21 02:20:05 +0000
@@ -28,11 +28,9 @@
*/
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.List;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
/**
@@ -46,19 +44,21 @@
private String longNumber;
- private List<SmsGatewayConfig> gateways;
-
private Integer pollingInterval;
private boolean enabled = false;
+ private List<SmsGatewayConfig> gateways;
+
public SmsConfiguration()
{
+ this.gateways = new ArrayList<SmsGatewayConfig>();
}
public SmsConfiguration( boolean enabled )
{
this.enabled = enabled;
+ this.gateways = new ArrayList<SmsGatewayConfig>();
}
public boolean isEnabled()
@@ -81,11 +81,13 @@
this.longNumber = longNumber;
}
- @XmlElementWrapper( name = "gateways" )
- @XmlElements( { @XmlElement( name = "bulksms", type = BulkSmsGatewayConfig.class ),
- @XmlElement( name = "clickatell", type = ClickatellGatewayConfig.class ),
- @XmlElement( name = "http", type = GenericHttpGatewayConfig.class ),
- @XmlElement( name = "modem", type = ModemGatewayConfig.class ) } )
+ /*
+ * @XmlElementWrapper( name = "gateways" ) @XmlElements( { @XmlElement( name =
+ * "bulksms", type = BulkSmsGatewayConfig.class ), @XmlElement( name =
+ * "clickatell", type = ClickatellGatewayConfig.class ), @XmlElement( name =
+ * "http", type = GenericHttpGatewayConfig.class ), @XmlElement( name =
+ * "modem", type = ModemGatewayConfig.class ) } )
+ */
public List<SmsGatewayConfig> getGateways()
{
return gateways;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java 2012-03-14 10:36:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsTransportService.java 2012-03-21 02:20:05 +0000
@@ -37,4 +37,6 @@
extends OutboundSmsService
{
Map<String, String> getGatewayMap();
+
+ String stopService();
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java 2012-03-21 02:20:05 +0000
@@ -83,7 +83,7 @@
{
// TODO: Need to make these problems available in GUI!
log.warn( "Unable to initialize service " + smsConfigurable.getClass().getSimpleName()
- + "with configuration " + smsConfiguration, t );
+ + " with configuration " + smsConfiguration, t );
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2012-03-14 10:36:55 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2012-03-21 02:20:05 +0000
@@ -65,9 +65,9 @@
private final String CLICKATELL_GATEWAY = "clickatell_gw";
- private final String HTTP_GATEWAY = "generic_http_gw";
+ private final String HTTP_GATEWAY = "http_gw";
- private final String MODEM_GATEWAY = "modem_gateway";
+ private final String MODEM_GATEWAY = "modem_gw";
// -------------------------------------------------------------------------
// Implementation methods
@@ -80,6 +80,17 @@
}
@Override
+ public Map<String, String> getGatewayMap()
+ {
+ if ( gatewayMap == null || gatewayMap.isEmpty() )
+ {
+ reloadConfig();
+ }
+
+ return gatewayMap;
+ }
+
+ @Override
public void sendMessage( OutboundSms sms, String gatewayId )
throws SmsServiceException
{
@@ -179,19 +190,21 @@
log.debug( "Loading configuration" );
- reloadConfig();
-
- if ( config.isEnabled() )
+ if ( config.isEnabled() && reloadConfig() )
{
log.debug( "Starting SmsLib" );
startService();
}
else
{
- log.debug( "Sms not enabled, won't start service" );
+ log.debug( "Sms not enabled or there is no any gateway, won't start service" );
}
}
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
private String createTmpGroup( Set<String> recipients )
{
String groupName = Thread.currentThread().getName();
@@ -234,27 +247,38 @@
}
}
- private void stopService()
+ @Override
+ public String stopService()
{
+ String status = "success";
+
try
{
getService().stopService();
}
catch ( SMSLibException e )
{
+ status = "Unable to stop smsLib service" + e.getCause().getMessage();
+
log.warn( "Unable to stop smsLib service", e );
throw new SmsServiceException( "Unable to stop smsLib service", e );
}
catch ( IOException e )
{
+ status = "Unable to stop smsLib service" + e.getCause().getMessage();
+
log.warn( "Unable to stop smsLib service", e );
throw new SmsServiceException( "Unable to stop smsLib service", e );
}
catch ( InterruptedException e )
{
+ status = "Unable to stop smsLib service" + e.getCause().getMessage();
+
log.warn( "Unable to stop smsLib service", e );
throw new SmsServiceException( "Unable to stop smsLib service", e );
}
+
+ return status;
}
private Service getService()
@@ -262,7 +286,7 @@
return Service.getInstance();
}
- private void reloadConfig()
+ private boolean reloadConfig()
throws SmsServiceException
{
Service service = Service.getInstance();
@@ -273,6 +297,8 @@
AGateway gateway = null;
+ boolean reloaded = false;
+
// Add gateways
for ( SmsGatewayConfig gatewayConfig : config.getGateways() )
{
@@ -299,14 +325,20 @@
gatewayMap.put( MODEM_GATEWAY, gateway.getGatewayId() );
}
+ reloaded = true;
+
log.debug( "Added gateway " + gatewayConfig.getName() );
}
catch ( GatewayException e )
{
+ reloaded = false;
+
log.warn( "Unable to load gateway " + gatewayConfig.getName(), e );
throw new SmsServiceException( "Unable to load gateway" + gatewayConfig.getName(), e );
}
}
+
+ return reloaded;
}
private class OutboundNotification
@@ -318,16 +350,4 @@
log.debug( "Sent message through gateway " + gateway.getGatewayId() + ": " + msg );
}
}
-
- @Override
- public Map<String, String> getGatewayMap()
- {
- if ( gatewayMap == null || gatewayMap.isEmpty() )
- {
- reloadConfig();
- }
-
- return gatewayMap;
- }
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2012-03-07 10:32:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2012-03-21 02:20:05 +0000
@@ -457,5 +457,13 @@
"smtpPassword" : {
"required" : true
}
+ },
+ "SMSConfig" : {
+ "pollingInterval" : {
+ "digits" : true
+ },
+ "serverPhoneNumber" : {
+ "digits" : true
+ }
}
};
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java 2012-03-14 10:36:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetMobileConfigurationAction.java 1970-01-01 00:00:00 +0000
@@ -1,78 +0,0 @@
-package org.hisp.dhis.mobile.action;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.sms.SmsConfigurationManager;
-import org.hisp.dhis.sms.config.SmsConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author
- * @version $Id$
- */
-
-public class GetMobileConfigurationAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- @Autowired
- private SmsConfigurationManager smsConfigurationManager;
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private SmsConfiguration smsConfig;
-
- public SmsConfiguration getSmsConfig()
- {
- return smsConfig;
- }
-
- public boolean getSmsServiceStatus()
- {
- return this.smsConfig != null && this.smsConfig.isEnabled();
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- smsConfig = smsConfigurationManager.getSmsConfiguration();
-
- return SUCCESS;
- }
-}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/GetSmsConfigurationAction.java 2012-03-21 02:20:05 +0000
@@ -0,0 +1,128 @@
+package org.hisp.dhis.mobile.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hisp.dhis.sms.SmsConfigurationManager;
+import org.hisp.dhis.sms.config.BulkSmsGatewayConfig;
+import org.hisp.dhis.sms.config.ClickatellGatewayConfig;
+import org.hisp.dhis.sms.config.ModemGatewayConfig;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.hisp.dhis.sms.config.SmsGatewayConfig;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+
+public class GetSmsConfigurationAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private SmsConfigurationManager smsConfigurationManager;
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Map<Integer, SmsGatewayConfig> gatewayConfigMap1 = new HashMap<Integer, SmsGatewayConfig>();
+
+ public Map<Integer, SmsGatewayConfig> getGatewayConfigMap1()
+ {
+ return gatewayConfigMap1;
+ }
+
+ private Map<Integer, Integer> gatewayConfigMap2 = new HashMap<Integer, Integer>();
+
+ public Map<Integer, Integer> getGatewayConfigMap2()
+ {
+ return gatewayConfigMap2;
+ }
+
+ private SmsConfiguration smsConfig;
+
+ public SmsConfiguration getSmsConfig()
+ {
+ return smsConfig;
+ }
+
+ public boolean getSmsServiceStatus()
+ {
+ return this.smsConfig != null && this.smsConfig.isEnabled();
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ smsConfig = smsConfigurationManager.getSmsConfiguration();
+
+ if ( smsConfig != null )
+ {
+ int index = 0;
+
+ for ( SmsGatewayConfig gw : smsConfig.getGateways() )
+ {
+ index = smsConfig.getGateways().indexOf( gw );
+
+ gatewayConfigMap1.put( index, gw );
+
+ if ( gw instanceof BulkSmsGatewayConfig )
+ {
+ gatewayConfigMap2.put( 0, index );
+ }
+ else if ( gw instanceof ClickatellGatewayConfig )
+ {
+ gatewayConfigMap2.put( 1, index );
+ }
+ else if ( gw instanceof ModemGatewayConfig )
+ {
+ gatewayConfigMap2.put( 2, index );
+ }
+ else
+ {
+ gatewayConfigMap2.put( 3, index );
+ }
+ }
+ }
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/RemoveGatewayConfigAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/RemoveGatewayConfigAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/RemoveGatewayConfigAction.java 2012-03-21 02:20:05 +0000
@@ -0,0 +1,90 @@
+package org.hisp.dhis.mobile.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Iterator;
+
+import org.hisp.dhis.sms.SmsConfigurationManager;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.hisp.dhis.sms.config.SmsGatewayConfig;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+
+public class RemoveGatewayConfigAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private SmsConfigurationManager smsConfigurationManager;
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ SmsConfiguration smsConfig = smsConfigurationManager.getSmsConfiguration();
+
+ Iterator<SmsGatewayConfig> it = smsConfig.getGateways().iterator();
+
+ while( it.hasNext() )
+ {
+ if ( smsConfig.getGateways().indexOf( it.next() ) == id )
+ {
+ it.remove();
+
+ smsConfigurationManager.updateSmsConfiguration( smsConfig );
+
+ break;
+ }
+ }
+
+ return SUCCESS;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SaveSmsConfigurationAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SaveSmsConfigurationAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/SaveSmsConfigurationAction.java 2012-03-21 02:20:05 +0000
@@ -0,0 +1,90 @@
+package org.hisp.dhis.mobile.action;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.hisp.dhis.sms.SmsConfigurationManager;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Dang Duy Hieu
+ * @version $Id$
+ */
+
+public class SaveSmsConfigurationAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private SmsConfigurationManager smsConfigurationManager;
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Integer pollingInterval;
+
+ public void setPollingInterval( Integer pollingInterval )
+ {
+ this.pollingInterval = pollingInterval;
+ }
+
+ private String serverPhoneNumber;
+
+ public void setServerPhoneNumber( String longNumber )
+ {
+ this.serverPhoneNumber = longNumber;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ throws Exception
+ {
+ SmsConfiguration smsConfig = smsConfigurationManager.getSmsConfiguration();
+
+ if ( smsConfig == null )
+ {
+ smsConfig = new SmsConfiguration( true );
+ }
+
+ smsConfig.setPollingInterval( pollingInterval );
+ smsConfig.setLongNumber( serverPhoneNumber );
+
+ smsConfigurationManager.updateSmsConfiguration( smsConfig );
+
+ return SUCCESS;
+ }
+}
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowUpdateGateWayConfigFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowUpdateGateWayConfigFormAction.java 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ShowUpdateGateWayConfigFormAction.java 1970-01-01 00:00:00 +0000
@@ -1,103 +0,0 @@
-package org.hisp.dhis.mobile.action;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hisp.dhis.sms.SmsConfigurationManager;
-import org.hisp.dhis.sms.config.BulkSmsGatewayConfig;
-import org.hisp.dhis.sms.config.ClickatellGatewayConfig;
-import org.hisp.dhis.sms.config.ModemGatewayConfig;
-import org.hisp.dhis.sms.config.SmsConfiguration;
-import org.hisp.dhis.sms.config.SmsGatewayConfig;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Dang Duy Hieu
- * @version $Id$
- */
-
-public class ShowUpdateGateWayConfigFormAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- @Autowired
- private SmsConfigurationManager smsConfigurationManager;
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private Map<Integer, SmsGatewayConfig> gatewayConfigMap = new HashMap<Integer, SmsGatewayConfig>();
-
- public Map<Integer, SmsGatewayConfig> getGatewayConfigMap()
- {
- return gatewayConfigMap;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- throws Exception
- {
- SmsConfiguration smsConfig = smsConfigurationManager.getSmsConfiguration();
-
- if ( smsConfig != null )
- {
- for ( SmsGatewayConfig gw : smsConfig.getGateways() )
- {
- if ( gw instanceof BulkSmsGatewayConfig )
- {
- gatewayConfigMap.put( 0, gw );
- }
- else if ( gw instanceof ClickatellGatewayConfig )
- {
- gatewayConfigMap.put( 1, gw );
- }
- else if ( gw instanceof ModemGatewayConfig )
- {
- gatewayConfigMap.put( 2, gw );
- }
- else
- {
- gatewayConfigMap.put( 3, gw );
- }
- }
- }
-
- return SUCCESS;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateBulkGateWayConfigAction.java 2012-03-21 02:20:05 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.mobile.action;
/*
- * Copyright (c) 2004-2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,11 +49,6 @@
@Autowired
private SmsConfigurationManager smsConfigurationManager;
- public void setSmsConfigurationManager( SmsConfigurationManager smsConfigurationManager )
- {
- this.smsConfigurationManager = smsConfigurationManager;
- }
-
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -102,7 +97,7 @@
BulkSmsGatewayConfig gatewayConfig = (BulkSmsGatewayConfig) smsConfigurationManager
.checkInstanceOfGateway( BulkSmsGatewayConfig.class );
- int index = 0;
+ int index = -1;
if ( gatewayConfig == null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateClickatellGateWayConfigAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateClickatellGateWayConfigAction.java 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateClickatellGateWayConfigAction.java 2012-03-21 02:20:05 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.mobile.action;
/*
- * Copyright (c) 2004-2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,11 +49,6 @@
@Autowired
private SmsConfigurationManager smsConfigurationManager;
- public void setSmsConfigurationManager( SmsConfigurationManager smsConfigurationManager )
- {
- this.smsConfigurationManager = smsConfigurationManager;
- }
-
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -109,7 +104,7 @@
ClickatellGatewayConfig gatewayConfig = (ClickatellGatewayConfig) smsConfigurationManager
.checkInstanceOfGateway( ClickatellGatewayConfig.class );
- int index = 0;
+ int index = -1;
if ( gatewayConfig == null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateGenericHTTPGateWayConfigAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateGenericHTTPGateWayConfigAction.java 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateGenericHTTPGateWayConfigAction.java 2012-03-21 02:20:05 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.mobile.action;
/*
- * Copyright (c) 2004-2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -52,11 +52,6 @@
@Autowired
private SmsConfigurationManager smsConfigurationManager;
- public void setSmsConfigurationManager( SmsConfigurationManager smsConfigurationManager )
- {
- this.smsConfigurationManager = smsConfigurationManager;
- }
-
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -112,7 +107,7 @@
GenericHttpGatewayConfig gatewayConfig = (GenericHttpGatewayConfig) smsConfigurationManager
.checkInstanceOfGateway( GenericHttpGatewayConfig.class );
- int index = 0;
+ int index = -1;
if ( gatewayConfig == null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateModemGateWayConfigAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateModemGateWayConfigAction.java 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/UpdateModemGateWayConfigAction.java 2012-03-21 02:20:05 +0000
@@ -1,7 +1,7 @@
package org.hisp.dhis.mobile.action;
/*
- * Copyright (c) 2004-2011, University of Oslo
+ * Copyright (c) 2004-2012, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,11 +49,6 @@
@Autowired
private SmsConfigurationManager smsConfigurationManager;
- public void setSmsConfigurationManager( SmsConfigurationManager smsConfigurationManager )
- {
- this.smsConfigurationManager = smsConfigurationManager;
- }
-
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -137,7 +132,7 @@
ModemGatewayConfig gatewayConfig = (ModemGatewayConfig) smsConfigurationManager
.checkInstanceOfGateway( ModemGatewayConfig.class );
- int index = 0;
+ int index = -1;
if ( gatewayConfig == null )
{
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/META-INF/dhis/beans.xml 2012-03-21 02:20:05 +0000
@@ -6,9 +6,6 @@
<bean id="org.hisp.dhis.mobile.action.NoAction" class="org.hisp.dhis.mobile.action.NoAction"
scope="prototype" />
- <bean id="org.hisp.dhis.mobile.action.GetMobileConfigurationAction" class="org.hisp.dhis.mobile.action.GetMobileConfigurationAction"
- scope="prototype" />
-
<bean id="org.hisp.dhis.mobile.action.ShowSendSMSFormAction" class="org.hisp.dhis.mobile.action.ShowSendSMSFormAction"
scope="prototype" />
@@ -46,7 +43,13 @@
</bean>
<!-- SMS Service Configuration -->
+
+ <bean id="org.hisp.dhis.mobile.action.GetSmsConfigurationAction"
+ class="org.hisp.dhis.mobile.action.GetSmsConfigurationAction" scope="prototype"/>
+ <bean id="org.hisp.dhis.mobile.action.SaveSmsConfigurationAction"
+ class="org.hisp.dhis.mobile.action.SaveSmsConfigurationAction" scope="prototype"/>
+
<bean id="org.hisp.dhis.mobile.action.UpdateBulkGateWayConfigAction"
class="org.hisp.dhis.mobile.action.UpdateBulkGateWayConfigAction" scope="prototype"/>
@@ -59,7 +62,7 @@
<bean id="org.hisp.dhis.mobile.action.UpdateGenericHTTPGateWayConfigAction"
class="org.hisp.dhis.mobile.action.UpdateGenericHTTPGateWayConfigAction" scope="prototype"/>
- <bean id="org.hisp.dhis.mobile.action.ShowUpdateGateWayConfigFormAction"
- class="org.hisp.dhis.mobile.action.ShowUpdateGateWayConfigFormAction" scope="prototype"/>
+ <bean id="org.hisp.dhis.mobile.action.RemoveGatewayConfigAction"
+ class="org.hisp.dhis.mobile.action.RemoveGatewayConfigAction" scope="prototype"/>
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties 2012-03-21 02:20:05 +0000
@@ -41,8 +41,10 @@
outbound=Outbound
api_id=API ID
save_settings=Save Settings
+add_update_gw=Add or update gateway
show_send_sms_form=Show send SMS form
bulk_gw=BulkSMS Gateway
clickatell_gw=Clickatell Gateway
-generic_http_gw=Generic HTTP Gateway
-modem_gw=Modem Gateway
\ No newline at end of file
+http_gw=Generic HTTP Gateway
+modem_gw=Modem Gateway
+confirm_delete_gateway=Do you want to delete this gateway configuration ?
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-03-21 02:20:05 +0000
@@ -65,18 +65,49 @@
<!-- SMS Service Configuration Action -->
- <action name="showSMSConfigureForm" class="org.hisp.dhis.mobile.action.GetMobileConfigurationAction">
+ <action name="showSMSConfigureForm" class="org.hisp.dhis.mobile.action.GetSmsConfigurationAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-mobile/smsServiceConfiguration.vm</param>
<param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
<param name="requiredAuthorities">F_MOBILE_SETTINGS</param>
</action>
- <action name="showUpdateGateWayConfigForm" class="org.hisp.dhis.mobile.action.ShowUpdateGateWayConfigFormAction">
+ <action name="showUpdateGateWayConfigForm" class="org.hisp.dhis.mobile.action.GetSmsConfigurationAction">
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-mobile/updateGateway.vm</param>
<param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
- </action>
-
+ <param name="javascripts">javascript/gateway.js</param>
+ <param name="requiredAuthorities">F_MOBILE_SETTINGS</param>
+ </action>
+
+ <action name="saveSmsConfiguration" class="org.hisp.dhis.mobile.action.SaveSmsConfigurationAction">
+ <result name="success" type="redirect">showSMSConfigureForm.action</result>
+ </action>
+
+ <action name="saveBulkSMSConfig" class="org.hisp.dhis.mobile.action.UpdateBulkGateWayConfigAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="saveModemConfig" class="org.hisp.dhis.mobile.action.UpdateModemGateWayConfigAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="saveClickatellConfig" class="org.hisp.dhis.mobile.action.UpdateClickatellGateWayConfigAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="saveHTTPConfig" class="org.hisp.dhis.mobile.action.UpdateGenericHTTPGateWayConfigAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
+ <action name="removeGatewayConfig" class="org.hisp.dhis.mobile.action.RemoveGatewayConfigAction">
+ <result name="success" type="velocity-json">../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
</package>
</struts>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js 2012-03-21 02:20:05 +0000
@@ -14,7 +14,7 @@
showById( "genericHTTPFields" );
}
- currentType = type;
+ currentType = value;
}
function hideAll()
@@ -69,11 +69,11 @@
{
if ( currentType == 'modem' )
{
- jQuery.postJSON( "saveBulkSMSConfig.action", {
+ jQuery.postJSON( "saveModemConfig.action", {
gatewayType: getFieldValue( 'gatewayType' ),
name: getFieldValue( 'modemFields input[id=name]' ),
port: getFieldValue( 'modemFields input[id=port]' ),
- baudrate: getFieldValue( 'modemFields input[id=baudrate]' ),
+ baudRate: getFieldValue( 'modemFields input[id=baudRate]' ),
manufacturer: getFieldValue( 'modemFields input[id=manufacturer]' ),
model: getFieldValue( 'modemFields input[id=model]' ),
pin: getFieldValue( 'modemFields input[id=pin]' ),
@@ -96,7 +96,7 @@
}
else if ( currentType == 'clickatell' )
{
- jQuery.postJSON( "saveBulkSMSConfig.action", {
+ jQuery.postJSON( "saveClickatellConfig.action", {
gatewayType: getFieldValue( 'gatewayType' ),
name: getFieldValue( 'clickatellFields input[id=name]' ),
username: getFieldValue( 'clickatellFields input[id=username]' ),
@@ -108,7 +108,7 @@
}
else
{
- jQuery.postJSON( "saveBulkSMSConfig.action", {
+ jQuery.postJSON( "saveHTTPConfig.action", {
gatewayType: getFieldValue( 'gatewayType' ),
name: getFieldValue( 'genericHTTPFields input[id=name]' ),
username: getFieldValue( 'genericHTTPFields input[id=username]' ),
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm 2012-03-15 10:30:59 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm 2012-03-21 02:20:05 +0000
@@ -33,10 +33,10 @@
<tr>
<td><label for="type">$i18n.getString( "type" ):</label></td>
<td>
- #set( $keys = $gatewayMap.keySet() )
+ #set( $keys = $!gatewayMap.keySet() )
<select id="gatewayId" name="gatewayId" style="width: 100%;">
- #foreach( $key in $keys )
- <option value="$gatewayMap.get( $key )">$i18n.getString( $key )</option>
+ #foreach( $key in $!keys )
+ <option value="$!gatewayMap.get( $key )">$i18n.getString( $key )</option>
#end
</select>
</td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smsServiceConfiguration.vm 2012-03-21 02:20:05 +0000
@@ -9,9 +9,21 @@
}
</style>
+<script type="text/javascript">
+ jQuery(document).ready( function() {
+ validation2( "saveSmsConfigurationForm", function( form ) {
+ form.submit();
+ }, {
+ 'rules': getValidationRules( 'SMSConfig' )
+ } );
+ } );
+
+ var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_gateway" ) , "'")';
+</script>
+
<h3>$i18n.getString( "sms_service_configuration" )</h3>
-#if( $smsServiceStatus )
-<form id="add" name="addGateWayConfig" action="addGateWayConfig.action" method="post" >
+
+<form id="saveSmsConfigurationForm" name="saveSmsConfigurationForm" action="saveSmsConfiguration.action" method="post" >
<table id="detailsList">
<col/> ## Labels
<col/> ## Input
@@ -50,10 +62,11 @@
</tr>
<tr>
<td>$i18n.getString("server_phone_number"):</td>
- <td><input type="text" id="serverPhoneNumber" name="serverPhoneNumber" style="width:20em" value="$!smsConfig.longNumber"></td>
+ <td><input type="text" id="serverPhoneNumber" name="serverPhoneNumber" style="width:20em" value="$!smsConfig.longNumber">
+ <input type="submit" value="$i18n.getString( 'save_settings' )" style="width:13em"/></td>
</tr>
<tr>
- <td align="right" colspan="2"><input type="button" value="$i18n.getString('add')" onclick="window.location.href='showUpdateGateWayConfigForm.action'"/></td>
+ <td align="right" colspan="2"><input type="button" value="$i18n.getString('add_update_gw')" style="width:11em#if( !$smsServiceStatus );display:none#end" onclick="window.location.href='showUpdateGateWayConfigForm.action'"/></td>
</tr>
<tr>
<td colspan="2">
@@ -64,14 +77,15 @@
<th style="text-align:center; width: 50px;">$i18n.getString( "operation" )</th>
</tr>
</thead>
- <tbody>
- #set( $gateWays = $smsConfig.gateways )
- #foreach ($gateWay in $gateWays)
- <tr>
- <td>$gateWay.name</td>
+ <tbody id="list">
+ #set( $keys = $!gatewayConfigMap1.keySet() )
+ #foreach ($key in $!keys )
+ <tr id="tr${key}">
+ #set( $gw = $!gatewayConfigMap1.get( $key ) )
+ <td>$!encoder.htmlEncode( $gw.name )</td>
<td style="text-align:right">
- <!--a title="$i18n.getString( 'edit' )" href="editGateWayConfig.action?gateWayID="><img alt="$i18n.getString( 'edit' )" src="../images/edit.png"/></a>
- <a title="$i18n.getString( 'remove' )" href="#"><img alt="$i18n.getString( 'remove' )" src="../images/delete.png"/></a-->
+ <!--a title="$i18n.getString( 'edit' )" href="editGateWayConfig.action?gateWayID="><img alt="$i18n.getString( 'edit' )" src="../images/edit.png"/></a-->
+ <a href="javascript:removeGateway( $key, '$!encoder.jsEncode( $gw.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a>
</td>
</tr>
#end
@@ -82,6 +96,11 @@
</tbody>
</table>
</form>
-#else
- <p>SMS Service is not available</p>
-#end
+
+<script type="text/javascript">
+
+ function removeGateway( key, name )
+ {
+ removeItem( key, name, i18n_confirm_delete, "removeGatewayConfig.action" );
+ }
+</script>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm 2012-03-20 11:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm 2012-03-21 02:20:05 +0000
@@ -1,4 +1,3 @@
-<script type="text/javascript" src="javascript/gateway.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
@@ -8,7 +7,7 @@
'rules' : getValidationRulesGateway()
} );
- changeValueType("modem");
+ changeValueType("bulksms");
});
</script>
<h3>$i18n.getString( "add_update_gateway" )</h3>
@@ -31,7 +30,7 @@
<tr>
<th colspan="2">$i18n.getString( "gateway_configuration" )</th>
</tr>
- #set( $modemGateway = $!gatewayConfigMap.get( 2 ) )
+ #set( $modemGateway = $!gatewayConfigMap1.get( $gatewayConfigMap2.get( 2 ) ) )
<tbody id="modemFields">
<tr>
<td>$i18n.getString( "gateway_name" ):</td>
@@ -61,9 +60,8 @@
<td>$i18n.getString( "inbound" ):</td>
<td>
<select id="inbound" name="inbound" style="width:100%;">
- #if ( $!modemGateway.inbound )
- <option value="$!modemGateway.inbound">#if( $!modemGateway.inbound )$i18n.getString( "yes" )#else$i18n.getString( "no" )#end</option>
- #end
+ <option value="true" #if ( $modemGateway.inbound ) selected #end>$i18n.getString( "yes" )</option>
+ <option value="false" #if ( !$modemGateway.inbound ) selected #end>$i18n.getString( "no" )</option>
</select>
</td>
</tr>
@@ -71,14 +69,13 @@
<td>$i18n.getString( "outbound" ):</td>
<td>
<select id="outbound" name="outbound" style="width:100%;">
- #if ( $!modemGateway.outbound )
- <option value="$!modemGateway.outbound">#if( $!modemGateway.outbound )$i18n.getString( "yes" )#else$i18n.getString( "no" )#end</option>
- #end
+ <option value="true" #if ( $modemGateway.outbound ) selected #end>$i18n.getString( "yes" )</option>
+ <option value="false" #if ( !$modemGateway.outbound ) selected #end>$i18n.getString( "no" )</option>
</select>
</td>
</tr>
</tbody>
- #set( $bulkGateway = $!gatewayConfigMap.get( 0 ) )
+ #set( $bulkGateway = $!gatewayConfigMap1.get( $gatewayConfigMap2.get( 0 ) ) )
<tbody id="bulksmsFields">
<tr>
<td>$i18n.getString( "gateway_name" ):</td>
@@ -93,7 +90,7 @@
<td><input type="text" name="password" id="password" style="width: 28em" value="$!bulkGateway.password"/></td>
</tr>
</tbody>
- #set( $clickatellGateway = $!gatewayConfigMap.get( 1 ) )
+ #set( $clickatellGateway = $!gatewayConfigMap1.get( $gatewayConfigMap2.get( 1 ) ) )
<tbody id="clickatellFields">
<tr>
<td>$i18n.getString( "gateway_name" ):</td>
@@ -112,7 +109,7 @@
<td><input type="text" name="apiId" id="apiId" style="width: 28em" value="$!clickatellGateway.apiId"/></td>
</tr>
</tbody>
- #set( $httpGateway = $!gatewayConfigMap.get( 3 ) )
+ #set( $httpGateway = $!gatewayConfigMap1.get( $gatewayConfigMap2.get( 3 ) ) )
<tbody id="genericHTTPFields">
<tr>
<td>$i18n.getString( "gateway_name" ):</td>
@@ -132,8 +129,8 @@
</tr>
</tbody>
<tr>
- <td colspan="2" align="right"><input type="submit" value="$i18n.getString( 'save_settings' )" style="width: 28em"/>
- <input type="button" value="$i18n.getString( 'back' )" onclick="window.location.href='showSMSConfigureForm.action'" style="width: 28em"/></td>
+ <td colspan="2" align="right"><input type="submit" value="$i18n.getString( 'save_settings' )" style="width:8em"/>
+ <input type="button" value="$i18n.getString( 'back' )" onclick="window.location.href='showSMSConfigureForm.action'" style="width:8em"/></td>
</tr>
</table>
</form>