fleet/website/api/controllers/view-mdm-commands.js
Eric 048fcd13ed
Website: Add controls library pages (#33143)
Related to: https://github.com/fleetdm/confidential/issues/10737

Changes:
- Added `docs/scripts.yml`, a YAML file that contains a list of scripts
- Added `docs/mdm-commands.yml`, a YAML file that contains Windows and
Apple MDM commands
- Added `/mdm-commands`, a page that contains a list of MDM commands for
Windows and Apple commands
- Added `/scripts`, a page that contains a list of scripts
- Updated the `<docs-nav-and-search>` component to have a link to the
controls library, and reordered the lists.
- Updated the build static content script to add the scripts and mdm
commands from scripts.yml and mdm-commands.yml to the website's
`builtStaticContent` configuration.
- Updated the layout of the os-settings page to match the latest
wireframes
2025-09-19 12:02:55 -05:00

47 lines
1 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View mdm commands',
description: 'Display "Mdm commands" page.',
exits: {
success: {
viewTemplatePath: 'pages/mdm-commands'
},
badConfig: { responseType: 'badConfig' },
},
fn: async function () {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.mdmCommands)) {
throw {badConfig: 'builtStaticContent.scripts'};
}
let commands = sails.config.builtStaticContent.mdmCommands;
let appleCommands = _.filter(commands, (command)=>{
return command.platform === 'apple';
});
let windowsCommands = _.filter(commands, (command)=>{
return command.platform === 'windows';
});
let windowsCategories = _.groupBy(windowsCommands, 'category');
let appleCategories = _.groupBy(appleCommands, 'category');
// respond with view.
return {
windowsCategories,
windowsCommands,
appleCategories,
appleCommands,
algoliaPublicKey: sails.config.custom.algoliaPublicKey,
};
}
};