Skip to content

Commit

Permalink
testing sync fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
EarliestFall988 committed Nov 27, 2023
1 parent 8c3b681 commit 36872f1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
19 changes: 12 additions & 7 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Avalon;
using Avalon;

using Microsoft.AspNetCore.Mvc;

Expand All @@ -14,12 +14,15 @@
.AddJsonFile("appsettings.json")
.Build();

var splash = File.ReadAllText(new Uri(Path.Combine(Directory.GetCurrentDirectory(), "splash.html")).LocalPath);

// <p>or</p>\r\n <a href=\"/api/v1/sync\">Sync Manually</a>\r\n

string linkURI = env["VALK_DASHBOARD_LINK"];
string syncURI = env["SYNC_LINK"];

var splash = "<!DOCTYPE html>\r\n<html>\r\n<head>\r\n <meta charset=\"utf-8\" />\r\n <title>It Works!!</title>\r\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\r\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\r\n <link href=\"https://fonts.googleapis.com/css2?family=Roboto&display=swap\" rel=\"stylesheet\">\r\n</head>\r\n<style>\r\n .body {\r\n background-color: #171717;\r\n width: 90vw;\r\n height: 90vh;\r\n color: #ffffff;\r\n padding: 3rem;\r\n font-family: 'Roboto', sans-serif;\r\n display: block;\r\n box-sizing: border-box;\r\n }\r\n\r\n h1 {\r\n font-size: 3rem;\r\n }\r\n\r\n p {\r\n font-size: 1.25rem;\r\n }\r\n\r\n a {\r\n font-size: 1.25rem;\r\n color: #ffff;\r\n text-decoration: none;\r\n background-color: #1d4ed8;\r\n padding: 0.25rem;\r\n border-radius: 0.25rem;\r\n }\r\n\r\n</style>\r\n<body class=\"body\">\r\n " +
$"<h1>It Works!</h1>\r\n <p>Copy the link in your browser and paste it back in the Valkyrie Connection Page</p> <p> <a href=\"{linkURI ?? "https://google.com"}\"> Go To Dashboard </a> </p>\r\n</body>\r\n</html>";
//var splash = "<!DOCTYPE html>\r\n<html>\r\n<head>\r\n <meta charset=\"utf-8\" />\r\n <title>It Works!!</title>\r\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\r\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\r\n <link href=\"https://fonts.googleapis.com/css2?family=Roboto&display=swap\" rel=\"stylesheet\">\r\n</head>\r\n<style>\r\n .body {\r\n background-color: #171717;\r\n width: 90vw;\r\n height: 90vh;\r\n color: #ffffff;\r\n padding: 3rem;\r\n font-family: 'Roboto', sans-serif;\r\n display: block;\r\n box-sizing: border-box;\r\n }\r\n\r\n h1 {\r\n\r\n font-size: 3rem;\r\n }\r\n\r\n h1, h2 {\r\n user-select: none;\r\n }\r\n\r\n h2{\r\n font-size: 1.5rem;\r\n font-weight: 200;\r\n }\r\n\r\n p {\r\n font-size: 1.25rem;\r\n }\r\n\r\n a {\r\n font-size: 1.25rem;\r\n color: #ffff;\r\n text-decoration: none;\r\n background-color: #1d4ed8;\r\n padding: 0.25rem;\r\n border-radius: 0.25rem;\r\n }\r\n\r\n .sync-link {\r\n color: lightblue;\r\n text-decoration: underline;\r\n text-underline-offset: 0.25rem;\r\n font-size: 1.5rem;\r\n }\r\n\r\n .no-select {\r\n user-select: none;\r\n }\r\n\r\n</style>\r\n<body class=\"body\">\r\n " +
// $"<h1>It Works!🎉🎉</h1>\r\n <h2>Copy the link below and paste it back in the Valkyrie Connection Page</h2>\r\n <p> <span class=\"no-select\">👉</span><span class=\"sync-link\">{syncURI}</span></p>\r\n <p class=\"no-select\" ><a href=\"{linkURI}https://google.com\"> Go To Dashboard </a></p>\r\n</body>\r\n</html>";

// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
Expand Down Expand Up @@ -66,22 +69,24 @@
var instructionId = ctx.Request.RouteValues["id"] as string;
string key = ctx.Request.Headers["apikey"];

ctx.Response.Headers.Add("Content-Type", "application/json");

if (string.IsNullOrEmpty(key))
{
ctx.Response.StatusCode = 401;
return "No API key provided";
return JsonSerializer.Serialize(new message("No API key provided"));
}

if (apiKey != key)
{
ctx.Response.StatusCode = 401;
return "incorrect api key";
return JsonSerializer.Serialize(new message("incorrect api key"));
}

if (string.IsNullOrEmpty(instructionId))
{
ctx.Response.StatusCode = 400;
return "No instruction ID provided";
return JsonSerializer.Serialize(new message("No instruction ID provided"));
}

ctx.Response.Headers.Add("Content-Type", "application/json");
Expand All @@ -108,7 +113,7 @@
{

context.RequestAborted.ThrowIfCancellationRequested();

var instructionId = context.Request.RouteValues["id"] as string;
string key = context.Request.Headers["apikey"];

Expand Down
36 changes: 32 additions & 4 deletions splash.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
</head>
<script>

getURI = () => {
document.getElementById("link-to-paste").innerHTML = window.location.href + "api/v1/sync";
}

</script>
<style>
.body {
background-color: #171717;
Expand All @@ -23,6 +30,15 @@
font-size: 3rem;
}

h1, h2 {
user-select: none;
}

h2 {
font-size: 1.5rem;
font-weight: 200;
}

p {
font-size: 1.25rem;
}
Expand All @@ -36,9 +52,21 @@
border-radius: 0.25rem;
}

.sync-link {
color: lightblue;
text-decoration: underline;
text-underline-offset: 0.25rem;
font-size: 1.5rem;
}

.no-select {
user-select: none;
}
</style>
<body class="body">
<h1>It Works!</h1>
<p>Copy the link in your browser and paste it back in the Valkyrie Connection Page</p>
<body onload="getURI()" class="body">
<h1>It Works!🎉🎉</h1>
<h2>Copy the link below and paste it back in the Valkyrie Connection Page</h2>
<p> <span class="no-select">👉 </span><span id="link-to-paste" class="sync-link"></span></p>
<p class="no-select"><a href="https://google.com"> Go To Dashboard </a></p>
</body>
</html>
</html>

0 comments on commit 36872f1

Please sign in to comment.