| 
									
										
										
										
											2018-06-28 10:54:00 -07:00
										 |  |  | import EmberRouter from '@ember/routing/router'; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:46:47 -08:00
										 |  |  | import { get, getWithDefault } from '@ember/object'; | 
					
						
							| 
									
										
										
										
											2018-06-28 10:54:00 -07:00
										 |  |  | import { inject } from '@ember/service'; | 
					
						
							| 
									
										
										
										
											2018-01-20 00:46:47 -08:00
										 |  |  | import { scheduleOnce } from '@ember/runloop'; | 
					
						
							| 
									
										
										
										
											2018-05-02 23:32:43 -07:00
										 |  |  | import config from 'wherehows-web/config/environment'; | 
					
						
							| 
									
										
										
										
											2018-06-28 10:54:00 -07:00
										 |  |  | import Metrics from 'ember-metrics'; | 
					
						
							| 
									
										
										
										
											2017-01-17 19:20:46 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-28 10:54:00 -07:00
										 |  |  | const AppRouter = EmberRouter.extend({ | 
					
						
							| 
									
										
										
										
											2017-01-17 19:20:46 -08:00
										 |  |  |   location: config.locationType, | 
					
						
							| 
									
										
										
										
											2017-04-08 11:40:23 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   rootURL: config.rootURL, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-28 10:54:00 -07:00
										 |  |  |   metrics: inject(), | 
					
						
							| 
									
										
										
										
											2017-04-08 11:40:23 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   didTransition() { | 
					
						
							|  |  |  |     this._super(...arguments); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // On route transition / navigation invoke page tracking
 | 
					
						
							|  |  |  |     this._trackPage(); | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /** | 
					
						
							|  |  |  |    * Tracks the current page | 
					
						
							|  |  |  |    * @private | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   _trackPage() { | 
					
						
							|  |  |  |     scheduleOnce('afterRender', null, () => { | 
					
						
							| 
									
										
										
										
											2018-06-28 10:54:00 -07:00
										 |  |  |       //@ts-ignore types need update, location property is not a string post instantiation
 | 
					
						
							| 
									
										
										
										
											2017-04-10 11:54:55 -07:00
										 |  |  |       const page = get(this, 'location').getURL(); | 
					
						
							| 
									
										
										
										
											2018-06-28 10:54:00 -07:00
										 |  |  |       //@ts-ignore types need update
 | 
					
						
							| 
									
										
										
										
											2017-04-08 11:40:23 -07:00
										 |  |  |       const title = getWithDefault(this, 'currentRouteName', 'unknown.page.title'); | 
					
						
							| 
									
										
										
										
											2018-06-28 10:54:00 -07:00
										 |  |  |       const metrics = <Metrics>get(this, 'metrics'); | 
					
						
							| 
									
										
										
										
											2018-05-14 10:11:51 -07:00
										 |  |  |       // Reference to the _paq queue
 | 
					
						
							|  |  |  |       //   check if we are in a browser env
 | 
					
						
							|  |  |  |       const paq = window && window._paq ? window._paq : []; | 
					
						
							| 
									
										
										
										
											2017-04-08 11:40:23 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-10 11:54:55 -07:00
										 |  |  |       /** | 
					
						
							|  |  |  |        * Manually track Piwik siteSearch using the `trackSiteSearch` api | 
					
						
							|  |  |  |        *  rather than using Piwik's default reading of url's containing the | 
					
						
							|  |  |  |        *  "search", "q", "query", "s", "searchword", "k" and "keyword", keywords | 
					
						
							|  |  |  |        * @link https://developer.piwik.org/guides/tracking-javascript-guide#internal-search-tracking
 | 
					
						
							|  |  |  |        */ | 
					
						
							|  |  |  |       if (title.includes('search')) { | 
					
						
							| 
									
										
										
										
											2018-06-28 10:54:00 -07:00
										 |  |  |         //@ts-ignore types need update
 | 
					
						
							| 
									
										
										
										
											2017-04-10 11:54:55 -07:00
										 |  |  |         const routerJs = get(this, 'router'); | 
					
						
							|  |  |  |         const queryParams = routerJs ? get(routerJs, 'state.queryParams') : {}; | 
					
						
							| 
									
										
										
										
											2017-05-03 14:45:23 -07:00
										 |  |  |         const { keyword, category = 'datasets', page = 1 } = queryParams; | 
					
						
							| 
									
										
										
										
											2017-04-10 11:54:55 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // Early exit once we track search, so we do not invoke the
 | 
					
						
							|  |  |  |         //   default op by invoking `trackPageView` event
 | 
					
						
							| 
									
										
										
										
											2017-05-03 14:45:23 -07:00
										 |  |  |         return paq.push(['trackSiteSearch', keyword, category, page]); | 
					
						
							| 
									
										
										
										
											2017-04-10 11:54:55 -07:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       metrics.trackPage({ page, title }); | 
					
						
							| 
									
										
										
										
											2018-05-14 10:11:51 -07:00
										 |  |  |       paq.push(['enableHeartBeatTimer']); | 
					
						
							| 
									
										
										
										
											2017-04-08 11:40:23 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2017-01-17 19:20:46 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-19 11:46:05 -07:00
										 |  |  | AppRouter.map(function() { | 
					
						
							| 
									
										
										
										
											2017-03-24 19:13:41 -07:00
										 |  |  |   this.route('page-not-found', { | 
					
						
							|  |  |  |     path: '/*wildcard' | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-06-19 11:46:05 -07:00
										 |  |  |   this.route('datasets', function() { | 
					
						
							| 
									
										
										
										
											2018-02-08 17:09:13 -08:00
										 |  |  |     this.route( | 
					
						
							|  |  |  |       'dataset', | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         path: '/:dataset_id' | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       function() { | 
					
						
							|  |  |  |         this.route('properties'); | 
					
						
							|  |  |  |         this.route('comments'); | 
					
						
							|  |  |  |         this.route('schema'); | 
					
						
							|  |  |  |         this.route('ownership'); | 
					
						
							|  |  |  |         this.route('compliance'); | 
					
						
							|  |  |  |         this.route('sample'); | 
					
						
							| 
									
										
										
										
											2018-07-19 17:00:25 -07:00
										 |  |  |         this.route('relationships'); | 
					
						
							| 
									
										
										
										
											2018-03-14 22:29:23 -07:00
										 |  |  |         this.route('access'); | 
					
						
							| 
									
										
										
										
											2018-07-19 17:00:25 -07:00
										 |  |  |         this.route('health'); | 
					
						
							| 
									
										
										
										
											2018-02-08 17:09:13 -08:00
										 |  |  |       } | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2017-03-24 19:13:41 -07:00
										 |  |  |   }); | 
					
						
							|  |  |  |   this.route('search'); | 
					
						
							|  |  |  |   this.route('logout'); | 
					
						
							| 
									
										
										
										
											2018-07-16 10:45:52 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-24 19:13:41 -07:00
										 |  |  |   this.route('login'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-22 14:47:27 -07:00
										 |  |  |   this.route('browse', function() { | 
					
						
							|  |  |  |     this.route('entity', { | 
					
						
							|  |  |  |       path: '/:entity' | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-01-17 19:20:46 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-08 11:40:23 -07:00
										 |  |  | export default AppRouter; |