Add device page filter
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Simon 2021-10-05 23:43:23 +01:00
parent 26017568f0
commit d7c38191ce
4 changed files with 7 additions and 9 deletions

View File

@ -25,11 +25,12 @@ namespace ManagementPage.Pages
humidity = new List<DataSet>(); humidity = new List<DataSet>();
temperature = new List<DataSet>(); temperature = new List<DataSet>();
_dbClient = dbClient; _dbClient = dbClient;
device = new DeviceData("","",0);
} }
public async Task<IActionResult> OnGetAsync() public async Task<IActionResult> OnGetAsync()
{ {
var deviceId = 0l ; var deviceId = 0L;
try try
{ {
var idString = (string?)RouteData.Values.Where(k => k.Key == "id")?.First().Value; var idString = (string?)RouteData.Values.Where(k => k.Key == "id")?.First().Value;

View File

@ -50,7 +50,7 @@
<footer class="border-top footer text-muted"> <footer class="border-top footer text-muted">
<div class="container"> <div class="container">
&copy; 2021 - ManagementPage - <a asp-area="" asp-page="/Privacy">Privacy</a> &copy; 2021 - 51m0n</a>
</div> </div>
</footer> </footer>

View File

@ -44,12 +44,9 @@ namespace ManagementPage.Pages
var id = await binder.GetLocalAccount(User.FindFirstValue(ClaimTypes.NameIdentifier)); var id = await binder.GetLocalAccount(User.FindFirstValue(ClaimTypes.NameIdentifier));
name = User.FindFirstValue(ClaimTypes.GivenName); name = User.FindFirstValue(ClaimTypes.GivenName);
data.Clear();
_dbClient.DeviceCollection.AsQueryable().Where(s => id.Devices.Contains(s._id)).ToArray(); data.AddRange(_dbClient.DeviceCollection.AsQueryable().Where(s => id.Devices.Contains(s._id)).ToArray());
using var cursor = await _dbClient.DeviceCollection.FindAsync(new BsonDocument());
data = cursor.ToList();
foreach (var item in data) foreach (var item in data)
{ {
@ -66,7 +63,7 @@ namespace ManagementPage.Pages
{ {
return Page(); return Page();
} }
var id = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(),4); var id = BitConverter.ToInt64(Guid.NewGuid().ToByteArray(), 4);
var device = new DeviceData(NewDevice.Name, NewDevice.Passcode, id); var device = new DeviceData(NewDevice.Name, NewDevice.Passcode, id);
device._id = ObjectId.GenerateNewId(); device._id = ObjectId.GenerateNewId();
await _dbClient.DeviceCollection.InsertOneAsync(device); await _dbClient.DeviceCollection.InsertOneAsync(device);

View File

@ -14,7 +14,7 @@
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },
"applicationUrl": "https://environment.51m0n.com;http://+:80", "applicationUrl": "https://localhost:443;http://+:80",
"dotnetRunMessages": true "dotnetRunMessages": true
}, },
"IIS Express": { "IIS Express": {