[MRM-1574] display repo stats

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1233596 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-01-19 22:10:18 +00:00
parent 5e0f500e7f
commit 317cf9e4ce
5 changed files with 120 additions and 6 deletions

View File

@ -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()
{

View File

@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 611 B

View File

@ -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");

View File

@ -67,6 +67,7 @@
<th>Releases</th>
<th>Snapshots</th>
<th>Scan</th>
<th>Stats</th>
<th>${$.i18n.prop('edit')}</th>
<th>${$.i18n.prop('delete')}</th>
</tr>
@ -97,6 +98,11 @@
<img src="images/view-refresh.png" title="${$.i18n.prop('managedrepository.scan.now')}"/>
</a>
</td>
<td id="managedrepository-stats-${row.id()}">
<img src="images/utilities-system-monitor.png" title="${$.i18n.prop('managedrepository.stats')}"
data-bind="event: { mouseover: function(){ showStats(row) }, mouseout: function(){ hideStats(row) },}"
id="managedrepository-stats-img-${row.id()}"/>
</td>
<td><a href="#" data-bind="click: function(){ editManagedRepository(row) }">${$.i18n.prop('edit')}</a></td>
<td>
<a href="#" data-bind="click: function(){ removeManagedRepository(row) }">
@ -244,8 +250,15 @@
</div>
</script>
<script id="managed-repository-scan-now-modal-tmpl" type='text/x-jquery-tmpl'>
<div>
${$.i18n.prop('managedrepository.scan.all')}: <input type="checkbox" id="managed-repository-scan-now-all">
</div>
<div>
${$.i18n.prop('managedrepository.scan.all')}: <input type="checkbox" id="managed-repository-scan-now-all">
</div>
</script>
<script id="managed-repository-stats-tmpl" type='text/x-jquery-tmpl'>
<div id="managedrepository-stats-${managedRepository.id()}-popover" style="display:none">
<div>${$.i18n.prop('managedrepository.stats.endTime')}: ${scanEndTime()}</div>
<div>${$.i18n.prop('managedrepository.stats.duration')}: ${duration()}</div>
<div>${$.i18n.prop('managedrepository.stats.totalFileCount')}: ${totalFileCount()}</div>
<div>${$.i18n.prop('managedrepository.stats.newFileCount')}: ${newFileCount()}</div>
</div>
</script>