Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-HTMLStatusItem customization #111

Merged
merged 3 commits into from Feb 21, 2020
Merged

Conversation

jimmy58663
Copy link
Contributor

Modifications leave all original functionality and syntax in working order.

  • Added functionality to customize the background color of the status items using color hex codes. ('#5f6982')
  • Added functionality to customize the font color of the service status and name using color hex codes. ('#5f6982')
  • Added functionality to customize icons to any HTML icon that has a hex code consisting of 4 or 5 digits. ('&#x2620')
  • Removed CSS classes from status.css that are no longer needed.
  • Added CSS class 'icon' to handle formatting of the icons as the old classes did.

[string]$Percentage = '100%',

[ValidatePattern('^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$')]
[Parameter(ParameterSetName = 'Hex')]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For colors you should use what other commands are using. Register-ArgumentCompleter. It allows for pick from 800 colors but also takes '#COLOR' if typed in.

} elseif ($Icon -eq 'Good') {
#$IconType = 'performance'
if ($IconHex) {
$IconType = $IconHex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For icons you should allow a choice from Font Awesome like other commands are doing.

@PrzemyslawKlys
Copy link
Member

PrzemyslawKlys commented Feb 11, 2020

I believe we should leave the old option as one ParameterSet, and create fully customizable one with another set. Not sure if it's worth going with limiting it the way it was limited. It was created for Statusimo but Statusimo is very limited and I believe we should let people pick whatever they want for colors/percentage/icons.

@jimmy58663
Copy link
Contributor Author

I was able to update the colors to utilize the $Script:RGBColors and add the FontAwesome functionality for icons. Unfortunately, I am unable to reach FontAwesome from work where I am generating and using these reports. Are you alright with me keeping the $IconHex as a different parameter set? With the updates there are currently 4 parameter sets:

  • 'Statusimo' (Original parameters)
  • 'FontAwesomeBrands'
  • 'FontAwesomeRegular'
  • 'FontAwesomeSolid'

If you are looking to deprecate the original parameters once this is implemented, we could write a warning inside the 'Satusimo' parameter set. I will upload changes when I get home tonight.

@PrzemyslawKlys
Copy link
Member

Yes, we're looking to depreciate old original parameters as long as we update Statusimo to new ones. Yes you can use iconHex - how does that work anyway?

… names, deprecation warning of parameter set.
@jimmy58663
Copy link
Contributor Author

Changes have all been uploaded in the latest commit.

  • Font Awesome icon support
  • $Script:RGBColor support to align with other functions in the module
  • Added/changed parameter set names
  • Added a deprecation warning for the 'Statusimo' parameter set

The $IconHex works with UTF-8 Unicode character hex codes. All the main browsers support translation of these codes by default and a reference sheet of codes can be found at https://www.w3schools.com/charsets/ref_html_utf8.asp.

@PrzemyslawKlys
Copy link
Member

That is a cool feature. Probably others would have use of it instead of FontAwesome - with the same problem as yours. It might be worth adding it to other places where font awesome is used.

@PrzemyslawKlys
Copy link
Member

I guess we should also convert Font Awesome to use Register-ArgumentCompleter the same way colors do. But this needs fixing all over the place.

@jimmy58663
Copy link
Contributor Author

jimmy58663 commented Feb 12, 2020

It is something that may be beneficial to others. From what I read, Font Awesome does have the capability to be used locally if you wanted to do that instead. I believe you would download the latest CSS from them at build time, pushing to the PSGallery, and then in the head of your HTML instead of linking their site you link "the path to your module\resources\css\css.all". That reference would probably have to be built dynamically on install of the module or something since there are a few locations it could be. I am not sure how it would react to a source that does not exist if you just added all the locations.

The ArgumentCompleter seemed to work fine for me on the Font Awesome parameters. If you were to look into changing all of those autocomplete to standardize I would recommend dynamic parameters instead. I think the autocomplete functionality on them works better than the Register-ArgumentCompleter. If you would like, I could send you an example of how something like that would be implemented.

@PrzemyslawKlys
Copy link
Member

PrzemyslawKlys commented Feb 12, 2020

I do know how to build DynamicParams as I use it in PSWinReportingV2. But as far as I know, it's recommended to go for Register-ArgumentCompleter as it's an easier and cleaner way to work. It also allows to build one "source" and register it in multiple functions.

As for CSS, we are already doing that for other code/libraries.

But we're not doing linking to CSS local files but instead, we push it inline.

New-Html -UseJavaScrriptLinks -UseCssLinks {

}

If you don't use code like above all CSS/JS code is added inline. It's controlled by:

It's as simple as defining CssLink/CSS or/and JSlink/Js to have offline support. I was just not aware you can download https://use.fontawesome.com/releases/v5.11.2/css/all.css and use it offline. If you can then that is a trivial fix...

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/'
}
}

Just create all.css in resources, add CSS entry in that file and you've got offline support.

@PrzemyslawKlys PrzemyslawKlys merged commit 93c0c73 into EvotecIT:master Feb 21, 2020
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.

None yet

2 participants