From e4da4c23787e70f23bdeadc2887998ae5def171f Mon Sep 17 00:00:00 2001 From: Jared Date: Thu, 21 Jan 2021 07:42:23 -0800 Subject: [PATCH] Add MotD. --- Server/Pages/Index.cshtml | 4 ++++ Server/wwwroot/src/Main/App.ts | 19 +++++++++++++++++++ Server/wwwroot/src/Main/UI.ts | 3 ++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Server/Pages/Index.cshtml b/Server/Pages/Index.cshtml index f85db1728..ac745a54a 100644 --- a/Server/Pages/Index.cshtml +++ b/Server/Pages/Index.cshtml @@ -10,6 +10,10 @@ } else { + + } \ No newline at end of file diff --git a/Server/wwwroot/src/Main/App.ts b/Server/wwwroot/src/Main/App.ts index 96bebe17b..39c3e624b 100644 --- a/Server/wwwroot/src/Main/App.ts +++ b/Server/wwwroot/src/Main/App.ts @@ -26,7 +26,26 @@ export const MainApp = { HubConnection: BrowserHubConnection, UserSettings: UserSettings, Sound: Sound, + GetMotd() { + fetch("https://remotely.one/api/motd") + .then(async response => { + var content = await response.text(); + if (localStorage["remotely-motd"] == content) { + return; + } + + UI.MotdAlert.innerHTML += content; + UI.MotdAlert.removeAttribute("hidden"); + UI.MotdAlert.querySelector("button").addEventListener("click", () => { + localStorage["remotely-motd"] = content; + }); + }) + .catch(reason => { + console.warn(`Unable to retrieve message of the day. Error: ${reason}`); + }) + }, Init() { + MainApp.GetMotd(); UI.ConsoleTextArea.focus(); ApplyInputEventHandlers(); BrowserHubConnection.Connect(); diff --git a/Server/wwwroot/src/Main/UI.ts b/Server/wwwroot/src/Main/UI.ts index 7e9a4ab7e..abdd501a3 100644 --- a/Server/wwwroot/src/Main/UI.ts +++ b/Server/wwwroot/src/Main/UI.ts @@ -25,4 +25,5 @@ export var RightPaginationButton = document.querySelector("#rightPaginationButto export var TabContentWrapper = document.getElementById("tabContentWrapper") as HTMLDivElement; export var ToastsWrapper = document.getElementById("toastsWrapper") as HTMLDivElement; export var TotalDevicesCount = document.querySelector("#totalDevicesSpan") as HTMLSpanElement; -export var TotalPagesSpan = document.querySelector("#totalPagesSpan") as HTMLSpanElement; \ No newline at end of file +export var TotalPagesSpan = document.querySelector("#totalPagesSpan") as HTMLSpanElement; +export var MotdAlert = document.getElementById("motdAlert") as HTMLDivElement; \ No newline at end of file