Add theme option to UserOptions.

This commit is contained in:
Jared Goodwin 2020-02-23 14:22:16 -08:00
parent d474a786e8
commit 8ac490e759
4 changed files with 56 additions and 6 deletions

View File

@ -16,6 +16,16 @@
}
<form method="post">
<div asp-validation-summary="All"></div>
<div class="form-group">
<label asp-for="Options.Theme" class="control-label"></label>
<br />
<select asp-for="Options.Theme" asp-items="@Html.GetEnumSelectList<Remotely.Shared.Enums.Theme>()" class="form-control" ></select>
<br />
<span asp-validation-for="Options.Theme"></span>
</div>
<div class="form-group">
<label asp-for="Options.ConsolePrompt" class="control-label"></label>
<br />
@ -66,6 +76,7 @@
<br />
<span asp-validation-for="Options.CommandModeShortcutBash"></span>
</div>
<div class="form-group">
<button type="submit" class="btn btn-secondary">Save</button>
</div>

View File

@ -1,4 +1,5 @@
@inject Remotely.Server.Services.ApplicationConfig AppConfig
@inject UserManager<Remotely.Shared.Models.RemotelyUser> UserManager
<!DOCTYPE html>
<html>
<head>
@ -14,17 +15,38 @@
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link href="~/lib/fontawesome/css/all.min.css" rel="stylesheet" />
@if (AppConfig.Theme.ToLower() == "light")
@if (User.Identity.IsAuthenticated)
{
<link rel="stylesheet" href="~/css/Themes/yeti.min.css" />
<link rel="stylesheet" href="~/css/Themes/yeti.custom.css" asp-append-version="true" />
var user = await UserManager.GetUserAsync(User);
switch (user.UserOptions.Theme)
{
case Remotely.Shared.Enums.Theme.Light:
<link rel="stylesheet" href="~/css/Themes/yeti.min.css" />
<link rel="stylesheet" href="~/css/Themes/yeti.custom.css" asp-append-version="true" />
break;
case Remotely.Shared.Enums.Theme.Dark:
<link rel="stylesheet" href="~/css/Themes/cyborg.min.css" />
<link rel="stylesheet" href="~/css/Themes/cyborg.custom.css" asp-append-version="true" />
break;
default:
break;
}
}
else
{
<link rel="stylesheet" href="~/css/Themes/cyborg.min.css" />
<link rel="stylesheet" href="~/css/Themes/cyborg.custom.css" asp-append-version="true" />
if (AppConfig.Theme.ToLower() == "light")
{
<link rel="stylesheet" href="~/css/Themes/yeti.min.css" />
<link rel="stylesheet" href="~/css/Themes/yeti.custom.css" asp-append-version="true" />
}
else
{
<link rel="stylesheet" href="~/css/Themes/cyborg.min.css" />
<link rel="stylesheet" href="~/css/Themes/cyborg.custom.css" asp-append-version="true" />
}
}
<environment include="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/popper.js/popper.js"></script>

13
Shared/Enums/Theme.cs Normal file
View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
namespace Remotely.Shared.Enums
{
public enum Theme
{
Light,
Dark
}
}

View File

@ -1,4 +1,5 @@
using System;
using Remotely.Shared.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -25,5 +26,8 @@ namespace Remotely.Shared.Models
[Display(Name = "Bash Shortcut")]
[StringLength(10)]
public string CommandModeShortcutBash { get; set; } = "/bash";
[Display(Name = "Theme")]
public Theme Theme { get; set; }
}
}