-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove -export from report name, add export date to subheader, add "s…
…how all" to software table
- Loading branch information
Jeremiah Moran
committed
Apr 30, 2024
1 parent
ca484a7
commit 601d772
Showing
4 changed files
with
28 additions
and
28 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
templates/Device Inventory Report - Advanced DataTables.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"base_template": null, | ||
"template": { | ||
"name": "Device Inventory Report - Advanced DataTables", | ||
"template_css": ".content-wrapper {\r\n margin-left: 20px; /* Adjust the margin as needed */\r\n margin-right: 20px; /* Adjust the margin as needed */\r\n }\r\ntable {\r\n width: 100%;\r\n border-collapse: collapse;\r\n}\r\nth, td {\r\n border: 1px solid #ddd;\r\n padding: 8px;\r\n}\r\nth {\r\n background-color: #f2f2f2;\r\n text-align: left;\r\n}\r\ntr:nth-child(even){background-color: #f2f2f2}\r\n/* This is the default state where full headers are visible */\r\n.full-header .short-header {\r\n display: none;\r\n}\r\n\r\n/* Media query for mobile screens */\r\n@media screen and (max-width: 768px) {\r\n .full-header .short-header {\r\n display: inline-block; /* Show abbreviated headers */\r\n }\r\n .full-header {\r\n display: none; /* Hide full headers */\r\n }\r\n}", | ||
"template_md": "<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n <meta charset=\"UTF-8\">\r\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\r\n <title>{{ client.name }} | Computer Inventory Report</title>\r\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.datatables.net/1.13.7/css/jquery.dataTables.min.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.datatables.net/searchpanes/2.2.0/css/searchPanes.dataTables.min.css\">\r\n <link rel=\"stylesheet\" type=\"text/css\" href=\"https://cdn.datatables.net/select/1.7.0/css/select.dataTables.min.css\">\r\n <style>\r\n body {\r\n padding: 20px;\r\n }\r\n \r\n .container-fluid {\r\n max-width: 2500px;\r\n margin: 0 auto;\r\n padding-left: 30px;\r\n padding-right: 30px;\r\n }\r\n \r\n .card {\r\n margin-bottom: 20px;\r\n }\r\n \r\n .card-header {\r\n background-color: #f8f9fa;\r\n padding: 5px 20px;\r\n }\r\n \r\n .card-body {\r\n padding: 20px;\r\n }\r\n \r\n #loading {\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n height: 200px;\r\n font-size: 18px;\r\n font-weight: bold;\r\n }\r\n \r\n #computerTable {\r\n display: none;\r\n }\r\n \r\n div.dtsp-verticalContainer {\r\n display: flex;\r\n flex-direction: row;\r\n flex-wrap: nowrap;\r\n justify-content: flex-start;\r\n align-items: flex-start;\r\n padding-left: 10px;\r\n padding-right: 10px;\r\n }\r\n \r\n div.dtsp-verticalContainer div.dtsp-verticalPanes {\r\n flex-basis: 300px;\r\n flex-shrink: 0;\r\n margin-right: 10px;\r\n }\r\n \r\n div.dtsp-verticalContainer div.container-fluid {\r\n flex-grow: 1;\r\n }\r\n \r\n div.dtsp-panesContainer {\r\n border: 1px solid #ccc;\r\n border-radius: 6px;\r\n padding: 15px;\r\n }\r\n\r\n .dataTables_length select {\r\n width: auto;\r\n padding: 5px;\r\n border-radius: 4px;\r\n border: 1px solid #ccc;\r\n }\r\n\r\n .dataTables_length {\r\n float: left;\r\n margin-left: 20px;\r\n margin-top: 10px;\r\n }\r\n \r\n .dataTables_info {\r\n clear: none;\r\n float: left;\r\n margin-top: 5px;\r\n }\r\n \r\n .dataTables_length select {\r\n width: auto;\r\n padding: 5px;\r\n border-radius: 4px;\r\n border: 1px solid #ccc;\r\n }\r\n \r\n </style>\r\n</head>\r\n<body>\r\n <div class=\"container-fluid\">\r\n <div class=\"card\">\r\n <div class=\"card-header\">\r\n <h2 style=\"text-align: center;\">{{ client.name }}'s Computer Inventory Report</h2>\r\n <p style=\"text-align: center;\">Below is a list of all computers in your organization. This data was exported on {{datetime.date.today()}} and may not reflect the current status.</p>\r\n </div>\r\n <div class=\"card-body\">\r\n <div class=\"dtsp-verticalContainer\">\r\n <div class=\"dtsp-verticalPanes\"></div>\r\n <div class=\"container-fluid\">\r\n <div id=\"loading\">Loading...</div>\r\n <table id=\"computerTable\" class=\"display nowrap\" width=\"100%\">\r\n <thead>\r\n <tr>\r\n <th>Site Name</th>\r\n <th>Device Name</th>\r\n <th>Last User</th>\r\n <th>Operating System</th>\r\n <th>Manufacturer</th>\r\n <th>Model</th>\r\n <th>Serial #</th>\r\n <th>Battery Health</th>\r\n <th>Warranty Expiration</th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {% for item in data_sources.agentsList %}\r\n <tr>\r\n <td>\r\n {% set site = item.site__name if item.site__name else 'N/A' %}\r\n {% set site_parts = site.split(' - ') %}\r\n {% set site_filtered = site_parts[1:] | join(' ') %}\r\n {{ site_filtered }}\r\n </td>\r\n <td>{{ item.hostname if item.hostname else 'N/A' }}</td>\r\n <td>{{ item.last_logged_in_user if item.last_logged_in_user else 'N/A' }}</td>\r\n <td>\r\n {% set os = (item.operating_system|replace(\",\", \"\")) if item.operating_system else 'N/A' %}\r\n {% if 'Windows 10' in os or 'Windows 11' in os %}\r\n {% set os_parts = os.split(' ') %}\r\n {% set os_filtered = os_parts[:3] | join(' ') %}\r\n {{ os_filtered }}\r\n {% elif 'Windows Server' in os %}\r\n {% set os_parts = os.split(' ') %}\r\n {% set os_filtered = os_parts[:4] | join(' ') %}\r\n {{ os_filtered }}\r\n {% else %}\r\n {{ os }}\r\n {% endif %}\r\n </td>\r\n <td>{{ item.wmi_detail.comp_sys[0][0].Manufacturer if item.wmi_detail and item.wmi_detail.comp_sys and item.wmi_detail.comp_sys[0] and item.wmi_detail.comp_sys[0][0] and item.wmi_detail.comp_sys[0][0].Manufacturer else 'N/A' }}</td>\r\n <td>\r\n {% if item.wmi_detail and item.wmi_detail.comp_sys and item.wmi_detail.comp_sys[0] and item.wmi_detail.comp_sys[0][0] and item.wmi_detail.comp_sys[0][0].Manufacturer == 'LENOVO' and item.wmi_detail.comp_sys_prod and item.wmi_detail.comp_sys_prod[0] and item.wmi_detail.comp_sys_prod[0][0] %}\r\n {{ item.wmi_detail.comp_sys_prod[0][0].Version if item.wmi_detail.comp_sys_prod[0][0].Version else 'N/A' }}\r\n {% elif item.wmi_detail and item.wmi_detail.comp_sys and item.wmi_detail.comp_sys[0] and item.wmi_detail.comp_sys[0][0] %}\r\n {{ item.wmi_detail.comp_sys[0][0].Model if item.wmi_detail.comp_sys[0][0].Model else 'N/A' }}\r\n {% else %}\r\n N/A\r\n {% endif %}\r\n </td>\r\n <td>{{ item.wmi_detail.bios[0][0].SerialNumber if item.wmi_detail and item.wmi_detail.bios and item.wmi_detail.bios[0] and item.wmi_detail.bios[0][0] and item.wmi_detail.bios[0][0].SerialNumber else 'N/A' }}</td>\r\n <td>\r\n {% set battery = item.custom_fields.get('BatteryHealthPercentage', 'N/A') %}\r\n {% if battery is not none and battery != '' %}\r\n {% if 'No battery present on this system.' in battery or 'N/A' in battery %}\r\n <span>N/A</span>\r\n {% else %}\r\n {% set battery_percentage = battery|int %}\r\n {% if battery_percentage < 60 %}\r\n <span style=\"color: red;\">{{ battery }}%</span>\r\n {% elif battery_percentage < 80 %}\r\n <span style=\"color: orange;\">{{ battery }}%</span>\r\n {% else %}\r\n <span style=\"color: green;\">{{ battery }}%</span>\r\n {% endif %}\r\n {% endif %}\r\n {% else %}\r\n <span>N/A</span>\r\n {% endif %}\r\n </td>\r\n <td>\r\n {% set warranty = item.custom_fields.get('WarrantyExpiration', 'N/A') %}\r\n {% if warranty != 'N/A' and warranty != '' and warrant is not none %}\r\n {% set warranty_date = datetime.datetime.strptime(warranty, '%Y-%m-%dT%H:%M:%S') %}\r\n {% set pst_zone = ZoneInfo('America/Los_Angeles') %}\r\n {% set warranty_date_pst = warranty_date.astimezone(pst_zone) %}\r\n {% set warranty_formatted = warranty_date_pst.strftime('%Y-%m-%d') %}\r\n {% set current_date = datetime.datetime.now(pst_zone) %}\r\n {% set remaining_days = (warranty_date_pst.date() - current_date.date()).days %}\r\n {% if remaining_days > 90 %}\r\n <span style=\"color: green;\">{{ warranty_formatted }}</span>\r\n {% elif remaining_days > 0 %}\r\n <span style=\"color: orange;\">{{ warranty_formatted }}</span>\r\n {% else %}\r\n <span style=\"color: red;\">{{ warranty_formatted }}</span>\r\n {% endif %}\r\n {% else %}\r\n <span>N/A</span>\r\n {% endif %}\r\n </td>\r\n </tr>\r\n {% endfor %}\r\n </tbody>\r\n </table>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <script type=\"text/javascript\" src=\"https://code.jquery.com/jquery-3.7.0.js\"></script>\r\n <script type=\"text/javascript\" src=\"https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js\"></script>\r\n <script type=\"text/javascript\" src=\"https://cdn.datatables.net/searchpanes/2.2.0/js/dataTables.searchPanes.min.js\"></script>\r\n <script type=\"text/javascript\" src=\"https://cdn.datatables.net/select/1.7.0/js/dataTables.select.min.js\"></script>\r\n\r\n <script>\r\n $(document).ready(function() {\r\n var table = $('#computerTable').DataTable({\r\n searchPanes: {\r\n layout: 'columns-1'\r\n },\r\n dom: '<\"dtsp-dataTable\"frtilp>',\r\n pageLength: 40,\r\n lengthMenu: [10, 25, 50, 100, 'All'],\r\n language: {\r\n lengthMenu: \"Show _MENU_ entries\",\r\n info: \"Showing _START_ to _END_ of _TOTAL_ entries\"\r\n }\r\n });\r\n table.searchPanes();\r\n $(\"div.dtsp-verticalPanes\").append(table.searchPanes.container());\r\n \r\n // Hide the loading message and show the table\r\n $('#loading').hide();\r\n $('#computerTable').show();\r\n });\r\n </script>\r\n</body>\r\n</html>", | ||
"type": "html", | ||
"depends_on": [ | ||
"client" | ||
], | ||
"template_variables": "data_sources:\r\n agentsList:\r\n filter:\r\n site__client_id: '{{client.id}}'\r\n model: agent\r\n custom_fields:\r\n - WarrantyExpiration\r\n - BatteryHealthPercentage\r\n only:\r\n - hostname\r\n - operating_system\r\n - site__name\r\n - site__client__name\r\n - last_logged_in_user\r\n - wmi_detail" | ||
}, | ||
"assets": [] | ||
} |
Oops, something went wrong.