fleet/website/api/controllers/view-vulnerability-management.js
2024-07-18 14:41:54 -05:00

50 lines
1.7 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View vulnerability-management',
description: 'Display "Vulnerability management" page.',
exits: {
success: {
viewTemplatePath: 'pages/vulnerability-management'
},
badConfig: { responseType: 'badConfig' },
},
fn: async function () {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.testimonials) || !sails.config.builtStaticContent.compiledPagePartialsAppPath) {
throw {badConfig: 'builtStaticContent.testimonials'};
}
// Get testimonials for the <scrolalble-tweets> component.
let testimonialsForScrollableTweets = _.clone(sails.config.builtStaticContent.testimonials);
// Filter the testimonials by product category
testimonialsForScrollableTweets = _.filter(testimonialsForScrollableTweets, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Vulnerability management');
});
// Specify an order for the testimonials on this page using the last names of quote authors
let testimonialOrderForThisPage = ['Nico Waisman', 'Andre Shields', 'Dhruv Majumdar', 'Austin Anderson', 'Dan Grzelak', 'Nick Fohs', 'Chandra Majumdar', 'Charles Zaffery'];
testimonialsForScrollableTweets.sort((a, b)=>{
if(testimonialOrderForThisPage.indexOf(a.quoteAuthorName) === -1){
return 1;
} else if(testimonialOrderForThisPage.indexOf(b.quoteAuthorName) === -1) {
return -1;
}
return testimonialOrderForThisPage.indexOf(a.quoteAuthorName) - testimonialOrderForThisPage.indexOf(b.quoteAuthorName);
});
// Respond with view.
return {
testimonialsForScrollableTweets,
};
}
};