dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16647
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6376: (mobile) Showed feedback to user more robust:
------------------------------------------------------------
revno: 6376
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-03-26 11:42:44 +0700
message:
(mobile) Showed feedback to user more robust:
- When creating SMS Configuration and gateway details
- When sending SMS message from web to mobiles.
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/sendSMS.js
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/MessageSender.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.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/outbound/OutboundSmsServiceImpl.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java
dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ProcessingSendSMSAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ReloadStartStopServiceAction.java
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/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/MessageSender.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/MessageSender.java 2012-03-09 09:40:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/MessageSender.java 2012-03-26 04:42:44 +0000
@@ -43,5 +43,5 @@
* @param message the message to send.
* @param recipients the recipients will receive the sms message.
*/
- void sendMessage( String subject, String text, User sender, boolean isPhone, Set<?> recipients, String gatewayId );
+ String sendMessage( String subject, String text, User sender, boolean isPhone, Set<?> recipients, String gatewayId );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java 2012-03-12 20:25:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/config/SmsConfigurable.java 2012-03-26 04:42:44 +0000
@@ -44,7 +44,7 @@
* @throws SmsServiceException if the service cannot be initialized with the
* provided {@link SmsConfiguration}
*/
- void initialize( SmsConfiguration smsConfiguration )
+ String initialize( SmsConfiguration smsConfiguration )
throws SmsServiceException;
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java 2012-03-12 20:25:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsService.java 2012-03-26 04:42:44 +0000
@@ -46,7 +46,7 @@
* @param sms the message to be sent
* @throws SmsServiceException if unable to sent Message
*/
- void sendMessage( OutboundSms sms, String gatewayId )
+ String sendMessage( OutboundSms sms, String gatewayId )
throws SmsServiceException;
}
=== 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-21 02:20:05 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/SmsConfigurationManagerImpl.java 2012-03-26 04:42:44 +0000
@@ -58,34 +58,45 @@
private List<SmsConfigurable> smsConfigurables;
@PostConstruct
- public void initializeSmsConfigurables()
+ public String initializeSmsConfigurables()
{
if ( smsConfigurables == null )
{
- return;
+ return null;
}
SmsConfiguration smsConfiguration = getSmsConfiguration();
if ( smsConfiguration == null )
{
- return;
+ return null;
}
+ String message = null;
+
for ( SmsConfigurable smsConfigurable : smsConfigurables )
{
try
{
- smsConfigurable.initialize( smsConfiguration );
log.debug( "Initialized " + smsConfigurable );
+
+ message = smsConfigurable.initialize( smsConfiguration );
+
+ if ( message != null && !message.equals( "success" ) )
+ {
+ return message;
+ }
}
catch ( Throwable t )
{
- // TODO: Need to make these problems available in GUI!
log.warn( "Unable to initialize service " + smsConfigurable.getClass().getSimpleName()
+ " with configuration " + smsConfiguration, t );
+ return "Unable to initialize service " + smsConfigurable.getClass().getSimpleName()
+ + " with configuration " + smsConfiguration + t.getMessage();
}
}
+
+ return message;
}
@Override
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java 2012-03-21 08:24:25 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/OutboundSmsServiceImpl.java 2012-03-26 04:42:44 +0000
@@ -73,13 +73,15 @@
// -------------------------------------------------------------------------
@Override
- public void initialize( SmsConfiguration smsConfiguration )
+ public String initialize( SmsConfiguration smsConfiguration )
throws SmsServiceException
{
if ( smsConfiguration != null )
{
enabled = smsConfiguration.isEnabled();
}
+
+ return "success";
}
@Override
@@ -90,7 +92,7 @@
@Override
@Transactional
- public void sendMessage( OutboundSms sms, String gatewayId )
+ public String sendMessage( OutboundSms sms, String gatewayId )
throws SmsServiceException
{
if ( !enabled )
@@ -102,25 +104,29 @@
if ( transportService != null )
{
- sendMessageInternal( sms, gatewayId );
+ return sendMessageInternal( sms, gatewayId );
}
+
+ return "outboundsms_saved";
}
// -------------------------------------------------------------------------
// Support methods
// -------------------------------------------------------------------------
- private void sendMessageInternal( OutboundSms sms, String id )
+ private String sendMessageInternal( OutboundSms sms, String id )
{
try
{
- transportService.sendMessage( sms, id );
sms.setStatus( OutboundSmsStatus.SENT );
+ return transportService.sendMessage( sms, id );
}
catch ( SmsServiceException e )
{
log.debug( "Exception sending message " + sms, e );
sms.setStatus( OutboundSmsStatus.ERROR );
+
+ return "Exception sending message " + sms + e.getMessage();
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java 2012-03-21 08:24:25 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/SmsMessageSender.java 2012-03-26 04:42:44 +0000
@@ -69,12 +69,14 @@
// -------------------------------------------------------------------------
@SuppressWarnings( "unchecked" )
- public void sendMessage( String subject, String text, User sender, boolean isPhone, Set<?> recipients,
+ public String sendMessage( String subject, String text, User sender, boolean isPhone, Set<?> recipients,
String gatewayId )
{
+ String message = null;
+
if ( outboundSmsService == null || !outboundSmsService.isEnabled() )
{
- return;
+ return "outboundsmsservice_is_null_or_unable";
}
text = createMessage( subject, text, sender );
@@ -90,15 +92,20 @@
phones = getRecipients( (Set<User>) recipients );
}
- if ( !recipients.isEmpty() )
+ if ( !phones.isEmpty() && phones.size() > 0 )
{
- sendMessage( text, phones, gatewayId );
+ message = sendMessage( text, phones, gatewayId );
}
else if ( log.isDebugEnabled() )
{
log.debug( "Not sending message to any of the recipients" );
}
+ else
+ {
+ message = "not_sending_message_to_any_recipient";
+ }
+ return message;
}
private Set<String> getRecipients( Set<User> users )
@@ -153,15 +160,16 @@
return (length > 160) ? text.substring( 0, 157 ) + "..." : text;
}
- private void sendMessage( String text, Set<String> recipients, String id )
+ private String sendMessage( String text, Set<String> recipients, String id )
{
+ String message = null;
OutboundSms sms = new OutboundSms();
sms.setMessage( text );
sms.setRecipients( recipients );
try
{
- outboundSmsService.sendMessage( sms, id );
+ message = outboundSmsService.sendMessage( sms, id );
if ( log.isDebugEnabled() )
{
@@ -170,8 +178,12 @@
}
catch ( SmsServiceException e )
{
+ message = "Unable to send message through sms: " + sms + e.getCause().getMessage();
+
log.warn( "Unable to send message through sms: " + sms, e );
}
+
+ return message;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java'
--- dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java 2012-03-23 04:01:16 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/outbound/TestOutboundSmsService.java 2012-03-26 04:42:44 +0000
@@ -26,9 +26,11 @@
private static final Log log = LogFactory.getLog( TestOutboundSmsService.class );
private boolean enabled = true;
+
+ private String message = "success";
@Override
- public void sendMessage( OutboundSms sms, String gatewayId )
+ public String sendMessage( OutboundSms sms, String gatewayId )
throws SmsServiceException
{
if ( !enabled )
@@ -37,14 +39,17 @@
}
log.debug( "Send message: " + sms );
+
+ return message;
}
@Override
- public void initialize( SmsConfiguration config )
+ public String initialize( SmsConfiguration config )
throws SmsServiceException
{
this.enabled = config.isEnabled();
log.debug( "initialize()" );
+ return message;
}
@Override
=== 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-23 04:01:16 +0000
+++ dhis-2/dhis-services/dhis-service-sms/src/main/java/org/hisp/dhis/sms/smslib/SmsLibService.java 2012-03-26 04:42:44 +0000
@@ -93,28 +93,25 @@
}
@Override
- public void sendMessage( OutboundSms sms, String gatewayId )
+ public String sendMessage( OutboundSms sms, String gatewayId )
throws SmsServiceException
{
message = getServiceStatus();
if ( message != null && (message.equals( "service_stopped" ) || message.equals( "service_stopping" )) )
{
- message = "service_stopped_cannot_send_sms";
-
- return;
+ return message = "service_stopped_cannot_send_sms";
}
- String recipient;
+ String recipient = null;
Set<String> recipients = sms.getRecipients();
if ( recipients.size() == 0 )
{
- message = "there_is_no_recipient_cannot_send_sms";
-
log.warn( "Trying to send sms without recipients: " + sms );
- return;
+
+ return message = "there_is_no_recipient_cannot_send_sms";
}
else if ( recipients.size() == 1 )
{
@@ -151,24 +148,19 @@
}
catch ( SMSLibException e )
{
+ log.warn( "Unable to send message: " + sms, e );
message = "Unable to send message: " + sms + " " + e.getCause().getMessage();
-
- log.warn( "Unable to send message: " + sms, e );
- throw new SmsServiceException( "Unable to send message: " + sms, e );
}
catch ( IOException e )
{
+ log.warn( "Unable to send message: " + sms, e );
+
message = "Unable to send message: " + sms + " " + e.getCause().getMessage();
-
- log.warn( "Unable to send message: " + sms, e );
- throw new SmsServiceException( "Unable to send message: " + sms, e );
}
catch ( InterruptedException e )
{
+ log.warn( "Unable to send message: " + sms, e );
message = "Unable to send message: " + sms + " " + e.getCause().getMessage();
-
- log.warn( "Unable to send message: " + sms, e );
- throw new SmsServiceException( "Unable to send message: " + sms, e );
}
finally
{
@@ -185,13 +177,15 @@
}
else
{
+ log.warn( "Message not sent" );
message = "message_not_sent";
- log.warn( "Message not sent" );
}
+
+ return message;
}
@Override
- public void initialize( SmsConfiguration smsConfiguration )
+ public String initialize( SmsConfiguration smsConfiguration )
throws SmsServiceException
{
// FIXME: Implement a decent equals..
@@ -210,13 +204,30 @@
{
log.debug( "Stopping SmsLib" );
stopService();
+
+ if ( message != null && !message.equals( "success" ) )
+ {
+ return message;
+ }
}
log.debug( "Loading configuration" );
reloadConfig();
+ if ( message != null && !message.equals( "success" ) )
+ {
+ return message;
+ }
+
log.debug( "Starting SmsLib" );
startService();
+
+ if ( message != null && !message.equals( "success" ) )
+ {
+ return message;
+ }
+
+ return message;
}
@Override
@@ -231,47 +242,47 @@
AGateway gateway = null;
+ message = "success";
+
// Add gateways
if ( config.getGateways() == null || config.getGateways().isEmpty() )
{
message = "unable_load_configuration_cause_of_there_is_no_gateway";
}
-
- for ( SmsGatewayConfig gatewayConfig : config.getGateways() )
+ else
{
- try
- {
- gateway = gatewayFactory.create( gatewayConfig );
-
- service.addGateway( gateway );
-
- if ( gatewayConfig instanceof BulkSmsGatewayConfig )
- {
- gatewayMap.put( BULK_GATEWAY, gateway.getGatewayId() );
- }
- else if ( gatewayConfig instanceof ClickatellGatewayConfig )
- {
- gatewayMap.put( CLICKATELL_GATEWAY, gateway.getGatewayId() );
- }
- else if ( gatewayConfig instanceof GenericHttpGatewayConfig )
- {
- gatewayMap.put( HTTP_GATEWAY, gateway.getGatewayId() );
- }
- else
- {
- gatewayMap.put( MODEM_GATEWAY, gateway.getGatewayId() );
- }
-
- message = "success";
-
- log.debug( "Added gateway " + gatewayConfig.getName() );
- }
- catch ( GatewayException e )
- {
- message = "Unable to load gateway " + gatewayConfig.getName() + e.getCause().getMessage();
-
- log.warn( "Unable to load gateway " + gatewayConfig.getName(), e );
- throw new SmsServiceException( "Unable to load gateway" + gatewayConfig.getName(), e );
+ for ( SmsGatewayConfig gatewayConfig : config.getGateways() )
+ {
+ try
+ {
+ gateway = gatewayFactory.create( gatewayConfig );
+
+ service.addGateway( gateway );
+
+ if ( gatewayConfig instanceof BulkSmsGatewayConfig )
+ {
+ gatewayMap.put( BULK_GATEWAY, gateway.getGatewayId() );
+ }
+ else if ( gatewayConfig instanceof ClickatellGatewayConfig )
+ {
+ gatewayMap.put( CLICKATELL_GATEWAY, gateway.getGatewayId() );
+ }
+ else if ( gatewayConfig instanceof GenericHttpGatewayConfig )
+ {
+ gatewayMap.put( HTTP_GATEWAY, gateway.getGatewayId() );
+ }
+ else
+ {
+ gatewayMap.put( MODEM_GATEWAY, gateway.getGatewayId() );
+ }
+
+ log.debug( "Added gateway " + gatewayConfig.getName() );
+ }
+ catch ( GatewayException e )
+ {
+ log.warn( "Unable to load gateway " + gatewayConfig.getName(), e );
+ message = "Unable to load gateway " + gatewayConfig.getName() + e.getCause().getMessage();
+ }
}
}
}
@@ -279,7 +290,9 @@
@Override
public void startService()
{
- if ( config.isEnabled() && (message != null && message.equals( "success" )) )
+ message = "success";
+
+ if ( config != null && config.isEnabled() && (config.getGateways() != null && !config.getGateways().isEmpty()) )
{
try
{
@@ -287,30 +300,23 @@
}
catch ( SMSLibException e )
{
- message = "Unable to start smsLib service " + e.getCause().getMessage();
-
+ message = "Unable to start smsLib service " + e.getMessage();
log.warn( "Unable to start smsLib service", e );
- throw new SmsServiceException( "Unable to start smsLib service", e );
}
catch ( IOException e )
{
- message = "Unable to start smsLib service" + e.getCause().getMessage();
-
+ message = "Unable to start smsLib service" + e.getMessage();
log.warn( "Unable to start smsLib service", e );
- throw new SmsServiceException( "Unable to start smsLib service", e );
}
catch ( InterruptedException e )
{
- message = "Unable to start smsLib service" + e.getCause().getMessage();
-
+ message = "Unable to start smsLib service" + e.getMessage();
log.warn( "Unable to start smsLib service", e );
- throw new SmsServiceException( "Unable to start smsLib service", e );
}
}
else
{
- message = "sms_unable_or_there_is_no_gatewat_service_not_started";
-
+ message = "sms_unable_or_there_is_no_gateway_service_not_started";
log.debug( "Sms not enabled or there is no any gateway, won't start service" );
}
}
@@ -327,23 +333,17 @@
catch ( SMSLibException e )
{
message = "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 )
{
message = "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 )
{
message = "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 );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ProcessingSendSMSAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ProcessingSendSMSAction.java 2012-03-23 04:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ProcessingSendSMSAction.java 2012-03-26 04:42:44 +0000
@@ -35,10 +35,8 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.sms.MessageSender;
-import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
-import org.hisp.dhis.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -58,16 +56,10 @@
private SelectionTreeManager selectionTreeManager;
@Autowired
- private UserService userService;
-
- @Autowired
private CurrentUserService currentUserService;
@Autowired
private MessageSender messageSender;
-
- @Autowired
- private OutboundSmsTransportService smsLibService;
// -------------------------------------------------------------------------
// Input & Output
@@ -108,12 +100,12 @@
return message;
}
+ // -------------------------------------------------------------------------
+ // I18n
+ // -------------------------------------------------------------------------
+
private I18n i18n;
- // -------------------------------------------------------------------------
- // I18n
- // -------------------------------------------------------------------------
-
public void setI18n( I18n i18n )
{
this.i18n = i18n;
@@ -134,30 +126,47 @@
if ( smsMessage != null && !smsMessage.isEmpty() )
{
+ Collection<OrganisationUnit> units = selectionTreeManager.getReloadedSelectedOrganisationUnits();
+
+ if ( units != null && !units.isEmpty() )
+ {
+ Set<User> users = new HashSet<User>();
+
+ for ( OrganisationUnit unit : units )
+ {
+ if ( unit.getUsers() == null || unit.getUsers().isEmpty() )
+ {
+ if ( unit.getPhoneNumber() != null && !unit.getPhoneNumber().isEmpty() )
+ {
+ recipients.add( unit.getPhoneNumber() );
+ }
+ }
+ else
+ {
+ users.addAll( unit.getUsers() );
+ }
+ }
+
+ message = messageSender.sendMessage( smsSubject, smsMessage, currentUserService.getCurrentUser(),
+ false, users, gatewayId );
+
+ if ( message != null && !message.equals( "success" ) )
+ {
+ message = i18n.getString( message );
+
+ return ERROR;
+ }
+ }
+
if ( recipients != null && !recipients.isEmpty() )
{
- messageSender.sendMessage( smsSubject, smsMessage, currentUserService.getCurrentUser(), true,
+ message = messageSender.sendMessage( smsSubject, smsMessage, currentUserService.getCurrentUser(), true,
recipients, gatewayId );
- message = smsLibService.getMessageStatus();
-
- if ( message != null && !message.equals( "success" ) )
- {
- return ERROR;
- }
- }
-
- Collection<OrganisationUnit> units = selectionTreeManager.getSelectedOrganisationUnits();
-
- if ( units != null && !units.isEmpty() )
- {
- messageSender.sendMessage( smsSubject, smsMessage, currentUserService.getCurrentUser(), false,
- new HashSet<User>( userService.getUsersByOrganisationUnits( units ) ), gatewayId );
-
- message = smsLibService.getMessageStatus();
-
- if ( message != null && !message.equals( "success" ) )
- {
+ if ( message != null && !message.equals( "success" ) )
+ {
+ message = i18n.getString( message );
+
return ERROR;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ReloadStartStopServiceAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ReloadStartStopServiceAction.java 2012-03-23 04:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/ReloadStartStopServiceAction.java 2012-03-26 04:42:44 +0000
@@ -111,11 +111,11 @@
message = smsLibService.getMessageStatus();
if ( message != null && !message.equals( "success" ) )
- {
+ {
+ message = i18n.getString( message );
+
return INPUT;
}
-
- message = i18n.getString( message );
return SUCCESS;
}
=== 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-23 04:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties 2012-03-26 04:42:44 +0000
@@ -40,6 +40,7 @@
inbound=Inbound
outbound=Outbound
api_id=API ID
+outboundsms_saved=The gateway details saved but there is no message sent
save_settings=Save Settings
add_update_gw=Add or update gateway
start_sms_service=Start SMS Service
@@ -49,19 +50,24 @@
clickatell_gw=Clickatell Gateway
http_gw=Generic HTTP Gateway
modem_gw=Modem Gateway
+add_update_gateway_success=Add or Update gateway successfully
add_update_gateway_management=Add or Update Gateway Configuration Management
confirm_delete_gateway=Do you want to delete this gateway configuration ?
smsconfiguration_not_available=SMS Configuration is not available
+outboundsmsservice_is_null_or_unable=SMS Service is not available or unable
service_started=SMS Service is started
service_starting=SMS Service is starting
service_stopped=SMS Service is stopped
service_stopping=SMS Service is stopping
message_not_sent=Message not sent
please_select_a_gateway_type_to_send_sms=Please specify a gateway to send SMS
-service_stopped_cannot_send_sms=Service is stopped, can\'t send SMS
-there_is_no_recipient_cannot_send_sms=There is no any recipient, can\'t send SMS
+service_stopped_cannot_send_sms=Service is stopped, can't send SMS
+there_is_no_recipient_cannot_send_sms=There is no any recipient, can't send SMS
+please_verify_phone=Please verify phone number(s). Separate them by the semicolon (;)
+please_select_orgunit=Please select one or many organisation unit
+not_sending_message_to_any_recipient=Not sending message to any of the recipients
unable_load_gateway=Unable to load gateway
unable_start_smslib_service=Unable to start smsLib service
unable_stop_smslib_service=Unable to stop smsLib service
-sms_unable_or_there_is_no_gatewat_service_not_started=Sms not enabled or there is no any gateway, won\'t start service
+sms_unable_or_there_is_no_gateway_service_not_started=SMS Service is not enabled or there is no any gateway, won't start service
unable_load_configuration_cause_of_there_is_no_gateway=Unable to load the configuration cause there is no any gateway
\ 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-23 04:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/struts.xml 2012-03-26 04:42:44 +0000
@@ -29,7 +29,7 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-mobile/sendSMSPage.vm</param>
<param name="menu">/dhis-web-maintenance-mobile/menu.vm</param>
- <param name="javascripts">../dhis-web-commons/oust/oust.js</param>
+ <param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/sendSMS.js</param>
<param name="requiredAuthorities">F_MOBILE_SENDSMS</param>
</action>
=== 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-21 02:20:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/gateway.js 2012-03-26 04:42:44 +0000
@@ -123,7 +123,7 @@
function showMessage( json )
{
if ( json.response == "success" ) {
- showSuccessMessage( json.message );
+ showSuccessMessage( i18n_add_update_success );
} else {
showErrorMessage( json.message );
}
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/sendSMS.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/sendSMS.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/javascript/sendSMS.js 2012-03-26 04:42:44 +0000
@@ -0,0 +1,70 @@
+var isChecked = false;
+var isOrgunitSelected = false;
+
+function selectedOrganisationUnit( unitIds )
+{
+ isOrgunitSelected = (unitIds && unitIds.length > 0);
+}
+
+function toggleSMSGUI( checked )
+{
+ if ( checked ) {
+ hideById( 'phoneType' );
+ showById( 'orgunitType' );
+ } else {
+ showById( 'phoneType' );
+ hideById( 'orgunitType' );
+ }
+
+ isChecked = checked;
+}
+
+function sendSMSMessage( _form )
+{
+ var params = "";
+
+ if ( !isChecked )
+ {
+ var list = getFieldValue( "recipient" );
+
+ if ( list == '' )
+ {
+ showErrorMessage( i18n_no_recipient );
+ return;
+ }
+
+ list = list.split( ";" )
+
+ for ( var i in list )
+ {
+ if ( list[i] && list[i] != '' )
+ {
+ params += "recipients=" + + "&";
+ }
+ }
+
+ params = "?" + params.substring( 0, params.length - 1 );
+ }
+ else
+ {
+ if ( !isOrgunitSelected )
+ {
+ showErrorMessage( i18n_please_select_orgunit );
+ return;
+ }
+ }
+
+ jQuery.postUTF8( _form.action + params,
+ {
+ gatewayId: getFieldValue( 'gatewayId' ),
+ smsMessage: getFieldValue( 'smsMessage' )
+ }, function ( json )
+ {
+ if ( json.response == "success" ) {
+ showSuccessMessage( json.message );
+ }
+ else {
+ showErrorMessage( json.message );
+ }
+ } );
+}
=== 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-23 04:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/sendSMSPage.vm 2012-03-26 04:42:44 +0000
@@ -1,12 +1,14 @@
<script type="text/javascript">
jQuery(document).ready( function() {
- validation2( "sendSMSForm", function( form )
- {
- sendSMSMessage( form );
- }, {
- 'rules' : getValidationRulesForSMSPage()
- } );
+ validation( "sendSMSForm", function( form ) { sendSMSMessage( form ); } );
+
+ selectionTreeSelection.setListenerFunction( selectedOrganisationUnit );
+
+ toggleSMSGUI( false );
});
+
+ var i18n_please_verify_phone = '$encoder.jsEscape( $i18n.getString( "please_verify_phone" ) , "'")';
+ var i18n_please_select_orgunit = '$encoder.jsEscape( $i18n.getString( "please_select_orgunit" ) , "'")';
</script>
<style type="text/css">
@@ -20,7 +22,7 @@
</style>
<h3>Send SMS</h3>
-#if ( !$smsServiceStatus )
+#if ( $!gatewayMap && $!gatewayMap.size() > 0 )
<form id="sendSMSForm" name="sendSMSForm" action="sendSMS.action">
<table id="detailsList">
<col width="300px"/>
@@ -73,61 +75,4 @@
#parse( "dhis-web-commons/loader/loader.vm" )
#else
<p>No Sms service available</p>
-#end
-
-<script type="text/javascript">
-
- var isChecked = false;
-
- function toggleSMSGUI( checked )
- {
- if ( checked ) {
- hideById( 'phoneType' );
- showById( 'orgunitType' );
- } else {
- showById( 'phoneType' );
- hideById( 'orgunitType' );
- }
-
- isChecked = checked;
- }
-
- function sendSMSMessage( _form )
- {
- var params = "";
-
- if ( !isChecked )
- {
- var list = getFieldValue( "recipient" ).split( ";" )
-
- for ( var i in list ) {
- params += "recipients=" + list[i] + "&";
- }
-
- params = "?" + params.substring( 0, params.length - 1 );
- }
-
- jQuery.postUTF8( _form.action + params,
- {
- smsMessage: getFieldValue( 'smsMessage' )
- }, function ( json )
- {
- if ( json.response == "success" ) {
- showSuccessMessage( json.message );
- }
- } );
- }
-
- function getValidationRulesForSMSPage()
- {
- var rules = {};
-
- if ( isChecked ) {
- rules = { 'treeSelectedId': { 'required': true } };
- } else {
- rules = { 'recipient': { 'required': true } };
- }
-
- return rules;
- }
-</script>
\ No newline at end of file
+#end
\ 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-23 04:01:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/updateGateway.vm 2012-03-26 04:42:44 +0000
@@ -9,6 +9,8 @@
changeValueType("bulksms");
});
+
+ var i18n_add_update_success = '$encoder.jsEscape( $i18n.getString( "add_update_gateway_success" ) , "'")';
</script>
<h3>$i18n.getString( "add_update_gateway_management" )</h3>
<form id="addGateWayConfigForm" name="addGateWayConfigForm">