Merge pull request #364 from SeyedHashtag/ordev3

Update user display to show usage days and remove expiry days column
This commit is contained in:
Whispering Wind
2026-01-06 22:12:31 +01:00
committed by GitHub
4 changed files with 19 additions and 18 deletions

View File

@ -180,10 +180,10 @@ $(function () {
$("#userTable tbody tr.user-main-row").each(function () { $("#userTable tbody tr.user-main-row").each(function () {
let showRow; let showRow;
switch (filter) { switch (filter) {
case "on-hold": showRow = $(this).find("td:eq(3) i").hasClass("text-warning"); break; case "on-hold": showRow = $(this).find("td.status-cell i").hasClass("text-warning"); break;
case "online": showRow = $(this).find("td:eq(3) i").hasClass("text-success"); break; case "online": showRow = $(this).find("td.status-cell i").hasClass("text-success"); break;
case "enable": showRow = $(this).find("td:eq(8) i").hasClass("text-success"); break; case "enable": showRow = $(this).find("td.enable-cell i").hasClass("text-success"); break;
case "disable": showRow = $(this).find("td:eq(8) i").hasClass("text-danger"); break; case "disable": showRow = $(this).find("td.enable-cell i").hasClass("text-danger"); break;
default: showRow = true; default: showRow = true;
} }
$(this).toggle(showRow).find(".user-checkbox").prop("checked", false); $(this).toggle(showRow).find(".user-checkbox").prop("checked", false);
@ -278,10 +278,11 @@ $(function () {
const dataRow = $(event.relatedTarget).closest("tr.user-main-row"); const dataRow = $(event.relatedTarget).closest("tr.user-main-row");
const url = GET_USER_URL_TEMPLATE.replace('U', user); const url = GET_USER_URL_TEMPLATE.replace('U', user);
const trafficText = dataRow.find("td:eq(4)").text(); const trafficText = dataRow.find("td.traffic-cell").text();
const expiryText = dataRow.find("td:eq(6)").text(); const usageDaysText = dataRow.find("td.usage-days-cell").text();
const expiryText = usageDaysText.split('/')[1] || "0";
const note = dataRow.data('note'); const note = dataRow.data('note');
const statusText = dataRow.find("td:eq(3)").text().trim(); const statusText = dataRow.find("td.status-cell").text().trim();
$('#editPasswordError').text(''); $('#editPasswordError').text('');
$('#editExpirationDaysError').text(''); $('#editExpirationDaysError').text('');
@ -298,7 +299,7 @@ $(function () {
} }
$("#editNote").val(note || ''); $("#editNote").val(note || '');
$("#editBlocked").prop("checked", !dataRow.find("td:eq(8) i").hasClass("text-success")); $("#editBlocked").prop("checked", !dataRow.find("td.enable-cell i").hasClass("text-success"));
$("#editUnlimitedIp").prop("checked", dataRow.find(".unlimited-ip-cell i").hasClass("text-primary")); $("#editUnlimitedIp").prop("checked", dataRow.find(".unlimited-ip-cell i").hasClass("text-primary"));
const passwordInput = $("#editPassword"); const passwordInput = $("#editPassword");

View File

@ -10,6 +10,7 @@ class User(BaseModel):
expiry_date: str expiry_date: str
expiry_days: str expiry_days: str
day_usage: str day_usage: str
usage_days_display: str
enable: bool enable: bool
unlimited_ip: bool unlimited_ip: bool
online_count: int = 0 online_count: int = 0
@ -88,6 +89,7 @@ class User(BaseModel):
percentage = (used_bytes / quota_bytes) * 100 percentage = (used_bytes / quota_bytes) * 100
traffic_used_display = f"{used_formatted}/{quota_formatted} ({percentage:.1f}%)" traffic_used_display = f"{used_formatted}/{quota_formatted} ({percentage:.1f}%)"
usage_days_display = f"{day_usage}/{display_expiry_days}"
return { return {
'username': user_data['username'], 'username': user_data['username'],
@ -97,6 +99,7 @@ class User(BaseModel):
'expiry_date': display_expiry_date, 'expiry_date': display_expiry_date,
'expiry_days': display_expiry_days, 'expiry_days': display_expiry_days,
'day_usage': day_usage, 'day_usage': day_usage,
'usage_days_display': usage_days_display,
'enable': not user_data.get('blocked', False), 'enable': not user_data.get('blocked', False),
'unlimited_ip': user_data.get('unlimited_user', False), 'unlimited_ip': user_data.get('unlimited_user', False),
'online_count': user_data.get('online_count', 0), 'online_count': user_data.get('online_count', 0),

View File

@ -128,9 +128,8 @@
<th>Username</th> <th>Username</th>
<th class="d-none d-md-table-cell">Status</th> <th class="d-none d-md-table-cell">Status</th>
<th class="d-none d-md-table-cell">Traffic Usage</th> <th class="d-none d-md-table-cell">Traffic Usage</th>
<th class="d-none d-md-table-cell text-nowrap">Expiry Date</th>
<th class="d-none d-md-table-cell text-nowrap">Expiry Days</th>
<th class="d-none d-md-table-cell text-nowrap">Day Usage</th> <th class="d-none d-md-table-cell text-nowrap">Day Usage</th>
<th class="d-none d-md-table-cell text-nowrap">Expiry Date</th>
<th class="d-none d-md-table-cell">Enable</th> <th class="d-none d-md-table-cell">Enable</th>
<th class="d-none d-md-table-cell">Note</th> <th class="d-none d-md-table-cell">Note</th>
<th class="d-none d-md-table-cell text-nowrap requires-iplimit-service" style="display: none;">Unlimited IP</th> <th class="d-none d-md-table-cell text-nowrap requires-iplimit-service" style="display: none;">Unlimited IP</th>

View File

@ -12,7 +12,7 @@
</td> </td>
<td>{{ loop.index + (offset if offset is defined else 0) }}</td> <td>{{ loop.index + (offset if offset is defined else 0) }}</td>
<td data-username="{{ user.username }}">{{ user.username }}</td> <td data-username="{{ user.username }}">{{ user.username }}</td>
<td class="d-none d-md-table-cell"> <td class="d-none d-md-table-cell status-cell">
{% if user.status == "Online" %} {% if user.status == "Online" %}
<i class="fas fa-circle text-success"></i> Online <i class="fas fa-circle text-success"></i> Online
{% if user.online_count and user.online_count > 0 %} {% if user.online_count and user.online_count > 0 %}
@ -28,11 +28,10 @@
<i class="fas fa-circle text-danger"></i> {{ user.status }} <i class="fas fa-circle text-danger"></i> {{ user.status }}
{% endif %} {% endif %}
</td> </td>
<td class="d-none d-md-table-cell">{{ user.traffic_used }}</td> <td class="d-none d-md-table-cell traffic-cell">{{ user.traffic_used }}</td>
<td class="d-none d-md-table-cell">{{ user.expiry_date }}</td> <td class="d-none d-md-table-cell usage-days-cell">{{ user.usage_days_display }}</td>
<td class="d-none d-md-table-cell">{{ user.expiry_days }}</td> <td class="d-none d-md-table-cell expiry-date-cell">{{ user.expiry_date }}</td>
<td class="d-none d-md-table-cell">{{ user.day_usage }}</td> <td class="d-none d-md-table-cell enable-cell">
<td class="d-none d-md-table-cell">
{% if user.enable %} {% if user.enable %}
<i class="fas fa-check-circle text-success"></i> <i class="fas fa-check-circle text-success"></i>
{% else %} {% else %}
@ -100,9 +99,8 @@
</span> </span>
</p> </p>
<p><strong>Traffic Usage:</strong> <span>{{ user.traffic_used }}</span></p> <p><strong>Traffic Usage:</strong> <span>{{ user.traffic_used }}</span></p>
<p><strong>Day Usage:</strong> <span>{{ user.usage_days_display }}</span></p>
<p><strong>Expiry Date:</strong> <span>{{ user.expiry_date }}</span></p> <p><strong>Expiry Date:</strong> <span>{{ user.expiry_date }}</span></p>
<p><strong>Expiry Days:</strong> <span>{{ user.expiry_days }}</span></p>
<p><strong>Day Usage:</strong> <span>{{ user.day_usage }}</span></p>
<p><strong>Note:</strong> <span>{{ user.note or 'N/A' }}</span></p> <p><strong>Note:</strong> <span>{{ user.note or 'N/A' }}</span></p>
<p><strong>Enable:</strong> <p><strong>Enable:</strong>
<span> <span>