Added server rename setting

This commit is contained in:
Marcel Baumgartner 2023-04-04 01:54:06 +02:00
parent 1a39faff9e
commit ef58478232
5 changed files with 57 additions and 1 deletions

View file

@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace Moonlight.App.Models.Forms;
public class ServerRenameDataModel
{
[Required(ErrorMessage = "You need to enter a name")]
[MaxLength(32, ErrorMessage = "The name cannot be longer that 32 characters")]
public string Name { get; set; }
}

View file

@ -53,6 +53,8 @@
if(Tags.Contains("pythonfile"))
Settings.Add("Python file", typeof(PythonFileSetting));
Settings.Add("Server rename", typeof(ServerRenameSetting));
Settings.Add("Server reset", typeof(ServerResetSetting));
return Task.CompletedTask;

View file

@ -0,0 +1,41 @@
@using Moonlight.App.Repositories.Servers
@using Moonlight.App.Database.Entities
@using Moonlight.App.Models.Forms
@inject ServerRepository ServerRepository
<div class="input-group mb-3">
<LazyLoader @ref="LazyLoader" Load="Load">
<SmartForm Model="Model" OnValidSubmit="Rename">
<div class="input-group mb-3">
<InputText @bind-Value="Model.Name" type="text" class="form-control"></InputText>
<button class="btn btn-primary" type="submit"><TL>Rename</TL></button>
</div>
</SmartForm>
</LazyLoader>
</div>
@code
{
[CascadingParameter]
public Server CurrentServer { get; set; }
private ServerRenameDataModel Model = new();
private LazyLoader LazyLoader;
private Task Load(LazyLoader arg)
{
Model.Name = CurrentServer.Name;
return Task.CompletedTask;
}
private async Task Rename()
{
CurrentServer.Name = Model.Name;
ServerRepository.Update(CurrentServer);
await LazyLoader.Reload();
}
}

View file

@ -179,7 +179,7 @@
.Where(x => x.Owner.Id == User.Id)
.Count(x => x.Image.Id == image.Id);
if(serversCount < limit.Amount)
if(serversCount <= limit.Amount)
Images.Add(image, limit);
}
}

View file

@ -471,3 +471,6 @@ Default;Default
You reached the maximum amount of servers for every image of your subscription;You reached the maximum amount of servers for every image of your subscription
Personal information;Personal information
Enter code;Enter code
Server rename;Server rename
Create code;Create code
Save subscription;Save subscription