Add RCON support to UI for adding consoles
This commit is contained in:
parent
1281ebff15
commit
463322b709
7 changed files with 1548 additions and 24 deletions
|
@ -12,7 +12,7 @@ namespace LANCommander.Data.Models
|
||||||
public string Path { get; set; } = "";
|
public string Path { get; set; } = "";
|
||||||
|
|
||||||
public string Host { get; set; } = "";
|
public string Host { get; set; } = "";
|
||||||
public int Port { get; set; }
|
public int? Port { get; set; }
|
||||||
|
|
||||||
// Change to a secure string at some point
|
// Change to a secure string at some point
|
||||||
public string Password { get; set; } = "";
|
public string Password { get; set; } = "";
|
||||||
|
|
1431
LANCommander/Migrations/20230818054703_NullRconPort.Designer.cs
generated
Normal file
1431
LANCommander/Migrations/20230818054703_NullRconPort.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
36
LANCommander/Migrations/20230818054703_NullRconPort.cs
Normal file
36
LANCommander/Migrations/20230818054703_NullRconPort.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace LANCommander.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class NullRconPort : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "Port",
|
||||||
|
table: "ServerConsoles",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "INTEGER");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "Port",
|
||||||
|
table: "ServerConsoles",
|
||||||
|
type: "INTEGER",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "INTEGER",
|
||||||
|
oldNullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -683,7 +683,7 @@ namespace LANCommander.Migrations
|
||||||
b.ToTable("Servers");
|
b.ToTable("Servers");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LANCommander.Data.Models.ServerLog", b =>
|
modelBuilder.Entity("LANCommander.Data.Models.ServerConsole", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
|
@ -711,7 +711,7 @@ namespace LANCommander.Migrations
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int>("Port")
|
b.Property<int?>("Port")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<Guid?>("ServerId")
|
b.Property<Guid?>("ServerId")
|
||||||
|
@ -1296,7 +1296,7 @@ namespace LANCommander.Migrations
|
||||||
b.Navigation("UpdatedBy");
|
b.Navigation("UpdatedBy");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LANCommander.Data.Models.ServerLog", b =>
|
modelBuilder.Entity("LANCommander.Data.Models.ServerConsole", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
|
b.HasOne("LANCommander.Data.Models.User", "CreatedBy")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
|
@ -1309,7 +1309,7 @@ namespace LANCommander.Migrations
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("LANCommander.Data.Models.Server", null)
|
b.HasOne("LANCommander.Data.Models.Server", null)
|
||||||
.WithMany("ServerLogs")
|
.WithMany("ServerConsoles")
|
||||||
.HasForeignKey("ServerId1");
|
.HasForeignKey("ServerId1");
|
||||||
|
|
||||||
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
|
b.HasOne("LANCommander.Data.Models.User", "UpdatedBy")
|
||||||
|
@ -1415,7 +1415,7 @@ namespace LANCommander.Migrations
|
||||||
|
|
||||||
modelBuilder.Entity("LANCommander.Data.Models.Server", b =>
|
modelBuilder.Entity("LANCommander.Data.Models.Server", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ServerLogs");
|
b.Navigation("ServerConsoles");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LANCommander.Data.Models.User", b =>
|
modelBuilder.Entity("LANCommander.Data.Models.User", b =>
|
||||||
|
|
|
@ -3,23 +3,72 @@
|
||||||
@using LANCommander.Extensions;
|
@using LANCommander.Extensions;
|
||||||
|
|
||||||
<Space Direction="DirectionVHType.Vertical" Size="@("large")" Style="width: 100%">
|
<Space Direction="DirectionVHType.Vertical" Size="@("large")" Style="width: 100%">
|
||||||
<SpaceItem>
|
@foreach (var console in Value)
|
||||||
<Table TItem="ServerConsole" DataSource="@Value" HidePagination="true">
|
{
|
||||||
<PropertyColumn Property="m => m.Name">
|
<SpaceItem>
|
||||||
<Input Type="text" @bind-Value="context.Name" />
|
@if (console.Type == ServerConsoleType.RCON)
|
||||||
</PropertyColumn>
|
{
|
||||||
<PropertyColumn Property="m => m.Path">
|
<Card Size="small">
|
||||||
<Input Type="text" @bind-Value="context.Path" />
|
<Body>
|
||||||
</PropertyColumn>
|
<Form Layout="@FormLayout.Vertical" Model="@console">
|
||||||
<ActionColumn>
|
<GridRow Gutter="16">
|
||||||
<Space Style="display: flex; justify-content: end">
|
<GridCol Span="8">
|
||||||
<SpaceItem>
|
<FormItem Label="Type">
|
||||||
<Button OnClick="() => RemoveConsole(context)" Type="@ButtonType.Text" Danger Icon="@IconType.Outline.Close" />
|
<Select @bind-Value="context.Type" TItem="ServerConsoleType" TItemValue="ServerConsoleType" DataSource="Enum.GetValues<ServerConsoleType>()">
|
||||||
</SpaceItem>
|
<LabelTemplate Context="Value">@Value.GetDisplayName()</LabelTemplate>
|
||||||
</Space>
|
<ItemTemplate Context="Value">@Value.GetDisplayName()</ItemTemplate>
|
||||||
</ActionColumn>
|
</Select>
|
||||||
</Table>
|
</FormItem>
|
||||||
</SpaceItem>
|
<FormItem Label="Name">
|
||||||
|
<Input @bind-Value="context.Name" />
|
||||||
|
</FormItem>
|
||||||
|
</GridCol>
|
||||||
|
|
||||||
|
<GridCol Span="16">
|
||||||
|
<FormItem Label="Server">
|
||||||
|
<InputGroup Compact>
|
||||||
|
<Input @bind-Value="context.Host" Placeholder="Host" />
|
||||||
|
<Input @bind-Value="context.Port" Placeholder="Port" Style="width: 25%" />
|
||||||
|
</InputGroup>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem Label="Password">
|
||||||
|
<InputPassword @bind-Value="context.Password" Placeholder="Password" />
|
||||||
|
</FormItem>
|
||||||
|
</GridCol>
|
||||||
|
</GridRow>
|
||||||
|
</Form>
|
||||||
|
</Body>
|
||||||
|
</Card>
|
||||||
|
}
|
||||||
|
else if (console.Type == ServerConsoleType.LogFile)
|
||||||
|
{
|
||||||
|
<Card Size="small">
|
||||||
|
<Body>
|
||||||
|
<Form Layout="@FormLayout.Vertical" Model="@console">
|
||||||
|
<GridRow Gutter="16">
|
||||||
|
<GridCol Span="8">
|
||||||
|
<FormItem Label="Type">
|
||||||
|
<Select @bind-Value="context.Type" TItem="ServerConsoleType" TItemValue="ServerConsoleType" DataSource="Enum.GetValues<ServerConsoleType>()">
|
||||||
|
<LabelTemplate Context="Value">@Value.GetDisplayName()</LabelTemplate>
|
||||||
|
<ItemTemplate Context="Value">@Value.GetDisplayName()</ItemTemplate>
|
||||||
|
</Select>
|
||||||
|
</FormItem>
|
||||||
|
<FormItem Label="Name">
|
||||||
|
<Input Type="text" @bind-Value="context.Name" />
|
||||||
|
</FormItem>
|
||||||
|
</GridCol>
|
||||||
|
<GridCol Span="16">
|
||||||
|
<FormItem Label="Path">
|
||||||
|
<Input Type="text" @bind-Value="context.Path" Placeholder="Host" />
|
||||||
|
</FormItem>
|
||||||
|
</GridCol>
|
||||||
|
</GridRow>
|
||||||
|
</Form>
|
||||||
|
</Body>
|
||||||
|
</Card>
|
||||||
|
}
|
||||||
|
</SpaceItem>
|
||||||
|
}
|
||||||
|
|
||||||
<SpaceItem>
|
<SpaceItem>
|
||||||
<GridRow Justify="end">
|
<GridRow Justify="end">
|
||||||
|
|
|
@ -202,7 +202,7 @@ namespace LANCommander.Services
|
||||||
{
|
{
|
||||||
if (!RconConnections.ContainsKey(console.Id))
|
if (!RconConnections.ContainsKey(console.Id))
|
||||||
{
|
{
|
||||||
var rcon = new RCON(new IPEndPoint(IPAddress.Parse(console.Host), console.Port), console.Password);
|
var rcon = new RCON(new IPEndPoint(IPAddress.Parse(console.Host), console.Port.GetValueOrDefault()), console.Password);
|
||||||
|
|
||||||
RconConnections[console.Id] = rcon;
|
RconConnections[console.Id] = rcon;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
.ant-select-selector {
|
.ant-select-selector {
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ant-card .ant-form > .ant-form-item {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ant-card .ant-form > .ant-form-item:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue