Skip to content

Commit

Permalink
Improved Diagram percent logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelinux committed Feb 24, 2024
1 parent 18e7a56 commit ce73d46
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 40 deletions.
4 changes: 2 additions & 2 deletions AsBuiltReport.Microsoft.AD.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
@{
ModuleName = 'Diagrammer.Microsoft.AD';
ModuleVersion = '0.1.9'
ModuleVersion = '0.2.0'
}
)

Expand Down Expand Up @@ -131,7 +131,7 @@
} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''
HelpInfoURI = 'https://github.com/AsBuiltReport/AsBuiltReport.Microsoft.AD#readme'

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ The **Options** schema allows certain options within the report to be toggled on
| Include.DCs | Array List | Empty | Allow only a list of Active Directory Domain FQDN to document. |
| EnableDiagrams | true / false | true | Toggle to enable/disable of Infrastructure Diagrams |


### InfoLevel

The **InfoLevel** schema allows configuration of each section of the report at a granular level. The following sections can be set.
Expand Down
3 changes: 2 additions & 1 deletion Src/Private/Get-AbrADForest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ function Get-AbrADForest {
}

if ($Graph) {
If ((Get-DiaImagePercent -GraphObj $Graph).Width -gt 1500) { $ImagePrty = 10 } else { $ImagePrty = 50 }
Section -Style Heading3 "Forest Diagram." {
Image -Base64 $Graph -Text "Forest Diagram" -Percent (Get-ImagePercent -Graph $Graph) -Align Center
Image -Base64 $Graph -Text "Forest Diagram" -Percent $ImagePrty -Align Center
Paragraph "Image preview: Opens the image in a new tab to view it at full resolution." -Tabs 2
}
BlankLine -Count 2
Expand Down
11 changes: 6 additions & 5 deletions Src/Private/Get-AbrADSite.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ function Get-AbrADSite {
$inObj = [ordered] @{
'Subnet' = $Item.Name
'Description' = ConvertTo-EmptyToFiller $Item.Description
'Sites' = & {
try {
$Item.Site.Split(",")[0].SubString($Item.Site.Split(",")[0].IndexOf("=") + 1)
} catch { "No site assigned" }
'Sites' = Switch ([string]::IsNullOrEmpty($Item.Site)) {
$true { "No site assigned" }
$false { $Item.Site.Split(",")[0].SubString($Item.Site.Split(",")[0].IndexOf("=") + 1) }
default { 'Unknown' }
}
}
$OutObj += [pscustomobject]$inObj
Expand Down Expand Up @@ -291,8 +291,9 @@ function Get-AbrADSite {
}

if ($Graph) {
If ((Get-DiaImagePercent -GraphObj $Graph).Width -gt 1500) { $ImagePrty = 10 } else { $ImagePrty = 50 }
Section -Style Heading4 "Site Inventory Diagram." {
Image -Base64 $Graph -Text "Site Inventory Diagram" -Percent (Get-ImagePercent -Graph $Graph) -Align Center
Image -Base64 $Graph -Text "Site Inventory Diagram" -Percent $ImagePrty -Align Center
Paragraph "Image preview: Opens the image in a new tab to view it at full resolution." -Tabs 2
}
BlankLine -Count 2
Expand Down
31 changes: 0 additions & 31 deletions Src/Private/SharedUtilsFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1866,37 +1866,6 @@ function get-Severity {
}
}
}

function Get-ImagePercent {
<#
.SYNOPSIS
Used by As Built Report to get base64 image percentage calculated from image width.
This low the diagram image to fit the report page margins
.DESCRIPTION
.NOTES
Version: 0.1.0
Author: Jonathan Colon
.EXAMPLE
.LINK
#>
[CmdletBinding()]
[OutputType([System.Int32])]
Param
(
[Parameter (
Position = 0,
Mandatory)]
[string]
$Graph
)
$Image_FromStream = [System.Drawing.Image]::FromStream((New-Object System.IO.MemoryStream(, [convert]::FromBase64String($Graph))))
If ($Image_FromStream.Width -gt 1500) {
return 10
} else {
return 50
}
} # end

Function Get-ADExchangeServer {
<#
.SYNOPSIS
Expand Down

0 comments on commit ce73d46

Please sign in to comment.