musician dashboard2 progresbar exact % and try monitors
This commit is contained in:
parent
b72af48cd1
commit
35dd1c64c2
|
@ -23,8 +23,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% if usage.data.progres_bar %}
|
{% if usage.data.progres_bar %}
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
<div class="progress-bar bg-secondary w-{{ usage.data.percent }}" role="progressbar" aria-valuenow="{{ usage.data.used }}"
|
<div class="progress-bar bg-secondary" style="width:{{ usage.data.percent }}%"></div>
|
||||||
aria-valuemin="0" aria-valuemax="{{ usage.data.total }}"></div>
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if usage.data.alert %}
|
{% if usage.data.alert %}
|
||||||
|
@ -66,5 +65,13 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <div class="embed-responsive embed-responsive-16by9">
|
||||||
|
<iframe class="embed-responsive-item" src="{{ history_disk }}" allowfullscreen></iframe>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="embed-responsive embed-responsive-16by9">
|
||||||
|
<iframe class="embed-responsive-item" src="{{ history_traffic }}" allowfullscreen></iframe>
|
||||||
|
</div> -->
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -16,3 +16,10 @@ def get_bootstraped_percent(value, total):
|
||||||
bootstraped = min(100, bootstraped)
|
bootstraped = min(100, bootstraped)
|
||||||
|
|
||||||
return bootstraped
|
return bootstraped
|
||||||
|
|
||||||
|
def get_bootstraped_percent_exact(value, total):
|
||||||
|
try:
|
||||||
|
percent = 100 * float(value)/float(total)
|
||||||
|
except (TypeError, ZeroDivisionError):
|
||||||
|
return 0
|
||||||
|
return percent
|
|
@ -48,7 +48,7 @@ from .models import DatabaseService
|
||||||
from .models import Mailbox as MailboxService
|
from .models import Mailbox as MailboxService
|
||||||
from .models import MailinglistService, SaasService
|
from .models import MailinglistService, SaasService
|
||||||
from .settings import ALLOWED_RESOURCES, MUSICIAN_EDIT_ENABLE_PHP_OPTIONS
|
from .settings import ALLOWED_RESOURCES, MUSICIAN_EDIT_ENABLE_PHP_OPTIONS
|
||||||
from .utils import get_bootstraped_percent
|
from .utils import get_bootstraped_percent, get_bootstraped_percent_exact
|
||||||
|
|
||||||
from .webapps.views import *
|
from .webapps.views import *
|
||||||
from .websites.views import *
|
from .websites.views import *
|
||||||
|
@ -57,6 +57,7 @@ from .lists.views import *
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
from django.urls import reverse
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
class DashboardView2(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
class DashboardView2(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
template_name = "musician/dashboard2.html"
|
template_name = "musician/dashboard2.html"
|
||||||
|
@ -74,17 +75,13 @@ class DashboardView2(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
# account
|
# account
|
||||||
account = related_resources.filter(resource_id__verbose_name='account-disk')
|
account = related_resources.filter(resource_id__verbose_name='account-disk')
|
||||||
# account_trafic = related_resources.filter(resource_id__verbose_name='account-traffic')
|
# account_trafic = related_resources.filter(resource_id__verbose_name='account-traffic')
|
||||||
# print(account_trafic.first())
|
# history_disk = reverse('admin:resources_resourcedata_show_history', args=(account.first().pk,))
|
||||||
# /admin/resources/resourcedata/17000
|
# history_traffic = reverse('admin:resources_resourcedata_show_history', args=(account_trafic.first().pk,))
|
||||||
# mailbox
|
|
||||||
mailboxes = related_resources.filter(resource_id__verbose_name='mailbox-disk')
|
mailboxes = related_resources.filter(resource_id__verbose_name='mailbox-disk')
|
||||||
# lists
|
|
||||||
lists = related_resources.filter(resource_id__verbose_name='list-traffic')
|
lists = related_resources.filter(resource_id__verbose_name='list-traffic')
|
||||||
# Database
|
|
||||||
databases = related_resources.filter(resource_id__verbose_name='database-disk')
|
databases = related_resources.filter(resource_id__verbose_name='database-disk')
|
||||||
# nextcloud
|
|
||||||
nextcloud = related_resources.filter(resource_id__verbose_name='nextcloud-disk')
|
nextcloud = related_resources.filter(resource_id__verbose_name='nextcloud-disk')
|
||||||
# domains
|
|
||||||
domains = Domain.objects.filter(account_id=self.request.user)
|
domains = Domain.objects.filter(account_id=self.request.user)
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,6 +111,8 @@ class DashboardView2(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
'resource_usage': resource_usage,
|
'resource_usage': resource_usage,
|
||||||
'notifications': notifications,
|
'notifications': notifications,
|
||||||
"support_email_anchor": support_email_anchor,
|
"support_email_anchor": support_email_anchor,
|
||||||
|
# 'history_disk': history_disk,
|
||||||
|
# 'history_traffic': history_traffic,
|
||||||
})
|
})
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
@ -161,7 +160,7 @@ class DashboardView2(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
'total': limit_rs,
|
'total': limit_rs,
|
||||||
'alert': alert,
|
'alert': alert,
|
||||||
'unit': name_resource.capitalize(),
|
'unit': name_resource.capitalize(),
|
||||||
'percent': get_bootstraped_percent(total_rs, limit_rs),
|
'percent': get_bootstraped_percent_exact(total_rs, limit_rs),
|
||||||
},
|
},
|
||||||
'objects': resource_data,
|
'objects': resource_data,
|
||||||
}
|
}
|
||||||
|
@ -176,6 +175,7 @@ class DashboardView2(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
alert = format_html(f"<span class='text-danger'>{size_left * -1} extra size</span>")
|
alert = format_html(f"<span class='text-danger'>{size_left * -1} extra size</span>")
|
||||||
elif size_left <= 1:
|
elif size_left <= 1:
|
||||||
alert = format_html(f"<span class='text-warning'>{size_left} size left</span>")
|
alert = format_html(f"<span class='text-warning'>{size_left} size left</span>")
|
||||||
|
print(f"get: {get_bootstraped_percent_exact(total_size, allowed_size)}, total: {total_size}, limit: {allowed_size}")
|
||||||
return {
|
return {
|
||||||
'verbose_name': _('Account'),
|
'verbose_name': _('Account'),
|
||||||
'data': {
|
'data': {
|
||||||
|
@ -184,7 +184,7 @@ class DashboardView2(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
'total': allowed_size,
|
'total': allowed_size,
|
||||||
'alert': alert,
|
'alert': alert,
|
||||||
'unit': 'GiB Size',
|
'unit': 'GiB Size',
|
||||||
'percent': get_bootstraped_percent(total_size, allowed_size),
|
'percent': get_bootstraped_percent_exact(total_size, allowed_size),
|
||||||
},
|
},
|
||||||
'objects': account,
|
'objects': account,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue