fleet/website/api/controllers/view-device-management.js
Eric 0434fdb8a2
Website: add testimonial (#35870)
Changes:
- Added a new testimonial and added it to the /device-management and
/testimonials pages
2025-11-18 11:48:49 -06:00

83 lines
2.8 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View device management',
description: 'Display "Device management" page.',
exits: {
success: {
viewTemplatePath: 'pages/device-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);
// Specify an order for the testimonials on this page using the last names of quote authors
let testimonialOrderForThisPage = [
'Bart Reardon',
'Scott MacVicar',
'Mike Meyer',
'Luis Madrigal',
'Tom Larkin',
'Kenny Botelho',
'Erik Gomez',
'Chandra Majumdar',
'Eric Tan',
'Matt Carr',
'Nico Waisman',
'Dan Grzelak',
'Philip Chotipradit',
'Roger Cantrell',
'Chayce O\'Neal',
'David Bodmer',
'Fiona Skelton',
];
// Filter the testimonials by product category
testimonialsForScrollableTweets = _.filter(testimonialsForScrollableTweets, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Device management') && _.contains(testimonialOrderForThisPage, testimonial.quoteAuthorName);
});
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);
});
let showSwagForm = false;
// Due to shipping costs, we'll check the requesting user's cf-ipcountry to see if they're in the US, and their cf-iplongitude header to see if they're in the contiguous US.
if(sails.config.environment === 'production') {
// Log a warning if the cloudflare headers we use are missing in production.
// 2025-11-18: This warning was temporarily disabled until the website is back on Cloudflare.
// if(!this.req.get('cf-ipcountry') || !this.req.get('cf-iplongitude')) {
// sails.log.warn('When a user visted the device management page, the Cloudflare header we use to determine if they are visiting from the contiguous United States is missing.');
// }
}
if(this.req.get('cf-ipcountry') === 'US' && this.req.get('cf-iplongitude') > -125) {
showSwagForm = true;
}
// Respond with view.
return {
testimonialsForScrollableTweets,
showSwagForm,
};
}
};