Testing custom loaders
This commit is contained in:
@@ -50,5 +50,6 @@ public class CreateServerForm
|
|||||||
[Description("The allocations the server should have")]
|
[Description("The allocations the server should have")]
|
||||||
[MultiSelection("Port", "Port", Icon = "bx-network-chart")]
|
[MultiSelection("Port", "Port", Icon = "bx-network-chart")]
|
||||||
[Section("Deployment", Icon = "bx-cube")]
|
[Section("Deployment", Icon = "bx-cube")]
|
||||||
|
[CustomItemLoader("FreeAllocations")]
|
||||||
public List<ServerAllocation> Allocations { get; set; } = new();
|
public List<ServerAllocation> Allocations { get; set; } = new();
|
||||||
}
|
}
|
||||||
@@ -41,6 +41,9 @@
|
|||||||
</Template>
|
</Template>
|
||||||
</CrudColumn>
|
</CrudColumn>
|
||||||
</View>
|
</View>
|
||||||
|
<CustomLoaders>
|
||||||
|
<DefineCustomLoader T="ServerAllocation" Id="FreeAllocations" Func="LoadFreeAllocations" />
|
||||||
|
</CustomLoaders>
|
||||||
<NoItemsView>
|
<NoItemsView>
|
||||||
<IconAlert Title="No servers found" Color="primary" Icon="bx-search-alt">
|
<IconAlert Title="No servers found" Color="primary" Icon="bx-search-alt">
|
||||||
Create a new server in order to manage it using this page. Need help? Check out our <a href="https://docs.moonlightpanel.xyz">documentation</a>
|
Create a new server in order to manage it using this page. Need help? Check out our <a href="https://docs.moonlightpanel.xyz">documentation</a>
|
||||||
@@ -56,9 +59,17 @@
|
|||||||
.Get()
|
.Get()
|
||||||
.Include(x => x.Owner)
|
.Include(x => x.Owner)
|
||||||
.Include(x => x.Image)
|
.Include(x => x.Image)
|
||||||
|
.Include(x => x.Allocations)
|
||||||
.Include(x => x.Node);
|
.Include(x => x.Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<ServerAllocation> LoadFreeAllocations(Repository<ServerAllocation> repository)
|
||||||
|
{
|
||||||
|
return repository
|
||||||
|
.Get()
|
||||||
|
.FromSqlRaw("SELECT * FROM `ServerAllocations` WHERE ServerId IS NULL");
|
||||||
|
}
|
||||||
|
|
||||||
private async Task CustomAdd(Server form) => await ServerService.Create(form);
|
private async Task CustomAdd(Server form) => await ServerService.Create(form);
|
||||||
|
|
||||||
private async Task CustomDelete(Server s) => await ServerService.Delete(s);
|
private async Task CustomDelete(Server s) => await ServerService.Delete(s);
|
||||||
|
|||||||
Reference in New Issue
Block a user