Changeset 467
- Timestamp:
- 06/26/13 15:24:09 (12 years ago)
- Location:
- Dev/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/index.js
r466 r467 21 21 Router.register(route); 22 22 }); 23 Router.startup();24 23 25 session.restore(); 24 session.restore().then(function(){ 25 Router.startup(); 26 }); 26 27 27 28 }); -
Dev/trunk/src/client/qed-client/pages/templates/surveyRun.html
r466 r467 45 45 <div> 46 46 <div class="qedLabel">Export results</div> 47 <a target="_blank" href="/ surveyRun/${surveyRunId}/csv" class="qedField">To CSV</a>47 <a target="_blank" href="/api/surveyRuns/${surveyRunId}/responses.csv" class="qedField">To CSV</a> 48 48 </div> 49 49 </fieldset> -
Dev/trunk/src/server/app.js
r466 r467 75 75 76 76 // ensure we're authenticated on API calls 77 app.use('/api', function(req,res,next){77 function ensureAuthenticated(req,res,next){ 78 78 if (!req.user) { 79 79 return res.send(401,{error:"Login before accessing API."}); … … 81 81 return next(); 82 82 } 83 } );83 } 84 84 85 85 app.get( 86 86 '/api/login', 87 ensureAuthenticated, 87 88 returnUser); 88 89 89 90 app.post( 90 '/api/logout', function(req,res){ 91 '/api/logout', 92 ensureAuthenticated, 93 function(req,res){ 91 94 req.logout(); 92 95 res.send(200,{}); 93 96 }); 94 97 95 app.get( '/api/surveyRun/:id/response/csv',96 function(req, res) {97 var id = req.params.id;98 // query CouchDB and build the CSV file99 res.set({100 'Content-Type': 'text/csv',101 'Content-Disposition': 'attachment; filename=responses-'+id+'.csv'102 });103 res.send(200, "Response for surveyRun "+id);98 app.get( 99 '/api/surveyRuns/:id/responses.csv', 100 ensureAuthenticated, 101 function(req, res) { 102 var id = req.params.id; 103 // query CouchDB and build the CSV file 104 res.set({ 105 'Content-Type': 'text/csv', 106 'Content-Disposition': 'attachment; filename=surveyRun-'+id+'-responses.csv' 104 107 }); 108 res.send(200, "Response for surveyRun "+id); 109 }); 105 110 106 111 // forward to couch 112 app.use('/api/data', ensureAuthenticated); 107 113 app.use('/api/data', proxy(settings.couchDbURL)); 108 114
Note: See TracChangeset
for help on using the changeset viewer.