Skip to content

Commit

Permalink
Update ProxyNode and UserInfoView to display shared and occupied node…
Browse files Browse the repository at this point in the history
… counts
  • Loading branch information
Ehco1996 committed May 9, 2024
1 parent 0d9db4f commit beafcd9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
4 changes: 4 additions & 0 deletions apps/proxy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ 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
12 changes: 11 additions & 1 deletion apps/sspanel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,24 @@ def get(self, request):
user_active_nodes_types = {node.node_type for node in user_active_nodes}
if len(user_active_nodes_types) > 1:
user_active_nodes_types.add("all")

shared_node_count = 0
occupied_node_count = 0
for node in user_active_nodes:
if node.is_shared_node:
shared_node_count += 1
else:
occupied_node_count += 1

context = {
"user": user,
"anno": anno,
"min_traffic": min_traffic,
"max_traffic": max_traffic,
"themes": THEME_CHOICES,
"sub_link": user.sub_link,
"active_node_count": user_active_nodes.count(),
"shared_node_count": shared_node_count,
"occupied_node_count": occupied_node_count,
"active_node_types": user_active_nodes_types,
"supported_clients": UserSubManager.CLIENT_SET,
"usp_list": UserSocialProfile.list_by_user_id(user.id),
Expand Down
10 changes: 9 additions & 1 deletion templates/web/node_occupancy.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
<div class="hero-body">
<div class="container">
<h1 class="title">独享节点</h1>
<h2 class="subtitle">受够了和别人共享节点?来买一个独享节点吧 :)</h2>
<ul>
<li>流量和共享节点分开计算</li>
<li>
购买后,可在当前页面观察到流量的使用情况
</li>
<li>
购买后,直接从订阅连接里就能拉取到所有的独享节点
</li>
</ul>
</div>
</div>
</section>
Expand Down
7 changes: 5 additions & 2 deletions templates/web/user_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ <h2 class="subtitle">根据您的客户端一键选择</h2>
{% else %}
<li>
状态:
<code>正常使用(可用节点{{ active_node_count }}条)</code>
<code>正常使用</code>
</li>
{% endif %}
<li>
Expand All @@ -226,9 +226,12 @@ <h2 class="subtitle">根据您的客户端一键选择</h2>
<code>{{ user.proxy_password }}</code>
</li>
<li>
到期时间:
共享节点共<span class="has-text-info">({{ shared_node_count }}条)</span>到期时间:
<code>{{ user.level_expire_time }} </code>
</li>
<li>
独享节点共<span class="has-text-info">({{ occupied_node_count }}条)</span>
</li>
<li>
上次使用时间:
<code>{{ user.last_use_time }}</code>
Expand Down

0 comments on commit beafcd9

Please sign in to comment.