Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62afd65
commit fb3a7bd
Showing
42 changed files
with
541 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
@using Monitor.Models | ||
@using System.Globalization | ||
|
||
<Card Title="@Title"> | ||
<Body> | ||
<GridRow Align="center"> | ||
@if (ShowMin) | ||
{ | ||
<GridCol Xs="24" Sm="@SizeMd"> | ||
<Statistic Title="Min aujourd'hui" Value="@GetValue(Data.TotalToday.Min)" Suffix="@Suffix" /> | ||
</GridCol> | ||
} | ||
<GridCol Xs="24" Sm="@SizeMd"> | ||
<Statistic Title="Moyenne aujourd'hui" Value="@GetValue(Data.TotalToday.Average)" Suffix="@Suffix" /> | ||
</GridCol> | ||
<GridCol Xs="24" Sm="@SizeMd"> | ||
<Statistic Title="Max aujourd'hui" Value="@GetValue(Data.TotalToday.Max)" Suffix="@Suffix" /> | ||
</GridCol> | ||
</GridRow> | ||
<GridRow> | ||
@if (ShowMin) | ||
{ | ||
<GridCol Xs="24" Sm="@SizeMd"> | ||
<Statistic Title="Min hier" Value="@GetValue(Data.TotalYesterday.Min)" Suffix="@Suffix" /> | ||
</GridCol> | ||
} | ||
<GridCol Xs="24" Sm="@SizeMd"> | ||
<Statistic Title="Moyenne hier" Value="@GetValue(Data.TotalYesterday.Average)" Suffix="@Suffix" /> | ||
</GridCol> | ||
<GridCol Xs="24" Sm="@SizeMd"> | ||
<Statistic Title="Max hier" Value="@GetValue(Data.TotalYesterday.Max)" Suffix="@Suffix" /> | ||
</GridCol> | ||
</GridRow> | ||
<GridRow> | ||
@if (ShowMin) | ||
{ | ||
<GridCol Xs="24" Sm="@SizeMd"> | ||
<Statistic Title="Min" Value="@GetValue(Data.Total.Min)" Suffix="@Suffix" /> | ||
</GridCol> | ||
} | ||
<GridCol Xs="24" Sm="@SizeMd"> | ||
<Statistic Title="Moyenne" Value="@GetValue(Data.Total.Average)" Suffix="@Suffix" /> | ||
</GridCol> | ||
<GridCol Xs="24" Sm="@SizeMd"> | ||
<Statistic Title="Max" Value="@GetValue(Data.Total.Max)" Suffix="@Suffix" /> | ||
</GridCol> | ||
</GridRow> | ||
</Body> | ||
</Card> | ||
|
||
@code { | ||
[Parameter] | ||
public required StatsView Data { get; set; } | ||
|
||
[Parameter] | ||
public required string Title { get; set; } | ||
|
||
[Parameter] | ||
public string? Suffix { get; set; } | ||
|
||
[Parameter] | ||
public bool ShowMin { get; set; } = true; | ||
|
||
[Parameter] | ||
public Type Type { get; set; } = typeof(double); | ||
|
||
private int SizeMd => ShowMin ? 8 : 12; | ||
|
||
private string GetValue(double value) | ||
{ | ||
if (Type == typeof(DateTime)) | ||
{ | ||
return DateTimeOffset.FromUnixTimeSeconds((long)value).ToString("dd/MM HH:mm:ss", CultureInfo.CurrentCulture); | ||
} | ||
|
||
if (Type == typeof(TimeSpan)) | ||
{ | ||
return TimeSpan.FromSeconds(value).ToString(); | ||
} | ||
|
||
return value.ToString(CultureInfo.CurrentCulture); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
namespace Monitor.Models; | ||
|
||
public class StatsView | ||
{ | ||
public class UnitData | ||
{ | ||
public DateTime DateTime { get; set; } | ||
|
||
public double Value { get; set; } | ||
} | ||
|
||
public class Data | ||
{ | ||
public double Average { get; set; } | ||
public double Min { get; set; } | ||
public double Max { get; set; } | ||
|
||
public void FromData(IQueryable<UnitData> data) | ||
{ | ||
if (data.Any()) | ||
{ | ||
Average = Math.Round(data.Average(d => d.Value), 2); | ||
Min = Math.Round(data.Min(d => d.Value), 2); | ||
Max = Math.Round(data.Max(d => d.Value), 2); | ||
} | ||
} | ||
} | ||
|
||
public Data Total { get; set; } = new(); | ||
public Data TotalToday { get; set; } = new(); | ||
public Data TotalYesterday { get; set; } = new(); | ||
|
||
public void FromData(IQueryable<UnitData> data) | ||
{ | ||
Total.FromData(data); | ||
|
||
var today = DateTime.Today; | ||
var yesterday = DateTime.Today.AddDays(-1); | ||
|
||
TotalToday.FromData(data.Where(d => d.DateTime.Date == today)); | ||
TotalYesterday.FromData(data.Where(d => d.DateTime.Date == yesterday)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Monitor.Services; | ||
|
||
namespace Monitor; | ||
|
||
public class MqttConnect(EntitiesManagerService entitiesManagerService) : BackgroundService | ||
{ | ||
protected override async Task ExecuteAsync(CancellationToken cancellationToken) | ||
{ | ||
await entitiesManagerService.ConnectMqtt(); | ||
} | ||
} |
Oops, something went wrong.