Skip to content

Commit

Permalink
tweak run info
Browse files Browse the repository at this point in the history
  • Loading branch information
drittich committed Nov 21, 2022
1 parent bd0ff8d commit 36aa6bc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions DnsTube.Service/ClientApp/src/controllers/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function init() {

// get old log right away
getLog();
getRunInfo();

getSettingsAsync().then(async Settings => {
_settings = Settings;
Expand All @@ -34,6 +33,7 @@ function init() {
// refresh log to show DNS entry fetch status
getLog();
setupSse();
getRunInfo();
});

getPublicIp();
Expand Down Expand Up @@ -227,7 +227,7 @@ function setupSse() {
}
async function getRunInfo() {
let runInfo = await getRunInfoAsync();
(document.getElementById("last-update")! as HTMLInputElement).value = format(parseJSON(runInfo!.lastRun), "yyyy-MM-dd HH:mm:ss");
(document.getElementById("next-update")! as HTMLInputElement).value = format(parseJSON(runInfo!.nextRun), "yyyy-MM-dd HH:mm:ss");
(document.getElementById("last-update")! as HTMLInputElement).value = format(parseISO(runInfo!.lastRun), "yyyy-MM-dd HH:mm:ss");
(document.getElementById("next-update")! as HTMLInputElement).value = format(parseISO(runInfo!.nextRun), "yyyy-MM-dd HH:mm:ss");
}

4 changes: 3 additions & 1 deletion DnsTube.Service/Controllers/Api/SettingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public record RunInfo(string LastRun, string NextRun);
[Route("runinfo")]
public RunInfo GetRunInfo()
{
return new RunInfo(WorkerService.LastRun.ToString("yyyy-MM-ddTHH:mm:ss"), WorkerService.NextRun.ToString("yyyy-MM-ddTHH:mm:ss"));
if (WorkerService.LastRun == DateTimeOffset.MinValue)
throw new Exception("not ready");
return new RunInfo(WorkerService.LastRun.ToString("yyyy-MM-ddTHH:mm:sszzz"), WorkerService.NextRun.ToString("yyyy-MM-ddTHH:mm:sszzz"));
}
}
}
4 changes: 2 additions & 2 deletions DnsTube.Service/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class WorkerService : BackgroundService
private IConfiguration _configuration;
private IServerSentEventsService _serverSentEventsService;

public static DateTime LastRun;
public static DateTime NextRun;
public static DateTimeOffset LastRun;
public static DateTimeOffset NextRun;

public WorkerService(ILogger<WorkerService> logger, ISettingsService settingsService, IGitHubService githubService, ICloudflareService cloudflareService, ILogService logService, IIpAddressService ipAddressService, IConfiguration configuration, IServerSentEventsService serverSentEventsService)
{
Expand Down

0 comments on commit 36aa6bc

Please sign in to comment.