Enhance promo code management and user statistics features

- Introduced a unified promo code management system, allowing admins to view and manage both active and inactive promo codes with detailed information.
- Updated the promo code detail view to include status indicators and management options for editing, toggling status, and viewing activation history.
- Enhanced user statistics display by restructuring the information layout and adding new labels for clarity.
- Improved localization files to support new messages and labels related to promo code management and user statistics.
- Implemented error handling for suspicious promo code attempts, integrating a notification system for better admin awareness.
This commit is contained in:
machka-pasla
2025-08-03 21:09:03 +03:00
parent aa97618165
commit a5b408d204
11 changed files with 442 additions and 108 deletions
+11 -29
View File
@@ -470,41 +470,23 @@ class PanelApiService:
return await panel_sync_dal.get_panel_sync_status(session)
async def get_panel_statistics(self) -> Optional[Dict[str, Any]]:
"""Get general panel statistics"""
response_data = await self._request("GET", "/admin/stats", log_full_response=False)
async def get_system_stats(self) -> Optional[Dict[str, Any]]:
"""Get system statistics (CPU, memory, users counts)"""
response_data = await self._request("GET", "/system/stats", log_full_response=False)
if response_data and not response_data.get("error") and "response" in response_data:
return response_data.get("response")
return None
async def get_bandwidth_stats(self) -> Optional[Dict[str, Any]]:
"""Get bandwidth statistics"""
response_data = await self._request("GET", "/system/stats/bandwidth", log_full_response=False)
if response_data and not response_data.get("error") and "response" in response_data:
return response_data.get("response")
return None
async def get_nodes_statistics(self) -> Optional[List[Dict[str, Any]]]:
async def get_nodes_statistics(self) -> Optional[Dict[str, Any]]:
"""Get nodes statistics"""
response_data = await self._request("GET", "/admin/nodes/stats", log_full_response=False)
if response_data and not response_data.get("error") and "response" in response_data:
return response_data.get("response", {}).get("nodes", [])
return None
async def get_system_info(self) -> Optional[Dict[str, Any]]:
"""Get system information"""
response_data = await self._request("GET", "/admin/system/info", log_full_response=False)
if response_data and not response_data.get("error") and "response" in response_data:
return response_data.get("response")
return None
async def get_online_users_count(self) -> Optional[int]:
"""Get count of currently online users"""
response_data = await self._request("GET", "/admin/stats/online-users", log_full_response=False)
if response_data and not response_data.get("error") and "response" in response_data:
return response_data.get("response", {}).get("count", 0)
return None
async def get_users_activity_stats(self) -> Optional[Dict[str, Any]]:
"""Get users activity statistics (today, week, never connected)"""
response_data = await self._request("GET", "/admin/stats/users-activity", log_full_response=False)
response_data = await self._request("GET", "/system/stats/nodes", log_full_response=False)
if response_data and not response_data.get("error") and "response" in response_data:
return response_data.get("response")
return None