musician saas nextcloud progresbar
This commit is contained in:
parent
e24b62e9e2
commit
a88c2decd3
|
@ -4,18 +4,20 @@ from django.urls import reverse_lazy
|
||||||
|
|
||||||
from django.views.generic.base import RedirectView, TemplateView
|
from django.views.generic.base import RedirectView, TemplateView
|
||||||
from django.views.generic.detail import DetailView
|
from django.views.generic.detail import DetailView
|
||||||
|
from django.views.generic.list import ListView
|
||||||
from django.views.generic.edit import (CreateView, DeleteView, FormView,
|
from django.views.generic.edit import (CreateView, DeleteView, FormView,
|
||||||
UpdateView)
|
UpdateView)
|
||||||
from django.views.generic.list import ListView
|
|
||||||
|
|
||||||
|
from orchestra.contrib.saas.models import SaaS
|
||||||
|
from orchestra.contrib.resources.models import Resource, ResourceData
|
||||||
|
|
||||||
|
from orchestra.contrib.musician.settings import ALLOWED_RESOURCES
|
||||||
|
from orchestra.contrib.musician.utils import get_bootstraped_percent_exact
|
||||||
from orchestra.contrib.musician.mixins import (CustomContextMixin, ExtendedPaginationMixin,
|
from orchestra.contrib.musician.mixins import (CustomContextMixin, ExtendedPaginationMixin,
|
||||||
UserTokenRequiredMixin)
|
UserTokenRequiredMixin)
|
||||||
|
|
||||||
from .forms import ( NextcloudChangePasswordForm, SaasNextcloudUpdateForm,
|
from .forms import ( NextcloudChangePasswordForm, SaasNextcloudUpdateForm,
|
||||||
SaasWordpressUpdateForm, NextcloudCreateForm )
|
SaasWordpressUpdateForm, NextcloudCreateForm )
|
||||||
from orchestra.contrib.saas.models import SaaS
|
|
||||||
|
|
||||||
from orchestra.contrib.musician.settings import ALLOWED_RESOURCES
|
|
||||||
|
|
||||||
|
|
||||||
class SaasNextcloudListView(CustomContextMixin, UserTokenRequiredMixin, ListView):
|
class SaasNextcloudListView(CustomContextMixin, UserTokenRequiredMixin, ListView):
|
||||||
|
@ -29,7 +31,16 @@ class SaasNextcloudListView(CustomContextMixin, UserTokenRequiredMixin, ListView
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return self.model.objects.filter(account=self.request.user, service='nextcloud')
|
# return self.model.objects.filter(account=self.request.user, service='nextcloud')
|
||||||
|
qs = self.model.objects.filter(account=self.request.user, service='nextcloud')
|
||||||
|
disk_resource = Resource.objects.get(name='nextcloud-disk')
|
||||||
|
for Nuser in qs:
|
||||||
|
try:
|
||||||
|
Nuser.usage = Nuser.resource_set.get(resource=disk_resource)
|
||||||
|
except ResourceData.DoesNotExist:
|
||||||
|
Nuser.usage = ResourceData(resource=disk_resource)
|
||||||
|
Nuser.percent = get_bootstraped_percent_exact(Nuser.usage.used, Nuser.usage.allocated)
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
class SaasWordpressListView(CustomContextMixin, UserTokenRequiredMixin, ListView):
|
class SaasWordpressListView(CustomContextMixin, UserTokenRequiredMixin, ListView):
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
<th scope="col">{% trans "Name" %}</th>
|
<th scope="col">{% trans "Name" %}</th>
|
||||||
<th scope="col">{% trans "Status" %}</th>
|
<th scope="col">{% trans "Status" %}</th>
|
||||||
<th scope="col">{% trans "Service" %}</th>
|
<th scope="col">{% trans "Service" %}</th>
|
||||||
|
<th scope="col">{% trans "Disk usage" %}</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -32,6 +33,17 @@
|
||||||
<i class="fab fa-{{ saas.service }}"></i> {{ saas.service|capfirst }}
|
<i class="fab fa-{{ saas.service }}"></i> {{ saas.service|capfirst }}
|
||||||
<span class="sr-only">{% trans "Open service admin panel" %}</span> <i class="fas fa-external-link-alt"></i></a>
|
<span class="sr-only">{% trans "Open service admin panel" %}</span> <i class="fas fa-external-link-alt"></i></a>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if saas.usage.used %}
|
||||||
|
{{ saas.usage.used|floatformat }}
|
||||||
|
{% else %}
|
||||||
|
0
|
||||||
|
{% endif %}
|
||||||
|
{{ saas.usage.unit }}
|
||||||
|
<div class="progress">
|
||||||
|
<div class="progress-bar bg-secondary" style="width: {{ saas.percent }}%"></div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
<a class="btn btn-outline-warning" role="button" href="{% url 'musician:saas-nextcloud-update' saas.id %}">
|
<a class="btn btn-outline-warning" role="button" href="{% url 'musician:saas-nextcloud-update' saas.id %}">
|
||||||
<i class="fas fa-tools"></i></a>
|
<i class="fas fa-tools"></i></a>
|
||||||
|
|
Loading…
Reference in a new issue