Skip to content

Commit

Permalink
fix html
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Aug 11, 2024
1 parent ed4a46d commit c1fed29
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
8 changes: 4 additions & 4 deletions apps/proxy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,6 @@ def ehco_relay_port(self):
def relay_count(self):
return self.relay_rules.all().count()

@property
def is_shared_node(self):
return not OccupancyConfig.objects.filter(proxy_node=self).exists()

@cached_property
def online_info(self):
return UserTrafficLog.get_latest_online_log_info(self)
Expand Down Expand Up @@ -1107,6 +1103,10 @@ def get_user_occupancies(cls, user: User, out_of_usage=False, limit=None):
query = query[:limit]
return query

@classmethod
def check_node_occupied_by_user(cls, node: ProxyNode, user: User):
return cls._valid_occupancy_query().filter(proxy_node=node, user=user).exists()

def human_total_traffic(self):
return utils.traffic_format(self.total_traffic)

Expand Down
6 changes: 3 additions & 3 deletions apps/sspanel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ def get(self, request):
shared_node_count = 0
occupied_node_count = 0
for node in user_active_nodes:
if node.is_shared_node:
shared_node_count += 1
else:
if UserProxyNodeOccupancy.check_node_occupied_by_user(node, user):
occupied_node_count += 1
else:
shared_node_count += 1

context = {
"user": user,
Expand Down
40 changes: 15 additions & 25 deletions templates/web/node_occupancy.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
{% extends 'base.html' %}
{% block authed %}
<div class="column is-12">
<section class="hero is-warning is-smaill">
<section class="hero is-warning is-small">
<div class="hero-body">
<div class="container">
<h1 class="title">独享节点</h1>
<ul>
<li>流量和共享节点分开计算</li>
<li>
购买后,可在当前页面观察到流量的使用情况
</li>
<li>
购买后,直接从订阅连接里就能拉取到所有的独享节点
</li>
<li>购买后,可在当前页面观察到流量的使用情况</li>
<li>购买后,直接从订阅连接里就能拉取到所有的独享节点</li>
</ul>
</div>
</div>
Expand Down Expand Up @@ -46,9 +42,9 @@ <h1 class="title">独享节点</h1>
</li>
</ul>
</div>
<div class="#-table" id="id-#-table-purchasable">
<div class="#-table is-active" id="id-#-table-purchasable">
{% for node in purchasable_proxy_nodes %}
<div class="#-plan {{ node.occupancy_config.color }} {{ node.occupancy_config.bulma_is_active }} ">
<div class="#-plan {{ node.occupancy_config.color }} {{ node.occupancy_config.bulma_is_active }}">
<div class="plan-header">{{ node.name }}</div>
<div class="plan-price">
<span class="plan-price-amount">
Expand Down Expand Up @@ -84,7 +80,7 @@ <h1 class="title">独享节点</h1>
</div>
<div class="#-table is-hidden" id="id-#-table-renewable">
{% for node in renewable_proxy_nodes %}
<div class="#-plan {{ node.occupancy_config.color }} {{ node.occupancy_config.bulma_is_active }} ">
<div class="#-plan {{ node.occupancy_config.color }} {{ node.occupancy_config.bulma_is_active }}">
<div class="plan-header">{{ node.name }}</div>
<div class="plan-price">
<span class="plan-price-amount">
Expand Down Expand Up @@ -126,15 +122,13 @@ <h1 class="title">独享节点</h1>
<a class="is-active" id="tab-usable">可使用</a>
<a id="tab-outdated">已过期</a>
</p>
<a class="panel-block" id="block-usable">
<div class="panel-block is-active" id="block-usable">
<table class="table is-striped is-fullwidth">
<thead>
<tr>
<th>节点</th>
<th>开始时间</th>
<th>到期时间</th>
<th>已用流量</th>
<th>总流量</th>
<th>流量进度</th>
</tr>
</thead>
Expand All @@ -144,27 +138,24 @@ <h1 class="title">独享节点</h1>
<td>{{ o.proxy_node.name }}</td>
<td>{{ o.start_time }}</td>
<td>{{ o.end_time }}</td>
<td>{{ o.human_used_traffic }}</td>
<td>{{ o.human_total_traffic }}</td>
<td>
<progress class="progress {{ o.progress_color }}"
value="{{ o.used_traffic }}"
max="{{ o.total_traffic }}"></progress>{{ o.used_percentage }}%
max="{{ o.total_traffic }}"></progress>{{ o.used_percentage }}{{ o.used_percentage }}
<span>{{ o.human_used_traffic }} / {{ o.human_total_traffic }}</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</a>
<a class="panel-block is-hidden" id="block-outdated">
</div>
<div class="panel-block is-hidden" id="block-outdated">
<table class="table is-striped is-fullwidth">
<thead>
<tr>
<th>节点</th>
<th>开始时间</th>
<th>到期时间</th>
<th>已用流量</th>
<th>总流量</th>
<th>流量进度</th>
</tr>
</thead>
Expand All @@ -174,18 +165,17 @@ <h1 class="title">独享节点</h1>
<td>{{ o.proxy_node.name }}</td>
<td>{{ o.start_time }}</td>
<td>{{ o.end_time }}</td>
<td>{{ o.human_used_traffic }}</td>
<td>{{ o.human_total_traffic }}</td>
<td>
<progress class="progress {{ o.progress_color }}"
value="{{ o.used_traffic }}"
max="{{ o.total_traffic }}"></progress>{{ o.used_percentage }}%
value="{{ o.used_traffic }}"
max="{{ o.total_traffic }}"></progress>{{ o.used_percentage }}{{ o.used_percentage }}
<span>{{ o.human_used_traffic }} / {{ o.human_total_traffic }}</span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</a>
</div>
</nav>
</div>
</div>
Expand Down

0 comments on commit c1fed29

Please # to comment.