2023-01-11 17:29:38 +00:00
module . exports = {
2024-01-24 13:22:24 +00:00
friendlyName : 'View device management' ,
2023-01-11 17:29:38 +00:00
2024-01-24 13:22:24 +00:00
description : 'Display "Device management" page.' ,
2023-01-11 17:29:38 +00:00
exits : {
success : {
2024-01-24 13:22:24 +00:00
viewTemplatePath : 'pages/device-management'
2023-12-18 21:09:58 +00:00
} ,
badConfig : { responseType : 'badConfig' } ,
2023-01-11 17:29:38 +00:00
} ,
fn : async function ( ) {
2023-12-18 21:09:58 +00:00
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.
2024-01-13 01:22:36 +00:00
let testimonialsForScrollableTweets = _ . clone ( sails . config . builtStaticContent . testimonials ) ;
2024-12-06 00:03:44 +00:00
// Specify an order for the testimonials on this page using the last names of quote authors
let testimonialOrderForThisPage = [
2025-05-28 18:17:12 +00:00
'Bart Reardon' ,
2024-12-06 00:03:44 +00:00
'Scott MacVicar' ,
2025-04-07 17:05:18 +00:00
'Mike Meyer' ,
'Luis Madrigal' ,
'Tom Larkin' ,
2024-12-06 00:03:44 +00:00
'Kenny Botelho' ,
'Erik Gomez' ,
'Chandra Majumdar' ,
'Eric Tan' ,
'Matt Carr' ,
'Nico Waisman' ,
'Dan Grzelak' ,
2025-07-09 00:17:55 +00:00
'Philip Chotipradit' ,
'Roger Cantrell' ,
2025-09-24 02:14:36 +00:00
'Chayce O\'Neal' ,
'David Bodmer'
2024-12-06 00:03:44 +00:00
] ;
2024-01-13 01:22:36 +00:00
// Filter the testimonials by product category
testimonialsForScrollableTweets = _ . filter ( testimonialsForScrollableTweets , ( testimonial ) => {
2024-12-06 00:03:44 +00:00
return _ . contains ( testimonial . productCategories , 'Device management' ) && _ . contains ( testimonialOrderForThisPage , testimonial . quoteAuthorName ) ;
2024-01-13 01:22:36 +00:00
} ) ;
testimonialsForScrollableTweets . sort ( ( a , b ) => {
2024-02-12 22:40:56 +00:00
if ( testimonialOrderForThisPage . indexOf ( a . quoteAuthorName ) === - 1 ) {
2024-01-13 01:22:36 +00:00
return 1 ;
2024-02-12 22:40:56 +00:00
} else if ( testimonialOrderForThisPage . indexOf ( b . quoteAuthorName ) === - 1 ) {
2024-01-13 01:22:36 +00:00
return - 1 ;
}
2024-02-12 22:40:56 +00:00
return testimonialOrderForThisPage . indexOf ( a . quoteAuthorName ) - testimonialOrderForThisPage . indexOf ( b . quoteAuthorName ) ;
2024-01-13 01:22:36 +00:00
} ) ;
2024-10-30 05:59:55 +00:00
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.
2024-11-01 21:11:00 +00:00
if ( sails . config . environment === 'production' ) {
// Log a warning if the cloudflare headers we use are missing in production.
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.' ) ;
}
}
2024-10-30 05:59:55 +00:00
if ( this . req . get ( 'cf-ipcountry' ) === 'US' && this . req . get ( 'cf-iplongitude' ) > - 125 ) {
showSwagForm = true ;
}
2023-01-11 17:29:38 +00:00
// Respond with view.
2023-12-18 21:09:58 +00:00
return {
testimonialsForScrollableTweets ,
2024-10-30 05:59:55 +00:00
showSwagForm ,
2023-12-18 21:09:58 +00:00
} ;
2023-01-11 17:29:38 +00:00
}
} ;