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

@@ -49,14 +49,20 @@ public partial class LdapService : IDisposable
public string[] AssetsAttributes => ["CN", "description", "l", "owner", "serialNumber", "name"];
public string[] LocationsAttributes => ["cn", "l", "street", "description"];
public string[] GroupsAttributes => ["cn", "gidNumber", "description"];
public async Task<IEnumerable<Dictionary<string, string>>> ListLocationsAsync()
public async Task<IEnumerable<LocationModel>> ListLocationsAsync()
{
return await ListObjectBy(LocationsBaseDn, "", LocationsAttributes);
IEnumerable<Dictionary<string, string>> locations = await ListObjectBy(LocationsBaseDn, "", LocationsAttributes);
List<LocationModel> models = [];
locations.ToList().ForEach(x => models.Add(new LocationModel(x) {Cn = x["cn"]}));
return models;
}
public async Task<IEnumerable<Dictionary<string, string>>> ListUsersAsync()
public async Task<IEnumerable<UserModel>> ListUsersAsync()
{
return await ListObjectBy(UsersBaseDn, "", UsersAttributes);
IEnumerable<Dictionary<string, string>> users = await ListObjectBy(UsersBaseDn, "", UsersAttributes);
List<UserModel> models = [];
users.ToList().ForEach(x => models.Add(new UserModel(x) {Uid = x["uid"]}));
return models;
}
public async Task<MigrationModel> GetMigrationVersionAsync()
@@ -158,9 +164,12 @@ public partial class LdapService : IDisposable
return new AssetModel((await ListObjectBy(AssetsBaseDn, $"cn={cn}", attributes)).First()) { Cn = cn };
}
public async Task<IEnumerable<Dictionary<string, string>>> ListDeviceAsync()
public async Task<IEnumerable<AssetModel>> ListDeviceAsync()
{
return await ListObjectBy(AssetsBaseDn, "(objectClass=device)", AssetsAttributes);
IEnumerable<Dictionary<string, string>> devices = await ListObjectBy(AssetsBaseDn, "(objectClass=device)", AssetsAttributes);
List<AssetModel> models = [];
devices.ToList().ForEach(x => models.Add(new AssetModel(x) {Cn = x["cn"]}));
return models;
}
public async Task CreateUser(string uid, LdapAttributeSet attributeSet)