diff --git a/core/scripts/webpanel/assets/js/users.js b/core/scripts/webpanel/assets/js/users.js index 0abab355..fa516887 100644 --- a/core/scripts/webpanel/assets/js/users.js +++ b/core/scripts/webpanel/assets/js/users.js @@ -180,10 +180,10 @@ $(function () { $("#userTable tbody tr.user-main-row").each(function () { let showRow; switch (filter) { - case "on-hold": showRow = $(this).find("td:eq(3) i").hasClass("text-warning"); break; - case "online": showRow = $(this).find("td:eq(3) i").hasClass("text-success"); break; - case "enable": showRow = $(this).find("td:eq(8) i").hasClass("text-success"); break; - case "disable": showRow = $(this).find("td:eq(8) i").hasClass("text-danger"); break; + case "on-hold": showRow = $(this).find("td.status-cell i").hasClass("text-warning"); break; + case "online": showRow = $(this).find("td.status-cell i").hasClass("text-success"); break; + case "enable": showRow = $(this).find("td.enable-cell i").hasClass("text-success"); break; + case "disable": showRow = $(this).find("td.enable-cell i").hasClass("text-danger"); break; default: showRow = true; } $(this).toggle(showRow).find(".user-checkbox").prop("checked", false); @@ -278,10 +278,11 @@ $(function () { const dataRow = $(event.relatedTarget).closest("tr.user-main-row"); const url = GET_USER_URL_TEMPLATE.replace('U', user); - const trafficText = dataRow.find("td:eq(4)").text(); - const expiryText = dataRow.find("td:eq(6)").text(); + const trafficText = dataRow.find("td.traffic-cell").text(); + const usageDaysText = dataRow.find("td.usage-days-cell").text(); + const expiryText = usageDaysText.split('/')[1] || "0"; 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(''); $('#editExpirationDaysError').text(''); @@ -298,7 +299,7 @@ $(function () { } $("#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")); const passwordInput = $("#editPassword"); diff --git a/core/scripts/webpanel/routers/user/viewmodel.py b/core/scripts/webpanel/routers/user/viewmodel.py index ab193650..3a0d0848 100644 --- a/core/scripts/webpanel/routers/user/viewmodel.py +++ b/core/scripts/webpanel/routers/user/viewmodel.py @@ -10,6 +10,7 @@ class User(BaseModel): expiry_date: str expiry_days: str day_usage: str + usage_days_display: str enable: bool unlimited_ip: bool online_count: int = 0 @@ -88,6 +89,7 @@ def __parse_user_data(user_data: dict) -> dict: percentage = (used_bytes / quota_bytes) * 100 traffic_used_display = f"{used_formatted}/{quota_formatted} ({percentage:.1f}%)" + usage_days_display = f"{day_usage}/{display_expiry_days}" return { 'username': user_data['username'], @@ -97,6 +99,7 @@ def __parse_user_data(user_data: dict) -> dict: 'expiry_date': display_expiry_date, 'expiry_days': display_expiry_days, 'day_usage': day_usage, + 'usage_days_display': usage_days_display, 'enable': not user_data.get('blocked', False), 'unlimited_ip': user_data.get('unlimited_user', False), 'online_count': user_data.get('online_count', 0), diff --git a/core/scripts/webpanel/templates/users.html b/core/scripts/webpanel/templates/users.html index f342e92d..4699e191 100644 --- a/core/scripts/webpanel/templates/users.html +++ b/core/scripts/webpanel/templates/users.html @@ -128,9 +128,8 @@

User List {% if total_users is defined %}(Status Traffic Usage - Expiry Date - Expiry Days Day Usage + Expiry Date Enable Note Unlimited IP diff --git a/core/scripts/webpanel/templates/users_rows.html b/core/scripts/webpanel/templates/users_rows.html index 4e367108..ff473eff 100644 --- a/core/scripts/webpanel/templates/users_rows.html +++ b/core/scripts/webpanel/templates/users_rows.html @@ -12,7 +12,7 @@ {{ loop.index + (offset if offset is defined else 0) }} {{ user.username }} - + {% if user.status == "Online" %} Online {% if user.online_count and user.online_count > 0 %} @@ -28,11 +28,10 @@ {{ user.status }} {% endif %} - {{ user.traffic_used }} - {{ user.expiry_date }} - {{ user.expiry_days }} - {{ user.day_usage }} - + {{ user.traffic_used }} + {{ user.usage_days_display }} + {{ user.expiry_date }} + {% if user.enable %} {% else %} @@ -100,9 +99,8 @@

Traffic Usage: {{ user.traffic_used }}

+

Day Usage: {{ user.usage_days_display }}

Expiry Date: {{ user.expiry_date }}

-

Expiry Days: {{ user.expiry_days }}

-

Day Usage: {{ user.day_usage }}

Note: {{ user.note or 'N/A' }}

Enable: