-
Notifications
You must be signed in to change notification settings - Fork 7
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
0 parents
commit 4946a1f
Showing
97 changed files
with
62,220 additions
and
0 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,56 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
|
||
jobs: | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
Solution_Name: ReplayBrowser.sln | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install .NET Core | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 8.0.x | ||
|
||
- name: Build Client | ||
run: dotnet build ./ReplayBrowser/Client/Client.csproj | ||
|
||
- name: Build Server | ||
run: dotnet build ./ReplayBrowser/Server/Server.csproj | ||
|
||
- name: Install SSH Key | ||
uses: webfactory/ssh-agent@v0.9.0 | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
- name: Prepare files for deployment | ||
run: | | ||
mkdir deploy | ||
echo '${{ secrets.SERVER_APPSETTINGS }}' > ./deploy/ReplayBrowser/Server/appsettings.Secret.json | ||
echo '${{ secrets.CLIENT_APPSETTINGS }}' > ./deploy/ReplayBrowser/Client/appsettings.json | ||
rsync -av --exclude='bin' --exclude='obj' --exclude='.git' --exclude='deploy' ./ ./deploy | ||
- name: Upload files to server | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.SERVER_IP }} | ||
username: ${{ secrets.SERVER_USERNAME }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
source: "./deploy/*" | ||
target: /home/${{ secrets.SERVER_USERNAME }}/ReplayBrowser | ||
|
||
- name: Restart services | ||
run: | | ||
ssh -o StrictHostKeyChecking=no -i ${{ secrets.SSH_PRIVATE_KEY }} ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "sudo systemctl restart replaybrowser.client.service" | ||
ssh -o StrictHostKeyChecking=no -i ${{ secrets.SSH_PRIVATE_KEY }} ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "sudo systemctl restart replaybrowser.server.service" |
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,6 @@ | ||
bin/ | ||
obj/ | ||
/packages/ | ||
riderModule.iml | ||
/_ReSharper.Caches/ | ||
*/appsettings.Secret.json |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,7 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Run Client + Server" type="CompoundRunConfigurationType"> | ||
<toRun name="Client: https" type="LaunchSettings" /> | ||
<toRun name="Server: https" type="LaunchSettings" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Shared\Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" data-bs-theme="dark"> | ||
|
||
<head> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||
<base href="/"/> | ||
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"/> | ||
<script src="popper.min.js"></script> | ||
<script src="bootstrap/js/bootstrap.bundle.js"></script> | ||
<link rel="stylesheet" href="app.css"/> | ||
<link rel="stylesheet" href="Client.styles.css"/> | ||
<link rel="icon" type="image/png" href="favicon.png"/> | ||
<HeadOutlet/> | ||
</head> | ||
|
||
<body> | ||
<Routes/> | ||
<script src="_framework/blazor.web.js"></script> | ||
</body> | ||
|
||
</html> |
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,13 @@ | ||
@inherits LayoutComponentBase | ||
|
||
<div class="page"> | ||
<main class="container my-5"> | ||
@Body | ||
</main> | ||
</div> | ||
|
||
<div id="blazor-error-ui"> | ||
An unhandled error has occurred. | ||
<a href="" class="reload">Reload</a> | ||
<a class="dismiss">🗙</a> | ||
</div> |
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,18 @@ | ||
#blazor-error-ui { | ||
background: lightyellow; | ||
bottom: 0; | ||
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); | ||
display: none; | ||
left: 0; | ||
padding: 0.6rem 1.25rem 0.7rem 1.25rem; | ||
position: fixed; | ||
width: 100%; | ||
z-index: 1000; | ||
} | ||
|
||
#blazor-error-ui .dismiss { | ||
cursor: pointer; | ||
position: absolute; | ||
right: 0.75rem; | ||
top: 0.5rem; | ||
} |
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,36 @@ | ||
@page "/Error" | ||
@using System.Diagnostics | ||
|
||
<PageTitle>Error</PageTitle> | ||
|
||
<h1 class="text-danger">Error.</h1> | ||
<h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
||
@if (ShowRequestId) | ||
{ | ||
<p> | ||
<strong>Request ID:</strong> <code>@RequestId</code> | ||
</p> | ||
} | ||
|
||
<h3>Development Mode</h3> | ||
<p> | ||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred. | ||
</p> | ||
<p> | ||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong> | ||
It can result in displaying sensitive information from exceptions to end users. | ||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> | ||
and restarting the app. | ||
</p> | ||
|
||
@code{ | ||
[CascadingParameter] private HttpContext? HttpContext { get; set; } | ||
|
||
private string? RequestId { get; set; } | ||
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
|
||
protected override void OnInitialized() => | ||
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; | ||
|
||
} |
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,42 @@ | ||
@page "/" | ||
@using Replay = Shared.Models.Replay | ||
@inject HttpClient Http | ||
@inject NavigationManager NavigationManager | ||
@inject IJSRuntime JSRuntime | ||
@attribute [StreamRendering] | ||
|
||
<PageTitle>Replay viewer</PageTitle> | ||
<h1>Replay browser for Space Station 14</h1> | ||
<hr/> | ||
<SearchBar></SearchBar> | ||
<hr/> | ||
<h4>Most recent replays</h4> | ||
|
||
<div class="replay-list"> | ||
@if (Replays.Count == 0 && !IsLoading) | ||
{ | ||
<p><em>It looks like there are no replays available yet. Please check again later.</em></p> | ||
} else if (IsLoading) | ||
{ | ||
<p><em>Loading replays... Please wait...</em></p> | ||
} | ||
else | ||
{ | ||
foreach (var replay in Replays) | ||
{ | ||
<Replay ReplayData="replay"></Replay> | ||
} | ||
} | ||
</div> | ||
|
||
@code { | ||
private bool IsLoading { get; set; } = true; | ||
private List<Replay> Replays { get; set; } = []; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
Replays = await Http.GetFromJsonAsync<List<Replay>>("replays/most-recent"); | ||
Console.WriteLine($"Fetched {Replays.Count} replays."); | ||
IsLoading = false; | ||
} | ||
} |
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,6 @@ | ||
.replay-list { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: space-between; | ||
margin: 0 0 1rem 0; | ||
} |
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,94 @@ | ||
@page "/search" | ||
@using Replay = Shared.Models.Replay | ||
@using System.Net | ||
@inject HttpClient Http | ||
@inject NavigationManager NavigationManager | ||
|
||
<PageTitle>Replay viewer</PageTitle> | ||
<h1>Replay browser for Space Station 14</h1> | ||
<p>Search for replays by using the search bar below</p> | ||
<a href="/" class="btn btn-primary">Back to main page</a> | ||
<hr/> | ||
<SearchBar></SearchBar> | ||
<hr/> | ||
@if (ErrorMessage != null) | ||
{ | ||
<p class="alert alert-danger"> | ||
@ErrorMessage | ||
<br/> | ||
<button class="btn btn-danger" type="button" data-bs-toggle="collapse" data-bs-target="#errorDetails" aria-expanded="false" aria-controls="errorDetails"> | ||
Show error details | ||
</button> | ||
<div class="collapse" id="errorDetails"> | ||
<div class="card card-body" style="white-space: pre-wrap;"> | ||
@ErrorDetails | ||
</div> | ||
</div> | ||
</p> | ||
} else switch (Replays.Count) | ||
{ | ||
case 0 when IsLoading: | ||
<div class="replay-list"> | ||
<p>Loading...</p> | ||
</div> | ||
break; | ||
case 0: | ||
<div class="replay-list"> | ||
<p>No results... :(</p> | ||
</div> | ||
break; | ||
default: | ||
{ | ||
<p>Found @Replays.Count replays</p> | ||
<div class="replay-list"> | ||
@foreach (var replay in Replays) | ||
{ | ||
<Replay ReplayData="replay"></Replay> | ||
} | ||
</div> | ||
|
||
break; | ||
} | ||
} | ||
|
||
@code { | ||
public List<Replay> Replays { get; set; } = new List<Replay>(); | ||
public bool IsLoading { get; set; } = true; | ||
public string? ErrorMessage { get; set; } | ||
public string? ErrorDetails { get; set; } | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
// Get mode and query from query string | ||
var uri = new Uri(NavigationManager.Uri); | ||
var query = uri.Query; | ||
|
||
var response = await Http.GetAsync("/search" + query); | ||
|
||
if (response.StatusCode == HttpStatusCode.BadRequest) | ||
{ | ||
ErrorMessage = "Invalid search query"; | ||
ErrorDetails = await response.Content.ReadAsStringAsync(); | ||
ErrorDetails = ErrorDetails.Replace("\n", "<br>"); | ||
return; | ||
} | ||
|
||
if (response.StatusCode != HttpStatusCode.OK) | ||
{ | ||
ErrorMessage = "Failed to load replays"; | ||
ErrorDetails = await response.Content.ReadAsStringAsync(); | ||
ErrorDetails = ErrorDetails.Replace("\n", "<br>"); | ||
return; | ||
} | ||
|
||
var loadedReplays = await response.Content.ReadFromJsonAsync<List<Replay>>(); | ||
if (loadedReplays == null) | ||
{ | ||
ErrorMessage = "Failed to load replays"; | ||
return; | ||
} | ||
|
||
Replays = loadedReplays; | ||
IsLoading = false; | ||
} | ||
} |
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,6 @@ | ||
.replay-list { | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: space-between; | ||
margin: 0 0 1rem 0; | ||
} |
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,38 @@ | ||
@page "/replay/{id}" | ||
@attribute [StreamRendering] | ||
@inject HttpClient Http | ||
|
||
<PageTitle>Replay viewer</PageTitle> | ||
@if (Replay == null && !IsLoading) | ||
{ | ||
<p>Replay not found</p> | ||
} | ||
else if (IsLoading) | ||
{ | ||
<p>Loading...</p> | ||
} | ||
else | ||
{ | ||
<ReplayViewer Replay="Replay" /> | ||
} | ||
|
||
@code { | ||
[Parameter] public string Id { get; set; } | ||
public Shared.Models.Replay? Replay { get; set; } | ||
public bool IsLoading { get; set; } = true; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
var response = await Http.GetAsync($"replay/{Id}"); | ||
if (response.IsSuccessStatusCode) | ||
{ | ||
Replay = await response.Content.ReadFromJsonAsync<Shared.Models.Replay>(); | ||
} | ||
else | ||
{ | ||
Replay = null; | ||
} | ||
|
||
IsLoading = false; | ||
} | ||
} |
Oops, something went wrong.