Skip to content

Commit

Permalink
Add MotD.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Jan 21, 2021
1 parent 7e61c23 commit e4da4c2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Server/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
}
else
{
<div id="motdAlert" class="alert alert-info alert-dismissible mr-5" role="alert" hidden>
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>

<partial name="_LoadingWheel" model="Model" />
<partial name="_IndexLoggedIn" model="Model" />
}
19 changes: 19 additions & 0 deletions Server/wwwroot/src/Main/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion Server/wwwroot/src/Main/UI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
export var TotalPagesSpan = document.querySelector("#totalPagesSpan") as HTMLSpanElement;
export var MotdAlert = document.getElementById("motdAlert") as HTMLDivElement;

0 comments on commit e4da4c2

Please sign in to comment.