Skip to content

Commit 992bcd8

Browse files
committed
Working app
1 parent 7638219 commit 992bcd8

18 files changed

+245
-71
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,7 @@ $RECYCLE.BIN/
452452
!.vscode/tasks.json
453453
!.vscode/launch.json
454454
!.vscode/extensions.json
455+
456+
## Sass output
457+
wwwroot/css/bootstrap.css
458+
wwwroot/css/bootstrap.css.map

App.razor

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<Router AppAssembly="@typeof(Program).Assembly">
22
<Found Context="routeData">
33
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4-
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
54
</Found>
65
<NotFound>
76
<LayoutView Layout="@typeof(MainLayout)">
8-
<p role="alert">Sorry, there's nothing at this address.</p>
7+
<div class="container-fluid d-flex justify-content-center text-center">
8+
<h1 class="display-3">Sorry, there's nothing at this address. <i class="bi bi-emoji-frown"></i></h1>
9+
</div>
910
</LayoutView>
1011
</NotFound>
1112
</Router>
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@if (releases is null)
2+
{
3+
<div class="container-fluid d-flex justify-content-center text-primary">
4+
<div class="spinner-border" role="status">
5+
<span class="visually-hidden">Loading...</span>
6+
</div>
7+
</div>
8+
}
9+
else
10+
{
11+
<table class="table table-hover">
12+
<thead>
13+
<tr>
14+
<th scope="col">Version</th>
15+
<th scope="col" class="text-end">Upload time</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
@foreach(var release in releases)
20+
{
21+
<tr>
22+
<th scope="row">
23+
<a href="/gmoddotnet-runtime/@release.Id" class="text-decoration-none">
24+
@release.TagName
25+
</a>
26+
</th>
27+
<td class="text-end">@TimeHelper.GetUploadTimeString(release.CreatedAt)</td>
28+
</tr>
29+
}
30+
</tbody>
31+
</table>
32+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Components;
6+
using Octokit;
7+
using Semver;
8+
9+
namespace GmodNetBuildBrowser.Components
10+
{
11+
public partial class GmodNetRuntimeVersions
12+
{
13+
[Inject]
14+
public GitHubClient githubClient { get; set; }
15+
16+
List<Release> releases;
17+
18+
protected override async Task OnInitializedAsync()
19+
{
20+
releases = (await githubClient.Repository.Release.GetAll("GmodNET", "runtime-nightly")).ToList();
21+
22+
releases.Sort((x, y) =>
23+
{
24+
return -SemVersion.Compare(SemVersion.Parse(x.TagName), SemVersion.Parse(y.TagName));
25+
});
26+
}
27+
}
28+
}

GmodNetBuildBrowser.csproj

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
<ItemGroup>
99
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0-preview.6.21355.2" />
1010
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0-preview.6.21355.2" PrivateAssets="all" />
11+
<PackageReference Include="Octokit" Version="0.50.0" />
12+
<PackageReference Include="semver" Version="2.0.6" />
1113
</ItemGroup>
1214

15+
<ItemGroup>
16+
<Watch Include="wwwroot/css/bootstrap.css" />
17+
</ItemGroup>
18+
19+
<Target Name="BuildCss" BeforeTargets="BeforeBuild" Inputs="custom-bootstrap.scss" Outputs="wwwroot/css/bootstrap.css">
20+
<Exec Command="sass custom-bootstrap.scss wwwroot/css/bootstrap.css" />
21+
</Target>
22+
1323
</Project>

GmodNetBuildBrowser.sln

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.0.31521.260
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GmodNetBuildBrowser", "GmodNetBuildBrowser.csproj", "{8B91E4EB-A6D2-410E-813A-6D6A6C88D2A8}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GmodNetBuildBrowser", "GmodNetBuildBrowser.csproj", "{8B91E4EB-A6D2-410E-813A-6D6A6C88D2A8}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Pages/GmodDotNetRuntimeBuild.razor

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
@page "/gmoddotnet-runtime/{Id:int}"
2+
3+
@if (release is null && initException is null)
4+
{
5+
<div class="container-fluid d-flex justify-content-center">
6+
<div class="spinner-border text-primary" role="status" style="width: 5em; height: 5em">
7+
<span class="visually-hidden">Loading...</span>
8+
</div>
9+
</div>
10+
}
11+
@if (release is not null && initException is null)
12+
{
13+
<div class="container-fluid d-flex justify-content-center text-primary">
14+
<h3 class="display-6">Gmod.NET Runtime Build</h3>
15+
</div>
16+
17+
<div class="container-fluid d-flex justify-content-center mt-3 text-center">
18+
<h4>Version @release.TagName</h4>
19+
</div>
20+
21+
<div class="container-fluid d-flex justify-content-center mt-3 text-center">
22+
Upload time: @TimeHelper.GetUploadTimeString(release.CreatedAt)
23+
</div>
24+
25+
<div class="container-fluid d-flex justify-content-center mt-3 text-center">
26+
<h5>Assets:</h5>
27+
</div>
28+
29+
<div class="container-fluid mt-1">
30+
@foreach (var asset in release.Assets)
31+
{
32+
<div class="container-fluid d-flex justify-content-center mt-3 text-center">
33+
<a href="@asset.BrowserDownloadUrl" class="text-decoration-none" target="_blank">
34+
<i class="bi bi-box-seam"></i> @asset.Name
35+
</a>
36+
</div>
37+
}
38+
</div>
39+
}
40+
@if (initException is not null)
41+
{
42+
<div class="container-fluid d-flex justify-content-center">
43+
<div class="alert alert-warning container mt-4">
44+
<div class="d-flex justify-content-center">
45+
<h2>Error</h2>
46+
</div>
47+
<div class="d-flex justify-content-center text-center">
48+
It seems like requested build does not exist <i class="bi bi-emoji-frown-fill"></i>
49+
</div>
50+
</div>
51+
</div>
52+
}

Pages/GmodDotNetRuntimeBuild.razor.cs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Components;
6+
using Octokit;
7+
8+
namespace GmodNetBuildBrowser.Pages
9+
{
10+
public partial class GmodDotNetRuntimeBuild
11+
{
12+
[Parameter]
13+
public int Id { get; set; }
14+
15+
[Inject]
16+
public GitHubClient gitHubClient { get; set; }
17+
18+
Release release;
19+
Exception initException;
20+
21+
protected override async Task OnInitializedAsync()
22+
{
23+
try
24+
{
25+
release = await gitHubClient.Repository.Release.Get("GmodNET", "runtime-nightly", Id);
26+
}
27+
catch (Exception ex)
28+
{
29+
initException = ex;
30+
Console.WriteLine("Exception was thrown while requesting GitHub release");
31+
Console.WriteLine(ex.ToString());
32+
}
33+
}
34+
}
35+
}

Pages/Index.razor

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
@page "/"
22

3-
<h1>Hello, worldd!</h1>
3+
<div class="container-fluid d-flex justify-content-center mb-2">
4+
<h3 class="text-primary display-6">Packages List</h3>
5+
</div>
6+
7+
<div class="accordion" id="accordionPackages">
8+
<div class="accordion-item">
9+
<h3 class="accordion-header" id="headingGmodDotNetRuntime">
10+
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseGmodDotNetRuntime" aria-expanded="false" aria-controls="collapseGmodDotNetRuntime">
11+
<div>
12+
<h5><i class="bi bi-archive-fill"></i> Gmod.NET Runtime</h5>
13+
</div>
14+
</button>
15+
</h3>
16+
<div id="collapseGmodDotNetRuntime" class="accordion-collapse collapse" aria-labelledby="headingGmodDotNetRuntime" data-bs-parent="#accordionPackages">
17+
<div class="accordion-body">
18+
<GmodNetRuntimeVersions />
19+
</div>
20+
</div>
21+
</div>
22+
</div>

Program.cs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Net.Http;
88
using System.Text;
99
using System.Threading.Tasks;
10+
using Octokit;
1011

1112
namespace GmodNetBuildBrowser
1213
{
@@ -18,6 +19,7 @@ public static async Task Main(string[] args)
1819
builder.RootComponents.Add<App>("#app");
1920

2021
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
22+
builder.Services.AddScoped<GitHubClient>(sp => new GitHubClient(new ProductHeaderValue("gmodnet-nightly-builds-browser")));
2123

2224
await builder.Build().RunAsync();
2325
}

Shared/MainLayout.razor

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
@inherits LayoutComponentBase
22

3-
<div class="container-fluid d-flex justify-content-center text-white" style="background-color: #7952b3">
4-
<h2>GmodNET Nightly Builds</h2>
3+
<div class="container-fluid d-flex justify-content-center text-white bg-primary pt-1">
4+
<a href="/" class="text-white text-decoration-none"><h1><i class="bi bi-archive-fill"></i> GmodNET Nightly Builds</h1></a>
55
</div>
66

7-
<div class="page">
7+
<div class="container d-flex justify-content-center mt-3">
8+
<a href="https://dev.azure.com/GmodNET/gmodnet-artifacts/_packaging?_a=feed&feed=gmodnet-packages" target="_blank" class="text-decoration-none">
9+
<h2 class="text-center"><i class="ms-Icon ms-Icon--NugetLogo"></i> Go to Nightly NuGet Packages</h2>
10+
</a>
11+
</div>
12+
13+
<div class="container-sm bg-white shadow-sm mt-3 rounded-2 pt-2 pb-3">
814
@Body
915
</div>

TimeHelper.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace GmodNetBuildBrowser
7+
{
8+
public static class TimeHelper
9+
{
10+
public static string GetUploadTimeString(DateTimeOffset uploadTimeOffset)
11+
{
12+
DateTime uploadTime = uploadTimeOffset.ToLocalTime().DateTime;
13+
14+
DateTime currentTime = DateTime.Now;
15+
16+
TimeSpan timeDelta = currentTime - uploadTime;
17+
18+
string result = uploadTime.ToString("yyyy-MM-dd HH:mm:ss");
19+
20+
if (timeDelta.TotalMinutes < 2)
21+
{
22+
result += " (just now)";
23+
}
24+
else if (timeDelta.TotalHours < 2)
25+
{
26+
result += $" ({(int)timeDelta.TotalMinutes} minutes ago)";
27+
}
28+
else if (timeDelta.TotalDays < 2)
29+
{
30+
result += $" ({(int)timeDelta.TotalHours} hours ago)";
31+
}
32+
33+
return result;
34+
}
35+
}
36+
}

_Imports.razor

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
@using Microsoft.JSInterop
99
@using GmodNetBuildBrowser
1010
@using GmodNetBuildBrowser.Shared
11+
@using GmodNetBuildBrowser.Components

custom-bootstrap.scss

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
$primary: #6f42c1;
2+
3+
@import url("https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/11.0.0/css/fabric.min.css");
4+
@import url("https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css");
5+
6+
@import "scss/bootstrap.scss";

scss/_accordion.scss

-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@
4747

4848
&:focus {
4949
z-index: 3;
50-
border-color: $accordion-button-focus-border-color;
5150
outline: 0;
52-
box-shadow: $accordion-button-focus-box-shadow;
5351
}
5452
}
5553

wwwroot/css/app.css

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
html, body {
2-
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
3-
}
4-
5-
#blazor-error-ui {
1+
#blazor-error-ui {
62
background: lightyellow;
73
bottom: 0;
84
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);

wwwroot/index.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<head>
55
<meta charset="utf-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
7-
<title>GmodNetBuildBrowser</title>
7+
<title>GmodNET Nightly Builds</title>
88
<base href="/" />
9-
<link href="/css/bootstrap.min.css" rel="stylesheet" />
9+
<link href="/css/bootstrap.css" rel="stylesheet" />
1010
<link href="/css/app.css" rel="stylesheet" />
1111
<link href="/GmodNetBuildBrowser.styles.css" rel="stylesheet" />
1212
</head>
@@ -15,10 +15,10 @@
1515
<div id="app">
1616
<div style="height: 100vh; width: 100vw; display: flex; justify-content: center; flex-direction: column">
1717
<div style="width: 100vw; display: flex; justify-content: center">
18-
<div style="display: flex; flex-direction: column; align-content:center">
19-
<img src="/load-spinner.svg" />
18+
<div class="d-flex flex-column text-primary">
19+
<div class="d-flex justify-content-center"><div class="spinner-border" style="width: 5em; height: 5em" role="status"></div></div>
2020
<div style="display: flex; justify-content: center">
21-
<h1>Loading...</h1>
21+
<h1 class="mt-4">Loading...</h1>
2222
</div>
2323
</div>
2424
</div>

0 commit comments

Comments
 (0)