Skip to content

Commit

Permalink
closes #863
Browse files Browse the repository at this point in the history
  • Loading branch information
ppazos committed Mar 6, 2018
1 parent 662d420 commit 2f6d865
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import grails.converters.*
class StatsController {

def versionFSRepoService
def OPTService

/**
* Show stats dashboard for all the organizations accessible by the user.
Expand Down Expand Up @@ -167,10 +168,10 @@ class StatsController {

account.organizations.each { org ->

size = (versionFSRepoService.getRepoSizeInBytes(org.uid) / 1024).setScale(1,0)
size = ((versionFSRepoService.getRepoSizeInBytes(org.uid) + OPTService.getRepoSizeInBytesOrg(org.uid)) / 1024).setScale(1,0)

// size is set in KB
stats[org.name] = size
stats[org.uid] = size

if (!plan_repo_total_size) max_repo_size += stats[org.name]
}
Expand Down
1 change: 0 additions & 1 deletion grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,6 @@ account.update.planNotFound=Plan not found
account.update.errorAssigningPlan=Plan assignment returned an error
account.update.ok=Account updated!
account.stats.repo_usage=Disk usage
account.stats.lowUsageOrganizationsAreNotShown=Only organizations with more than 5% of usage are shown

account.create.title=Create account
account.attr.companyName=Company name
Expand Down
1 change: 0 additions & 1 deletion grails-app/i18n/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,6 @@ account.update.planNotFound=El plan no existe
account.update.errorAssigningPlan=Ocurrió un error al asignar el plan
account.update.ok=Cuenta actualizada con éxito
account.stats.repo_usage=Uso de disco
account.stats.lowUsageOrganizationsAreNotShown=Se muestran las organizaciones con más del 5% de uso

account.create.title=Crear cuenta
account.attr.companyName=Nombre de la empresa
Expand Down
41 changes: 7 additions & 34 deletions grails-app/views/account/show.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@
<th><g:message code="account.attr.enabled" default="Enabled" /></th>
<td><g:formatBoolean boolean="${account?.enabled}" /></td>
</tr>
<tr>
<th>
<g:message code="account.stats.repo_usage" default="Repository usage" />
<span class="help-block"><g:message code="account.stats.lowUsageOrganizationsAreNotShown" /></span>
</th>
<td>
<div id="account_stats"></div>
</td>
</tr>
<tr>
<th>
<g:message code="account.stats.organizations" default="Organizations" />
Expand All @@ -54,7 +45,10 @@
<td>
<ul>
<g:each in="${account.organizations}" var="org">
<li>${org.name}</li>
<li>
<g:link controller="organization" action="show" params="[uid: org.uid]">${org.name}</g:link>
<span id="${org.uid}"></span>
</li>
</g:each>
</ul>
</td>
Expand Down Expand Up @@ -92,16 +86,11 @@
var bar = $('<div class="progress"></div>');
var org_count = Object.keys(json.usage).length;
var i = 0;
for (org_name in json.usage)
for (org_uid in json.usage)
{
percent = precisionRound( json.usage[org_name] * 100 / json.max_repo_size, 1);
percent = precisionRound( json.usage[org_uid] * 100 / json.max_repo_size, 1);
// do not display if usage is too low to show
if (percent >= 5)
{
org_bar = '<div class="progress-bar progress-bar-'+ classes[i%org_count] +'" style="width: '+ percent +'%">'+ org_name +'</div>';
bar.append( org_bar );
}
$('#'+ org_uid).text(percent +'%').append(' <i class="fa fa-database" aria-hidden="true" title="${message(code:'account.stats.repo_usage')}"></i>');
i++;
}
Expand All @@ -110,21 +99,5 @@
});
});
</script>

<%-- TODO: show organizations
<g:if test="${account?.organizations}">
<ol>
<li class="fieldcontain">
<span id="organizations-label" class="property-label"><g:message code="account.organizations.label" default="Organizations" /></span>
<g:each in="${account.organizations}" var="o">
<span class="property-value" aria-labelledby="organizations-label"><g:link controller="organization" action="show" id="${o.id}">${o?.encodeAsHTML()}</g:link></span>
</g:each>
</li>
</ol>
</g:if>
--%>

</body>
</html>

0 comments on commit 2f6d865

Please sign in to comment.