Refactor configuration data export and template loading functions
- Updated Export-ConfigurationData to use resolved configuration data directly and added error handling for missing data. - Enhanced Load-Templates to streamline category loading and improve error handling for missing template directories. - Removed Merge-ConfigurationData function as it is no longer needed. - Refactored Merge-Templates to improve merging logic and handle default files more effectively. - Introduced Get-TemplatePreviewData function to handle template preview data retrieval and merging. - Added Import-OrderedPowerShellDataFile function to support ordered hashtable imports. - Updated Update-ParametersPanel to handle parameter and variable tab updates more efficiently. - Improved Update-TreeView to handle cases where resources are not found. - Added new parameters to Environment.Default.psd1 for Active Directory configuration. - Created new template BGW-LAN.psd1 for domain configuration.
This commit is contained in:
@@ -2,54 +2,64 @@ function Update-ParametersPanel {
|
||||
Param(
|
||||
[System.Collections.Hashtable] $ConfigurationData
|
||||
)
|
||||
|
||||
if ($ConfigurationData.Contains("Parameters") -or $ConfigurationData.Contains("Variables")) {
|
||||
if ($ConfigurationData.Contains("Parameters")) {
|
||||
if (!($tabControl.Controls | ? { $_.Text -eq "Parameters" })) {
|
||||
$ParametersTabPage = (
|
||||
[TabPageBuilder]::new("Parameters").
|
||||
Build()
|
||||
)
|
||||
}
|
||||
|
||||
$GridView = (
|
||||
[DataGridViewBuilder]::new().
|
||||
SetHeaderColumns(@("Name", "Value")).
|
||||
SetHeaderColumnReadOnly("Name").
|
||||
Build()
|
||||
)
|
||||
|
||||
foreach ($Parameter in $ConfigurationData.Parameters.GetEnumerator()) {
|
||||
$GridView.Rows.Add($Parameter.Name, $($Parameter.Value.Value)) | Out-Null
|
||||
|
||||
}
|
||||
$ParametersTabPage.Controls.Add($GridView)
|
||||
$tabControl.Controls.Add($ParametersTabPage)
|
||||
|
||||
}
|
||||
|
||||
if ($ConfigurationData.Contains("Variables")) {
|
||||
if (!($tabControl.Controls | ? { $_.Text -eq "Variables" })) {
|
||||
$VariablesTabPage = (
|
||||
[TabPageBuilder]::new("Variables").
|
||||
Build()
|
||||
)
|
||||
}
|
||||
|
||||
$GridView = (
|
||||
[DataGridViewBuilder]::new().
|
||||
SetHeaderColumns(@("Name", "Value")).
|
||||
SetHeaderColumnReadOnly("Name").
|
||||
Build()
|
||||
)
|
||||
|
||||
foreach ($Variable in $ConfigurationData.Variables.GetEnumerator()) {
|
||||
$GridView.Rows.Add($Variable.Name, $($Variable.Value)) | Out-Null
|
||||
|
||||
}
|
||||
$VariablesTabPage.Controls.Add($GridView)
|
||||
$tabControl.Controls.Add($VariablesTabPage)
|
||||
|
||||
foreach ($tabName in @("Parameters", "Variables")) {
|
||||
$existingTabs = @($tabControl.Controls | Where-Object { $_.Text -eq $tabName })
|
||||
foreach ($tab in $existingTabs) {
|
||||
$tabControl.Controls.Remove($tab)
|
||||
$tab.Dispose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($null -eq $ConfigurationData) {
|
||||
return
|
||||
}
|
||||
|
||||
if ($ConfigurationData.Contains("Parameters")) {
|
||||
$parametersTabPage = (
|
||||
[TabPageBuilder]::new("Parameters").
|
||||
Build()
|
||||
)
|
||||
|
||||
$gridView = (
|
||||
[DataGridViewBuilder]::new().
|
||||
SetHeaderColumns(@("Name", "Value", "Type", "Required")).
|
||||
SetHeaderColumnReadOnly("Name").
|
||||
Build()
|
||||
)
|
||||
|
||||
foreach ($parameter in $ConfigurationData.Parameters.GetEnumerator()) {
|
||||
$value = $parameter.Value
|
||||
$gridView.Rows.Add(
|
||||
$parameter.Name,
|
||||
$value.Value,
|
||||
$value.Type,
|
||||
$value.Required
|
||||
) | Out-Null
|
||||
}
|
||||
|
||||
$parametersTabPage.Controls.Add($gridView)
|
||||
$tabControl.Controls.Add($parametersTabPage)
|
||||
}
|
||||
|
||||
if ($ConfigurationData.Contains("Variables")) {
|
||||
$variablesTabPage = (
|
||||
[TabPageBuilder]::new("Variables").
|
||||
Build()
|
||||
)
|
||||
|
||||
$gridView = (
|
||||
[DataGridViewBuilder]::new().
|
||||
SetHeaderColumns(@("Name", "Value")).
|
||||
SetHeaderColumnReadOnly("Name").
|
||||
Build()
|
||||
)
|
||||
|
||||
foreach ($variable in $ConfigurationData.Variables.GetEnumerator()) {
|
||||
$gridView.Rows.Add($variable.Name, $variable.Value) | Out-Null
|
||||
}
|
||||
|
||||
$variablesTabPage.Controls.Add($gridView)
|
||||
$tabControl.Controls.Add($variablesTabPage)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user