Implemented live asset table in /Home/Index

This commit is contained in:
2025-10-05 21:29:17 +02:00
parent ee44b7d8c8
commit 43cac9e304
7 changed files with 60 additions and 50 deletions

View File

@@ -19,7 +19,7 @@ public class AssetsController : Controller
}
[HttpGet("Index")]
public async Task<IEnumerable<Dictionary<string, string>>> Index()
public async Task<IEnumerable<AssetModel>> Index()
{
var list = await _ldap.ListDeviceAsync();
return list;

View File

@@ -22,9 +22,23 @@ public class HomeController : Controller
[Authorize]
[HttpGet("Index")]
[HttpGet("/")]
public IActionResult Index()
public async Task<IActionResult> Index()
{
return View();
IEnumerable<UserModel> users = await _ldap.ListUsersAsync();
IEnumerable<AssetModel> assets = await _ldap.ListDeviceAsync();
IEnumerable<LocationModel> locations = await _ldap.ListLocationsAsync();
List<AssetsTableViewModel> assetsTableViewModels = [];
foreach (AssetModel asset in assets)
{
assetsTableViewModels.Add(new()
{
AssetCn = asset.Cn,
AssetName = asset.Name,
LocationName = asset.Location,
UserUID = asset.Owner?.Split('=')[1],
});
}
return View(new HomeIndexViewModel() { AssetsTableViewModels = assetsTableViewModels });
}
[HttpPost("Login")]

View File

@@ -18,9 +18,9 @@ public class LocationsController : Controller
}
[HttpGet("Index")]
public async Task<IEnumerable<Dictionary<string, string>>> Index()
public async Task<IEnumerable<LocationModel>> Index()
{
IEnumerable<Dictionary<string, string>> list = await _ldap.ListLocationsAsync();
IEnumerable<LocationModel> list = await _ldap.ListLocationsAsync();
return list;
}