-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix async for Artist_artistsWorksList remove boilerplate code clean up console statements
- Loading branch information
Showing
16 changed files
with
165 additions
and
114 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
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
21 changes: 21 additions & 0 deletions
21
RadiocomDataViewApp/Components/Sitewide/ApplicationUpdateModal.razor
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,21 @@ | ||
|
||
|
||
<Modal @ref="ApplicationUpdate" Closing="@((args) => args.Cancel = true)"> | ||
<ModalBackdrop /> | ||
<ModalContent Centered="true"> | ||
<ModalBody> | ||
|
||
<Paragraph> | ||
This application has an update. Reload the page to get it. | ||
</Paragraph> | ||
|
||
|
||
|
||
</ModalBody> | ||
<ModalFooter> | ||
</ModalFooter> | ||
</ModalContent> | ||
|
||
</Modal> | ||
|
||
|
32 changes: 32 additions & 0 deletions
32
RadiocomDataViewApp/Components/Sitewide/ApplicationUpdateModal.razor.cs
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,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Blazorise; | ||
using Microsoft.AspNetCore.Components; | ||
using RadiocomDataViewApp.Interfaces; | ||
|
||
namespace RadiocomDataViewApp.Components.Sitewide | ||
{ | ||
public partial class ApplicationUpdateModal : ComponentBase | ||
{ | ||
private Modal ApplicationUpdate; | ||
|
||
[Inject] | ||
public IUpdateService UpdateService { get; set; } | ||
|
||
|
||
protected override async Task OnParametersSetAsync() | ||
{ | ||
|
||
await base.OnParametersSetAsync(); | ||
|
||
UpdateService.OnWelcomeHasChanged += WelcomeHasChanged; | ||
} | ||
|
||
private void WelcomeHasChanged() | ||
{ | ||
ApplicationUpdate.Show(); | ||
} | ||
} | ||
} |
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,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace RadiocomDataViewApp.Interfaces | ||
{ | ||
public interface IUpdateService | ||
{ | ||
public event Action OnWelcomeHasChanged; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
@page "/artist/{ArtistId:int}/artistworks" | ||
@{ | ||
} | ||
<h3>All Songs by @_artistName</h3> | ||
|
||
@if (_artistWorkInfos != null) | ||
{ | ||
|
||
<ListComponent TItem="ArtistWorkDisplay" Items="@_artistWorkInfos.Select(x=> new ArtistWorkDisplay(x)).OrderBy(x => x.Name)" ListItemHrefGenerator="HrefGenerator" /> | ||
<h3>All Songs by @_artistName</h3> | ||
<ListComponent TItem="ArtistWorkDisplay" Items="@_artistWorkInfos.Select(x => new ArtistWorkDisplay(x)).OrderBy(x => x.Name)" ListItemHrefGenerator="HrefGenerator" /> | ||
} | ||
else | ||
{ | ||
<p>Loading...</p> | ||
} |
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 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
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,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Net.Http.Json; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using RadiocomDataViewApp.Interfaces; | ||
|
||
namespace RadiocomDataViewApp.Services | ||
{ | ||
public class UpdateService : IUpdateService, IAsyncDisposable, IDisposable | ||
{ | ||
private readonly HttpClient _httpClient; | ||
private readonly DateTime _welcomeTime; | ||
|
||
private readonly Timer _welcomeTimer; | ||
private bool disposedValue; | ||
private readonly Random _random; | ||
|
||
public UpdateService(HttpClient httpClient, DateTime welcomeTime) | ||
{ | ||
_httpClient = httpClient; | ||
_welcomeTime = welcomeTime; | ||
_random = new Random(); | ||
|
||
_welcomeTimer = new Timer(HasApplicationUpdate, null, TimeSpan.FromHours(1), TimeSpan.FromHours(5)); | ||
} | ||
|
||
public event Action OnWelcomeHasChanged; | ||
|
||
private async void HasApplicationUpdate(object state) | ||
{ | ||
|
||
bool welcomeHasChanged = await _httpClient.GetFromJsonAsync<ApplicationUpdateCheck>("/appsettings.json?r=" + _random.Next()) | ||
.ContinueWith(x => _welcomeTime != x.Result.welcome); | ||
if (welcomeHasChanged) | ||
{ | ||
OnWelcomeHasChanged?.Invoke(); | ||
} | ||
} | ||
|
||
|
||
|
||
private class ApplicationUpdateCheck | ||
{ | ||
public DateTime welcome { get; set; } | ||
} | ||
|
||
protected virtual void Dispose(bool disposing) | ||
{ | ||
if (!disposedValue) | ||
{ | ||
if (disposing) | ||
{ | ||
_welcomeTimer.Dispose(); | ||
} | ||
|
||
disposedValue = true; | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(disposing: true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
public ValueTask DisposeAsync() | ||
{ | ||
return ((IAsyncDisposable)_welcomeTimer).DisposeAsync(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
@Body | ||
</div> | ||
<WelcomeModal/> | ||
<ApplicationUpdateModal/> | ||
</LayoutContent> | ||
</Layout> | ||
</Layout> | ||
|
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
{ | ||
"version": 1201234, | ||
"welcome": "2021-01-24T00:00:00.000-08:00" | ||
} |
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 |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
<a href="" class="reload">Reload</a> | ||
<a class="dismiss">🗙</a> | ||
</div> | ||
<script src="_framework/blazor.webassembly.js"></script> | ||
|
||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script> | ||
|
@@ -35,15 +35,10 @@ | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
|
||
<script src="_content/Blazorise.Charts/blazorise.charts.js"></script> | ||
|
||
<script src="_framework/blazor.webassembly.js"></script> | ||
<script type="text/javascript"> | ||
function foo(a, b) { | ||
console.log(a); | ||
console.log(b); | ||
|
||
} | ||
(function () { | ||
console.log("plugin"); | ||
Chart.plugins.register({ | ||
afterEvent: function (chartInstance, chartEvent) { | ||
var canvas = chartInstance.chart.canvas; | ||
|