From 317cf9e4ce6a0ecf7b68a59b64723316055ff125 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 19 Jan 2012 22:10:18 +0000 Subject: [PATCH] [MRM-1574] display repo stats git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1233596 13f79535-47bb-0310-9956-ffa450edef68 --- .../model/ArchivaRepositoryStatistics.java | 12 +++ .../DefaultManagedRepositoriesService.java | 3 +- .../images/utilities-system-monitor.png | Bin 0 -> 611 bytes .../main/webapp/js/archiva/repositories.js | 90 +++++++++++++++++- .../js/archiva/templates/repositories.html | 21 +++- 5 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRepositoryStatistics.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRepositoryStatistics.java index 7b55e64ff..92c2fb00d 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRepositoryStatistics.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRepositoryStatistics.java @@ -44,6 +44,8 @@ public class ArchivaRepositoryStatistics private long newFileCount; + private long duration; + public ArchivaRepositoryStatistics() { // no op @@ -129,6 +131,16 @@ public class ArchivaRepositoryStatistics this.newFileCount = newFileCount; } + public void setDuration( long duration ) + { + this.duration = duration; + } + + public long getDuration() + { + return duration; + } + @Override public String toString() { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java index 87f589179..4860a3c32 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java @@ -181,7 +181,8 @@ public class DefaultManagedRepositoriesService { ArchivaRepositoryStatistics archivaRepositoryStatistics = new BeanReplicator().replicateBean( stats, ArchivaRepositoryStatistics.class ); - + archivaRepositoryStatistics.setDuration( archivaRepositoryStatistics.getScanEndTime().getTime() + - archivaRepositoryStatistics.getScanStartTime().getTime() ); return archivaRepositoryStatistics; } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png new file mode 100644 index 0000000000000000000000000000000000000000..8734e777a1799c9a9d0293d692b3549f2506f418 GIT binary patch literal 611 zcmV-p0-XJcP){lZ-v(r|Lj~5OgyaOZ2LJfeicB?^@C`JZr?Az7B z%cTZg`BR8Uk|Z%vq7ZR}iq)SDP7c%v1Bu8L;M*)gFoKYRtH+LS+(amWlo3J-J~!s*-9O61 z*EP)dJ6L0}#{PPO-3oZ}uA3-Ts8|uj3L!smu=5$dStASro-Xy${E-2R?G0dc-WEsb z9nLu}J?g;u9cXRPR%3Ci1{(odXN(OGaBuF_CfwpYz>BthSnKb xD?=NN)@$d68cm~7Ux!IxdUEo{_J8C5<|lAN08`nh^nm~X002ovPDHLkV1lX$`TPI? literal 0 HcmV?d00001 diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js index fd7c0a1f4..550399286 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js @@ -92,6 +92,37 @@ $(function() { } + ArchivaRepositoryStatistics=function(scanEndTime,scanStartTime,totalArtifactCount,totalArtifactFileSize,totalFileCount, + totalGroupCount,totalProjectCount,newFileCount,duration,managedRepository){ + //private Date scanEndTime; + this.scanEndTime = ko.observable(scanEndTime); + + //private Date scanStartTime; + this.scanStartTime = ko.observable(scanStartTime); + + //private long totalArtifactCount; + this.totalArtifactCount = ko.observable(totalArtifactCount); + + //private long totalArtifactFileSize; + this.totalArtifactFileSize = ko.observable(totalArtifactFileSize); + + //private long totalFileCount; + this.totalFileCount = ko.observable(totalFileCount); + + //private long totalGroupCount; + this.totalGroupCount = ko.observable(totalGroupCount); + + //private long totalProjectCount; + this.totalProjectCount = ko.observable(totalProjectCount); + + //private long newFileCount; + this.newFileCount = ko.observable(newFileCount); + + this.duration = ko.observable(duration); + + this.managedRepository = managedRepository; + } + ManagedRepositoryViewModel=function(managedRepository, update, managedRepositoriesViewModel){ this.managedRepository=managedRepository; this.managedRepositoriesViewModel = managedRepositoriesViewModel; @@ -296,7 +327,53 @@ $(function() { $("#managed-repository-delete-warning-tmpl").tmpl(managedRepository)); } + showStats=function(managedRepository){ + if ($(calculatePopoverId(managedRepository)).html()){ + // we ask stats all the time ? if yes uncomment return + return; + //$(calculatePopoverId(managedRepository)).html(""); + } + var curRepo=managedRepository; + var url = "restServices/archivaServices/managedRepositoriesService/getManagedRepositoryStatistics/"+managedRepository.id(); + $.ajax(url, + { + type: "GET", + dataType: 'json', + success: function(data) { + if (data.archivaRepositoryStatistics==null){ + return; + } + var archivaRepositoryStatistics=mapArchivaRepositoryStatistics(data.archivaRepositoryStatistics); + archivaRepositoryStatistics.managedRepository=curRepo; + $("#managedrepository-stats-"+curRepo.id()).append($("#managed-repository-stats-tmpl").tmpl(archivaRepositoryStatistics)); + $("#managedrepository-stats-img-"+curRepo.id()).attr("data-content",$(calculatePopoverId(curRepo)).html()); + $("#managedrepository-stats-img-"+curRepo.id()).popover( + { + placement: "left", + html: true + } + ); + //$(calculatePopoverId(managedRepository)).show(); + $("#managedrepository-stats-img-"+curRepo.id()).popover('show') + + }, + error: function(data) { + var res = $.parseJSON(data.responseText); + displayRestError(res); + }, + complete: function(){ + } + } + ); + } + + hideStats=function(managedRepository){ + } + + calculatePopoverId=function(managedRepository){ + return "#managedrepository-stats-"+managedRepository.id() + " #managedrepository-stats-"+managedRepository.id()+"-popover"; + } } @@ -369,12 +446,23 @@ $(function() { return mappedManagedRepositories; } mapManagedRepository=function(data){ - + if (data==null){ + return null; + } return new ManagedRepository(data.id,data.name,data.layout,data.indexDirectory,data.location,data.snapshots,data.releases, data.blockRedeployments,data.cronExpression, data.scanned,data.daysOlder,data.retentionCount,data.deleteReleasedSnapshots,data.stageRepoNeeded); } + mapArchivaRepositoryStatistics=function(data){ + if (data==null){ + return null; + } + return new ArchivaRepositoryStatistics(data.scanEndTime,data.scanStartTime,data.totalArtifactCount,data.totalArtifactFileSize, + data.totalFileCount,data.totalGroupCount,data.totalProjectCount,data.newFileCount, + data.duration,data.managedRepository) + } + activateManagedRepositoriesGridTab=function(){ $("#main-content #managed-repository-edit-li").removeClass("active"); $("#main-content #managed-repository-edit").removeClass("active"); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html index 4dad39121..2d3618d9f 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html @@ -67,6 +67,7 @@ Releases Snapshots Scan + Stats ${$.i18n.prop('edit')} ${$.i18n.prop('delete')} @@ -97,6 +98,11 @@ + + + ${$.i18n.prop('edit')} @@ -244,8 +250,15 @@ + \ No newline at end of file -- 2.39.5