2018-01-20 00:46:47 -08:00
|
|
|
import Router from '@ember/routing/router';
|
|
|
|
import { get, getWithDefault } from '@ember/object';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { scheduleOnce } from '@ember/runloop';
|
2017-01-17 19:20:46 -08:00
|
|
|
import config from './config/environment';
|
|
|
|
|
2017-04-08 11:40:23 -07:00
|
|
|
const AppRouter = Router.extend({
|
2017-01-17 19:20:46 -08:00
|
|
|
location: config.locationType,
|
2017-04-08 11:40:23 -07:00
|
|
|
|
|
|
|
rootURL: config.rootURL,
|
|
|
|
|
|
|
|
metrics: service(),
|
|
|
|
|
|
|
|
didTransition() {
|
|
|
|
this._super(...arguments);
|
|
|
|
|
|
|
|
// On route transition / navigation invoke page tracking
|
|
|
|
this._trackPage();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tracks the current page
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
_trackPage() {
|
|
|
|
scheduleOnce('afterRender', null, () => {
|
2017-04-10 11:54:55 -07:00
|
|
|
const page = get(this, 'location').getURL();
|
2017-04-08 11:40:23 -07:00
|
|
|
const title = getWithDefault(this, 'currentRouteName', 'unknown.page.title');
|
2017-04-10 11:54:55 -07:00
|
|
|
const metrics = get(this, 'metrics');
|
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')) {
|
|
|
|
// Reference to the _paq queue
|
|
|
|
// check if we are in a browser env
|
|
|
|
const paq = window && window._paq ? window._paq : [];
|
|
|
|
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 });
|
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');
|
|
|
|
this.route('relations');
|
|
|
|
}
|
|
|
|
);
|
2017-03-24 19:13:41 -07:00
|
|
|
});
|
|
|
|
this.route('search');
|
2017-06-19 11:46:05 -07:00
|
|
|
this.route('metrics', function() {
|
2017-03-24 19:13:41 -07:00
|
|
|
this.route('metricspage', {
|
|
|
|
path: '/page/:page'
|
|
|
|
});
|
|
|
|
|
|
|
|
this.route('metric', {
|
|
|
|
path: '/:metric_id'
|
|
|
|
});
|
|
|
|
|
2017-06-19 11:46:05 -07:00
|
|
|
this.route(
|
|
|
|
'metricname',
|
|
|
|
{
|
|
|
|
path: '/name/:metric_name'
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
this.route('metricnamepage', {
|
2017-03-24 19:13:41 -07:00
|
|
|
path: '/page/:page'
|
|
|
|
});
|
2017-06-19 11:46:05 -07:00
|
|
|
|
|
|
|
this.route(
|
|
|
|
'metricgroup',
|
|
|
|
{
|
|
|
|
path: '/:metric_group'
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
this.route('metricnamesubpage', {
|
|
|
|
path: '/page/:page'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2017-03-24 19:13:41 -07:00
|
|
|
});
|
2017-06-19 11:46:05 -07:00
|
|
|
this.route('flows', function() {
|
2017-03-24 19:13:41 -07:00
|
|
|
this.route('flowspage', {
|
|
|
|
path: '/page/:page'
|
|
|
|
});
|
|
|
|
|
2017-06-19 11:46:05 -07:00
|
|
|
this.route(
|
|
|
|
'flowsname',
|
|
|
|
{
|
|
|
|
path: '/name/:name'
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
this.route('flowssubpage', {
|
2017-03-24 19:13:41 -07:00
|
|
|
path: '/page/:page'
|
|
|
|
});
|
2017-06-19 11:46:05 -07:00
|
|
|
|
|
|
|
this.route(
|
|
|
|
'flow',
|
|
|
|
{
|
|
|
|
path: '/:flow_id'
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
this.route('pagedflow', {
|
|
|
|
path: '/page/:page'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
2017-04-26 22:49:36 -07:00
|
|
|
|
|
|
|
this.route('flow', {
|
|
|
|
path: '/:flow_id'
|
|
|
|
});
|
2017-03-24 19:13:41 -07:00
|
|
|
});
|
|
|
|
this.route('logout');
|
2017-06-19 11:46:05 -07:00
|
|
|
this.route('metadata', function() {
|
2017-03-24 19:13:41 -07:00
|
|
|
this.route('user', {
|
|
|
|
path: '/:user'
|
|
|
|
});
|
|
|
|
});
|
2017-06-19 11:46:05 -07:00
|
|
|
this.route('idpc', function() {
|
2017-03-24 19:13:41 -07:00
|
|
|
this.route('user', {
|
|
|
|
path: '/:user'
|
|
|
|
});
|
|
|
|
});
|
2017-06-19 11:46:05 -07:00
|
|
|
this.route('scripts', function() {
|
2017-03-24 19:13:41 -07:00
|
|
|
this.route('page', {
|
|
|
|
path: '/page/:page'
|
|
|
|
});
|
|
|
|
|
|
|
|
this.route('script', {
|
|
|
|
path: '/:script_id'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-06-19 11:46:05 -07:00
|
|
|
this.route(
|
|
|
|
'schemahistory',
|
|
|
|
{
|
|
|
|
path: 'schemas'
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
this.route('page', {
|
|
|
|
path: '/page/:page'
|
|
|
|
});
|
2017-03-24 19:13:41 -07:00
|
|
|
|
2017-06-19 11:46:05 -07:00
|
|
|
this.route('schema', {
|
|
|
|
path: '/:schema'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
this.route('lineage', function() {
|
2017-03-24 19:13:41 -07:00
|
|
|
this.route('dataset', {
|
|
|
|
path: '/dataset/:id'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
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;
|