setDataToPanel
Introduction
The setDataToPanel methods allow you to override the data source URL of any configured panel at runtime. This is primarily intended for debugging and testing purposes.
Methods
setDataToPanel(_:)
Applies a single structured override to a panel.
nonisolated func setDataToPanel(_ override: MaestroPanelOverride) async -> Result<Void, MaestroPanelOverrideError>
Parameters
| Parameter | Type | Description |
|---|---|---|
override | MaestroPanelOverride | The structured override to apply. |
Return Value
A Result<Void, MaestroPanelOverrideError> indicating success or the specific error encountered.
setDataToPanels(_:)
Applies multiple structured overrides in a single call.
nonisolated func setDataToPanels(_ overrides: [MaestroPanelOverride]) async -> [Result<Void, MaestroPanelOverrideError>]
Parameters
| Parameter | Type | Description |
|---|---|---|
overrides | [MaestroPanelOverride] | An array of overrides to apply. |
Return Value
An array of Result<Void, MaestroPanelOverrideError>, one per override in the same order.
setDataToPanel(panelName:interfaceName:overwriteUrl:)
A backward-compatible convenience method using string parameters.
nonisolated func setDataToPanel(panelName: String, interfaceName: String, overwriteUrl: String) async -> String
Parameters
| Parameter | Type | Description |
|---|---|---|
panelName | String | The panel identifier (rawValue or display name). |
interfaceName | String | The interface to override (e.g., "overrideUrl"). |
overwriteUrl | String | The URL to use as the data source. |
Return Value
A String — "Success" or a description of the error.
Types
MaestroPanelOverride
A structured override describing how to replace the data source of a panel.
public struct MaestroPanelOverride: Sendable {
public var panelIdentifier: String
public var interfaceName: String
public var url: String
public init(panelIdentifier: String, interfaceName: String, url: String)
}
| Property | Type | Description |
|---|---|---|
panelIdentifier | String | The panel to target. Accepts the canonical rawValue or the display name. |
interfaceName | String | The sub-interface to override (currently "overrideUrl" is supported). |
url | String | The URL to use as the override data source. |
MaestroPanelOverrideError
Errors returned when applying a panel override.
public enum MaestroPanelOverrideError: Error, Sendable {
case noActiveEvent
case unsupportedPanelIdentifier(String)
case panelNotConfigured(MaestroPanelType)
case emptyURL
case unknown
case interfaceUnsupported(String)
}
| Case | Description |
|---|---|
noActiveEvent | No event is currently active. |
unsupportedPanelIdentifier | The provided panel identifier is not recognized. |
panelNotConfigured | The panel is not configured for the current event. |
emptyURL | The provided URL is empty. |
interfaceUnsupported | The provided interface name is not supported. |
unknown | An unknown error occurred. |
Code Example
// Override the Stats panel data source
let override = MaestroPanelOverride(
panelIdentifier: "stats",
interfaceName: "overrideUrl",
url: "https://api.npoint.io/your-json-slug"
)
let result = await MaestroManager.shared.setDataToPanel(override)
switch result {
case .success:
print("Stats endpoint overridden successfully")
case .failure(let error):
print("Failed to override: \(error.description)")
}
Notes
- An active event must be open before applying overrides.
- The target panel must be configured for the current event.
- Currently only the
"overrideUrl"interface is supported.