Skip to content

Update New-TableConditionalFormatting.ps1#100

Merged
PrzemyslawKlys merged 9 commits intoEvotecIT:masterfrom
opustecnica:master
Jan 10, 2020
Merged

Update New-TableConditionalFormatting.ps1#100
PrzemyslawKlys merged 9 commits intoEvotecIT:masterfrom
opustecnica:master

Conversation

@opustecnica
Copy link
Contributor

Rather than removing the original code, I have commented it out and noted the begin and end of the proposed change for ease of reading. Comments and commented code could be removed later if others can test mods successfully.

THX.

@PrzemyslawKlys
Copy link
Member

Works great.

One question - would it be possible to make this case insensitive for both Chrome/IE? Right now both old and new versions were case sensitive for stuff and I'm not sure this is best.

Maybe another switch -CaseInsenstive or something if needed?

@opustecnica
Copy link
Contributor Author

opustecnica commented Jan 4, 2020

Przemyslaw,

A couple of comments just to make sure we are playing from the same music sheet.

Could you please say more about the case sensitive/insensitive issue?

In PowerShell, regex are implemented as case Insensitive by default. That is, the switch statement in question will select the appropriate action regardless of how the users spells "CoNtAins" or "LikE".

THX

@PrzemyslawKlys
Copy link
Member

Import-Module .\PSWriteHTML.psd1 -Force

$Process = Get-Process | Select-Object -First 10

New-HTML -TitleText 'My title' -UseCssLinks:$true -UseJavaScriptLinks:$true -FilePath $PSScriptRoot\Example21.html -Show {
    New-HTMLContent -HeaderText 'Test' -BackgroundColor Azure {
        New-HTMLTable -DataTable $Process -PagingOptions @(50, 100, 150, 200) -Find '' {
            New-HTMLTableButtonPDF
            New-HTMLTableCondition -Name 'HandleCount' -Type number -Operator gt -Value 300 -BackgroundColor Yellow
            New-HTMLTableCondition -Name 'ID' -Type number -Operator gt -Value 16000 -BackgroundColor Green
            New-HTMLTableCondition -Name 'Name' -Type string -Operator like -Value 'Cod' -BackgroundColor Red -Row
        } -PreContent {
            New-HTMLText -Text 'This will be before. You can put other html here.' -Alignment center -Color Red -FontSize 20
        } -PostContent {
            New-HTMLText -Text 'This will be after table. You can put other html here.' -Alignment center -Color Blue -FontSize 20
        } -ResponsivePriorityOrder NonpagedSystemMemorySize, PeakWorkingSet64, Company -ResponsivePriorityOrderIndex 20
        New-HTMLTable -DataTable $Process -PagingOptions @(50, 100, 150, 200) -DefaultSortColumn 'PriorityClass' {
            New-HTMLText -Text 'This also works... ' -Alignment center -Color Red -FontSize 20
            New-HTMLText -Text 'But it doesnt have the same control' -Alignment center -Color Red -FontSize 20
            New-HTMLTableCondition -Name 'HandleCount' -Type number -Operator gt -Value 300 -BackgroundColor Yellow
            New-HTMLTableCondition -Name 'ID' -Type number -Operator gt -Value 16000 -BackgroundColor Green
            New-HTMLTableCondition -Name 'Name' -Type string -Operator eq -Value 'browser_broker' -BackgroundColor Gold -Row
        }
    }
    New-HTMLContent -HeaderText 'Test' {
        New-HTMLContainer {
            New-HTMLText -Text 'You can also use Container for that' -Alignment center -Color Red -FontSize 20
            New-HTMLTable -DataTable $Process -PagingOptions @(50, 100, 150, 200) -DefaultSortColumn 'PriorityClass' {
                New-HTMLTableCondition -Name 'HandleCount' -Type number -Operator gt -Value 300 -BackgroundColor Yellow
                New-HTMLTableCondition -Name 'ID' -Type number -Operator gt -Value 16000 -BackgroundColor Green
                New-HTMLTableCondition -Name 'Name' -Type string -Operator eq -Value 'browser_broker' -BackgroundColor Gold -Row
            }
            New-HTMLText -Text 'See?' -Alignment center -Color Red -FontSize 20
            New-HTMLTable -DataTable $Process -PagingOptions @(50, 100, 150, 200) -DefaultSortColumn 'PriorityClass' {
                New-HTMLTableCondition -Name 'HandleCount' -Type number -Operator gt -Value 300 -BackgroundColor Yellow
                New-HTMLTableCondition -Name 'ID' -Type number -Operator gt -Value 16000 -BackgroundColor Green
                New-HTMLTableCondition -Name 'Name' -Type string -Operator eq -Value 'browser_broker' -BackgroundColor Gold -Row
            }
        }
        New-HTMLContainer {
            New-HTMLText -Text 'Test test1' -Alignment center -Color Red -FontSize 20
            New-HTMLTable -DataTable $Process -PagingOptions @(50, 100, 150, 200) -DefaultSortColumn 'PriorityClass' {
                New-HTMLTableCondition -Name 'HandleCount' -Type number -Operator gt -Value 300 -BackgroundColor Yellow
                New-HTMLTableCondition -Name 'ID' -Type number -Operator gt -Value 16000 -BackgroundColor Green
                New-HTMLTableCondition -Name 'Name' -Type string -Operator eq -Value 'browser_broker' -BackgroundColor Gold -Row
            }
            New-HTMLText -Text 'Test test2' -Alignment center -Color Red -FontSize 20
        }
    }
    New-HTMLTable -DataTable $Process -DefaultSortIndex 10 -OrderMulti {
        New-HTMLTableCondition -Name 'HandleCount' -Type number -Operator gt -Value 300 -BackgroundColor Yellow
        New-HTMLTableCondition -Name 'ID' -Type number -Operator gt -Value 16000 -BackgroundColor Green
        New-HTMLTableCondition -Name 'Name' -Type string -Operator eq -Value 'browser_broker' -BackgroundColor Gold -Row
    }
}

I'm using this to test.

If I use:

          New-HTMLTableCondition -Name 'Name' -Type string -Operator like -Value 'Cod' -BackgroundColor Red -Row

It will find Code.exe process but it won't find it if use 'cod'.

PowerShell is not a problem. JS is what I mean. Also, I wonder if the implementation shouldn't be adjusted to support PowerShell style.

For example in PowerShell -like requires wildcard to work. Some people may use a wildcard to do that and it will not work. I was thinking that maybe we could detect wildcard is used and replace it with empty string?

Also not sure if you noticed the inline switch ...

New-HTMLTableCondition -Name 'Name' -Type string -Operator like -Value 'Cod' -BackgroundColor Red -Row -Inline

This switch basically forces conditions during PowerShell runtime rather than using JS code. This is why I would like to fix discrepancies between those two.

@opustecnica
Copy link
Contributor Author

Gotcha! Let me play with it a bit.

@opustecnica
Copy link
Contributor Author

Przemyslaw,

I changed the JS code to use REGEX in a Case Insensitive mode. I have tested it on my end with positive output. Could you please verify?

THX

                    # [BEGIN] Proposed change to handle IE11 JS shortcomings
                    switch -Regex ($Condition.Operator) {
                        "contains|like" {
                            # "if (data[$($ConditionHeaderNr)].indexOf('$($Condition.Value)') >= 0 ) {"
                            # [Case Insensitive] Allow for case insensitive lookups when using "contains|like"
                            "if (/$($Condition.Value)/i.test(data[$($ConditionHeaderNr)])) {"
                         }
                         default {
                             "if (data[$ConditionHeaderNr] $($Condition.Operator) '$($Condition.Value)') {"
                         }
                    }
                    # [END] Proposed change to handle IE11 JS shortcomings

PS As we did not close the previous PR,, I appended the change to the same one.

@PrzemyslawKlys
Copy link
Member

PrzemyslawKlys commented Jan 4, 2020

Will do.

Btw. it's expected that any more changes are appended to not-closed PR ;-) Thanks for your work

Edit. Sorry wrong button.

@PrzemyslawKlys
Copy link
Member

It seems to work. Do we do anything with added '*' just in case someone uses it the way they use in PowerShell?

@PrzemyslawKlys
Copy link
Member

And btw you should always replace the old code with new code when doing PR. When something will go wrong we can just revert the change. There's no need to separately have code commented out. Not a big deal but at least we know what was replaced.

@opustecnica
Copy link
Contributor Author

Understood. Just treading lightly as we have never worked together and different people approach coding in different ways/styles. To that end, if it were my decision I would trim any pre/post asterisks and "align" the syntax with PowerShell standards. My thought here is that users of the module are PowerShell coders and might not either look at the source code or even understand JS.
My preference would be to modify the "$Condition.Value" as close as feasible to the usage of the value. Just to make it easy to read/understand later on. Again, just a personal preference. Just a time management position ;-).

# "if (/$($Condition.Value)/i.test(data[$($ConditionHeaderNr)])) {"
 "if (/$($Condition.Value.Replace('*',''))/i.test(data[$($ConditionHeaderNr)])) {

What are your thoughts on the matter?

@opustecnica
Copy link
Contributor Author

opustecnica commented Jan 4, 2020

PS One more thought:

What if the user were to employ a $ConditionValue with an asterisk in the middle of the string (e.g. "Co*.exe")? We could fairly easily replace any string instance of "*" with a REGEX ".*" that JS would interpret properly. I believe this to be a more encompassing approach.

@PrzemyslawKlys
Copy link
Member

I assume zero knowledge html/js/css is required for this module. So anything that works in PS should translate automatically. Therefore if you know how to fix it for "PowerShell like experience" be my guest! I appreciate your help.

I'm a noob when it comes to HTML/CSS/JS and regex I only do if I have to ;)

@PrzemyslawKlys
Copy link
Member

Should I assume this is ready? Can you always mark your PR's as draft or ready so that I know? :) Thanks

@opustecnica
Copy link
Contributor Author

opustecnica commented Jan 8, 2020

Przemyslaw,

Sorry for the delay. I usually have time for these activities in the evenings and/or weekends.
As far as the JS changes in question are concerned, it is all done. We now support PS "Like" style syntax in that the asterisk is treated as a wildcard regardless of its position.

Depending on the update/publishing schedule you have in mind, we could close this one or wait for other changes to accumulate.

A few other considerations:

I use the module under uncommon conditions and in complete absence of an internet connection. This implies the HTML product must contain all needed CSSs and JSs. I am currently attempting to resolve an issues that paralyzes the browser for up to 60 seconds when using UseCSSLinks:$false and UseJavaScriptLinks:$false in conjunction with TABs ... The issue is evident when changing tab. I can see the issue is related to JavaScript but have yet to find a definitive culprit.

Beside that, I have half baked tests working for:

  1. Using images that are not stored within the module's tree.
  2. Enable RegEx on all search fields. This is incredibly useful to include or exclude items from searches.
  3. Allow changes to options (e.g. PDF page size from A3 to Letter/A4 - Landscape/Portrait)
  4. Allow use of localized CSS for Roboto fonts.

@PrzemyslawKlys
Copy link
Member

That's a weird issue. Without UseJS and UseCss it should work. I believe only Awesome Fonts are not included in a package as I am not sure how portable that is. You can review Configuration ps1 file that has all the headers/footers for a missing section where Links are provided but not files.

Keep in mind switching tabs has perf issues because of DataTables refresh (I have an open issue for that). Make sure it's not related to that.

@PrzemyslawKlys
Copy link
Member

Here's the config I meant:

$Script:Configuration = [ordered] @{
Features = [ordered] @{
Default = @{
Comment = 'Always Required Default Visual Settings'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\default.css"
}
}
DefaultHeadings = @{
Comment = 'Always Required Default Headings'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\headings.css"
}
}
Accordion = @{
Comment = 'Accordion'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\accordion-1.css"
}
}
CodeBlocks = @{
Comment = 'EnlighterJS CodeBlocks'
Header = @{
CssLink = 'https://evotec.xyz/wp-content/uploads/pswritehtml/enlighterjs30/enlighterjs.min.css'
Css = "$PSScriptRoot\..\Resources\CSS\enlighterjs.min.css"
JsLink = 'https://evotec.xyz/wp-content/uploads/pswritehtml/enlighterjs30/enlighterjs.min.js'
JS = "$PSScriptRoot\..\Resources\JS\enlighterjs.min.js"
}
Footer = @{
}
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\enlighterjs.css"
}
FooterAlways = @{
JS = "$PSScriptRoot\..\Resources\JS\enlighterjs-footer.js"
}
}
ChartsApex = @{
Comment = 'Apex Charts'
Header = @{
JsLink = 'https://cdn.jsdelivr.net/npm/apexcharts@3.11.1/dist/apexcharts.min.js'
JS = "$PSScriptRoot\..\Resources\JS\apexcharts.min.js"
}
HeaderAlways = @{
#Css = "$PSScriptRoot\..\Resources\CSS\apexcharts.css"
}
}
ChartsXkcd = @{
Header = @{
JsLink = @(
'https://cdn.jsdelivr.net/npm/chart.xkcd@1.1.12/dist/chart.xkcd.min.js'
)
Js = @(
"$PSScriptRoot\..\Resources\JS\chart.xkcd.min.js"
)
}
}
Jquery = @{
Comment = 'Jquery'
Header = @{
JsLink = 'https://code.jquery.com/jquery-3.4.1.min.js'
Js = "$PSScriptRoot\..\Resources\JS\jquery-3.4.1.min.js"
}
}
DataTablesOld = @{
Comment = 'DataTables'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\datatables.css"
CssNoscript = "$PSScriptRoot\..\Resources\CSS\datatables.noscript.css"
}
Header = @{
CssLink = 'https://cdn.datatables.net/v/dt/jq-3.3.1/dt-1.10.18/af-2.3.2/b-1.5.4/b-colvis-1.5.4/b-html5-1.5.4/b-print-1.5.4/cr-1.5.0/fc-3.2.5/fh-3.1.4/kt-2.5.0/r-2.2.2/rg-1.1.0/rr-1.2.4/sc-1.5.0/sl-1.2.6/datatables.min.css'
Css = "$PSScriptRoot\..\Resources\CSS\datatables.min.css"
JsLink = @(
"https://cdn.datatables.net/v/dt/jq-3.3.1/dt-1.10.18/af-2.3.2/b-1.5.4/b-colvis-1.5.4/b-html5-1.5.4/b-print-1.5.4/cr-1.5.0/fc-3.2.5/fh-3.1.4/kt-2.5.0/r-2.2.2/rg-1.1.0/rr-1.2.4/sc-1.5.0/sl-1.2.6/datatables.min.js"
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js"
"https://cdn.datatables.net/plug-ins/1.10.19/sorting/datetime-moment.js"
)
JS = @(
"$PSScriptRoot\..\Resources\JS\datatables.min.js"
"$PSScriptRoot\..\Resources\JS\moment.min.js"
"$PSScriptRoot\..\Resources\JS\datetime-moment.js"
)
}
}
DataTablesSearchFade = @{
Comment = 'DataTables SearchFade'
Header = @{
CssLink = 'https://cdn.datatables.net/plug-ins/preview/searchFade/dataTables.searchFade.min.css'
Css = "$PSScriptRoot\..\Resources\CSS\datatablesSearchFade.css"
JsLink = "https://cdn.datatables.net/plug-ins/preview/searchFade/dataTables.searchFade.min.js"
JS = "$PSScriptRoot\..\Resources\JS\datatables.SearchFade.min"
}
}
DataTables = @{
Comment = 'DataTables'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\datatables.css"
CssNoscript = "$PSScriptRoot\..\Resources\CSS\datatables.noscript.css"
}
Header = @{
CssLink = @(
"https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css"
"https://cdn.datatables.net/autofill/2.3.4/css/autoFill.dataTables.css"
"https://cdn.datatables.net/buttons/1.6.1/css/buttons.dataTables.min.css"
"https://cdn.datatables.net/colreorder/1.5.2/css/colReorder.dataTables.min.css"
"https://cdn.datatables.net/fixedcolumns/3.3.0/css/fixedColumns.dataTables.min.css"
"https://cdn.datatables.net/fixedheader/3.1.6/css/fixedHeader.dataTables.min.css"
"https://cdn.datatables.net/keytable/2.5.1/css/keyTable.dataTables.min.css"
"https://cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css"
"https://cdn.datatables.net/rowgroup/1.1.1/css/rowGroup.dataTables.min.css"
"https://cdn.datatables.net/rowreorder/1.2.6/css/rowReorder.dataTables.min.css"
"https://cdn.datatables.net/scroller/2.0.1/css/scroller.dataTables.min.css"
"https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css"
)
Css = @(
"$PSScriptRoot\..\Resources\CSS\jquery.dataTables.min.css"
"$PSScriptRoot\..\Resources\CSS\autoFill.dataTables.css"
"$PSScriptRoot\..\Resources\CSS\buttons.dataTables.min.css"
"$PSScriptRoot\..\Resources\CSS\colReorder.dataTables.min.css"
"$PSScriptRoot\..\Resources\CSS\fixedColumns.dataTables.min.css"
"$PSScriptRoot\..\Resources\CSS\fixedHeader.dataTables.min.css"
"$PSScriptRoot\..\Resources\CSS\keyTable.dataTables.min.css"
"$PSScriptRoot\..\Resources\CSS\responsive.dataTables.min.css"
"$PSScriptRoot\..\Resources\CSS\rowGroup.dataTables.min.css"
"$PSScriptRoot\..\Resources\CSS\rowReorder.dataTables.min.css"
"$PSScriptRoot\..\Resources\CSS\scroller.dataTables.min.css"
"$PSScriptRoot\..\Resources\CSS\select.dataTables.min.css"
)
JsLink = @(
#"https://code.jquery.com/jquery-3.3.1.min.js"
#"https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"
#"https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"
#"https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"
"https://nightly.datatables.net/js/jquery.dataTables.min.js"
"https://cdn.datatables.net/autofill/2.3.4/js/dataTables.autoFill.min.js"
"https://cdn.datatables.net/buttons/1.6.1/js/dataTables.buttons.min.js"
"https://cdn.datatables.net/buttons/1.6.1/js/buttons.colVis.min.js"
"https://cdn.datatables.net/buttons/1.6.1/js/buttons.html5.min.js"
"https://cdn.datatables.net/buttons/1.6.1/js/buttons.print.min.js"
"https://cdn.datatables.net/colreorder/1.5.2/js/dataTables.colReorder.min.js"
"https://cdn.datatables.net/fixedcolumns/3.3.0/js/dataTables.fixedColumns.min.js"
"https://cdn.datatables.net/fixedheader/3.1.6/js/dataTables.fixedHeader.min.js"
"https://cdn.datatables.net/keytable/2.5.1/js/dataTables.keyTable.min.js"
"https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"
"https://cdn.datatables.net/rowgroup/1.1.1/js/dataTables.rowGroup.min.js"
"https://cdn.datatables.net/rowreorder/1.2.6/js/dataTables.rowReorder.min.js"
"https://cdn.datatables.net/scroller/2.0.1/js/dataTables.scroller.min.js"
"https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js"
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"
"https://cdn.datatables.net/plug-ins/1.10.20/sorting/datetime-moment.js"
)
JS = @(
"$PSScriptRoot\..\Resources\JS\jquery.dataTables.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.autoFill.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.buttons.min.js"
"$PSScriptRoot\..\Resources\JS\buttons.colVis.min.js"
"$PSScriptRoot\..\Resources\JS\buttons.html5.min.js"
"$PSScriptRoot\..\Resources\JS\buttons.print.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.colReorder.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.fixedColumns.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.fixedHeader.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.keyTable.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.responsive.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.rowGroup.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.rowReorder.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.scroller.min.js"
"$PSScriptRoot\..\Resources\JS\dataTables.select.min.js"
"$PSScriptRoot\..\Resources\JS\moment.min.js"
"$PSScriptRoot\..\Resources\JS\datetime-moment.js"
)
}
}
DataTablesPDF = @{
Comment = 'DataTables PDF Features'
Header = @{
JsLink = @(
'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js'
'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js'
)
Js = @(
"$PSScriptRoot\..\Resources\JS\pdfmake.min.js"
"$PSScriptRoot\..\Resources\JS\vfs_fonts.js"
)
}
}
DataTablesExcel = @{
Comment = 'DataTables Excel Features'
Header = @{
JsLink = @(
'https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js'
)
JS = @(
"$PSScriptRoot\..\Resources\JS\jszip.min.js"
)
}
}
DataTablesSimplify = @{
Comment = 'DataTables (not really) - Simplified'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\datatables.simplify.css"
}
}
D3Mitch = @{
Comment = 'D3Mitch Feature'
Header = @{
JsLink = @(
#'https://cdn.jsdelivr.net/npm/d3-mitch-tree@1.0.5/lib/d3-mitch-tree.min.js'
'https://cdn.jsdelivr.net/gh/deltoss/d3-mitch-tree@1.0.2/dist/js/d3-mitch-tree.min.js'
)
CssLink = @(
'https://cdn.jsdelivr.net/gh/deltoss/d3-mitch-tree@1.0.2/dist/css/d3-mitch-tree.min.css'
'https://cdn.jsdelivr.net/gh/deltoss/d3-mitch-tree@1.0.2/dist/css/d3-mitch-tree-theme-default.min.css'
)
}
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\hierarchicalTree.css"
}
}
Fonts = @{
Comment = 'Default fonts'
HeaderAlways = @{
CssLink = 'https://fonts.googleapis.com/css?family=Roboto|Hammersmith+One|Questrial|Oswald'
}
}
FontsAwesome = @{
Comment = 'Default fonts icons'
HeaderAlways = @{
CssLink = 'https://use.fontawesome.com/releases/v5.11.2/css/all.css'
}
Other = @{
Link = 'https://use.fontawesome.com/releases/v5.11.2/svgs/'
}
}
FullCalendar = @{
Comment = 'FullCalendar Basic'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\calendar.css"
}
}
FullCalendarCore = @{
Comment = 'FullCalendar Core'
Header = @{
CssLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/core@4.3.1/main.min.css'
Css = "$PSScriptRoot\..\Resources\CSS\fullCalendarCore.css"
JSLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/core@4.3.1/main.min.js'
JS = "$PSScriptRoot\..\Resources\JS\fullCalendarCore.js"
}
}
FullCalendarDayGrid = @{
Comment = 'FullCalendar DayGrid'
Header = @{
CssLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/daygrid@4.3.0/main.min.css'
Css = "$PSScriptRoot\..\Resources\CSS\fullCalendarDayGrid.css"
JSLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/daygrid@4.3.0/main.min.js'
JS = "$PSScriptRoot\..\Resources\JS\fullCalendarDayGrid.js"
}
}
FullCalendarInteraction = @{
Comment = 'FullCalendar Interaction'
Header = @{
JSLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/interaction@4.3.0/main.min.js'
JS = "$PSScriptRoot\..\Resources\JS\FullCalendarInteraction.js"
}
}
FullCalendarList = @{
Comment = 'FullCalendar List'
Header = @{
CssLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/list@4.3.0/main.min.css'
Css = "$PSScriptRoot\..\Resources\CSS\fullCalendarList.css"
JSLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/list@4.3.0/main.min.js'
JS = "$PSScriptRoot\..\Resources\JS\fullCalendarList.js"
}
}
FullCalendarRRule = @{
Comment = 'FullCalendar RRule'
Header = @{
JSLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/rrule'
JS = "$PSScriptRoot\..\Resources\JS\fullCalendarRRule.js"
#https://cdn.jsdelivr.net/npm/@fullcalendar/rrule@4.3.0/main.min.js
}
}
FullCalendarTimeGrid = @{
Comment = 'FullCalendar TimeGrid'
Header = @{
CssLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/timegrid@4.3.0/main.min.css'
Css = "$PSScriptRoot\..\Resources\CSS\fullCalendarTimeGrid.css"
JSLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/timegrid@4.3.0/main.min.js'
JS = "$PSScriptRoot\..\Resources\JS\fullCalendarTimeGrid.js"
}
}
FullCalendarTimeLine = @{
Comment = 'FullCalendar TimeLine'
Header = @{
CssLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/timeline@4.3.0/main.min.css'
Css = "$PSScriptRoot\..\Resources\CSS\fullCalendarTimeLine.css"
JSLink = 'https://cdn.jsdelivr.net/npm/@fullcalendar/timeline@4.3.0/main.min.js'
JS = "$PSScriptRoot\..\Resources\JS\fullCalendarTimeLine.js"
}
}
HideSection = @{
Comment = 'Hide Section Code'
HeaderAlways = @{
JS = "$PSScriptRoot\..\Resources\JS\HideSection.js"
}
}
FancyTree = @{
Header = @{
JSLink = @(
'https://cdnjs.cloudflare.com/ajax/libs/jquery.fancytree/2.33.0/jquery.fancytree-all-deps.min.js'
)
CSSLink = @(
'https://cdn.jsdelivr.net/npm/jquery.fancytree@2.33/dist/skin-win8/ui.fancytree.min.css'
)
}
}
JustGage = @{
Comment = 'Just Gage Library'
Header = @{
JSLink = @(
'https://cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js'
'https://cdnjs.cloudflare.com/ajax/libs/justgage/1.3.3/justgage.min.js'
)
JS = @(
"$PSScriptRoot\..\Resources\JS\raphael-min.js"
"$PSScriptRoot\..\Resources\JS\justgage.min.js"
)
}
}
<#
JsTree = @{
Header = @{
JSLink = @(
'https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js'
)
CSSLink = @(
'https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css'
)
JS = @(
"$PSScriptRoot\..\Resources\JS\stree.min.js"
)
CSS = @(
"$PSScriptRoot\..\Resources\CSS\style.min.css"
)
}
}
#>
Popper = @{
Comment = 'Popper and Tooltip for FullCalendar'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\popper.css"
}
Header = @{
JSLink = @(
'https://unpkg.com/popper.js/dist/umd/popper.min.js'
'https://unpkg.com/tooltip.js/dist/umd/tooltip.min.js'
)
JS = @(
"$PSScriptRoot\..\Resources\JS\popper.js"
"$PSScriptRoot\..\Resources\JS\tooltip.js"
)
}
}
Tabs = @{
Comment = 'Elastic Tabs'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\tabs-elastic.css"
}
FooterAlways = @{
JS = "$PSScriptRoot\..\Resources\JS\tabs-elastic.js"
}
CustomActionsReplace = @{
'ColorSelector' = ConvertFrom-Color -Color "DodgerBlue"
'ColorTarget' = ConvertFrom-Color -Color "MediumSlateBlue"
}
}
Tabbis = @{
Comment = 'Elastic Tabbis'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\tabbis.css"
}
FooterAlways = @{
JS = @(
"$PSScriptRoot\..\Resources\JS\tabbis.js"
"$PSScriptRoot\..\Resources\JS\tabbisAdditional.js"
)
}
CustomActionsReplace = @{
'ColorSelector' = ConvertFrom-Color -Color "DodgerBlue"
'ColorTarget' = ConvertFrom-Color -Color "MediumSlateBlue"
}
}
TabbisGradient = @{
Comment = 'Elastic Tabs Gradient'
FooterAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\tabs-elastic.gradient.css"
}
CustomActionsReplace = @{
'ColorSelector' = ConvertFrom-Color -Color "DodgerBlue"
'ColorTarget' = ConvertFrom-Color -Color "MediumSlateBlue"
}
}
TabbisTransition = @{
Comment = 'Elastic Tabs Transition'
FooterAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\tabs-elastic.transition.css"
}
}
TimeLine = @{
Comment = 'Timeline Simple'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\timeline-simple.css"
}
}
Toasts = @{
Comment = 'Toasts Looking Messages'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\Toasts.css"
}
}
StatusButtonical = @{
Comment = 'Status Buttonical'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\status.css"
}
}
TuiGrid = @{
Comment = 'Tui Grid'
Header = @{
Css = "$PSScriptRoot\..\Resources\CSS\tuigrid.css"
CssLink = 'https://cdn.jsdelivr.net/npm/tui-grid@3.5.0/dist/tui-grid.css'
}
}
VisNetwork = @{
Comment = 'VIS Network Dynamic, browser based visualization libraries'
HeaderAlways = @{
Css = "$PSScriptRoot\..\Resources\CSS\vis-network.diagram.css"
}
Header = @{
JsLink = 'https://unpkg.com/vis-network@6.4.6/dist/vis-network.min.js'
Js = "$PSScriptRoot\..\Resources\JS\vis-network.min.js"
Css = "$PSScriptRoot\..\Resources\CSS\vis-network.min.css"
CssLink = 'https://unpkg.com/vis-network@6.4.6/dist/vis-network.min.css'
}
FooterAlways = @{
JS = "$PSScriptRoot\..\Resources\JS\vis-networkFunctions.js"
}
}
}
}
function Get-ResourcesContentFromWeb {
param(
[uri[]] $ResourceLinks,
[ValidateSet('CSS', 'JS')][string] $Type
)
$Output = foreach ($Link in $ResourceLinks) {
# [uri] $Link = $File
$Splitted = $Link.OriginalString -split '/'
$FileName = $Splitted[-1]
$FilePath = [IO.Path]::Combine('C:\Users\przemyslaw.klys\OneDrive - Evotec\Support\GitHub\PSWriteHTML\Resources', $Type, $FileName)
$FilePathScriptRoot = -Join ('"', '$PSScriptRoot\..\Resources\', "$Type", '\', $FileName, '"')
$FilePathScriptRoot
#[IO.Path]::Combine('C:\Users\przemyslaw.klys\OneDrive - Evotec\Support\GitHub\PSWriteHTML\Resources\CSS', $FileName)
Invoke-WebRequest -Uri $Link -OutFile $FilePath
}
$Output
}
#Get-ResourcesContentFromWeb -ResourceLinks $($Script:Configuration).Features.DataTables.Header.JsLink -Type 'JS'
#Get-ResourcesContentFromWeb -ResourceLinks $($Script:Configuration).Features.DataTables.Header.CssLink -Type 'CSS'
#Get-ResourcesContentFromWeb -ResourceLinks $($Script:Configuration).Features.VisNetwork.Header.JsLink -Type 'JS'
#Get-ResourcesContentFromWeb -ResourceLinks $($Script:Configuration).Features.VisNetwork.Header.CssLink -Type 'CSS'
#Get-ResourcesContentFromWeb -ResourceLinks $($Script:Configuration).Features.Jquery.Header.JsLink -Type 'JS'
#Get-ResourcesContentFromWeb -ResourceLinks $($Script:Configuration).Features.Jquery.Header.CssLink -Type 'CSS'
#Get-ResourcesContentFromWeb -ResourceLinks $($Script:Configuration).Features.ChartsApex.Header.JsLink -Type 'JS'
#Get-ResourcesContentFromWeb -ResourceLinks $($Script:Configuration).Features.ChartsApex.Header.CssLink -Type 'CSS'

@PrzemyslawKlys
Copy link
Member

Btw.

  1. It's already implemented. Take a look at those functions.

image

function New-TableButtonPDF {
<#
.SYNOPSIS
Allows more control when adding buttons to Table
.DESCRIPTION
Allows more control when adding buttons to Table. Works only within Table or New-HTMLTable scriptblock.
.PARAMETER Title
Document title (appears above the table in the generated PDF). The special character * is automatically replaced with the value read from the host document's title tag.
.PARAMETER DisplayName
The button's display text. The text can be configured using this option
.PARAMETER MessageBottom
Message to be shown at the bottom of the table, or the caption tag if displayed at the bottom of the table.
.PARAMETER MessageTop
Message to be shown at the top of the table, or the caption tag if displayed at the top of the table.
.PARAMETER FileName
File name to give the created file (plus the extension defined by the extension option). The special character * is automatically replaced with the value read from the host document's title tag.
.PARAMETER Extension
The extension to give the created file name. (default .pdf)
.PARAMETER PageSize
Paper size for the created PDF. This can be A3, A4, A5, LEGAL, LETTER or TABLOID. Other options are available.
.PARAMETER Orientation
Paper orientation for the created PDF. This can be portrait or landscape
.PARAMETER Header
Indicate if the table header should be included in the exported data or not.
.PARAMETER Footer
Indicate if the table footer should be included in the exported data or not.
.EXAMPLE
Dashboard -Name 'Dashimo Test' -FilePath $PSScriptRoot\DashboardEasy05.html -Show {
Section -Name 'Test' -Collapsable {
Container {
Panel {
Table -DataTable $Process {
TableButtonPDF
TableButtonCopy
TableButtonExcel
} -Buttons @() -DisableSearch -DisablePaging -HideFooter
}
Panel {
Table -DataTable $Process -Buttons @() -DisableSearch -DisablePaging -HideFooter
}
Panel {
Table -DataTable $Process {
TableButtonPDF -PageSize A10 -Orientation landscape
TableButtonCopy
TableButtonExcel
} -Buttons @() -DisableSearch -DisablePaging -HideFooter
}
}
}
}
.NOTES
Options are based on this URL: https://datatables.net/reference/button/pdfHtml5
#>
[alias('TableButtonPDF', 'EmailTableButtonPDF','New-HTMLTableButtonPDF')]
[CmdletBinding()]
param(
[string] $Title,
[string] $DisplayName,
[string] $MessageBottom,
[string] $MessageTop,
[string] $FileName,
[string] $Extension,
[string][ValidateSet('4A0', '2A0', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10',
'B0', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10',
'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10',
'RA0', 'RA1', 'RA2', 'RA3', 'RA4',
'SRA0', 'SRA1', 'SRA2', 'SRA3', 'SRA4',
'EXECUTIVE', 'FOLIO', 'LEGAL', 'LETTER', 'TABLOID')] $PageSize = 'A3',
[string][ValidateSet('portrait', 'landscape')] $Orientation = 'landscape',
[switch] $Header,
[switch] $Footer
)
$Button = @{ }
$Button.extend = 'pdfHtml5'
$Button.pageSize = $PageSize
$Button.orientation = $Orientation
if ($MessageBottom) {
$Button.messageBottom = $MessageBottom
}
if ($MessageTop) {
$Button.messageTop = $MessageTop
}
if ($DisplayName) {
$Button.text = $DisplayName
}
if ($Title) {
$Button.title = $Title
}
if ($FileName) {
$Button.filename = $FileName
}
if ($Extension) {
$Button.extension = $Extension
}
if ($Header) {
$Button.header = $Header.IsPresent
}
if ($Footer) {
$Button.footer = $Footer.IsPresent
}
[PSCustomObject] @{
Type = 'TableButtonPDF'
Output = $Button
}
}

@opustecnica
Copy link
Contributor Author

My bad!
I should have looked at the code/documentation.

Stupid question. Do you know at what point charts stopped working in IE? The module version I currently use to generate some 50 reports is 0.0.45. Quite old I know. The deterrent to the upgrades was the tailoring performed to the code to make it work for my purposes. This was with the assumption that mines were personal needs not worthy of merging to the mainstream release. I am now trying to work on those modifications for merging to the official release in the hope that this might be useful to somebody else AND make upgrades easier for me ;-). Time and prioritization is always an issue. Hence I have decided to work first on all of the changes required to make sure the current reports can be created with the current module version. One of my unfortunate requirements is for the IE11 compatibility. I have noticed that the Apex charts no longer work on IE11. I am planning to go through each version between 0.0.45 and 0.0.71 to understand at what point the charts stopped working and analyze the diffs. We might have to add one more .js source (babeljs.io) to compensate for polyfill functions not supported natively by IE11.

@PrzemyslawKlys
Copy link
Member

Well, not sure which charts you mean but current version works for me:

image

New-HTML {

    New-HTMLSection -HeaderText 'Donut Charts - Defaults' -CanCollapse {
        New-HTMLPanel {
            New-HTMLChart {
                New-ChartToolbar -Download
                New-ChartBarOptions -Gradient
                New-ChartLegend -Name 'Time', 'Money', 'Taxes'
                New-ChartBar -Name 'Test' -Value 1, 2, 3
                New-ChartBar -Name 'Test1' -Value 2, 5, 7
                New-ChartBar -Name 'Test2' -Value 3, 1, 2
            }
        }
        New-HTMLPanel {
            New-HTMLChart {
                New-ChartToolbar -Download
                New-ChartBarOptions -Gradient
                New-ChartLegend -Name 'Time', 'Money', 'Taxes'
                New-ChartBar -Name 'Test' -Value 1, 2, 3
                New-ChartBar -Name 'Test1' -Value 2, 5, 7
                New-ChartBar -Name 'Test2' -Value 3, 1, 2
            }
        }
        New-HTMLPanel {
            New-HTMLChart {
                New-ChartToolbar -Download
                New-ChartBarOptions -Gradient
                New-ChartLegend -Name 'Time', 'Money', 'Taxes'
                New-ChartBar -Name 'Test' -Value 1, 2, 3
                New-ChartBar -Name 'Test1' -Value 2, 5, 7
                New-ChartBar -Name 'Test2' -Value 3, 1, 2
            }
        }
    }
} -ShowHTML -FilePath $PSScriptRoot\Example-ChartBarNext.html -UseCssLinks -UseJavaScriptLinks

@opustecnica
Copy link
Contributor Author

In an attempt to save time ... I wasted some. Note to self.
To verify which features were working on Chrome vs IE11, I downloaded the Examples folder and opened one at a time all the HTML files in both browsers. The (Chart) HTML files failed in IE11. What I should have done was to rerun all the building.ps1 tests.
Long story short, I rerun the "Example-ChartBarNext.ps1" and the resulting HTML loads properly in IE11.
Lesson learned.

@PrzemyslawKlys
Copy link
Member

There was a time where IE 11 was broken because I thought it can't work for most of the functions we use. I was wrong and at some point, I started fixing issues mostly related to tabs/tables but impacting other code. As that was fixed everything should work - although I guess I should (or someone should) create a compatibility table for features.

Best would be to actually have pester tests with selenium that verify things... but that's hard to create. Maybe someone will, some day.

@opustecnica
Copy link
Contributor Author

opustecnica commented Jan 9, 2020

Przemyslaw,

I have added a [switch]$RegularExpression to the New-HTMLTable function to enable, if desired, RegEx on by field/column searches (-Filtering). The parameter is then passed to the Add-TableFiltering for injection into the JavaScript DataTable snippet. Let me know if you want to modify the variables names.

Among the many useful searches, I often use the "All-Except": '^((?!EXCLUDED_PATTERN).)*$' and '^((?!EXCLUDE_THIS|EXCLUDE_THAT).)*$' for multiple omissions.

@PrzemyslawKlys
Copy link
Member

Can you please create examples showing some usage? So that it can be part of this commit?

@PrzemyslawKlys
Copy link
Member

I think the name should be SearchRegularExpression with alias RegularExpression

@opustecnica
Copy link
Contributor Author

RegularExpression is now an alias of SearchRegularExpression.
I have added an example to the Examples directory to test for Smart vs RegEx Searches and Wildcard Conditional Formatting.

@PrzemyslawKlys PrzemyslawKlys merged commit 902a7bf into EvotecIT:master Jan 10, 2020
@PrzemyslawKlys
Copy link
Member

Thank you :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants