dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24928
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12266: Made apps available as any other module in the module overview page
------------------------------------------------------------
revno: 12266
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-09-26 20:17:41 +0200
message:
Made apps available as any other module in the module overview page
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java
dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppListAction.java
dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/index.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/modules.vm
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/Module.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java
--
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/appmanager/AppManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java 2013-09-26 17:20:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/AppManager.java 2013-09-26 18:17:41 +0000
@@ -39,12 +39,10 @@
{
final String ID = AppManager.class.getName();
- final String KEY_APP_FOLDER_PATH = "appFolderPath";
-
+ final String KEY_APP_FOLDER_PATH = "appFolderPath";
final String KEY_APP_BASE_URL = "appBaseUrl";
-
final String KEY_APP_STORE_URL = "appStoreUrl";
-
+
/**
* Gets the Base URL for accessing the apps
* @return the apps baseurl
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/TextUtils.java 2013-09-26 18:17:41 +0000
@@ -112,7 +112,7 @@
* Gets the sub string of the given string. If the beginIndex is larger than
* the length of the string, the empty string is returned. If the beginIndex +
* the length is larger than the length of the string, the part of the string
- * following the beginIndex is returned.
+ * following the beginIndex is returned. Method is out-of-range safe.
*
* @param string the string.
* @param beginIndex the zero-based begin index.
=== modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppListAction.java'
--- dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppListAction.java 2013-09-26 17:20:47 +0000
+++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppListAction.java 2013-09-26 18:17:41 +0000
@@ -64,11 +64,11 @@
//TODO create settings to set for external server like Apache2/nginx
//TODO Should be a per-app setting
- private String appsRootUrl;
+ private String appBaseUrl;
- public String getAppsRootUrl()
+ public String getAppBaseUrl()
{
- return appsRootUrl;
+ return appBaseUrl;
}
// -------------------------------------------------------------------------
@@ -81,7 +81,7 @@
{
appList = appManager.getInstalledApps();
- appsRootUrl = appManager.getAppBaseUrl();
+ appBaseUrl = appManager.getAppBaseUrl();
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/index.vm'
--- dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/index.vm 2013-09-26 16:53:50 +0000
+++ dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/index.vm 2013-09-26 18:17:41 +0000
@@ -5,9 +5,9 @@
<li style="margin-left: 15px; margin-top: 6px;">$i18n.getString( "appmanager_you_have_no_apps_installed" )</li>
#else
#foreach( $app in $appList )
- <li class="introItem" onclick="window.location.href='$appsRootUrl/${app.folderName}/${app.launchPath}'">
+ <li class="introItem" onclick="window.location.href='${appBaseUrl}/${app.folderName}/${app.launchPath}'">
<span class="introItemHeader">
- <img style="float:left; margin-right:15px" src="$appsRootUrl/${app.folderName}/${app.icons.icon48}">
+ <img style="float:left; margin-right:15px" src="${appBaseUrl}/${app.folderName}/${app.icons.icon48}">
${app.name}
</span><br>
$i18n.getString( "appmanager_author" ): ${app.developer.name}<br>
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/modules.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/modules.vm 2013-09-26 14:59:56 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/about/modules.vm 2013-09-26 18:17:41 +0000
@@ -1,5 +1,10 @@
+
<ul class="moduleList">
#foreach( $module in $menuModules )
+#if ( $module.icon ) ## detect if app
+ #introListImgApp( $module )
+#else
#introListImgItem( "${module.defaultAction}" "${module.name}" "${module.name}" )
#end
+#end
</ul>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2013-08-23 17:03:06 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2013-09-26 18:17:41 +0000
@@ -64,7 +64,7 @@
$i18n.getString( "yes_no" )
#elseif ( $type == "int" )
$i18n.getString( "number" )
-#else
+#else
$i18n.getString( "unknown" )
#end
#end
@@ -80,6 +80,13 @@
</li>
#end
+#macro( introListImgApp $module )
+<li class="introItem" onclick="window.location.href='${appBaseUrl}/${module.defaultAction}'">
+ <img src="${appBaseUrl}/${module.icon}" class="introIcon">
+ <div class="introItemText"><div class="introItemHeader">${module.name}</div><div>${module.description}</div></div>
+</li>
+#end
+
#macro( organisationUnitSelectionTree $cleanAll $multipleSelectionAllowed $required )
#if( $multipleSelectionAllowed )
#parse( "/dhis-web-commons/oust/selectionTreeMultipleSelect.vm" )
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java 2013-09-18 12:45:52 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/SystemSettingInterceptor.java 2013-09-26 18:17:41 +0000
@@ -38,6 +38,7 @@
import com.opensymphony.xwork2.interceptor.Interceptor;
import static org.hisp.dhis.setting.SystemSettingManager.*;
+import static org.hisp.dhis.appmanager.AppManager.KEY_APP_BASE_URL;
import static org.apache.commons.lang.StringUtils.defaultIfEmpty;
@@ -97,6 +98,7 @@
map.put( KEY_MULTI_ORGANISATION_UNIT_FORMS, systemSettingManager.getSystemSetting( KEY_MULTI_ORGANISATION_UNIT_FORMS, false ) );
map.put( KEY_ACCOUNT_RECOVERY, systemSettingManager.getSystemSetting( KEY_ACCOUNT_RECOVERY, false ) );
map.put( KEY_CONFIGURATION, configurationService.getConfiguration() );
+ map.put( KEY_APP_BASE_URL, systemSettingManager.getSystemSetting( KEY_APP_BASE_URL ) );
map.put( SYSPROP_PORTAL, defaultIfEmpty( System.getProperty( SYSPROP_PORTAL ), String.valueOf( false ) ) );
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java 2013-09-26 14:59:56 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java 2013-09-26 18:17:41 +0000
@@ -86,7 +86,7 @@
handle.put( KEY_MAINTENANCE_MODULES, moduleManager.getAccessibleMaintenanceModules() );
handle.put( KEY_SERVICE_MODULES, moduleManager.getAccessibleServiceModules() );
- handle.put( KEY_MENU_MODULES, moduleManager.getAccessibleMenuModules() );
+ handle.put( KEY_MENU_MODULES, moduleManager.getAccessibleMenuModulesAndApps() );
actionInvocation.getStack().push( handle );
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java 2013-09-26 14:59:56 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java 2013-09-26 18:17:41 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -39,7 +40,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.dispatcher.Dispatcher;
+import org.hisp.dhis.appmanager.App;
+import org.hisp.dhis.appmanager.AppManager;
import org.hisp.dhis.security.ActionAccessResolver;
+import org.hisp.dhis.system.util.TextUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.entities.PackageConfig;
@@ -53,6 +58,8 @@
{
private static final Log LOG = LogFactory.getLog( DefaultModuleManager.class );
+ private static final String APP_MANAGER_NAME = "dhis-web-appmanager";
+
private boolean modulesDetected = false;
private Map<String, Module> modulesByName = new HashMap<String, Module>();
@@ -71,6 +78,9 @@
// Dependencies
// -------------------------------------------------------------------------
+ @Autowired
+ private AppManager appManager;
+
private ActionAccessResolver actionAccessResolver;
public void setActionAccessResolver( ActionAccessResolver actionAccessResolver )
@@ -135,6 +145,30 @@
return getAccessibleModules( menuModules );
}
+
+ public List<Module> getAccessibleMenuModulesAndApps()
+ {
+ List<Module> modules = getAccessibleMenuModules();
+
+ modules.remove( new Module( APP_MANAGER_NAME ) );
+
+ List<App> apps = appManager.getInstalledApps();
+
+ for ( App app : apps )
+ {
+ String defaultAction = app.getFolderName() + File.separator + app.getLaunchPath();
+ String icon = app.getFolderName() + File.separator + app.getIcons().getIcon48();
+ String description = TextUtils.subString( app.getDescription(), 0, 80 );
+
+ Module module = new Module( app.getName(), app.getName(), defaultAction );
+ module.setIcon( icon );
+ module.setDescription( description );
+
+ modules.add( module );
+ }
+
+ return modules;
+ }
public List<Module> getMaintenanceMenuModules()
{
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/Module.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/Module.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/Module.java 2013-09-26 18:17:41 +0000
@@ -39,6 +39,12 @@
private String namespace;
private String defaultAction;
+
+ // Apps only
+
+ private String icon;
+
+ private String description;
// -------------------------------------------------------------------------
// Constructors
@@ -47,6 +53,11 @@
public Module()
{
}
+
+ public Module( String name )
+ {
+ this.name = name;
+ }
public Module( String name, String namespace )
{
@@ -93,4 +104,57 @@
{
this.defaultAction = defaultAction;
}
+
+ public String getIcon()
+ {
+ return icon;
+ }
+
+ public void setIcon( String icon )
+ {
+ this.icon = icon;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription( String description )
+ {
+ this.description = description;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( name == null ) ? 0 : name.hashCode() );
+ return result;
+ }
+
+ @Override
+ public boolean equals( Object object )
+ {
+ if ( this == object )
+ {
+ return true;
+ }
+
+ if ( object == null )
+ {
+ return false;
+ }
+
+ if ( getClass() != object.getClass() )
+ {
+ return false;
+ }
+
+ final Module other = (Module) object;
+
+ return name.equals( other.getName() );
+ }
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java 2013-09-26 14:59:56 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java 2013-09-26 18:17:41 +0000
@@ -47,6 +47,8 @@
List<Module> getAccessibleMenuModules();
+ List<Module> getAccessibleMenuModulesAndApps();
+
List<Module> getMaintenanceMenuModules();
List<Module> getAccessibleMaintenanceModules();