Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions Examples/Example-Carousel/Example-Carousel03.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Import-Module .\PSWriteHTML.psd1 -Force

# Minimal demo showing carousels + charts + tables inside tabs
# Charts/tables in the non-active tab should render correctly on first show

$Data = Get-Process |
Select-Object -First 12 Name, Id, CPU

New-HTML -Name 'Tabs + Carousel' -FilePath "$PSScriptRoot\Example-Carousel03.html" -Online -Show {
New-HTMLTab -Name 'Tab 1' -Heading 'First' {
New-HTMLSection -HeaderText 'Visible Tab' -Invisible {
New-HTMLCarousel {
New-CarouselSlide {
New-HTMLChart {
New-ChartPie -Name 'A' -Value 10
New-ChartPie -Name 'B' -Value 20
New-ChartPie -Name 'C' -Value 30
} -Title 'Pie - Tab 1'
}
New-CarouselSlide {
New-HTMLText -Text 'Second slide (Tab 1)'
}
}
}
New-HTMLSection -HeaderText 'Table' -Invisible {
New-HTMLTable -DataTable $Data -HideFooter
}
}

New-HTMLTab -Name 'Tab 2' -Heading 'Second' {
# This tab is initially hidden; content should reflow on tab activation
New-HTMLSection -HeaderText 'Hidden Tab (initial)' -Invisible {
New-HTMLCarousel {
New-CarouselSlide {
New-HTMLChart {
New-ChartPie -Name 'X' -Value 30
New-ChartPie -Name 'Y' -Value 40
New-ChartPie -Name 'Z' -Value 50
} -Title 'Pie - Tab 2'
}
New-CarouselSlide {
New-HTMLText -Text 'Second slide (Tab 2)'
}
}
}
New-HTMLSection -HeaderText 'Table in hidden Tab' -Invisible {
New-HTMLTable -DataTable $Data -HideFooter
}

# Collapsible section to verify reflow on show/hide
New-HTMLSection -HeaderText 'Collapsible Carousel' -CanCollapse -Collapsed {
New-HTMLCarousel {
New-CarouselSlide {
New-HTMLChart {
New-ChartLegend -LegendPosition bottom -HorizontalAlign right
New-ChartBarOptions -Distributed
New-ChartBar -Name 'One' -Value 10
New-ChartBar -Name 'Two' -Value 20
New-ChartBar -Name 'Three' -Value 15
} -Title 'Bar - Collapsible'
}
New-CarouselSlide {
New-HTMLText -Text 'Collapsed initially; open to reflow.'
}
}
}
}
}
48 changes: 48 additions & 0 deletions Examples/Example-TableColumnHighlight/Example-SearchBuilder.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Import-Module .\PSWriteHTML.psd1 -Force

$ProcessesAll = Get-Process | Select-Object -First 3 #-Property Name, Id, StartTime

New-HTML -TitleText 'Title' -Online -FilePath $PSScriptRoot\Example-SearchBuilder.html -ShowHTML {
#New-HTMLTableStyle -BackgroundColor Blue -Type RowSelected
#New-HTMLTableStyle -BackgroundColor Yellow -Type RowHover
#New-HTMLTableStyle -BackgroundColor Yellow -Type RowHoverSelected

New-HTMLSection -HeaderText 'Search Builder 1' {
New-HTMLTable -DataTable $ProcessesAll -SearchBuilder -Buttons excelHtml5, copyHtml5, csvHtml5 {
#New-HTMLTableContent -ColumnName 'PriorityClass' -BackgroundColor Salmon
New-HTMLTableContent -ColumnName 'HandleCount' -BackGroundColor Salmon
New-HTMLTableCondition -ColumnName 'Product' -BackgroundColor Salmon -Value '1Password' -ChildRowFill Both
New-HTMLTableCondition -ColumnName 'Name' -BackgroundColor AirForceBlue -Value '1password'
}
New-HTMLTable -DataTable $ProcessesAll -SearchBuilder -Buttons excelHtml5, copyHtml5, csvHtml5 {
#New-HTMLTableContent -ColumnName 'PriorityClass' -BackgroundColor Salmon
New-HTMLTableContent -ColumnName 'HandleCount' -BackGroundColor Salmon
New-HTMLTableCondition -ColumnName 'Product' -BackgroundColor Salmon -Value '1Password'
New-HTMLTableCondition -ColumnName 'Name' -BackgroundColor AirForceBlue -Value '1password'

New-HTMLTableCondition -ColumnName 'VM' -BackgroundColor Alizarin
} -DataStore JavaScript
}
# New-HTMLSection -HeaderText 'Search Builder as button' {
# New-HTMLTable -DataTable $ProcessesAll
# }
# # This won't really work - button + searchBuilder
# New-HTMLSection -HeaderText 'Search Builder + button' {
# # Search Builder will be disabled, button will work
# New-HTMLTable -DataTable $ProcessesAll -SearchBuilder
# }
}

# New-HTML -TitleText 'Title' -FilePath $PSScriptRoot\Example-SearchBuilder2.html {
# New-HTMLSection -HeaderText 'Search Builder 1' {
# New-HTMLTable -DataTable $ProcessesAll -Filtering -ScrollX -SearchBuilder -Buttons excelHtml5, copyHtml5, csvHtml5
# }
# New-HTMLSection -HeaderText 'Search Builder as button' {
# New-HTMLTable -DataTable $ProcessesAll
# }
# # This won't really work - button + searchBuilder
# New-HTMLSection -HeaderText 'Search Builder + button' {
# # Search Builder will be disabled, button will work
# New-HTMLTable -DataTable $ProcessesAll -SearchBuilder
# }
# } -ShowHTML
17 changes: 10 additions & 7 deletions Private/Parameters.Configuration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
param(

)
$ConfigurationURL = 'https://cdn.jsdelivr.net/gh/evotecit/cdn@0.0.30'
$ConfigurationURL = 'https://cdn.jsdelivr.net/gh/evotecit/cdn@0.0.31'
$Configuration = [ordered] @{
Features = [ordered] @{
Inject = @{
Expand Down Expand Up @@ -959,14 +959,17 @@
Email = $false
}
DataTablesConditions = @{
Comment = 'DataTables Conditions'
FooterAlways = @{
JS = @(
"$PSScriptRoot\..\Resources\JS\dataTables.conditions.js"
Comment = 'DataTables Conditions'
Header = @{
JsLink = @(
"https://cdn.jsdelivr.net/npm/@evotecit/htmlextensions@0.1.2/dist/datatables.columnHighlighter.js"
)
JS = @(
"$PSScriptRoot\..\Resources\JS\dataTables.columnHighlighter.js"
)
}
Default = $true
Email = $false
Default = $true
Email = $false
}
DataTablesColReorder = @{
Comment = 'DataTables ColReorder Features'
Expand Down
163 changes: 163 additions & 0 deletions Private/Tables/Convert-TableConditionsToHighlighterRules.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
function Convert-TableConditionsToHighlighterRules {
[CmdletBinding()]
param(
[Parameter(Mandatory)][System.Collections.IEnumerable] $ConditionalFormatting,
[Parameter(Mandatory)][string[]] $Header
)

# Build rules with idiomatic array comprehensions for clarity and simplicity
[array] $rules = @(
foreach ($Entry in $ConditionalFormatting) {
if (-not $Entry) { continue }

$ct = $Entry.ConditionType

if ($ct -eq 'Condition') {
# Single condition or unconditional highlight
$isUnconditional = ($Entry.PSObject.Properties.Name -notcontains 'Value') -or ($null -eq $Entry.Value)
if (-not $isUnconditional) {
$cond = New-TablePluginCondition -Condition $Entry
}

# Determine target names
$targetNames = if ($Entry.Row) {
$Header
} elseif ($Entry.HighlightHeaders) {
$Entry.HighlightHeaders
} else {
@($Entry.Name)
}

# Build targets
$fill = $null
if ($Entry.ChildRowFill) {
if ($Entry.ChildRowFill -eq 'Parent') { $fill = 'parent' }
elseif ($Entry.ChildRowFill -eq 'Both') { $fill = 'both' }
}
[array] $targets = @(
foreach ($n in $targetNames) {
$t = [ordered]@{
column = $n
css = $Entry.Style
}
if ($fill) { $t['fill'] = $fill }
$t
}
)

# Build failTargets, if any
$failTargets = $null
if ($Entry.FailStyle.Keys.Count -gt 0) {
$failTargets = @(
foreach ($n in $targetNames) {
$ft = [ordered]@{
column = $n
css = $Entry.FailStyle
}
# Do not propagate fill to fail targets by default
$ft
}
)
}

if ($isUnconditional) {
$rule = [ordered]@{
conditionsContainer = @() # unconditional
targets = $targets
}
} else {
$rule = [ordered]@{
conditionsContainer = @(
[ordered]@{
logic = 'AND'
conditions = @($cond)
}
)
targets = $targets
}
}
if ($failTargets) {
$rule['failTargets'] = $failTargets
}

[pscustomobject]$rule

} elseif ($ct -eq 'ConditionGroup') {
# Grouped conditions
[array] $conditions = @(
foreach ($Nested in $Entry.Conditions) {
if ($Nested.Type -eq 'TableCondition') {
New-TablePluginCondition -Condition $Nested.Output
}
}
)
$groupUnconditional = ($conditions.Count -eq 0)

# Determine targets
$targetNames = if ($Entry.Row) {
$Header
} elseif ($Entry.HighlightHeaders) {
$Entry.HighlightHeaders
} else {
@(
foreach ($Nested in $Entry.Conditions) {
if ($Nested.Type -eq 'TableCondition') { $Nested.Output.Name }
}
)
}

$fill = $null
if ($Entry.ChildRowFill) {
if ($Entry.ChildRowFill -eq 'Parent') { $fill = 'parent' }
elseif ($Entry.ChildRowFill -eq 'Both') { $fill = 'both' }
}
[array] $targets = @(
foreach ($n in $targetNames) {
$t = [ordered]@{
column = $n
css = $Entry.Style
}
if ($fill) { $t['fill'] = $fill }
$t
}
)

$failTargets = $null
if ($Entry.FailStyle.Keys.Count -gt 0) {
$failTargets = @(
foreach ($n in $targetNames) {
[ordered]@{
column = $n
css = $Entry.FailStyle
}
}
)
}

if ($groupUnconditional) {
$rule = [ordered]@{
conditionsContainer = @() # unconditional
targets = $targets
}
} else {
$rule = [ordered]@{
conditionsContainer = @(
[ordered]@{
logic = $Entry.Logic
conditions = $conditions
}
)
targets = $targets
}
}
if ($failTargets) {
$rule['failTargets'] = $failTargets
}

[pscustomobject]$rule
}
}
)

return ,$rules
}
52 changes: 52 additions & 0 deletions Private/Tables/New-TablePluginCondition.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
function New-TablePluginCondition {
[CmdletBinding()]
param(
[Parameter(Mandatory)][pscustomobject] $Condition
)

# Map PSWriteHTML condition to plugin condition schema
$plugin = [ordered]@{
columnName = $Condition.Name
operator = ($Condition.Operator | ForEach-Object { $_.ToLower() })
type = ($Condition.Type | ForEach-Object { $_.ToLower() })
value = $Condition.Value
caseSensitive = $Condition.CaseSensitive
dateTimeFormat = $Condition.DateTimeFormat
reverseCondition = $Condition.ReverseCondition
}

if ($plugin.type -eq 'date' -and $null -ne $Condition.Value) {
if ($Condition.Value -is [datetime]) {
[void]$plugin.Remove('value')
$plugin['valueDate'] = [ordered]@{
year = $Condition.Value.Year
month = $Condition.Value.Month
day = $Condition.Value.Day
hours = $Condition.Value.Hour
minutes = $Condition.Value.Minute
seconds = $Condition.Value.Second
}
} elseif ($Condition.Value -is [System.Collections.IEnumerable]) {
[array] $dates = @(
foreach ($dv in $Condition.Value) {
if ($dv -is [datetime]) {
[ordered]@{
year = $dv.Year
month = $dv.Month
day = $dv.Day
hours = $dv.Hour
minutes = $dv.Minute
seconds = $dv.Second
}
}
}
)
if ($dates.Count -gt 0) {
[void]$plugin.Remove('value')
$plugin['valueDate'] = $dates
}
}
}

[pscustomobject]$plugin
}
Loading
Loading