Panel Management
Managing panels encompasses the following interactions:
- Listing all panel IDs
- Getting the definition of a panel
- Creating or updating a panel
- Deleting a panel
The following examples assume you already have a configured
BoomackClient
instance in the variable client
.
See Get Started if you do not know how to configure
a BoomackClient instance.
List Panel IDs
The method GetPanelIds() returns a IdListResponse, which is an enumerable of strings.
var response = await client.GetPanelIds();
foreach (var id in response)
{
Console.WriteLine("- " + id);
}
Get Panel
The method GetPanel(string) returns a PanelLayoutResponse.
var response = await client.GetPanel("default");
var layout = response.PanelLayout;
Console.WriteLine("Layout Type: {0}", layout.Type);
if (layout is GridPanelLayout gridLayout)
{
Console.WriteLine("Grid: {0}x{1}",
gridLayout.Grid.Rows, gridLayout.Grid.Columns);
}
if (layout is DocumentPanelLayout documentLayout)
{
Console.WriteLine("Slots:");
foreach (var slotId in documentLayout.Slots.Keys)
{
Console.WriteLine("- {0}", slotId);
}
}
Create or Update Panel
On the HTTP API level of the Boomack Server, creating and updating are the same operation. Both are implemented by an HTTP PUT request.
To make the code using this client library more readable, however, two methods are available that do the same thing in the background:
var layout = new GridPanelLayout()
{
Title = "My Panel",
DefaultSlot = "main",
Grid = new GridLayout()
{
Rows = 4,
Columns = 2,
},
Slots = new Dictionary<string, GridSlot>()
{
{ "top", new GridSlot() { ColumnSpan = 2, Border = false, Toolbar = false } },
{ "main", new GridSlot() { Row = 1, RowSpan = 2, ColumnSpan = 2 } },
{ "left", new GridSlot() { Row = 3 } },
{ "right", new GridSlot() { Row = 3, Column = 1 } },
},
};
var response = await client.AddPanel("my-panel", layout);
Hint: If you do not like the ambivalence in this design, just use SetPanelLayout(string, PanelLayout) in all cases.
Delete Panel
For the deletion of a panel you just need the panel ID.
await client.DeletePanel("my-panel");
Important: You can not delete the panel default
.
Next: Preset Management