-
Notifications
You must be signed in to change notification settings - Fork 137
Module listings
As of MunkiReport v4.2 there is a new way of creating listings. Instead of creating a page with html snippets, you only provide a YAML
data structure and MunkiReport will build the listing view based on that structure. This is the preferred way of generating a listing as it makes these views independent of the presentation (which is extremely convenient if/when MR switches presentation framework)
Note: if you convert the listing of a module to the new format, and you create a new release for the module, make sure the release version is a full version higher (e.g. v1.4 -> v2.0).
Below you see a simplified example of a listing view:
i18n_title: disk_report.report
js_link: module/disk_report/js/format_storage
not_null_column: freespace
table:
-
column: machine.computer_name
i18n_header: listing.computername
formatter: clientDetail
tab_link: storage-tab
-
column: reportdata.serial_number
i18n_header: serial
-
column: reportdata.long_username
i18n_header: username
-
column: diskreport.mountpoint
i18n_header: disk_report.mountpoint
-
column: diskreport.media_type
i18n_header: disk_report.media_type
formatter: upperCase
-
column: diskreport.volumetype
i18n_header: disk_report.volume_type
formatter: formatVolumeType
-
column: diskreport.freespace
i18n_header: disk_report.free
formatter: fileSize
filter: freeSpaceFilter
-
column: diskreport.totalsize
i18n_header: disk_report.total_size
formatter: fileSize
-
column: diskreport.smartstatus
i18n_header: disk_report.smartstatus
formatter: smartStatus
-
column: diskreport.encrypted
i18n_header: disk_report.encryption_status
formatter: encryptionStatus
This is the i18n string that should translate to the proper title for the listing.
Table is a list that contains the fields that you want in your table. Table entries contain at least column
and i18n_header
table:
-
column: machine.computer_name
i18n_header: listing.computername
formatter: clientDetail
tab_link: storage-tab
-
column: reportdata.serial_number
i18n_header: serial
key | example | Comment |
---|---|---|
column | machine.computer_name | database column, prefix with table name if it's ambiguous |
i18n_header | listing.computername | i18n identifier for the column |
formatter | displayTypeFormat | name of a js function to format the column, see Formatters |
filter | displayTypeFilter | name of a js function to filter the column, see Filters |
tab_link | displays-tab | which clienttab to link to when using the clientDetail formatter |
Optional link to a js file that contains Formatters or Filters.
js_link: module/disk_report/js/format_storage
Optional call to an init function that is called when loading the page.
js_init: initializeManagedInstalls('$name', '$version')
Optional value that contains a column that should not be NULL
in the result.
not_null_column: displays.vendor
formatter: timestampToMoment
There are a couple of built-in formatters:
formatter | description |
---|---|
clientDetail | uses the computer_name and serial_number to create a link to the client detail |
timestampToMoment | converts UNIX timestamp to moment |
binaryYesNo | converts a 1 or 0 to a localised yes or no
|
binaryEnabledDisabled | converts a 1 or 0 to a localised Enabled or Disabled button |
fileSize | converts bytes to human readable file size |
upperCase | changes the column to uppercase |
osVersion | converts OS version integer (101404) to formatted version (10.14.4) |
Custom formatters can be supplied in a separate .js
file. Here's an example:
var appNameToLink = function(colNumber, row){
var col = $('td:eq('+colNumber+')', row),
appName = col.text();
col.html($('<a>').attr('href', appUrl+'/module/inventory/items/'+appName).text(appName))
}
As you can see, the formatter receives the column number and the row, which can be used to reference the table cell. You can then manipulate the data and overwrite the cell contents.
Filters are used to modify the request for data. Here's an example:
filter: osFilter
The filter function receives the column number and a reference to the request data object.
Built-in filters:
filter | description |
---|---|
osFilter | Converts an OS version string (10.14.4) to a db stored integer (101404) |
columnNameFilter | If the search term matches the column name, do a search for value > 0 |
Custom filters can be supplied in a separate .js
file. Here's an example:
var displayTypeFilter = function(colNumber, d){
// Look for 'external' keyword
if(d.search.value.match(/^external$/))
{
// Add column specific search
d.columns[colNumber].search.value = '= 1';
// Clear global search
d.search.value = '';
}
// Look for 'internal' keyword
if(d.search.value.match(/^internal/))
{
// Add column specific search
d.columns[colNumber].search.value = '= 0';
// Clear global search
d.search.value = '';
}
}
- General Upgrade Procedures
- How to Upgrade Versions
- Troubleshooting Upgrades
- Migrating sqlite to MySQL