mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
Add branding reset button. Add numeric inputs for rgb values.
This commit is contained in:
parent
7178314d90
commit
37feeed7ba
@ -1,17 +1,20 @@
|
||||
@using Remotely.Server.Models
|
||||
|
||||
<div>
|
||||
<label>Color Sample:</label>
|
||||
<div class="color-sample mb-1" style="background-color:@($"rgb({Red},{Green},{Blue})")"></div>
|
||||
<div>Color Sample:</div>
|
||||
<div class="color-sample mb-4" style="background-color:@($"rgb({Red},{Green},{Blue})")"></div>
|
||||
|
||||
<label>Red</label>
|
||||
<div>Red</div>
|
||||
<input type="range" min="0" max="255" class="form-control red-picker" @bind="Red" />
|
||||
<input type="number" min="0" max="255" class="form-control mb-4" style="width: 150px" @bind="Red" />
|
||||
|
||||
<label>Green</label>
|
||||
<div>Green</div>
|
||||
<input type="range" min="0" max="255" class="form-control green-picker" @bind="Green" />
|
||||
<input type="number" min="0" max="255" class="form-control mb-4" style="width: 150px" @bind="Green" />
|
||||
|
||||
<label>Blue</label>
|
||||
<div>Blue</div>
|
||||
<input type="range" min="0" max="255" class="form-control blue-picker" @bind="Blue" />
|
||||
<input type="number" min="0" max="255" class="form-control mb-4" style="width: 150px" @bind="Blue" />
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
@page "/branding"
|
||||
@inherits AuthComponentBase
|
||||
@inject IDataService DataService
|
||||
@inject IToastService ToastService
|
||||
@inject IDataService DataService
|
||||
@inject IToastService ToastService
|
||||
@inject IJsInterop JsInterop
|
||||
@using Remotely.Server.Models
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
|
||||
<h3 class="mb-3">Branding</h3>
|
||||
|
||||
@ -63,6 +64,7 @@ else
|
||||
<ColorPicker @bind-Color="_inputModel.TitleButtonColor" />
|
||||
</div>
|
||||
<div class="form-group text-right">
|
||||
<button class="btn btn-secondary mr-3" type="button" @onclick="ResetBranding">Reset</button>
|
||||
<button class="btn btn-primary" type="submit">Submit</button>
|
||||
</div>
|
||||
</EditForm>
|
||||
@ -89,6 +91,32 @@ else
|
||||
public byte[] IconBytes { get; set; }
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
await LoadBrandingInfo();
|
||||
}
|
||||
|
||||
private async Task HandleValidSubmit(EditContext context)
|
||||
{
|
||||
await DataService.UpdateBrandingInfo(
|
||||
User.OrganizationID,
|
||||
_inputModel.ProductName,
|
||||
_inputModel.IconBytes,
|
||||
_inputModel.TitleForegroundColor,
|
||||
_inputModel.TitleBackgroundColor,
|
||||
_inputModel.TitleButtonColor);
|
||||
|
||||
if (_inputModel?.IconBytes?.Any() == true)
|
||||
{
|
||||
_base64Icon = Convert.ToBase64String(_inputModel.IconBytes);
|
||||
}
|
||||
|
||||
_alertMessage = "Branding saved.";
|
||||
ToastService.ShowToast("Branding saved.");
|
||||
}
|
||||
|
||||
private async Task IconUploadInputChanged(InputFileChangeEventArgs args)
|
||||
{
|
||||
if (args.File is null)
|
||||
@ -107,26 +135,8 @@ else
|
||||
await rs.ReadAsync(_inputModel.IconBytes, 0, (int)args.File.Size);
|
||||
}
|
||||
|
||||
private async Task HandleValidSubmit(EditContext context)
|
||||
private async Task LoadBrandingInfo()
|
||||
{
|
||||
await DataService.UpdateBrandingInfo(
|
||||
User.OrganizationID,
|
||||
_inputModel.ProductName,
|
||||
_inputModel.IconBytes,
|
||||
_inputModel.TitleForegroundColor,
|
||||
_inputModel.TitleBackgroundColor,
|
||||
_inputModel.TitleButtonColor);
|
||||
|
||||
_base64Icon = Convert.ToBase64String(_inputModel.IconBytes);
|
||||
|
||||
_alertMessage = "Branding saved.";
|
||||
ToastService.ShowToast("Branding saved.");
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
var organization = await DataService.GetOrganizationByUserName(User.UserName);
|
||||
|
||||
var brandingInfo = await DataService.GetBrandingInfo(organization.ID);
|
||||
@ -151,4 +161,15 @@ else
|
||||
_inputModel.TitleButtonColor.Green = brandingInfo.ButtonForegroundGreen;
|
||||
_inputModel.TitleButtonColor.Blue = brandingInfo.ButtonForegroundBlue;
|
||||
}
|
||||
|
||||
private async Task ResetBranding()
|
||||
{
|
||||
var result = await JsInterop.Confirm("Are you sure you want to reset branding to default?");
|
||||
if (result)
|
||||
{
|
||||
await DataService.ResetBranding(User.OrganizationID);
|
||||
await LoadBrandingInfo();
|
||||
ToastService.ShowToast("Branding reset.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -186,6 +186,8 @@ namespace Remotely.Server.Services
|
||||
Task<bool> RemoveUserFromDeviceGroup(string orgID, string groupID, string userID);
|
||||
Task RenameApiToken(string userName, string tokenId, string tokenName);
|
||||
|
||||
Task ResetBranding(string organizationId);
|
||||
|
||||
void SetAllDevicesNotOnline();
|
||||
|
||||
Task SetDisplayName(RemotelyUser user, string displayName);
|
||||
@ -1713,6 +1715,24 @@ namespace Remotely.Server.Services
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task ResetBranding(string organizationId)
|
||||
{
|
||||
using var dbContext = _dbFactory.CreateDbContext();
|
||||
|
||||
var organization = await dbContext.Organizations
|
||||
.Include(x => x.BrandingInfo)
|
||||
.FirstOrDefaultAsync(x => x.ID == organizationId);
|
||||
|
||||
if (organization is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
organization.BrandingInfo = new BrandingInfo();
|
||||
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public void SetAllDevicesNotOnline()
|
||||
{
|
||||
using var dbContext = _dbFactory.CreateDbContext();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user