update container list page
This commit is contained in:
parent
d477b11827
commit
a35ab33a07
3 changed files with 24 additions and 0 deletions
|
@ -36,6 +36,9 @@ class ControllerContainers:
|
|||
models.Containers.ipv6,
|
||||
models.Containers.status,
|
||||
models.ContainersStatisticsState.size,
|
||||
models.ContainersStatisticsState.cpu,
|
||||
models.ContainersStatisticsState.memory,
|
||||
models.ContainersStatisticsState.net_total,
|
||||
).join(models.ContainersStatisticsState).where(
|
||||
models.Containers.user == self.user_id
|
||||
)
|
||||
|
@ -50,6 +53,11 @@ class ControllerContainers:
|
|||
'ipv6': item.ipv6,
|
||||
'status': item.status,
|
||||
'size': item.containersstatisticsstate.size,
|
||||
'cpu': item.containersstatisticsstate.cpu,
|
||||
'memory': item.containersstatisticsstate.memory,
|
||||
'net_tx': item.containersstatisticsstate.net_tx,
|
||||
'net_rx': item.containersstatisticsstate.net_rx,
|
||||
'net_total': item.containersstatisticsstate.net_total,
|
||||
})
|
||||
return containers
|
||||
|
||||
|
@ -101,6 +109,11 @@ class ControllerContainersStatistics:
|
|||
|
||||
class ControllerContainersStatisticsState:
|
||||
def get(self, container_id):
|
||||
"""
|
||||
Получение данных последнего отчёта
|
||||
:param container_id:
|
||||
:return:
|
||||
"""
|
||||
return models.ContainersStatisticsState.select().where(
|
||||
models.ContainersStatisticsState.container == container_id
|
||||
).execute()
|
||||
|
@ -111,6 +124,11 @@ class ControllerContainersStatisticsState:
|
|||
return self.create(container_id, statistics)
|
||||
|
||||
def exists(self, container_id):
|
||||
"""
|
||||
Проверка наличияя записи отчёта в таблице
|
||||
:param container_id:
|
||||
:return:
|
||||
"""
|
||||
if models.ContainersStatisticsState.select().where(
|
||||
models.ContainersStatisticsState.container == container_id
|
||||
).count() == 0:
|
||||
|
|
|
@ -262,6 +262,7 @@ def stats(container_id):
|
|||
return redirect(url_for('containers.index'))
|
||||
# get container details
|
||||
container_details = containers.get_item(container_id)
|
||||
print ControllerContainersStatisticsState().get(container_id)
|
||||
# return
|
||||
return render_template(
|
||||
'default/containers/stats.html',
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<th width="45%">ID</th>
|
||||
<th>IP</th>
|
||||
<th>Диск</th>
|
||||
<th>Память</th>
|
||||
<th>Статус</th>
|
||||
<th width="10%"> </th>
|
||||
</tr>
|
||||
|
@ -43,6 +44,10 @@
|
|||
{% set size_gb = (container.size / 1024 / 1024) %}
|
||||
{{ '%0.2f' | format(size_gb|float) }}GB
|
||||
</td>
|
||||
<td>
|
||||
{% set memory_mb = (container.memory / 1024 / 1024) %}
|
||||
{{ '%0.2f' | format(memory_mb|float) }}MB
|
||||
</td>
|
||||
<td>
|
||||
{% if container['status'] == 0 %}
|
||||
Неактивно
|
||||
|
|
Loading…
Add table
Reference in a new issue