Skip to content

Commit b6d9f0a

Browse files
[+] Updater
1 parent 57cb282 commit b6d9f0a

22 files changed

+566
-7
lines changed

ProxyMov_DownloadServer.sln

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.12.35506.116 d17.12
4+
VisualStudioVersion = 17.12.35506.116
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxyMov_DownloadServer", "ProxyMov_DownloadServer\ProxyMov_DownloadServer.csproj", "{62D00E2E-8162-4E05-9314-8B1F7FAD5945}"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxyMov_DownloadServer.AppHost", "ProxyMov_DownloadServer.AppHost\ProxyMov_DownloadServer.AppHost.csproj", "{BF7EA1D5-F8D8-4C5B-8C2B-D78841BA8BE4}"
99
EndProject
1010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxyMov_DownloadServer.ServiceDefaults", "ProxyMov_DownloadServer.ServiceDefaults\ProxyMov_DownloadServer.ServiceDefaults.csproj", "{CD621B84-D1A3-4E00-A822-9BCF4A06B688}"
1111
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Starter", "Starter\Starter.csproj", "{BAD7EDA5-E06D-4CDA-A26D-3A6006564CCB}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Updater\Updater.csproj", "{4E28142A-C7F4-4F71-BE22-E1DDED8C6AA5}"
15+
EndProject
1216
Global
1317
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1418
Debug|Any CPU = Debug|Any CPU
@@ -27,6 +31,14 @@ Global
2731
{CD621B84-D1A3-4E00-A822-9BCF4A06B688}.Debug|Any CPU.Build.0 = Debug|Any CPU
2832
{CD621B84-D1A3-4E00-A822-9BCF4A06B688}.Release|Any CPU.ActiveCfg = Release|Any CPU
2933
{CD621B84-D1A3-4E00-A822-9BCF4A06B688}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{BAD7EDA5-E06D-4CDA-A26D-3A6006564CCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{BAD7EDA5-E06D-4CDA-A26D-3A6006564CCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{BAD7EDA5-E06D-4CDA-A26D-3A6006564CCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{BAD7EDA5-E06D-4CDA-A26D-3A6006564CCB}.Release|Any CPU.Build.0 = Release|Any CPU
38+
{4E28142A-C7F4-4F71-BE22-E1DDED8C6AA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{4E28142A-C7F4-4F71-BE22-E1DDED8C6AA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{4E28142A-C7F4-4F71-BE22-E1DDED8C6AA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
41+
{4E28142A-C7F4-4F71-BE22-E1DDED8C6AA5}.Release|Any CPU.Build.0 = Release|Any CPU
3042
EndGlobalSection
3143
GlobalSection(SolutionProperties) = preSolution
3244
HideSolutionNode = FALSE
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-ef": {
6+
"version": "9.0.0",
7+
"commands": [
8+
"dotnet-ef"
9+
],
10+
"rollForward": false
11+
}
12+
}
13+
}

ProxyMov_DownloadServer/Components/NavComponent.razor

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
<HxSidebar CssClass="sticky-top mb-4" ResponsiveBreakpoint="SidebarResponsiveBreakpoint.Large">
77
<HeaderTemplate>
8-
<div class="w-100">
8+
<div class="w-100">
9+
<h6 class="text-secondary ps-2 pt-1 pb-1" style="color: #212529">v.@(GetAssemblyVersion())</h6>
910
<LanguageSelectorComponent></LanguageSelectorComponent>
1011
</div>
1112
</HeaderTemplate>
@@ -17,7 +18,18 @@
1718

1819
</HxBadge>
1920
</ContentTemplate>
20-
</HxSidebarItem>
21+
</HxSidebarItem>
22+
@if (Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") != "true")
23+
{
24+
<HxSidebarItem Icon="BootstrapIcon.ArrowDownCircle" Href="@ProxyMov_DownloadServer.Misc.Routes.Updates">
25+
<ContentTemplate>
26+
<span class="ms-2">@LangText["NavCheckUpdates"]</span>
27+
<HxBadge Color="ThemeColor.Secondary" CssClass="ms-2">
28+
29+
</HxBadge>
30+
</ContentTemplate>
31+
</HxSidebarItem>
32+
}
2133
<HxSidebarItem Icon="BootstrapIcon.BoxArrowLeft" CssClass="mt-5 text-danger" Href="@ProxyMov_DownloadServer.Misc.Routes.Shutdown">
2234
<ContentTemplate>
2335
<span class="ms-2">@LangText["NavShutdownServer"]</span>
@@ -39,4 +51,9 @@
3951
{
4052
LangText = await I18nText.GetTextTableAsync<I18nText.Lang>(this);
4153
}
54+
55+
private string? GetAssemblyVersion()
56+
{
57+
return typeof(Program).Assembly.GetName().Version!.ToString();
58+
}
4259
}

ProxyMov_DownloadServer/Components/Pages/DashboardPage.razor

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@using Routes = ProxyMov_DownloadServer.Misc.Routes;
22
@using Microsoft.AspNetCore.Components.Rendering
33
@using System.Net
4+
@using Updater.Components
5+
@using Updater.Interfaces
46
@attribute [Route(Routes.Dashboard)]
57
@attribute [Route(Routes.Index)]
68
@inject IHxMessengerService ToastService
@@ -15,6 +17,10 @@
1517

1618
<PageTitle>Dashboard</PageTitle>
1719

20+
@if (Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") != "true")
21+
{
22+
<UpdateComponent></UpdateComponent>
23+
}
1824
<HxModal ShowCloseButton="false" CloseOnEscape="false" Size="ModalSize.Large" @ref="DownloadPathModal" Centered="true">
1925
<BodyTemplate>
2026
<div class="container">
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@using Updater.Components
2+
@using Updater.Interfaces
3+
@using Routes = ProxyMov_DownloadServer.Misc.Routes;
4+
@attribute [Route(Routes.Updates)]
5+
@inject IUpdateService UpdateService
6+
7+
<PageTitle>Updates</PageTitle>
8+
9+
<UpdateComponent ForceDownloadButton="true"></UpdateComponent>
10+
11+
@code {
12+
protected override async Task OnAfterRenderAsync(bool firstRender)
13+
{
14+
string assemblyVersion = typeof(Program).Assembly.GetName().Version.ToString();
15+
await UpdateService.CheckForUpdates(assemblyVersion);
16+
}
17+
}

ProxyMov_DownloadServer/Components/_Imports.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
@using ProxyMov_DownloadServer.Components
1111
@using Havit.Blazor.Components.Web
1212
@using Havit.Blazor.Components.Web.Bootstrap
13+
@using Updater;

ProxyMov_DownloadServer/Misc/Routes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ public static class Routes
88
public const string Shutdown = "/shutdown";
99
public const string ConverterSettings = "/convertersettings";
1010
public const string Logs = "/log";
11+
public const string Updates = "/updates";
1112
}
1213
}

ProxyMov_DownloadServer/Program.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@
99
using ProxyMov_DownloadServer.Components;
1010
using PuppeteerSharp;
1111
using Quartz;
12+
using System.Diagnostics;
1213
using System.Net;
14+
using System.Runtime.InteropServices;
1315
using Toolbelt.Blazor.Extensions.DependencyInjection;
1416
using Toolbelt.Blazor.I18nText;
1517

18+
const string hostUrl = "http://localhost:8080";
1619

1720
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
21+
22+
if (Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") != "true")
23+
{
24+
builder.WebHost.UseUrls(hostUrl);
25+
}
26+
1827
builder.AddServiceDefaults();
1928

2029
// Add services to the container.
@@ -48,6 +57,7 @@
4857
builder.Services.AddSingleton<IApiService, ApiService>();
4958
builder.Services.AddSingleton<IConverterService, ConverterService>();
5059
builder.Services.AddSingleton<IQuartzService, QuartzService>();
60+
builder.Services.AddSingleton<Updater.Interfaces.IUpdateService, Updater.Services.UpdateService>();
5161

5262
WebApplication app = builder.Build();
5363

@@ -155,7 +165,6 @@
155165
app.UseExceptionHandler("/Error");
156166
}
157167

158-
159168
app.UseHsts();
160169
app.UseHttpsRedirection();
161170
app.UseAntiforgery();
@@ -164,4 +173,28 @@
164173
app.MapRazorComponents<App>()
165174
.AddInteractiveServerRenderMode();
166175

176+
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") != "true")
177+
{
178+
OpenBrowser(hostUrl);
179+
}
180+
167181
app.Run();
182+
183+
static void OpenBrowser(string url)
184+
{
185+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
186+
{
187+
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
188+
}
189+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
190+
{
191+
if (Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") != "true")
192+
{
193+
Process.Start("xdg-open", url);
194+
}
195+
}
196+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
197+
{
198+
Process.Start("open", url);
199+
}
200+
}

ProxyMov_DownloadServer/ProxyMov_DownloadServer.csproj

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<UserSecretsId>398a6da7-3e7a-42d3-843a-cb313269bee2</UserSecretsId>
88
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
9+
<AssemblyVersion>2.0.0.0</AssemblyVersion>
10+
<ApplicationIcon>wwwroot\img\favicon.ico</ApplicationIcon>
911
</PropertyGroup>
1012

13+
<ItemGroup>
14+
<Compile Remove="Updates\**" />
15+
<Content Remove="Updates\**" />
16+
<EmbeddedResource Remove="Updates\**" />
17+
<None Remove="Updates\**" />
18+
</ItemGroup>
19+
1120
<ItemGroup>
1221
<Content Remove="settings.json" />
1322
</ItemGroup>
@@ -19,7 +28,7 @@
1928
<ItemGroup>
2029
<PackageReference Include="Aspire.Dashboard.Sdk.win-x64" Version="9.0.0" />
2130
<PackageReference Include="CliWrap" Version="3.6.7" />
22-
<PackageReference Include="Havit.Blazor.Components.Web.Bootstrap" Version="4.7.1" />
31+
<PackageReference Include="Havit.Blazor.Components.Web.Bootstrap" Version="4.7.2" />
2332
<PackageReference Include="HtmlAgilityPack" Version="1.11.71" />
2433
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
2534
<PackageReference Include="PuppeteerSharp" Version="19.0.1" />
@@ -31,6 +40,16 @@
3140

3241
<ItemGroup>
3342
<ProjectReference Include="..\ProxyMov_DownloadServer.ServiceDefaults\ProxyMov_DownloadServer.ServiceDefaults.csproj" />
43+
<ProjectReference Include="..\Updater\Updater.csproj" />
44+
</ItemGroup>
45+
46+
<ItemGroup>
47+
<None Update="Binaries\ffmpeg.exe">
48+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
49+
</None>
50+
<None Update="Binaries\ffprobe.exe">
51+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
52+
</None>
3453
</ItemGroup>
3554

3655
</Project>

ProxyMov_DownloadServer/i18ntext/Lang.de.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
"ProxyUsername": "Benutzername:",
1717
"ProxyPassword": "Passwort:",
1818
"Save": "Speichern",
19-
"Cancel": "Abbrechen"
19+
"Cancel": "Abbrechen",
20+
"NavCheckUpdates": "Updates prüfen"
2021
}

0 commit comments

Comments
 (0)