Commit 373da652 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou Committed by Giorgos Korfiatis

astakos: Display both summed up and per project quota in usage view

parent 38fc975e
......@@ -522,9 +522,9 @@ form input[type="text"]:-ms-input-placeholder,
.stats .bar span + em { position: absolute; }
.stats .bar { position: relative; }
.stats .red .bar span { background:#ef4f54; }
.stats .yellow .bar span { background:#f6921e; }
.stats .green .bar span { background:#55b577; }
.stats .resource-bar.red .bar span { background:#ef4f54; }
.stats .resource-bar.yellow .bar span { background:#f6921e; }
.stats .resource-bar.green .bar span { background:#55b577; }
.stats .img-wrap { float:left; width:100px; background:url(../images/statistics_icons.png) no-repeat center center; padding:30px 0; }
.stats .info { margin:0 25px ; width:320px; float:left; }
.stats .info p { color:#999; margin:0; }
......@@ -546,6 +546,10 @@ form input[type="text"]:-ms-input-placeholder,
.stats .red .img-wrap { background-position: 15px 7px; }
.stats .yellow .img-wrap { background-position: -124px 7px; }
.stats .green .img-wrap { background-position: -263px 7px; }
.stats .resource-bar.project { margin-top: 1em; }
.stats .resource-bar.project { margin-left: 100px; font-size: 0.8em;}
.stats .resource-bar.project h3 { margin-bottom: 0.5em; }
.stats .resource-bar.project .bar div { width:340px; height:25px; border:1px solid #000; margin-top:5px; overflow:hidden; font-size: 0.8em}
.projects .editable form textarea { width:70%; height:50px; max-width:70%; width:270px; height:120px;}
......
......@@ -10,6 +10,29 @@
{% block page.title %}Usage{% endblock %}
{% block page.body %}
<script id="projectQuotaTpl" type="text/template">
{% verbatim %}
<div class="resource-bar project clearfix project-{{id}} {{ usage.cls }}"
data-project="{{ id }}">
<div class="info" data-currvalue="" data-maxvalue="">
<h3>{{ name }}</h3>
<p>
<span class="currValue">{{ usage.curr }}</span> out of
<span class="maxValue">{{ usage.max }}</span> {{ report_desc }}
</p>
</div>
<div class="bar">
<div>
<span style="width:{{ usage.perc }}%"></span>
<em class="value"
style="left: {{ usage.label_left }}; color: {{ usage.label_color }}">
{{ usage.perc }}%
</em>
</div>
</div>
</div>
{% endverbatim %}
</script>
<script id="quotaTpl" type="text/template">
{% verbatim %}
......@@ -17,22 +40,26 @@
<li class="clearfix {{ resource_name }} {{ usage.cls }}"
data-resource="{{ name }}">
<div class="img-wrap">&nbsp;</div>
<div class="info" data-currvalue="" data-maxvalue="">
<h3>{{ report_desc }}</h3>
<p>
<span class="currValue">{{ usage.curr }}</span> out of
<span class="maxValue">{{ usage.max }}</span> {{ report_desc }}
</p>
<div class="summary resource-bar clearfix {{ usage.cls }}">
<div class="info" data-currvalue="" data-maxvalue="">
<h3>{{ report_desc }}</h3>
<p>
<span class="currValue">{{ usage.curr }}</span> out of
<span class="maxValue">{{ usage.max }}</span> {{ report_desc }}
</p>
<!--<span class="resource-extend">details</span>-->
</div>
<div class="bar">
<div>
<span style="width:{{ usage.perc }}%"></span>
<em class="value"
style="left: {{ usage.label_left }}; color: {{ usage.label_color }}">
{{ usage.perc }}%
</em>
</div>
</div>
</div>
<div class="bar">
<div>
<span style="width:{{ usage.perc }}%"></span>
<em
class="value"
style="left: {{ usage.label_left }}%; color: {{ usage.label_color }}">
{{ usage.perc }}%
</em>
</div>
<div class="projects">
</div>
</li>
{{/resources}}
......@@ -48,13 +75,15 @@
$(document).ready(function(){
var usageView = new UsageView({
'url': '{% url astakos-api-quotas %}',
'projects_url': '{% url astakos.api.projects.projects %}',
'cookie_name': '{{ token_cookie_name|safe }}',
'dataType': 'json',
'container': '#quota-container',
'quotas': {{ current_usage|safe }},
'quotas': {{ user_quotas|safe }},
'meta': {
'resources': {{ resource_catalog|safe }},
'groups': {{ resource_groups|safe }},
'projects_details': {{ projects_details|safe }},
'resources_order': {{ resources_order|safe }}
}
});
......
......@@ -74,6 +74,8 @@ from astakos.im import quotas
from astakos.im.views.util import render_response, _resources_catalog
from astakos.im.views.decorators import cookie_fix, signed_terms_required,\
required_auth_methods_assigned, valid_astakos_user_required, login_required
from astakos.api import projects as projects_api
from astakos.api.util import _dthandler
logger = logging.getLogger(__name__)
......@@ -840,8 +842,11 @@ def resource_usage(request):
resources_meta = presentation.RESOURCES
current_usage = quotas.get_user_quotas(request.user)
current_usage = json.dumps(current_usage['system'])
user_memberships = request.user.projectmembership_set.actually_accepted()
sources = [quotas.project_ref(m.project.uuid) for m in user_memberships]
user_quotas = quotas.get_user_quotas(request.user, sources=sources)
projects = [m.project for m in user_memberships]
user_projects = projects_api.get_projects_details(projects)
resource_catalog, resource_groups = _resources_catalog()
if resource_catalog is False:
# on fail resource_groups contains the result object
......@@ -852,16 +857,20 @@ def resource_usage(request):
resource_catalog = json.dumps(resource_catalog)
resource_groups = json.dumps(resource_groups)
resources_order = json.dumps(resources_meta.get('resources_order'))
projects_details = json.dumps(user_projects, default=_dthandler)
user_quotas = json.dumps(user_quotas)
interval = settings.USAGE_UPDATE_INTERVAL
return render_response('im/resource_usage.html',
context_instance=get_context(request),
resource_catalog=resource_catalog,
resource_groups=resource_groups,
resources_order=resources_order,
current_usage=current_usage,
projects_details=projects_details,
user_quotas=user_quotas,
token_cookie_name=settings.COOKIE_NAME,
usage_update_interval=
settings.USAGE_UPDATE_INTERVAL)
usage_update_interval=interval)
# TODO: action only on POST and user should confirm the removal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment