From 24e661252cff760c34e3ac9e67f9489fa6c1b780 Mon Sep 17 00:00:00 2001 From: MahanCh Date: Tue, 6 May 2025 17:20:20 +0330 Subject: [PATCH] add sms report loading --- ServiceHost/Areas/Admin/Pages/Index.cshtml | 66 ++++++++++--------- ServiceHost/Areas/Admin/Pages/Index.cshtml.cs | 9 ++- .../AssetsAdmin/page/Index/js/Index.js | 21 +++++- 3 files changed, 63 insertions(+), 33 deletions(-) diff --git a/ServiceHost/Areas/Admin/Pages/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Index.cshtml index b6a40be7..a36a3d4b 100644 --- a/ServiceHost/Areas/Admin/Pages/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Index.cshtml @@ -240,35 +240,38 @@
-
-
-
-
- -
- @*
مقدار اعتبار فعلی
*@ -
sms.ir
-
-
+
+
+
+
+ +
+ @*
مقدار اعتبار فعلی
*@ +
sms.ir
+
+
-
-
- پیامک باقیمانده - خطا در ای پی آی -
+
+
+ پیامک باقیمانده + +
- -
- -
-
-
+ +
+
+ +
+
+
+
+
@@ -793,10 +796,11 @@ { -@* *@ + var smsRemainingUrl = `@Url.Page("./Index", "SmsRemaining")`; + // var ajaxDataReport = `@Url.Page("./Index", "ReportDataAjax")`; + // var boolPermissionForReports = @(authHelper.GetPermissions().Any(x => x == 306) ? "true" : "false"); + } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs index 8ea4df36..005eb483 100644 --- a/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs @@ -48,7 +48,6 @@ namespace ServiceHost.Areas.Admin.Pages public string FolderPath; public int TaskCount; public int TicketCount; - public int SmsRemaining; public IndexModel(IWebHostEnvironment webHostEnvironment, IConfiguration configuration, IAuthHelper authHelper, IReportApplication reportApplication, IYearlySalaryApplication yearlySalaryApplication, IWorkshopApplication workshopApplication, IAccountApplication accountApplication, ITaskApplication taskApplication, ITicketApplication ticketApplication, ISmsService smsService) { @@ -89,6 +88,14 @@ namespace ServiceHost.Areas.Admin.Pages // Console.WriteLine(Path.GetFileName(fileEntry)); //} } + public async Task OnGetSmsRemaining() + { + var result = (int)await _smsService.GetCreditAmount(); + return new JsonResult(new + { + data = result + }); + } public async Task OnGetReportDataAjax() { diff --git a/ServiceHost/wwwroot/AssetsAdmin/page/Index/js/Index.js b/ServiceHost/wwwroot/AssetsAdmin/page/Index/js/Index.js index 2e3e24f0..6f299c25 100644 --- a/ServiceHost/wwwroot/AssetsAdmin/page/Index/js/Index.js +++ b/ServiceHost/wwwroot/AssetsAdmin/page/Index/js/Index.js @@ -5,12 +5,31 @@ loadingDiv.show(); }); - updateAmountColor(); + loadSmsRemaining(); //if (boolPermissionForReports) { // ReportAjaxData(); //} }); +function loadSmsRemaining() { + $.ajax({ + async: true, + contentType: 'charset=utf-8', + dataType: 'json', + type: 'GET', + url: smsRemainingUrl, + headers: { "RequestVerificationToken": antiForgeryToken }, + success: function (response) { + $('#amountSms').text(response.data); + $('#loadingSmsRemaining').hide(); + updateAmountColor(); + }, + error: function (xhr, status, error) { + console.error(xhr.responseText); + } + }); +} + function updateAmountColor() { const amountDiv = document.querySelector("#amountSms"); const smsDiv = document.getElementById('smsDiv');