Skip to content

Commit

Permalink
Quota UI: Showing percent consumed if quota is configured on an organ…
Browse files Browse the repository at this point in the history
…ization (PROJQUAY-0000) (#1249)

* Tracking aws ip ranges.json

* Reverting change

* Quota UI: Showing percent consumed if quota is configured on an organization (PROJQUAY-0000)
  • Loading branch information
Sunandadadi authored Apr 18, 2022
1 parent acab72d commit 923fc72
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions data/model/namespacequota.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def get_repo_quota_for_view(namespace_name, repo_name):
quotas = get_namespace_quota_list(repository_ref.namespace_user.username)

# Currently only one quota per namespace is supported
configured_namespace_quota = quotas[0].limit_bytes if quotas else []
configured_namespace_quota = quotas[0].limit_bytes if quotas else None

repo_size = model.repository.get_repository_size_and_cache(repository_ref.id).get(
"repository_size", 0
Expand All @@ -302,7 +302,7 @@ def get_quota_for_view(namespace_name):
quotas = get_namespace_quota_list(namespace_user.username)

# Currently only one quota per namespace is supported
configured_namespace_quota = quotas[0].limit_bytes if quotas else []
configured_namespace_quota = quotas[0].limit_bytes if quotas else None

namespace_quota_consumed = get_namespace_size(namespace_name)
namespace_quota_consumed = int(namespace_quota_consumed) if namespace_quota_consumed else 0
Expand Down
4 changes: 2 additions & 2 deletions static/directives/repo-list-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
<span ng-bind="::bytesToHumanReadableString(repository.quota_report.quota_bytes)"></span>
</span>
<span ng-if="::!repository.quota_report.quota_bytes"></span>
<span ng-if="::repository.quota_report.configured_quota.length > 0">
({{ ::quotaPercentConsumed(repository) }})%
<span ng-if="::repository.quota_report.configured_quota">
({{ ::quotaPercentConsumed(repository) }}%)
</span>
</td>

Expand Down
2 changes: 1 addition & 1 deletion static/js/directives/ui/repo-list-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ angular.module('quay').directive('repoListTable', function () {
};

$scope.quotaPercentConsumed = function(repository) {
if (repository.quota_report) {
if (repository.quota_report && repository.quota_report.configured_quota) {
return (repository.quota_report.quota_bytes / repository.quota_report.configured_quota * 100).toFixed(2);
}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion static/partials/org-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h3>Repositories</h3>
<h4>
Total Quota Consumed:
<span ng-if="organization.quota_report.quota_bytes">
{{ bytesToHumanReadableString(organization.quota_report.quota_bytes) + "(" + quotaPercentConsumed(organization) + "%)" }}
{{ bytesToHumanReadableString(organization.quota_report.quota_bytes) + " (" + quotaPercentConsumed(organization) + "%)" }}
</span>
<span ng-if="organization.quota_report.quota_bytes == '0'">--</span>
</h4>
Expand Down
6 changes: 3 additions & 3 deletions static/partials/super-user.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ <h3 style="margin-top: 0px;">Change Log</h3>
<span ng-if="current_org.quota_report.quota_bytes">
{{
current_org.quota_report.percent_consumed ?
( bytesToHumanReadableString(current_org.quota_report.quota_bytes) + "(" + current_org.quota_report.percent_consumed + "%)") :
( bytesToHumanReadableString(current_org.quota_report.quota_bytes) + " (" + current_org.quota_report.percent_consumed + "%)") :
bytesToHumanReadableString(current_org.quota_report.quota_bytes)
}}
</span>
<span ng-if="current_org.quota_report.configured_quota.length > 0 && !current_org.quota_report.quota_bytes">0</span>
<span ng-if="current_org.quota_report.configured_quota.length > 0">
<span ng-if="current_org.quota_report.configured_quota && !current_org.quota_report.quota_bytes">0</span>
<span ng-if="current_org.quota_report.configured_quota">
{{ " of " + bytesToHumanReadableString(current_org.quota_report.configured_quota) }}
</span>
</td>
Expand Down

0 comments on commit 923fc72

Please sign in to comment.