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

Change the default logo handling of the reports #44

Closed
rebelinux opened this issue Mar 11, 2023 · 4 comments
Closed

Change the default logo handling of the reports #44

rebelinux opened this issue Mar 11, 2023 · 4 comments
Assignees
Labels
in progress Assignee is currently focusing on this issue

Comments

@rebelinux
Copy link
Contributor

Is your feature request related to a problem? Please describe.

It would be good in my opinion that the default logo of the report be the AsBuiltReport project icon.

Describe the solution you'd like

We could add the ability for the user to set the logo of their choice, using the report configuration file (JSON).

@rebelinux
Copy link
Contributor Author

Example:

image

@tpcarman
Copy link
Contributor

Currently, the default style of each report module aligns to the vendor's branding guidelines (colours, fonts, logos etc). However, most vendors require permission to use their logos and other branding.

To standardise the look and feel of all reports, and to standardise the report construct, I am looking to use one default style for all report modules.

Users will still be able to create their own report style, to customise the report style to their needs.

@tpcarman tpcarman self-assigned this Jun 17, 2023
@tpcarman tpcarman added the in progress Assignee is currently focusing on this issue label Jun 17, 2023
@rebelinux
Copy link
Contributor Author

Although I remember you telling me that you didn't plan to put the base64 of the logo in the JSON file. I've been thinking more about this change and I'm interested in furthering the discussion a bit more.

Currently, to modify the logo it is essential to know the path where the report is installed:

PS C:\Users\jocolon> Get-Module -ListAvailable -Name AsBuiltReport.Microsoft.DHCP


    Directory: **C:\Users\jocolon\Documents\WindowsPowerShell\Modules**


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.2.0      AsBuiltReport.Microsoft.DHCP        Invoke-AsBuiltReport.Microsoft.DHCP

PS C:\Users\jocolon>

Then it is required to modify the 'AsBuiltReport.Microsoft.DHCP.Style.ps1' file with the custom Base64 string:

if ($ReportConfig.Report.ShowCoverPageImage) {
    Try {
        Image -Text 'AsBuiltReport Logo' -Align 'Center' -Percent 45 -Base64 "AsBuiltReport Base64 string"
    } Catch {
        Write-PScriboMessage -IsWarning "Unable to display cover page image. Please set 'ShowCoverPageImage' to 'false' in the report JSON configuration file to avoid this error."
    }
}

The next step would be to force the changes to be applied:

PS C:\Users\jocolon> Import-Module AsBuiltReport.Microsoft.DHCP -Force
PS C:\Users\jocolon>

There are several disadvantages to this process:

  1. The steps to modify the logo are complex and in many cases users are not proficient in Powershell.
  2. Changes made to the file 'AsBuiltReport.Microsoft.DHCP.Style.ps1' are lost once the module is updated.

I would like to propose this:

Add a new section inside the AsBuiltReport.Microsoft.DHCP.json file. In this example the 'Logo' variable would be empty by default.

AsBuiltReport.Microsoft.DHCP.json default template:

{
    "Report": {
        "Name": "Microsoft DHCP As Built Report",
        "Version": "1.0",
        "Status": "Released",
        "ShowCoverPageImage": true,
        "ShowTableOfContents": true,
        "ShowHeaderFooter": true,
        "ShowTableCaptions": true
    },
    "Options": {
        "ShowDefinitionInfo": false,
        "PSDefaultAuthentication": "Negotiate",
        "ServerDiscovery": "Domain",
        "Exclude": {
            "Domains": [],
            "DCs": []
        }
    },
    "InfoLevel": {
        "_comment_": "0 = Disabled, 1 = Enabled, 2 = Adv Summary, 3 = Detailed",
        "DHCP": 1
    },
    "HealthCheck": {
        "DHCP": {
            "Summary": true,
            "Credential": true,
            "Statistics": true,
            "BP": true
        }
    },
    // The Logo variable is empty by default
    "Style": {
        "Image": {
            "Percent": 20,
            "Logo": ""
        }
    }
}

The code inside the AsBuiltReport.Microsoft.DHCP.Style.ps1 file will validate if the Logo variable has a value. If no value is found, the default AsbuiltReport logo will be displayed.

# Cover Page Image
if ($ReportConfig.Report.ShowCoverPageImage -and (-Not $ReportConfig.Style.Image.Logo)) {
    Try {
        Image -Text 'AsBuiltReport Logo' -Align 'Center' -Percent 45 -Base64 "AsBuiltReport Base64 string"
        BlankLine -Count 1
    } Catch {
        Write-PScriboMessage -IsWarning "Unable to display cover page image. Please set 'ShowCoverPageImage' to 'false' in the report JSON configuration file to avoid this error."
    }
} else {
    try {
        Image -Text 'AsBuiltReport Logo' -Align 'Center' -Percent $ReportConfig.Style.Image.Percent -Base64 $($ReportConfig.Style.Image.Logo)
        BlankLine -Count 1
    } Catch {
        Write-PScriboMessage -IsWarning "Unable to display cover page image. Please set 'ShowCoverPageImage' to 'false' in the report JSON configuration file to avoid this error."
    }
}

In case the user wishes to specify a different logo, the command New-AsBuiltReportConfig should be used.

PS C:\Users\jocolon\> New-AsBuiltReportConfig -Report Microsoft.DHCP -FolderPath C:\Users\jocolon\
AsBuiltReport.Microsoft.DHCP report configuration file 'AsBuiltReport.Microsoft.DHCP.json' created in 'C:\Users\jocolon\'.
PS C:\Users\jocolon\> 

AsBuiltReport.Microsoft.DHCP.json generated with New-AsBuiltReportConfig:

{
    "Report": {
        "Name": "Microsoft DHCP As Built Report",
        "Version": "1.0",
        "Status": "Released",
        "ShowCoverPageImage": true,
        "ShowTableOfContents": true,
        "ShowHeaderFooter": true,
        "ShowTableCaptions": true
    },
    "Options": {
        "ShowDefinitionInfo": false,
        "PSDefaultAuthentication": "Negotiate",
        "ServerDiscovery": "Domain",
        "Exclude": {
            "Domains": [],
            "DCs": []
        }
    },
    "InfoLevel": {
        "_comment_": "0 = Disabled, 1 = Enabled, 2 = Adv Summary, 3 = Detailed",
        "DHCP": 1
    },
    "HealthCheck": {
        "DHCP": {
            "Summary": true,
            "Credential": true,
            "Statistics": true,
            "BP": true
        }
    },
    "Style": {
        "Image": {
            "Percent": 20,
            // Modified to specified custom logo
            "Logo": "Custom Logo Base64 string" 
        }
    }
}

Subsequently, the user will only need to run the New-AsBuiltReport command with the -ReportConfigFilePath parameter pointing to the modified JSON template. In this case, the modifications will not be lost when the user updates the AsBuiltReport.Microsoft.DHCP module.

Branch with changes:
https://github.com/rebelinux/AsBuiltReport.Microsoft.DHCP/tree/LogoInJson

I am writing this here because the slack chat has a time limit on past messages!

@tpcarman
Copy link
Contributor

If users wish to change the style and look of a report then they should be creating a customised style script. Some examples have been added to the Core module already, and instructions to develop a script is documented here.

If we incorporate an option to change the logo, then users will likely expect other changes (colours, fonts etc) can be made via this option also. A style script can extend beyond just logos, fonts and colours.

Personally, I use a custom style script to incorporate other document sections and unique information in addition to what the report extracts.

I think there should only be one method to customise the look and feel of a report, and that method should remain as it is currently, by creating a custom style.

tpcarman added a commit that referenced this issue Feb 21, 2024
### Added

- Add AsBuiltReport default style script to resolve [#44](#44)
- Add Core module version check and verbose reporting

### Changed

- Improve bug and feature request templates
- Increase actions/checkout to v4
- Update MIT License copyright year
- Code cleanup to remove outdated code and comments

### Fixed

- Fix ReadMe AsBuiltReport logo URL
- Fix [#45](#45)
tpcarman added a commit that referenced this issue Mar 28, 2024
### Added

- Add AsBuiltReport default style script to resolve [#44](#44)
- Add Core module version check and verbose reporting

### Changed

- Improve bug and feature request templates
- Increase actions/checkout to v4
- Update MIT License copyright year
- Code cleanup to remove outdated code and comments
- Update heading styles in sample style scripts
@tpcarman tpcarman mentioned this issue Mar 28, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress Assignee is currently focusing on this issue
Projects
None yet
Development

No branches or pull requests

2 participants