2024-12-23 19:12:00 -05:00
|
|
|
@*
|
|
|
|
* Copyright 2024 Ivy Collective <sys@ivycollective.dev>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*@
|
|
|
|
|
|
|
|
@page "/settings"
|
2024-12-23 15:37:42 -05:00
|
|
|
@layout MainLayout
|
|
|
|
@using Blazored.LocalStorage
|
|
|
|
@inject SettingsService savedSettings
|
|
|
|
@inject ILocalStorageService localStorage
|
|
|
|
@inject NavigationManager Navigation
|
|
|
|
|
|
|
|
<PageTitle>Settings</PageTitle>
|
|
|
|
|
|
|
|
<h1>Settings</h1>
|
|
|
|
|
2024-12-23 18:56:51 -05:00
|
|
|
<p>
|
|
|
|
<FluentButton OnClick="ApplySettingsAsync" Appearance="Appearance.Accent">Apply changes</FluentButton>
|
|
|
|
<FluentButton OnClick="ResetSettings">Undo changes</FluentButton>
|
|
|
|
</p>
|
2024-12-23 15:37:42 -05:00
|
|
|
|
|
|
|
<h2>Appearance</h2>
|
|
|
|
|
|
|
|
<p>Switch between light and dark mode, and pick your accent color</p>
|
|
|
|
|
2024-12-23 18:56:51 -05:00
|
|
|
<p>
|
|
|
|
<FluentRadioGroup Name="Color theme" Required="true" @bind-Value=TmpSettings.ThemeMode>
|
|
|
|
<FluentRadio Value="@DesignThemeModes.System">System (automatically set)</FluentRadio>
|
|
|
|
<FluentRadio Value="@DesignThemeModes.Light">Light</FluentRadio>
|
|
|
|
<FluentRadio Value="@DesignThemeModes.Dark">Dark</FluentRadio>
|
|
|
|
</FluentRadioGroup>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
<FluentSelect
|
|
|
|
Label="Accent color" Required="true"
|
|
|
|
Items="@(new List<OfficeColor>((OfficeColor[]) Enum.GetValues(typeof(OfficeColor))))"
|
|
|
|
@bind-SelectedOption=TmpSettings.AccentColor
|
|
|
|
/>
|
|
|
|
</p>
|
2024-12-23 15:37:42 -05:00
|
|
|
|
|
|
|
<h2>API Server</h2>
|
|
|
|
|
|
|
|
<p>If your API server isn't the default, you can change it here.</p>
|
|
|
|
<FluentTextField @bind-Value=TmpSettings.ApiURL Placeholder="@DefaultSettings.ApiURL" style="width: 100%;"></FluentTextField>
|
|
|
|
<p>Make sure the URL doesn't end with a /, and is a valid URL. You'll be automatically signed out when reloading the page.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2>Sign out</h2>
|
|
|
|
|
|
|
|
<p>You can sign out here. If you want to, you can optionally sign out of all linked applications for your account.</p>
|
|
|
|
|
2024-12-23 18:56:51 -05:00
|
|
|
<p>
|
|
|
|
<FluentButton Appearance="Appearance.Accent" OnClick="SignOut">Sign out</FluentButton>
|
|
|
|
<FluentAnchor Href='@savedSettings.Settings.RelativeUrl("/auth/unlink")'>Unlink applications</FluentAnchor>
|
|
|
|
</p>
|
2024-12-23 15:37:42 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2>Reset settings to defaults</h2>
|
|
|
|
|
|
|
|
<FluentButton OnClick="ResetToDefaultsAndSave">Reset all to defaults (cannot be undone)</FluentButton>
|
|
|
|
|
|
|
|
@code {
|
|
|
|
public SiteSettings DefaultSettings { get; set; } = new SiteSettings();
|
|
|
|
public SiteSettings TmpSettings { get; set; } = new SiteSettings();
|
|
|
|
|
|
|
|
protected override Task OnInitializedAsync() {
|
|
|
|
ResetSettings();
|
|
|
|
return Task.CompletedTask;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ResetSettings() {
|
|
|
|
TmpSettings = savedSettings.Settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task ApplySettingsAsync() {
|
|
|
|
savedSettings.Settings = TmpSettings;
|
|
|
|
await localStorage.SetItemAsync("settings", savedSettings.Serialize());
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task ResetToDefaultsAndSave() {
|
|
|
|
TmpSettings = DefaultSettings.Clone();
|
|
|
|
await ApplySettingsAsync();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task SignOut() {
|
|
|
|
await localStorage.RemoveItemAsync("jwt");
|
|
|
|
Navigation.NavigateTo("/login");
|
|
|
|
}
|
|
|
|
}
|