This guide outlines the standard procedure for creating a new, self-contained HTML report within the Axion project. The process involves creating a Python class to handle the logic and a corresponding YAML file to store the HTML template.
Navigate to the Reports Directory: All reports are located under factory.report/.
Choose a Sub-Package: Select an existing sub-package that matches the report's domain (e.g., package.system, package.core). If a suitable one doesn't exist, create a new directory.
Create the Files: Inside the chosen package directory, create two new files, following this naming convention:
ObjReport<YourReportName>.pyObjReport<YourReportName>.yamlReplace <YourReportName> with a descriptive, CamelCase name for your report.
The YAML file is used to externalize the HTML structure, keeping it separate from the Python logic.
Open the .yaml file.
Create a report Section: At the top level of the file, add a key named report.
Add the template Key: Inside the report section, create a key named template. The value should be a multi-line string (using |) containing the core HTML for your report's content area.
Use Placeholders: Use curly brace placeholders (e.g., {host}, {uptime}) for any data that will be dynamically inserted from the Python class.
Example (ObjReportServerState.yaml):
report:
template: |
<section class="content">
<div class="container-fluid">
<div class="card">
<div class="card-header">
<h3 class="card-title">Host: {host}</h3>
</div>
<div class="card-body">
<p>Uptime: {uptime} hours</p>
</div>
</div>
</div>
</section>
The Python class is responsible for loading the template, processing data, and rendering the final HTML page.
Open the .py file.
Set up Imports and Class Definition:
sys.path setup to import from factory.core.ObjReportAdminLte.Report.class Report(ObjReportAdminLte.Report):).Implement the __init__ Method:
super().__init__().self._IsA = "ObjReport<YourReportName>" and self.Description = "A brief description of the report.".self.template = self.read_template_from_yaml('template').Implement the Render Method:
def Render(self, data, ...):).placeholders dictionary. The keys must exactly match the placeholders you defined in your YAML template..format(): html_content = self.template.format(**placeholders).<!DOCTYPE>, <html>, <head> (with CSS links), and <body> (with JS script tags).html_content into the main content area of the full HTML structure.Before finishing, run the ruff linter on your new Python file to ensure it adheres to the project's coding standards.
ruff check factory.report/package.system/ObjReport<YourReportName>.py
Fix any errors or warnings reported by the linter.