Less broken UI code (still broken, don't get me wrong)
This commit is contained in:
parent
3c18736d01
commit
61ad0200ce
|
@ -1,17 +0,0 @@
|
||||||
@page "/counter"
|
|
||||||
|
|
||||||
<h1>Counter</h1>
|
|
||||||
|
|
||||||
<p>Current count: @currentCount</p>
|
|
||||||
|
|
||||||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private int currentCount = 0;
|
|
||||||
|
|
||||||
private void IncrementCount()
|
|
||||||
{
|
|
||||||
currentCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
@page "/fetchdata"
|
|
||||||
@inject HttpClient Http
|
|
||||||
|
|
||||||
<h1>Weather forecast</h1>
|
|
||||||
|
|
||||||
<p>This component demonstrates fetching data from the server.</p>
|
|
||||||
|
|
||||||
@if (forecasts == null)
|
|
||||||
{
|
|
||||||
<p>
|
|
||||||
<em>Loading...</em>
|
|
||||||
</p>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>Temp. (C)</th>
|
|
||||||
<th>Temp. (F)</th>
|
|
||||||
<th>Summary</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var forecast in forecasts)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
<td>@forecast.Date.ToShortDateString()</td>
|
|
||||||
<td>@forecast.TemperatureC</td>
|
|
||||||
<td>@forecast.TemperatureF</td>
|
|
||||||
<td>@forecast.Summary</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
}
|
|
||||||
|
|
||||||
@code {
|
|
||||||
private WeatherForecast[] forecasts;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
public class WeatherForecast
|
|
||||||
{
|
|
||||||
public DateTime Date { get; set; }
|
|
||||||
|
|
||||||
public int TemperatureC { get; set; }
|
|
||||||
|
|
||||||
public string Summary { get; set; }
|
|
||||||
|
|
||||||
public int TemperatureF => 32 + (int) (TemperatureC / 0.5556);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -53,9 +53,9 @@ Select a repository and click load to view contained packages
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Link { get; set; } = "https://gitlab.com/JFronny/UpTool2/snippets/1988600/raw";
|
public string Link { get; set; } = "";
|
||||||
|
|
||||||
private string CurrentPageLink => _baseLinkCurrent + "?link=" + Uri.EscapeDataString(Link);
|
private string CurrentPageLink => _baseLinkCurrent + (_baseLinkCurrent.EndsWith('/') ? "" : "/") + "?link=" + Uri.EscapeDataString(Link);
|
||||||
|
|
||||||
private string _baseLinkCurrent = "";
|
private string _baseLinkCurrent = "";
|
||||||
List<UTApp> _apps = new List<UTApp>();
|
List<UTApp> _apps = new List<UTApp>();
|
||||||
|
@ -160,18 +160,27 @@ Select a repository and click load to view contained packages
|
||||||
|
|
||||||
private async Task UpdateApps()
|
private async Task UpdateApps()
|
||||||
{
|
{
|
||||||
NavManager.NavigateTo(CurrentPageLink);
|
Uri uri;
|
||||||
Uri uri = new Uri(CurrentPageLink);
|
if (string.IsNullOrWhiteSpace(Link))
|
||||||
|
uri = NavManager.ToAbsoluteUri(NavManager.Uri);
|
||||||
|
else
|
||||||
|
uri = new Uri(CurrentPageLink);
|
||||||
if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("link", out StringValues linkInit))
|
if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("link", out StringValues linkInit))
|
||||||
{
|
{
|
||||||
Link = linkInit;
|
Link = linkInit;
|
||||||
_apps.Clear();
|
_apps.Clear();
|
||||||
_btnState = "disabled";
|
_btnState = "disabled";
|
||||||
|
NavManager.NavigateTo(CurrentPageLink);
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
_uriSelected = true;
|
_uriSelected = true;
|
||||||
await ProcessApps(await FetchRepo());
|
await ProcessApps(await FetchRepo());
|
||||||
_btnState = "";
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Link = "https://gitlab.com/JFronny/UpTool2/snippets/1988600/raw";
|
||||||
|
UpdateApps();
|
||||||
|
}
|
||||||
|
_btnState = "";
|
||||||
pLog.Clear();
|
pLog.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue