Skip to content
Open
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
1,389 changes: 1,389 additions & 0 deletions dev_base_template/TRMM_Base v3.0.html

Large diffs are not rendered by default.

1,521 changes: 1,521 additions & 0 deletions dev_base_template/TRMM_Base v3.1.html

Large diffs are not rendered by default.

599 changes: 599 additions & 0 deletions dev_base_template/TRMM_Base_CHANGELOG.md

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions dev_template/README - Using v3.0 Templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Using TRMM_Base v3.0 Templates

## Issue: Blank White Page

If you're seeing a blank white page when using the Windows Updates Not Installed v2.0 template, it's because the base template HTML is not embedded in the JSON file.

## Solution: Import Base Template First

### Step 1: Import TRMM_Base v3.0 into TRMM

1. Open the file: `dev_base_template/TRMM_Base v3.0.html`
2. Copy the **entire contents** of the file
3. In TRMM, go to: **Settings → Reporting → Base Templates**
4. Click **"Create New Base Template"**
5. Name: `TRMM_Base v3.0`
6. Paste the HTML into the template field
7. Click **Save**

### Step 2: Import the Report Template

Now that the base template exists in TRMM, you can import the report template:

1. The report template JSON references: `"name": "TRMM_Base v3.0"`
2. TRMM will find and use the base template you just created
3. Import the Windows Updates Not Installed v2.0 JSON normally

## Alternative: Embed Base Template in JSON

For production templates (in `templates/` folder), we embed the complete base template HTML in the JSON file's `base_template.html` field.

### To create a production-ready JSON:

```python
import json

# Read the base template HTML
with open('dev_base_template/TRMM_Base v3.0.html', 'r', encoding='utf-8') as f:
base_html = f.read()

# Read the report template JSON
with open('dev_template/Windows Updates Not Installed v2.0 - Advanced Table Controls.json', 'r', encoding='utf-8') as f:
template_json = json.load(f)

# Replace the placeholder with actual HTML
template_json['base_template']['html'] = base_html

# Write production-ready JSON
with open('templates/Windows Updates Not Installed v2.0 - Advanced Table Controls.json', 'w', encoding='utf-8') as f:
json.dump(template_json, f, indent=2, ensure_ascii=False)

print("Production template created!")
```

## Development Workflow

### For Development (`dev_template/` folder):
- Base template HTML is a placeholder comment
- **You must import the base template separately into TRMM**
- Easier to edit and version control (separate files)

### For Production (`templates/` folder):
- Base template HTML is fully embedded
- Complete, self-contained JSON file
- Users can import directly into TRMM without separate base template import

## Troubleshooting

**Q: Still seeing blank page after importing base template?**

A: Check that:
1. Base template name matches exactly: `TRMM_Base v3.0`
2. Report template references the correct name in `base_template.name`
3. No JavaScript errors in browser console (F12)
4. Data source query returns results (check `template_variables`)

**Q: JavaScript errors about undefined functions (buildHeader, renderBody)?**

A: The base template wasn't loaded. Import TRMM_Base v3.0 into TRMM first.

**Q: Table shows "Loading..." forever?**

A: Check:
1. Data source query is correct and returns data
2. JSON data is valid (check browser console)
3. Column definitions match your data fields
4. IDs are correct: `#tableHead`, `#tableBody`, `#loading`, `#tableWrap`

## Example: Device Inventory Report

For a working production example with embedded base template, see:
`templates/Device Inventory Report - Advanced DataTables v1.9 good column sort controls-export.json`

This file has the complete base template HTML embedded, so it works immediately when imported into TRMM.
162 changes: 162 additions & 0 deletions dev_template/create_production_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#!/usr/bin/env python3
"""
Create Production Template with Embedded Base Template
=======================================================

This script takes a development template (with base template placeholder)
and creates a production-ready template with the full base template HTML embedded.

Usage:
python create_production_template.py

Or import and use the function:
from create_production_template import embed_base_template
embed_base_template('dev_template/template.json', 'templates/template.json')
"""

import json
import os
from pathlib import Path


def embed_base_template(dev_template_path, output_path=None, base_template_path=None):
"""
Embed the full base template HTML into a report template JSON.

Args:
dev_template_path: Path to development template JSON (with placeholder)
output_path: Path to write production template (default: templates/ folder)
base_template_path: Path to base template HTML (default: auto-detect from JSON)

Returns:
Path to the created production template
"""
dev_template_path = Path(dev_template_path)

# Read the development template
print(f"Reading development template: {dev_template_path}")
with open(dev_template_path, 'r', encoding='utf-8') as f:
template_json = json.load(f)

# Determine base template path
if base_template_path is None:
base_name = template_json['base_template']['name']
# Try to find the base template file
possible_paths = [
Path('dev_base_template') / f'{base_name}.html',
Path('../dev_base_template') / f'{base_name}.html',
Path('.') / f'{base_name}.html'
]

for path in possible_paths:
if path.exists():
base_template_path = path
break

if base_template_path is None:
raise FileNotFoundError(
f"Could not find base template: {base_name}.html\n"
f"Tried: {[str(p) for p in possible_paths]}\n"
f"Please specify base_template_path manually."
)

base_template_path = Path(base_template_path)

# Read the base template HTML
print(f"Reading base template: {base_template_path}")
with open(base_template_path, 'r', encoding='utf-8') as f:
base_html = f.read()

# Replace the placeholder with actual HTML
template_json['base_template']['html'] = base_html

# Determine output path
if output_path is None:
# Default: templates/ folder with same filename
output_path = Path('templates') / dev_template_path.name
# If we're in dev_template/, go up one level
if dev_template_path.parent.name == 'dev_template':
output_path = dev_template_path.parent.parent / 'templates' / dev_template_path.name

output_path = Path(output_path)

# Create output directory if needed
output_path.parent.mkdir(parents=True, exist_ok=True)

# Write production-ready JSON
print(f"Writing production template: {output_path}")
with open(output_path, 'w', encoding='utf-8') as f:
json.dump(template_json, f, indent=2, ensure_ascii=False)

print("✓ Production template created successfully!")
print(f"\nTemplate size: {output_path.stat().st_size / 1024:.1f} KB")
print(f"Base template: {template_json['base_template']['name']}")
print(f"Report template: {template_json['template']['name']}")

return output_path


def main():
"""
Interactive script to create production templates.
"""
print("=" * 70)
print("Create Production Template with Embedded Base Template")
print("=" * 70)
print()

# Find development templates
dev_template_dir = Path('dev_template')
if not dev_template_dir.exists():
dev_template_dir = Path('.')

json_files = list(dev_template_dir.glob('*.json'))

if not json_files:
print("No JSON files found in dev_template/")
return

print("Available development templates:")
for i, path in enumerate(json_files, 1):
print(f" {i}. {path.name}")
print()

# Get user choice
while True:
try:
choice = input(f"Select template (1-{len(json_files)}) or 'all': ").strip().lower()

if choice == 'all':
selected = json_files
break
else:
idx = int(choice) - 1
if 0 <= idx < len(json_files):
selected = [json_files[idx]]
break
else:
print(f"Please enter a number between 1 and {len(json_files)}")
except (ValueError, KeyboardInterrupt):
print("\nCancelled.")
return

print()

# Process selected templates
for template_path in selected:
try:
print(f"\nProcessing: {template_path.name}")
print("-" * 70)
output_path = embed_base_template(template_path)
print()
except Exception as e:
print(f"✗ Error processing {template_path.name}: {e}")
print()

print("=" * 70)
print("Done!")
print()


if __name__ == '__main__':
main()
48 changes: 32 additions & 16 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,24 @@
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agent%20List_By%20Client%20with%20Specs%20%28pdf%29%20v1.6.json"
},
{
"name": "Agent Specs (md)",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agent%20Specs%20%28md%29.json"
"name": "Agent Specs v3.2",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agent%20Specs%20v3.2.json"
},
{
"name": "Agent Status Task and Check Dashboard v1.19",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agent%20Status%20Task%20and%20Check%20Dashboard%20v1.19.json"
},
{
"name": "Agent TRMM Install date_descending v1.6",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agent%20TRMM%20Install%20date_descending%20v1.6.json"
},
{
"name": "Agent Uptime_By Client (html) v1.5",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agent%20Uptime_By%20Client%20%28html%29%20v1.5.json"
"name": "Agent Uptime (html) v3.2",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agent%20Uptime%20%28html%29%20v3.2.json"
},
{
"name": "Agent Uptime_By Client (html) v3.2",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agent%20Uptime_By%20Client%20%28html%29%20v3.2.json"
},
{
"name": "Agent_ListClientThenSite (csv) v1.1",
Expand All @@ -40,13 +48,21 @@
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agents_Filtered%20by%20RAM%20%28csv%29.json"
},
{
"name": "Agents_Filtered by RAM (md)",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agents_Filtered%20by%20RAM%20%28md%29.json"
"name": "Agents_Filtered by RAM (md) v3.1",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agents_Filtered%20by%20RAM%20%28md%29%20v3.1.json"
},
{
"name": "Agents_Pending Reboot (csv)",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agents_Pending%20Reboot%20%28csv%29.json"
},
{
"name": "Agents_Pending Reboot (md) v1.2",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agents_Pending%20Reboot%20%28md%29%20v1.2.json"
},
{
"name": "Agents_Pending Reboot v3.1",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Agents_Pending%20Reboot%20v3.1.json"
},
{
"name": "Alerts - Interactive Dashboard (html) v1.6",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Alerts%20-%20Interactive%20Dashboard%20%28html%29%20v1.6.json"
Expand Down Expand Up @@ -128,8 +144,8 @@
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/All%20Fields%20-%20Windows%20Updates.json"
},
{
"name": "Antivirus Report v1.6",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Antivirus%20Report%20v1.6.json"
"name": "Antivirus Report v3.1",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Antivirus%20Report%20v3.1.json"
},
{
"name": "Antivirus Report_by Client (csv)",
Expand Down Expand Up @@ -172,17 +188,13 @@
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Machine%20Specs%20%28csv%29%20v1.1.json"
},
{
"name": "NOC Dashboard v1.31",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/NOC%20Dashboard%20v1.31.json"
"name": "NOC Dashboard v1.32",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/NOC%20Dashboard%20v1.32.json"
},
{
"name": "OS Operating Systems Report v1.8",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/OS%20Operating%20Systems%20Report%20v1.8.json"
},
{
"name": "Pending Reboot_By Agent (csv)",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Pending%20Reboot_By%20Agent%20%28csv%29.json"
},
{
"name": "Software Inventory_By Software Name",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Software%20Inventory_By%20Software%20Name.json"
Expand Down Expand Up @@ -228,8 +240,8 @@
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Windows%2011%20Compatible%20List_By%20Client%20%28csv%29.json"
},
{
"name": "Windows 11 Compatible List_By Client (html) v1.9",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Windows%2011%20Compatible%20List_By%20Client%20%28html%29%20v1.9.json"
"name": "Windows 11 Compatible List_By Client (html) v3.1",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Windows%2011%20Compatible%20List_By%20Client%20%28html%29%20v3.1.json"
},
{
"name": "Windows Updates Not Installed_By Client (csv)",
Expand All @@ -239,6 +251,10 @@
"name": "Windows Updates Not Installed_By Client (md)",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Windows%20Updates%20Not%20Installed_By%20Client%20%28md%29.json"
},
{
"name": "Windows Updates Not Installed_By Client v3.1",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Windows%20Updates%20Not%20Installed_By%20Client%20v3.1.json"
},
{
"name": "Windows Updates_By Device (csv)",
"download_url": "https://raw.githubusercontent.com/amidaware/reporting-templates/master/templates/Windows%20Updates_By%20Device%20%28csv%29.json"
Expand Down
17 changes: 0 additions & 17 deletions templates/Agent Specs (md).json

This file was deleted.

17 changes: 17 additions & 0 deletions templates/Agent Specs v3.2.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions templates/Agent Uptime (html) v3.2.json

Large diffs are not rendered by default.

Loading
Loading