Refactored endpoints, added source/metadat to frontend

This commit is contained in:
Gilles Lazures 2026-02-11 01:53:11 +01:00
parent 07398a9eac
commit f1511f1d3d
6 changed files with 62 additions and 15 deletions

View File

@ -6,14 +6,24 @@ namespace BrikInstaller;
public static class Constants { public static class Constants {
public static readonly JsonSerializerOptions _jsonOptions = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; public static readonly JsonSerializerOptions _jsonOptions = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
public static readonly string os = OsHelper.getOperatingSystem(); public static readonly string Os = OsHelper.getOperatingSystem();
public static readonly string arch = OsHelper.getArchitecture(); public static readonly string Arch = OsHelper.getArchitecture();
public static readonly string env = "DEV"; public static readonly string Env = "DEV";
public static readonly string __dirname = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
public static readonly string BaseDirectory = AppDomain.CurrentDomain.BaseDirectory; public static readonly string BaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
public static readonly string CurrentWorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
public static class URLs { public static class URLs {
public static readonly string basePoint = "https://brik.azures.fr/products"; public static readonly string ApiPoint = "https://brik.azures.fr";
public static class Endpoints {
public static string Manifest(string softName, string os, string arch)
=> $"{ApiPoint}/products/{softName}/{os}-{arch}/manifest";
public static string Download(string softName, string os, string arch)
=> $"{ApiPoint}/products/{softName}/{os}-{arch}/download/";
public static string Metadata()
=> $"{ApiPoint}/metadata";
}
} }
} }

View File

@ -14,10 +14,10 @@ class Program{
} }
public static PhotinoWindow CreateMainWindow() { public static PhotinoWindow CreateMainWindow() {
BrikPackage bpkg = new BrikPackage(Path.Combine(Constants.__dirname, "root.dat"), 66); BrikPackage bpkg = new BrikPackage(Path.Combine(Constants.CurrentWorkingDirectory, "root.dat"), 66);
List<string> entries = bpkg.ListEntries(); List<string> entries = bpkg.ListEntries();
foreach (string entry in entries) { foreach (string entry in entries) {
Console.WriteLine(entry); Console.WriteLine($"[File] > entry");
} }
var window = new PhotinoWindow() var window = new PhotinoWindow()
.SetTitle("Brik Installer") .SetTitle("Brik Installer")
@ -122,7 +122,7 @@ class Program{
case "installer::install": case "installer::install":
if (jsonPayload.TryGetProperty("soft", out var softName) && jsonPayload.TryGetProperty("path", out var softInstallPath)) { if (jsonPayload.TryGetProperty("soft", out var softName) && jsonPayload.TryGetProperty("path", out var softInstallPath)) {
try { try {
await GenericFilesService.SyncFilesAsync($"{Constants.URLs.basePoint}/{softName}/{Constants.os}-{Constants.arch}/download/", $"{Constants.URLs.basePoint}/{softName}/{Constants.os}-{Constants.arch}/manifest", softInstallPath.ToString()); await GenericFilesService.SyncFilesAsync(Constants.URLs.Endpoints.Download(softName.ToString(), Constants.Os, Constants.Arch), Constants.URLs.Endpoints.Download(softName.ToString(), Constants.Os, Constants.Arch), softInstallPath.ToString());
responsePayload = new { success = true }; responsePayload = new { success = true };
} catch (Exception) { } catch (Exception) {
responsePayload = new { success = false }; responsePayload = new { success = false };
@ -147,6 +147,17 @@ class Program{
} }
} }
break; break;
case "brik::metadata":
try {
HttpMethod httpMethod = HttpMethod.Get;
var response = await HttpHelper.FetchAsync(Constants.URLs.Endpoints.Metadata(), httpMethod);
string content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
responsePayload = new { success = true, content = content.ToString() };
} catch (Exception) {
responsePayload = new { success = false };
}
break;
} }
var finalResponse = new { requestId, payload = responsePayload }; var finalResponse = new { requestId, payload = responsePayload };
@ -159,7 +170,7 @@ class Program{
} }
public static void LoadPage(PhotinoWindow window, string url) { public static void LoadPage(PhotinoWindow window, string url) {
if (Constants.env == "PROD") { if (Constants.Env == "PROD") {
window.Load($"http://internal/{url}"); window.Load($"http://internal/{url}");
} else { } else {
window.Load($"src/resources/renderer/{url}"); window.Load($"src/resources/renderer/{url}");

View File

@ -10,7 +10,7 @@ namespace BrikInstaller.Services;
public static class RequirementsService { public static class RequirementsService {
public static async Task<RequirementCheckingResponse> CheckRequirementsAsync(PhotinoWindow window, string softName) { public static async Task<RequirementCheckingResponse> CheckRequirementsAsync(PhotinoWindow window, string softName) {
try { try {
string requirementsUrl = $"https://brik.azures.fr/products/{softName}/{Constants.os}-{Constants.arch}/requirements"; string requirementsUrl = $"https://brik.azures.fr/products/{softName}/{Constants.Os}-{Constants.Arch}/requirements";
var response = await HttpHelper.FetchAsync(requirementsUrl, HttpMethod.Get); var response = await HttpHelper.FetchAsync(requirementsUrl, HttpMethod.Get);

View File

@ -15,7 +15,7 @@ details.language {
margin-top: 10px; margin-top: 10px;
} }
aside > article.frame > section.author { aside > article.frame > section.source {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
position: fixed; position: fixed;
@ -23,14 +23,14 @@ aside > article.frame > section.author {
left: 10px; left: 10px;
} }
aside > article.frame > section.author > img { aside > article.frame > section.source > img {
width: 25px; width: 25px;
height: 25px; height: 25px;
margin-right: 5px; margin-right: 5px;
border-radius: 5px; border-radius: 5px;
} }
aside > article.frame > section.author > p { aside > article.frame > section.source > p {
font-size: 12px; font-size: 12px;
} }

View File

@ -198,7 +198,33 @@ async function quit() {
await system.call("installer::quit", finishState) await system.call("installer::quit", finishState)
} }
onFrameShowed("onboarding", () => { function setSourceLogo(url) {
const sourceSection = document.querySelector("section.source")
const sourceLogo = sourceSection.querySelector("img")
sourceLogo.src = url
}
function setSourceName(name) {
const sourceSection = document.querySelector("section.source")
const sourceName = sourceSection.querySelector("p")
sourceName.innerText = name
}
async function setupMetadata() {
const metadata = await system.call("brik::metadata")
if (metadata.success) {
try {
const parsed = JSON.parse(metadata.content)
setSourceName(parsed.name)
setSourceLogo(parsed.logo)
} catch (error) {
console.error(error)
}
}
}
onFrameShowed("onboarding", async () => {
await setupMetadata()
const languageDropdown = document.querySelector("details.language") const languageDropdown = document.querySelector("details.language")
if (languageDropdown.getAttribute("value") == null) { if (languageDropdown.getAttribute("value") == null) {
hideFrameNavigationButtons() hideFrameNavigationButtons()

View File

@ -142,7 +142,7 @@
</ul> </ul>
</section> </section>
</details> </details>
<section class="author"> <section class="source">
<img src="https://github.com/azures04.png?size=1024" alt=""> <img src="https://github.com/azures04.png?size=1024" alt="">
<p> <p>
azures04 azures04