update visitor realtime
parent
2ce8dd4748
commit
c160b15e2f
|
@ -46,6 +46,20 @@ namespace YourApp.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("active-users")]
|
||||||
|
public async Task<IActionResult> GetActiveUsers()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var data = await GetVisitorDataFromApiAsync();
|
||||||
|
return Ok(new { activeUsers = data.realtime });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return StatusCode(500, new { message = "Error fetching active users data", details = ex.Message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("visitor-stats")]
|
[HttpGet("visitor-stats")]
|
||||||
public async Task<IActionResult> GetVisitorStats()
|
public async Task<IActionResult> GetVisitorStats()
|
||||||
{
|
{
|
||||||
|
@ -57,6 +71,7 @@ namespace YourApp.Controllers
|
||||||
{
|
{
|
||||||
dailyVisitorCount = data.visitors.harian,
|
dailyVisitorCount = data.visitors.harian,
|
||||||
monthlyVisitorCount = data.visitors.bulanan,
|
monthlyVisitorCount = data.visitors.bulanan,
|
||||||
|
activeUsers = data.realtime,
|
||||||
lastUpdated = DateTime.UtcNow
|
lastUpdated = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,8 +116,9 @@ namespace YourApp.Controllers
|
||||||
public class ApiResponse
|
public class ApiResponse
|
||||||
{
|
{
|
||||||
public PageviewsData pageviews { get; set; }
|
public PageviewsData pageviews { get; set; }
|
||||||
public VisitorsData visits { get; set; }
|
public VisitsData visits { get; set; }
|
||||||
public visitorsData visitors { get; set; }
|
public VisitorsData visitors { get; set; }
|
||||||
|
public int realtime { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PageviewsData
|
public class PageviewsData
|
||||||
|
@ -112,17 +128,17 @@ namespace YourApp.Controllers
|
||||||
public int all { get; set; }
|
public int all { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class VisitsData
|
||||||
|
{
|
||||||
|
public int harian { get; set; }
|
||||||
|
public int bulanan { get; set; }
|
||||||
|
public int all { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class VisitorsData
|
public class VisitorsData
|
||||||
{
|
{
|
||||||
public int harian { get; set; }
|
public int harian { get; set; }
|
||||||
public int bulanan { get; set; }
|
public int bulanan { get; set; }
|
||||||
public int all { get; set; }
|
public int all { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class visitorsData
|
|
||||||
{
|
|
||||||
public int harian { get; set; }
|
|
||||||
public int bulanan { get; set; }
|
|
||||||
public int all { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -25,28 +25,40 @@
|
||||||
<p class="text-green-100 text-lg leading-relaxed max-w-sm mx-auto lg:mx-0">
|
<p class="text-green-100 text-lg leading-relaxed max-w-sm mx-auto lg:mx-0">
|
||||||
Bersama membangun Jakarta yang hijau dan berkelanjutan untuk generasi mendatang
|
Bersama membangun Jakarta yang hijau dan berkelanjutan untuk generasi mendatang
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@* Pengunjung *@
|
@* Pengunjung *@
|
||||||
<div class="flex items-center justify-center lg:justify-start space-x-3 mt-6">
|
<div class="py-6">
|
||||||
<div class="bg-white/10 backdrop-blur-sm rounded-xl p-4 border border-white/20 hover:bg-white/20 transition-all duration-300 group">
|
<div class="grid grid-cols-3 gap-2 lg:gap-3">
|
||||||
<div class="flex items-center space-x-3">
|
<div class="bg-white/10 backdrop-blur-sm rounded-xl p-3 lg:p-4 border border-white/20 hover:bg-white/20 transition-all duration-300 group">
|
||||||
<div class="w-10 h-10 bg-yellow-300/20 rounded-lg flex items-center justify-center flex-shrink-0">
|
<div class="flex flex-col items-center justify-center space-y-3">
|
||||||
<i class="text-yellow-300 w-5 h-5" data-lucide="users"></i>
|
<div class="w-8 h-8 lg:w-10 lg:h-10 bg-yellow-300/20 rounded-lg flex items-center justify-center flex-shrink-0">
|
||||||
|
<i class="text-yellow-300 w-4 h-4 lg:w-5 lg:h-5 animate-pulse" data-lucide="rss"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-left">
|
<div class="text-center">
|
||||||
<div class="text-2xl lg:text-3xl font-bold text-yellow-300 group-hover:text-yellow-200 transition-colors" id="dailyVisitors">0</div>
|
<div class="text-xl lg:text-2xl xl:text-3xl font-bold text-yellow-300 group-hover:text-yellow-200 transition-colors" id="activeUsers">0</div>
|
||||||
<div class="text-green-100 text-sm font-medium">Daily Visitor</div>
|
<div class="text-green-100 text-xs lg:text-sm font-medium">Active<br>User</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bg-white/10 backdrop-blur-sm rounded-xl p-4 border border-white/20 hover:bg-white/20 transition-all duration-300 group">
|
<div class="bg-white/10 backdrop-blur-sm rounded-xl p-3 lg:p-4 border border-white/20 hover:bg-white/20 transition-all duration-300 group">
|
||||||
<div class="flex items-center space-x-3">
|
<div class="flex flex-col items-center justify-center space-y-3">
|
||||||
<div class="w-10 h-10 bg-yellow-300/20 rounded-lg flex items-center justify-center flex-shrink-0">
|
<div class="w-8 h-8 lg:w-10 lg:h-10 bg-yellow-300/20 rounded-lg flex items-center justify-center flex-shrink-0">
|
||||||
<i class="text-yellow-300 w-5 h-5" data-lucide="trending-up"></i>
|
<i class="text-yellow-300 w-4 h-4 lg:w-5 lg:h-5 animate-pulse" data-lucide="users"></i>
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
<div class="text-xl lg:text-2xl xl:text-3xl font-bold text-yellow-300 group-hover:text-yellow-200 transition-colors" id="dailyVisitors">0</div>
|
||||||
|
<div class="text-green-100 text-xs lg:text-sm font-medium">Daily<br>Visitor</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white/10 backdrop-blur-sm rounded-xl p-3 lg:p-4 border border-white/20 hover:bg-white/20 transition-all duration-300 group">
|
||||||
|
<div class="flex flex-col items-center justify-center space-y-3">
|
||||||
|
<div class="w-8 h-8 lg:w-10 lg:h-10 bg-yellow-300/20 rounded-lg flex items-center justify-center flex-shrink-0">
|
||||||
|
<i class="text-yellow-300 w-4 h-4 lg:w-5 lg:h-5 animate-pulse" data-lucide="trending-up"></i>
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
<div class="text-xl lg:text-2xl xl:text-3xl font-bold text-yellow-300 group-hover:text-yellow-200 transition-colors" id="monthlyVisitors">0</div>
|
||||||
|
<div class="text-green-100 text-xs lg:text-sm font-medium">Monthly<br>Visitor</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-left">
|
|
||||||
<div class="text-2xl lg:text-3xl font-bold text-yellow-300 group-hover:text-yellow-200 transition-colors" id="monthlyVisitors">0</div>
|
|
||||||
<div class="text-green-100 text-sm font-medium">Monthly Visitor</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -650,19 +662,23 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
function updateVisitorCount() {
|
function updateVisitorCount() {
|
||||||
const dailyElement = document.getElementById('dailyVisitors');
|
const dailyElement = document.getElementById('dailyVisitors');
|
||||||
const monthlyElement = document.getElementById('monthlyVisitors');
|
const monthlyElement = document.getElementById('monthlyVisitors');
|
||||||
if (!dailyElement || !monthlyElement) return;
|
const activeUsersElement = document.getElementById('activeUsers');
|
||||||
|
if (!dailyElement || !monthlyElement || !activeUsersElement) return;
|
||||||
|
|
||||||
dailyElement.textContent = 'Loading...';
|
dailyElement.textContent = 'Load...';
|
||||||
monthlyElement.textContent = 'Loading...';
|
monthlyElement.textContent = 'Load...';
|
||||||
|
activeUsersElement.textContent = 'Load...';
|
||||||
|
|
||||||
fetchVisitorStats()
|
fetchVisitorStats()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
animateNumber(dailyElement, data.dailyVisitorCount || 0);
|
animateNumber(dailyElement, data.dailyVisitorCount || 0);
|
||||||
animateNumber(monthlyElement, data.monthlyVisitorCount || 0);
|
animateNumber(monthlyElement, data.monthlyVisitorCount || 0);
|
||||||
|
animateNumber(activeUsersElement, data.activeUsers || 0);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
dailyElement.textContent = 'N/A';
|
dailyElement.textContent = 'N/A';
|
||||||
monthlyElement.textContent = 'N/A';
|
monthlyElement.textContent = 'N/A';
|
||||||
|
activeUsersElement.textContent = 'N/A';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -13,7 +13,7 @@ using System.Reflection;
|
||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("dlh-net")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("dlh-net")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7b878f2f23b792ac106111be553e41fc4bf39e51")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2ce8dd4748fbcd06ff9789d46c594d47c73b4095")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("dlh-net")]
|
[assembly: System.Reflection.AssemblyProductAttribute("dlh-net")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("dlh-net")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("dlh-net")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
5ccc866dddad0e75443f0589ae496dcea3ef1157b4517bdfadf678dbcad813e6
|
594c0e71d9b1eec07dbe227fe5dc24badf0e5c38d75392e9ca7e2fc70f84a866
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue