Changed to get the version from the API.

This commit is contained in:
Roger Far 2025-03-21 16:02:45 -06:00
parent 53a1407ef8
commit 605868fe70
6 changed files with 27 additions and 5 deletions

View file

@ -0,0 +1,3 @@
export class Version {
public version: string;
}

View file

@ -55,7 +55,7 @@
<a class="navbar-item" routerLink="profile"> Profile </a> <a class="navbar-item" routerLink="profile"> Profile </a>
<a class="navbar-item" (click)="logout()"> Logout </a> <a class="navbar-item" (click)="logout()"> Logout </a>
<hr class="navbar-divider" /> <hr class="navbar-divider" />
<a href="https://github.com/rogerfar/rdt-client" target="_blank" class="navbar-item">Version 2.0.102</a> <a href="https://github.com/rogerfar/rdt-client" target="_blank" class="navbar-item">Version {{ version }}</a>
</div> </div>
</div> </div>
</div> </div>

View file

@ -15,6 +15,7 @@ export class NavbarComponent implements OnInit {
public profile: Profile; public profile: Profile;
public providerLink: string; public providerLink: string;
public version: string;
constructor( constructor(
private settingsService: SettingsService, private settingsService: SettingsService,
@ -50,6 +51,10 @@ export class NavbarComponent implements OnInit {
break; break;
} }
}); });
this.settingsService.getVersion().subscribe((result) => {
this.version = result.version;
});
} }
public logout(): void { public logout(): void {

View file

@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
import { Profile } from './models/profile.model'; import { Profile } from './models/profile.model';
import { Setting } from './models/setting.model'; import { Setting } from './models/setting.model';
import { APP_BASE_HREF } from '@angular/common'; import { APP_BASE_HREF } from '@angular/common';
import { Version } from './models/version.model';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
@ -26,6 +27,10 @@ export class SettingsService {
return this.http.get<Profile>(`${this.baseHref}Api/Settings/Profile`); return this.http.get<Profile>(`${this.baseHref}Api/Settings/Profile`);
} }
public getVersion(): Observable<Version> {
return this.http.get<Version>(`${this.baseHref}Api/Settings/Version`);
}
public testPath(path: string): Observable<void> { public testPath(path: string): Observable<void> {
return this.http.post<void>(`${this.baseHref}Api/Settings/TestPath`, { path }); return this.http.post<void>(`${this.baseHref}Api/Settings/TestPath`, { path });
} }

View file

@ -3,14 +3,10 @@ $utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
$version = (Get-Content "package.json" | ConvertFrom-Json).version $version = (Get-Content "package.json" | ConvertFrom-Json).version
$csProj = "$pwd\server\RdtClient.Web\RdtClient.Web.csproj" $csProj = "$pwd\server\RdtClient.Web\RdtClient.Web.csproj"
$navbar = "$pwd\client\src\app\navbar\navbar.component.html";
$newCsProj = (Get-Content $csProj) -replace '<Version>.*?<\/Version>', "<Version>$version</Version>" $newCsProj = (Get-Content $csProj) -replace '<Version>.*?<\/Version>', "<Version>$version</Version>"
[System.IO.File]::WriteAllLines($csProj, $newCsProj, $utf8NoBomEncoding) [System.IO.File]::WriteAllLines($csProj, $newCsProj, $utf8NoBomEncoding)
$newNavbar = (Get-Content $navbar) -replace 'Version .*?<', "Version $version<"
[System.IO.File]::WriteAllLines($navbar, $newNavbar, $utf8NoBomEncoding)
Write-Output "Commit and push now, press any key to continue" Write-Output "Commit and push now, press any key to continue"
[Console]::ReadKey() [Console]::ReadKey()

View file

@ -1,4 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.Reflection;
using Aria2NET; using Aria2NET;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -44,6 +45,18 @@ public class SettingsController(Settings settings, Torrents torrents) : Controll
var profile = await torrents.GetProfile(); var profile = await torrents.GetProfile();
return Ok(profile); return Ok(profile);
} }
[HttpGet]
[Route("Version")]
public ActionResult<Version> Version()
{
var version = Assembly.GetExecutingAssembly().GetName().Version!;
return Ok(new
{
Version = version
});
}
[HttpPost] [HttpPost]
[Route("TestPath")] [Route("TestPath")]