Selector/Selector.MAUI/Pages/Now.razor

151 lines
5.4 KiB
Plaintext
Raw Normal View History

@page "/now"
@using Selector.SignalR;
2023-01-27 23:31:32 +00:00
@using System.Linq;
2023-01-23 18:11:37 +00:00
@implements IDisposable
<h1 class="text-center">Now</h1>
<div class="app text-center">
2023-01-23 18:11:37 +00:00
2023-01-27 23:31:32 +00:00
<NowPlayingCard Track="@nowCache.LastPlaying?.Track" Episode="@nowCache.LastPlaying?.Episode" />
<PlayCountCard Track="@nowCache.LastPlaying?.Track" Count="@nowCache.LastPlayCount" Username="@nowCache.LastPlayCount?.Username" />
@if (nowCache.LastPlayCount?.AlbumCountData?.Count() > 3)
2023-01-27 23:31:32 +00:00
{
<div class="chart-card card">
<RadzenChart>
<RadzenLineSeries Smooth="@smooth" Data="@nowCache.LastPlayCount.ArtistCountData" CategoryProperty="TimeStamp" Title="Artist" ValueProperty="Value" Stroke="#598556" StrokeWidth="@strokeWidth">
2023-01-27 23:31:32 +00:00
<RadzenSeriesDataLabels Visible="@showDataLabels" />
</RadzenLineSeries>
<RadzenLineSeries Smooth="@smooth" Data="@nowCache.LastPlayCount.AlbumCountData" CategoryProperty="TimeStamp" Title="Album" ValueProperty="Value" Stroke="#a34c77" StrokeWidth="@strokeWidth">
2023-01-27 23:31:32 +00:00
<RadzenSeriesDataLabels Visible="@showDataLabels" />
</RadzenLineSeries>
<RadzenLineSeries Smooth="@smooth" Data="@nowCache.LastPlayCount.TrackCountData" CategoryProperty="TimeStamp" Title="Track" ValueProperty="Value" Stroke="#7a99c2" StrokeWidth="@strokeWidth">
2023-01-27 23:31:32 +00:00
<RadzenSeriesDataLabels Visible="@showDataLabels" />
</RadzenLineSeries>
<RadzenValueAxis>
<RadzenGridLines Visible="true" />
</RadzenValueAxis>
<RadzenCategoryAxis>
<RadzenGridLines Visible="true" />
</RadzenCategoryAxis>
<RadzenLegend Position="LegendPosition.Bottom" />
2023-01-27 23:31:32 +00:00
</RadzenChart>
</div>
}
@if (nowCache.LastPlayCount?.TrackCountData?.Count() > 3)
{
<div class="chart-card card">
<h2>Track History</h2>
2023-01-27 23:31:32 +00:00
<RadzenChart>
<RadzenLineSeries Smooth="@smooth" Data="@nowCache.LastPlayCount.TrackCountData" CategoryProperty="TimeStamp" Title="Track" ValueProperty="Value" Stroke="#7a99c2" StrokeWidth="@strokeWidth">
2023-01-27 23:31:32 +00:00
<RadzenSeriesDataLabels Visible="@showDataLabels" />
</RadzenLineSeries>
<RadzenValueAxis>
<RadzenGridLines Visible="true" />
</RadzenValueAxis>
<RadzenCategoryAxis>
<RadzenGridLines Visible="true" />
</RadzenCategoryAxis>
<RadzenLegend Visible="false" />
2023-01-27 23:31:32 +00:00
</RadzenChart>
</div>
}
@if (nowCache.LastPlayCount?.AlbumCountData?.Count() > 3)
{
<div class="chart-card card">
<h2>Album History</h2>
2023-01-27 23:31:32 +00:00
<RadzenChart>
<RadzenLineSeries Smooth="@smooth" Data="@nowCache.LastPlayCount.AlbumCountData" CategoryProperty="TimeStamp" Title="Album" ValueProperty="Value" Stroke="#a34c77" StrokeWidth="@strokeWidth">
2023-01-27 23:31:32 +00:00
<RadzenSeriesDataLabels Visible="@showDataLabels" />
</RadzenLineSeries>
<RadzenValueAxis>
<RadzenGridLines Visible="true" />
</RadzenValueAxis>
<RadzenCategoryAxis>
<RadzenGridLines Visible="true" />
</RadzenCategoryAxis>
<RadzenLegend Visible="false" />
2023-01-27 23:31:32 +00:00
</RadzenChart>
</div>
}
@if (nowCache.LastPlayCount?.ArtistCountData?.Count() > 3)
{
<div class="chart-card card">
<h2>Artist History</h2>
2023-01-27 23:31:32 +00:00
<RadzenChart>
<RadzenLineSeries Smooth="@smooth" Data="@nowCache.LastPlayCount.ArtistCountData" CategoryProperty="TimeStamp" Title="Artist" ValueProperty="Value" Stroke="#598556" StrokeWidth="@strokeWidth">
2023-01-27 23:31:32 +00:00
<RadzenSeriesDataLabels Visible="@showDataLabels" />
</RadzenLineSeries>
<RadzenValueAxis>
<RadzenGridLines Visible="true" />
</RadzenValueAxis>
<RadzenCategoryAxis>
<RadzenGridLines Visible="true" />
</RadzenCategoryAxis>
<RadzenLegend Visible="false" />
2023-01-27 23:31:32 +00:00
</RadzenChart>
</div>
}
</div>
<div class="v-space"></div>
@code {
[Inject]
private NowHubCache nowCache { get; set; }
2023-01-23 18:11:37 +00:00
2023-01-27 23:31:32 +00:00
private bool smooth = true;
private bool showDataLabels = false;
private double strokeWidth = 5;
protected override void OnInitialized()
2023-01-23 18:11:37 +00:00
{
nowCache.NewNowPlaying += OnNewPlaying;
nowCache.NewCard += OnNewCard;
nowCache.NewPlayCount += OnNewPlayCount;
nowCache.NewAudioFeature += OnNewAudioFeature;
}
private void OnNewPlaying(object sender, EventArgs args)
{
Update();
}
private void OnNewCard(object sender, EventArgs args)
{
Update();
}
private void OnNewPlayCount(object sender, EventArgs args)
{
Update();
}
private void OnNewAudioFeature(object sender, EventArgs args)
{
Update();
}
public void Update()
{
Application.Current.Dispatcher.Dispatch(() =>
{
StateHasChanged();
});
}
public void Dispose()
{
nowCache.NewNowPlaying -= OnNewPlaying;
nowCache.NewCard -= OnNewCard;
nowCache.NewPlayCount -= OnNewPlayCount;
nowCache.NewAudioFeature -= OnNewAudioFeature;
}
}