From 707cdb193ac7423404bf18b8bd86b814a1129724 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 5 Jul 2012 20:43:37 +0000 Subject: [PATCH] [MRM-1583] ui rewrite: rewrite reports page Submitted by Adrien Lecharpentier. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1357889 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-rest/archiva-rest-api/pom.xml | 5 + .../resources/META-INF/spring-context.xml | 1 + .../apache/archiva/i18n/default.properties | 31 ++- .../main/webapp/js/archiva/general-admin.js | 243 +++++++++++++++++- .../js/templates/archiva/general-admin.html | 174 ++++++++++++- .../webapp/js/templates/archiva/menu.html | 4 + .../DefaultRepositoryStatisticsManager.java | 1 + .../stats/RepositoryStatistics.java | 24 +- 8 files changed, 478 insertions(+), 5 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml index 0277de251..1dcae612c 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml @@ -55,6 +55,11 @@ archiva-repository-scanner + + org.apache.archiva + repository-statistics + + org.apache.archiva.redback redback-authorization-api diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml index a497537a1..b99001048 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml @@ -69,6 +69,7 @@ + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index 9e4417445..7ba34a498 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -141,6 +141,7 @@ menu.repository-scanning=Repository Scanning menu.system-status=System Status menu.appearance-configuration=Appearance menu.ui-configuration=UI Configuration +menu.reports=Reports #user user.change.password.required=Change password required @@ -416,4 +417,32 @@ fileupload.save=Save Files fileupload.upload.required=You must upload your files first. fileupload.artifacts.saved=Artifacts uploaded and saved on Server side. - +#reports +report.title = Reports +report.statistics.title = Repository statistics +report.statistics.selected-repositories.label = Selected repositories +repository.groups.available-repositories.label = Available repositories +report.statistics.row-count.label = Row count +report.statistics.start-date.label = Start date +report.statistics.end-date.label = End date +report.statistics.btn-view = View Statistics +report.statistics.endDate.explanations-title=Info +report.statistics.rowCount.explanations-title=Info +report.statistics.rowCount.explanations=set the number of report you want to read. If you have selected two or more \ + repositories, only the latest report of those repositories will be displayed. +report.statistics.repositories.required=You must select at least one repository +report.health.title = Repository Health +report.select.all-repositories = All repositories +report.health.groupId.label = GroupId +report.health.repositoryId.label = RepositoryId +report.health.btn-view = Show Report +report.repository.illegal-access = You have no access to the repository {0} +report.message.no-report=There is no report available. +report.health.result.id=ID +report.health.result.namespace=Namespace +report.health.result.project=Project +report.health.result.version=Version +report.health.result.name=Name +report.health.result.problem=Problem +report.health.result.message=Message +report.result.title=Result diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js index 055f7195b..40b2fe63e 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js @@ -17,7 +17,7 @@ * under the License. */ define("archiva.general-admin",["jquery","i18n","order!utils","order!jquery.tmpl","order!knockout","order!knockout.simpleGrid", - "jquery.validate","bootstrap"] + "knockout.sortable","jquery.validate","bootstrap"] , function() { //------------------------- @@ -875,4 +875,245 @@ define("archiva.general-admin",["jquery","i18n","order!utils","order!jquery.tmpl }); } + //--------------------------- + // report configuration page + //--------------------------- + StatisticsReportRequest=function() { + this.repositories = ko.observableArray( [] ); + this.rowCount = ko.observable(100); + this.startDate = ko.observable(); + this.endDate = ko.observable(); + } + + reportStatisticsFormValidator=function(){ + var validate = $("#report-statistics-form-id").validate({ + rules: { + rowCountStatistics: { + required:true, + number: true, + min: 10 + }, + startDate: { + date: true + }, + endDate: { + date: true + } + }, + showErrors: function(validator, errorMap, errorList) { + customShowError("#report-statistics-form-id", validator, errorMap, errorMap); + } + }) + } + ReportStatisticsViewModel=function(repositoriesAvailable){ + reportStatisticsFormValidator(); + + var self=this; + this.availableRepositories = ko.observableArray( repositoriesAvailable ); + this.statisticsReport = ko.observable( new StatisticsReportRequest() ); + + $("#startDate" ).datepicker(); + $("#endDate" ).datepicker(); + $("#rowCount-info-button" ).popover(); + + this.showStatistics=function() { + if (!$("#report-statistics-form-id").valid()) { + return; + } + if(this.statisticsReport().repositories().length==0){ + displayErrorMessage( $.i18n.prop('report.statistics.repositories.required'), "repositoriesErrorMessage" ); + return; + } + clearUserMessages( "repositoriesErrorMessage" ); + var resultTabContent = $("#report-result"); + + url = "restServices/archivaServices/reportServices/getStatisticsReport/?rowCount=" + + this.statisticsReport().rowCount(); + + for(var i=0;i ${$.i18n.prop('apperance-configuration.details-description')}

- +
@@ -702,3 +702,175 @@ {% } %} + + + + + + + + + diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/menu.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/menu.html index 527887795..dcd6c7f70 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/menu.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/menu.html @@ -66,6 +66,10 @@
  • ${$.i18n.prop('menu.ui-configuration')}
  • +
  • + ${$.i18n.prop('menu.reports')} +
  • + diff --git a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java index 4bad96e5f..d363543ad 100644 --- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java +++ b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java @@ -123,6 +123,7 @@ public class DefaultRepositoryStatisticsManager throws MetadataRepositoryException { RepositoryStatistics repositoryStatistics = new RepositoryStatistics(); + repositoryStatistics.setRepositoryId( repositoryId ); repositoryStatistics.setScanStartTime( startTime ); repositoryStatistics.setScanEndTime( endTime ); repositoryStatistics.setTotalFileCount( totalFiles ); diff --git a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java index 8e0863478..f32c6992f 100644 --- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java +++ b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java @@ -54,6 +54,8 @@ public class RepositoryStatistics private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" ); + private String repositoryId; + public Date getScanEndTime() { return scanEndTime; @@ -139,6 +141,16 @@ public class RepositoryStatistics return scanEndTime.getTime() - scanStartTime.getTime(); } + public String getRepositoryId() + { + return repositoryId; + } + + public void setRepositoryId( String repositoryId ) + { + this.repositoryId = repositoryId; + } + public String getFacetId() { return FACET_ID; @@ -167,6 +179,7 @@ public class RepositoryStatistics properties.put( "totalGroupCount", String.valueOf( totalGroupCount ) ); properties.put( "totalProjectCount", String.valueOf( totalProjectCount ) ); properties.put( "newFileCount", String.valueOf( newFileCount ) ); + properties.put( "repositoryId", repositoryId ); for ( Map.Entry entry : totalCountForType.entrySet() ) { properties.put( "count-" + entry.getKey(), String.valueOf( entry.getValue() ) ); @@ -184,6 +197,7 @@ public class RepositoryStatistics totalGroupCount = Long.parseLong( properties.get( "totalGroupCount" ) ); totalProjectCount = Long.parseLong( properties.get( "totalProjectCount" ) ); newFileCount = Long.parseLong( properties.get( "newFileCount" ) ); + repositoryId = properties.get( "repositoryId" ); totalCountForType.clear(); for ( Map.Entry entry : properties.entrySet() ) { @@ -244,6 +258,10 @@ public class RepositoryStatistics { return false; } + if ( !repositoryId.equals( that.repositoryId ) ) + { + return false; + } return true; } @@ -260,6 +278,7 @@ public class RepositoryStatistics result = 31 * result + (int) ( totalProjectCount ^ ( totalProjectCount >>> 32 ) ); result = 31 * result + (int) ( newFileCount ^ ( newFileCount >>> 32 ) ); result = 31 * result + totalCountForType.hashCode(); + result = 31 * result + repositoryId.hashCode(); return result; } @@ -269,7 +288,8 @@ public class RepositoryStatistics return "RepositoryStatistics{" + "scanEndTime=" + scanEndTime + ", scanStartTime=" + scanStartTime + ", totalArtifactCount=" + totalArtifactCount + ", totalArtifactFileSize=" + totalArtifactFileSize + ", totalFileCount=" + totalFileCount + ", totalGroupCount=" + totalGroupCount + ", totalProjectCount=" + - totalProjectCount + ", newFileCount=" + newFileCount + ", totalCountForType=" + totalCountForType + '}'; + totalProjectCount + ", newFileCount=" + newFileCount + ", totalCountForType=" + totalCountForType + ", " + + "repositoryId=" + repositoryId + '}'; } public Map getTotalCountForType() @@ -284,7 +304,7 @@ public class RepositoryStatistics public void setTotalCountForType( String type, long count ) { - totalCountForType.put( type, count ); + totalCountForType.put( type.replaceAll( "-", "_" ).replaceAll( "\\.", "_" ), count ); } private static final class ZeroForNullHashMap extends HashMap -- 2.39.5