11/* eslint-disable no-unused-vars */
2- // import config from 'config';
2+ import config from 'config' ;
33import _ from 'lodash' ;
44import { middleware as tcMiddleware } from 'tc-core-library-js' ;
55import util from '../../util' ;
@@ -13,7 +13,7 @@ module.exports = [
1313 permissions ( 'projectReporting.managers' ) ,
1414 async ( req , res , next ) => {
1515 const projectId = Number ( req . params . projectId ) ;
16- const reportName = req . query . reportName ;
16+ const reportName = config . lookerConfig . USE_MOCK ? 'mock' : req . query . reportName ;
1717 const authUser = req . authUser ;
1818
1919 try {
@@ -34,14 +34,21 @@ module.exports = [
3434 }
3535 // pick the report based on its name
3636 let result = { } ;
37+ let embedUrl = null ;
3738 const project = { id : projectId } ;
3839 switch ( reportName ) {
3940 case 'summary' :
40- result = await lookerSerivce . generateEmbedUrl ( req . authUser , project , member , '/embed/looks/1' ) ;
41+ embedUrl = '/embed/looks/1' ;
42+ break ;
43+ case 'mock' :
44+ embedUrl = config . lookerConfig . MOCK_EMBED_REPORT ;
4145 break ;
4246 default :
4347 return res . status ( 404 ) . send ( 'Report not found' ) ;
4448 }
49+ if ( embedUrl ) {
50+ result = await lookerSerivce . generateEmbedUrl ( req . authUser , project , member , embedUrl ) ;
51+ }
4552
4653 req . log . debug ( result ) ;
4754 return res . status ( 200 ) . json ( result ) ;
0 commit comments