=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java 2013-05-17 11:14:26 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/appmanager/App.java 2013-05-24 12:05:28 +0000 @@ -187,5 +187,29 @@ { this.activities = activities; } + + // ------------------------------------------------------------------------- + // Hashcode & Equals + // ------------------------------------------------------------------------- + @Override + public int hashCode() { + int hash = 7; + hash = 79 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final App other = (App) obj; + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } } === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java 2013-05-23 06:17:02 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AddAppAction.java 2013-05-24 12:05:28 +0000 @@ -136,11 +136,13 @@ if ( !manifestFound ) { message = i18n.getString( "appmanager_invalid_package" ); + return "failure"; } } else { message = i18n.getString( "appmanager_not_zip" ); + return "failure"; } } === 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-05-23 06:17:02 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppListAction.java 2013-05-24 12:05:28 +0000 @@ -55,7 +55,7 @@ public List getAppList() { - return appList; + return appManagerService.getInstalledApps(); } private List appFolderNames; @@ -73,15 +73,11 @@ public String execute() throws Exception { - appList = appManagerService.getInstalledApps(); - appFolderNames = new ArrayList(); - - for ( App app : appList ) + for ( App app : getAppList() ) { appFolderNames.add( appManagerService.getAppFolderName( app ) ); } - return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppSettingsAction.java' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppSettingsAction.java 2013-05-23 06:17:02 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppSettingsAction.java 2013-05-24 12:05:28 +0000 @@ -29,7 +29,9 @@ import com.opensymphony.xwork2.Action; import java.io.File; +import java.util.List; import org.apache.struts2.ServletActionContext; +import org.hisp.dhis.appmanager.App; import org.hisp.dhis.appmanager.AppManagerService; import org.hisp.dhis.i18n.I18n; import org.springframework.beans.factory.annotation.Autowired; @@ -86,6 +88,13 @@ appManagerService.setAppStoreUrl( appStoreUrl ); } + private List appList; + + public List getAppList() + { + return appManagerService.getInstalledApps(); + } + private I18n i18n; public void setI18n( I18n i18n ) === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppStoreAction.java' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppStoreAction.java 2013-05-23 06:17:02 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/AppStoreAction.java 2013-05-24 12:05:28 +0000 @@ -1,68 +1,70 @@ -package org.hisp.dhis.appmanager.action; - -/* - * Copyright (c) 2004-2013, 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 com.opensymphony.xwork2.Action; -import org.hisp.dhis.appmanager.AppManagerService; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Saptarshi Purkayastha - */ -public class AppStoreAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - @Autowired - private AppManagerService appManagerService; - - // ------------------------------------------------------------------------- - // Input & Output - // ------------------------------------------------------------------------- - - private String appStoreUrl; - - public String getAppStoreUrl() - { - return appManagerService.getAppStoreUrl(); - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() - throws Exception - { - return SUCCESS; - } -} +package org.hisp.dhis.appmanager.action; + +/* + * Copyright (c) 2004-2013, 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 com.opensymphony.xwork2.Action; +import static com.opensymphony.xwork2.Action.SUCCESS; +import org.hisp.dhis.appmanager.AppManagerService; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author Saptarshi Purkayastha + * @version $Id + */ +public class AppStoreAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + @Autowired + private AppManagerService appManagerService; + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String appStoreUrl; + + public String getAppStoreUrl() + { + return appManagerService.getAppStoreUrl(); + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + return SUCCESS; + } +} \ No newline at end of file === added file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/DeleteAppAction.java' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/DeleteAppAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/java/org/hisp/dhis/appmanager/action/DeleteAppAction.java 2013-05-24 12:05:28 +0000 @@ -0,0 +1,101 @@ +package org.hisp.dhis.appmanager.action; + +/* + * Copyright (c) 2004-2013, 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 com.opensymphony.xwork2.Action; +import java.io.File; +import org.apache.commons.io.FileUtils; +import org.apache.struts2.ServletActionContext; +import org.hisp.dhis.appmanager.App; +import org.hisp.dhis.appmanager.AppManagerService; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.security.authority.SystemAuthoritiesProvider; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author Saptarshi Purkayastha + * @version $Id$ + */ +public class DeleteAppAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + @Autowired + private AppManagerService appManagerService; + + private SystemAuthoritiesProvider authoritiesProvider; + + public void setAuthoritiesProvider( SystemAuthoritiesProvider authoritiesProvider ) + { + this.authoritiesProvider = authoritiesProvider; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + private String message; + + public String getMessage() + { + return message; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + String appName = ServletActionContext.getRequest().getParameter( "appName" ); + if ( null != appName ) + { + for ( App app : appManagerService.getInstalledApps() ) + { + if ( app.getName().equals( appName ) ) + { + String folderPath = appManagerService.getAppFolderPath() + File.separator + + appManagerService.getAppFolderName( app ); + FileUtils.forceDelete( new File( folderPath ) ); + message = i18n.getString( "appmanager_delete_success" ); + } + } + } + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/org/hisp/dhis/appmanager/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/org/hisp/dhis/appmanager/i18n_module.properties 2013-05-23 00:18:55 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/org/hisp/dhis/appmanager/i18n_module.properties 2013-05-24 12:05:28 +0000 @@ -9,6 +9,9 @@ appmanager_install_success=App Installed Successfully appmanager_invalid_package=Invalid App Package appmanager_not_zip=Incorrect App Package Format +appmanager_confirm_delete=Are you sure to delete this App? +appmanager_delete_success=App Deleted Successfully +appmanager_management=Manage Installed Apps #-- See module privilegies ----------------------------------------------------# === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/struts.xml 2013-05-23 00:18:55 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/resources/struts.xml 2013-05-24 12:05:28 +0000 @@ -21,11 +21,19 @@ /dhis-web-commons/ajax/jsonResponseSuccess.vm + /dhis-web-commons/ajax/jsonResponseError.vm /dhis-web-appmanager/menu.vm javascript/jquery.form.js + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + /dhis-web-appmanager/index.vm + /dhis-web-appmanager/menu.vm + javascript/jquery.form.js + + /main.vm /dhis-web-appmanager/getApps.vm @@ -40,7 +48,7 @@ /dhis-web-appmanager/menu.vm plainTextError F_SYSTEM_SETTING - javascript/jquery.form.js + javascript/jquery.form.js,javascript/deleteApp.js === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/appSettings.vm' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/appSettings.vm 2013-05-23 00:18:55 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/appSettings.vm 2013-05-24 12:05:28 +0000 @@ -1,12 +1,13 @@

$i18n.getString( "appmanager_settings" )

@@ -24,3 +25,41 @@ + +

$i18n.getString( "appmanager_management" )

+ + + + + +
+ + + + + + + + + + + + #set( $mark = false ) + #foreach( $app in $appList ) + + + + + + #if( $mark ) + #set( $mark = false ) + #else + #set( $mark = true ) + #end + #end + +
$i18n.getString( "appname" )$i18n.getString( "version" )$i18n.getString( "operations" )
$encoder.htmlEncode( $app.name )$encoder.htmlEncode( $app.version ) + +
+
+ === added file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/javascript/deleteApp.js' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/javascript/deleteApp.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/javascript/deleteApp.js 2013-05-24 12:05:28 +0000 @@ -0,0 +1,5 @@ +function deleteApp( appId, appName ) +{ + removeItem( appId, appName, i18n_confirm_delete, "deleteApp.action?appName="+appName ); +} + === modified file 'dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/javascript/uploadApp.js' --- dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/javascript/uploadApp.js 2013-05-23 00:18:55 +0000 +++ dhis-2/dhis-web/dhis-web-appmanager/src/main/webapp/dhis-web-appmanager/javascript/uploadApp.js 2013-05-24 12:05:28 +0000 @@ -4,20 +4,24 @@ var xhr = new XMLHttpRequest(); xhr.addEventListener('progress', function(e) { var done = e.position || e.loaded, total = e.totalSize || e.total; + jQuery("#progressbar").show(); jQuery("#progressbar").progressbar({value: (Math.floor(done / total * 1000) / 10)}); }, false); if (xhr.upload) { xhr.upload.onprogress = function(e) { var done = e.position || e.loaded, total = e.totalSize || e.total; + jQuery("#progressbar").show(); jQuery("#progressbar").progressbar({value: (Math.floor(done / total * 1000) / 10)}); - console.log('xhr.upload progress: ' + done + ' / ' + total + ' = ' + (Math.floor(done / total * 1000) / 10) + '%'); }; } xhr.onreadystatechange = function(e) { if (4 == this.readyState) { - console.log(['xhr upload complete', e]); - console.log(jQuery(".ui-progressbar-value")); jQuery(".ui-progressbar-value").html('
Upload complete
'); + setTimeout(function(){ + jQuery(".ui-progressbar-value").html(''); + jQuery("#progressbar").hide(); + }, 4000); + jQuery.growlUI( JSON.parse(xhr.responseText).response, JSON.parse(xhr.responseText).message, JSON.parse(xhr.responseText).response, 2000 ); jQuery("#uploadPackageForm")[0].reset(); } };