Skip to content

Commit

Permalink
Code Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelinux committed Feb 1, 2024
1 parent 97b7383 commit 496b6c3
Show file tree
Hide file tree
Showing 30 changed files with 660 additions and 734 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ The Veeam.Diagrammer supports the following Veeam Backup & Replication version;
### :closed_lock_with_key: Required Privileges

Only users with Veeam Backup Administrator role assigned can generate a Diagram

### PowerShell

This project is compatible with the following PowerShell versions;
Expand Down
36 changes: 13 additions & 23 deletions Src/Private/Convert-TableToHTML.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function Convert-TableToHTML
{
function Convert-TableToHTML {
<#
.SYNOPSIS
Creates a html table object
Expand Down Expand Up @@ -105,47 +104,38 @@ function Convert-TableToHTML
$HeaderColor = "black",

[string]
$HeaderFontColor="white",
$HeaderFontColor = "white",

[string]
$BorderColor="white"
$BorderColor = "white"
)
begin
{
begin {
$tableData = [System.Collections.ArrayList]::new()
if ( [string]::IsNullOrEmpty($Label) )
{
if ( [string]::IsNullOrEmpty($Label) ) {
$Label = $Name
}
}
process
{
if ( $null -ne $ScriptBlock )
{
process {
if ( $null -ne $ScriptBlock ) {
$Row = $ScriptBlock.Invoke()
}

if ( $null -ne $RowScript )
{
$Row = foreach ( $node in $Row )
{
if ( $null -ne $RowScript ) {
$Row = foreach ( $node in $Row ) {
@($node).ForEach($RowScript)
}
}

$results = foreach ( $node in $Row )
{
$results = foreach ( $node in $Row ) {
Row -Label $node
}

foreach ( $node in $results )
{
foreach ( $node in $results ) {
[void]$tableData.Add($node)
}
}
end
{
end {
$html = "<TABLE CELLBORDER='1' BORDER='0' CELLSPACING='0'><TR><TD bgcolor='$HeaderColor' align='center'><font color='$HeaderFontColor'><B>{0}</B></font></TD></TR>{1}</TABLE>" -f $Label, ($tableData -join '')
Node $Name @{label = $html; shape = 'none'; fontname = $Fontname; fontsize = $FontSize; style = $Style; penwidth = 1; fillcolor = $Fillcolor; color = $BorderColor}
Node $Name @{label = $html; shape = 'none'; fontname = $Fontname; fontsize = $FontSize; style = $Style; penwidth = 1; fillcolor = $Fillcolor; color = $BorderColor }
}
}
27 changes: 13 additions & 14 deletions Src/Private/Get-DiagBackupToFileProxy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,36 @@ function Get-DiagBackupToFileProxy {
fontsize = 18
penwidth = 1.5
labelloc = 't'
color=$SubGraphDebug.color
style='dashed,rounded'
color = $SubGraphDebug.color
style = 'dashed,rounded'
}
SubGraph MainSubGraph -Attributes $ProxiesAttr -ScriptBlock {
# Dummy Node used for subgraph centering
node DummyFileProxy @{Label=$DiagramDummyLabel; fontsize=18; fontname="Segoe Ui Black"; fontcolor='#005f4b'; shape='plain'}
Node DummyFileProxy @{Label = $DiagramDummyLabel; fontsize = 18; fontname = "Segoe Ui Black"; fontcolor = '#005f4b'; shape = 'plain' }
if ($Dir -eq "TB") {
node FileLeft @{Label='FileLeft'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
node FileLeftt @{Label='FileLeftt'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
node FileRight @{Label='FileRight'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
edge FileLeft,FileLeftt,DummyFileProxy,FileRight @{style=$EdgeDebug.style; color=$EdgeDebug.color}
rank FileLeft,FileLeftt,DummyFileProxy,FileRight
Node FileLeft @{Label = 'FileLeft'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node FileLeftt @{Label = 'FileLeftt'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node FileRight @{Label = 'FileRight'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Edge FileLeft, FileLeftt, DummyFileProxy, FileRight @{style = $EdgeDebug.style; color = $EdgeDebug.color }
Rank FileLeft, FileLeftt, DummyFileProxy, FileRight
}
foreach ($ProxyObj in $FileBackupProxy) {
$PROXYHASHTABLE = @{}
$ProxyObj.psobject.properties | ForEach-Object { $PROXYHASHTABLE[$_.Name] = $_.Value }
node $ProxyObj -NodeScript {$_.Name} @{Label=$PROXYHASHTABLE.Label; fontname="Segoe Ui"}
edge -From DummyFileProxy -To $ProxyObj.Name @{constraint="true"; minlen=1; style=$EdgeDebug.style; color=$EdgeDebug.color}
Node $ProxyObj -NodeScript { $_.Name } @{Label = $PROXYHASHTABLE.Label; fontname = "Segoe Ui" }
Edge -From DummyFileProxy -To $ProxyObj.Name @{constraint = "true"; minlen = 1; style = $EdgeDebug.style; color = $EdgeDebug.color }
}
Rank $FileBackupProxy.Name
}

if ($Dir -eq 'LR') {
edge $BackupServerInfo.Name -to DummyFileProxy @{minlen=3;}
Edge $BackupServerInfo.Name -To DummyFileProxy @{minlen = 3; }
} else {
edge $BackupServerInfo.Name -to DummyFileProxy @{minlen=3;}
Edge $BackupServerInfo.Name -To DummyFileProxy @{minlen = 3; }
}
}
}
}
catch {
} catch {
$_
}
}
Expand Down
27 changes: 13 additions & 14 deletions Src/Private/Get-DiagBackupToHvProxy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,35 @@ function Get-DiagBackupToHvProxy {
fontsize = 18
penwidth = 1.5
labelloc = 't'
color=$SubGraphDebug.color
style='dashed,rounded'
color = $SubGraphDebug.color
style = 'dashed,rounded'
}
SubGraph MainSubGraph -Attributes $ProxiesAttr -ScriptBlock {
# Dummy Node used for subgraph centering
node DummyHyperVProxy @{Label=$DiagramDummyLabel; fontsize=18; fontname="Segoe Ui Black"; fontcolor='#005f4b'; shape='plain'}
Node DummyHyperVProxy @{Label = $DiagramDummyLabel; fontsize = 18; fontname = "Segoe Ui Black"; fontcolor = '#005f4b'; shape = 'plain' }
if ($Dir -eq "TB") {
node HvLeft @{Label='HvLeft'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
node HvLeftt @{Label='HvLeftt'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
node HvRight @{Label='HvRight'; style=$EdgeDebug.style; color=$EdgeDebug.color; shape='plain'; fillColor='transparent'}
edge HvLeft,HvLeftt,DummyHyperVProxy,HvRight @{style=$EdgeDebug.style; color=$EdgeDebug.color}
rank HvLeft,HvLeftt,DummyHyperVProxy,HvRight
Node HvLeft @{Label = 'HvLeft'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node HvLeftt @{Label = 'HvLeftt'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Node HvRight @{Label = 'HvRight'; style = $EdgeDebug.style; color = $EdgeDebug.color; shape = 'plain'; fillColor = 'transparent' }
Edge HvLeft, HvLeftt, DummyHyperVProxy, HvRight @{style = $EdgeDebug.style; color = $EdgeDebug.color }
Rank HvLeft, HvLeftt, DummyHyperVProxy, HvRight
}
foreach ($ProxyObj in $HyperVBackupProxy) {
$PROXYHASHTABLE = @{}
$ProxyObj.psobject.properties | ForEach-Object { $PROXYHASHTABLE[$_.Name] = $_.Value }
node $ProxyObj -NodeScript {$_.Name} @{Label=$PROXYHASHTABLE.Label; fontname="Segoe Ui"}
edge -From DummyHyperVProxy -To $ProxyObj.Name @{constraint="true"; minlen=1; style=$EdgeDebug.style; color=$EdgeDebug.color}
Node $ProxyObj -NodeScript { $_.Name } @{Label = $PROXYHASHTABLE.Label; fontname = "Segoe Ui" }
Edge -From DummyHyperVProxy -To $ProxyObj.Name @{constraint = "true"; minlen = 1; style = $EdgeDebug.style; color = $EdgeDebug.color }
}
Rank $HyperVBackupProxy.Name
}

if ($Dir -eq 'LR') {
edge $BackupServerInfo.Name -to DummyHyperVProxy @{minlen=3;}
Edge $BackupServerInfo.Name -To DummyHyperVProxy @{minlen = 3; }
} else {
edge $BackupServerInfo.Name -to DummyHyperVProxy @{minlen=3;}
Edge $BackupServerInfo.Name -To DummyHyperVProxy @{minlen = 3; }
}
}
}
catch {
} catch {
$_
}
}
Expand Down
Loading

0 comments on commit 496b6c3

Please sign in to comment.