154 lines
2.9 KiB
JavaScript
Raw Normal View History

2017-01-17 19:20:46 -08:00
import Ember from 'ember';
import config from './config/environment';
const {
get,
Router,
getWithDefault,
inject: { service },
run: { scheduleOnce }
} = Ember;
const AppRouter = Router.extend({
2017-01-17 19:20:46 -08:00
location: config.locationType,
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, () => {
const page = get(this, 'url');
const title = getWithDefault(this, 'currentRouteName', 'unknown.page.title');
get(this, 'metrics').trackPage({ page, title });
});
}
2017-01-17 19:20:46 -08:00
});
AppRouter.map(function () {
this.route('page-not-found', {
path: '/*wildcard'
});
this.route('datasets', function () {
this.route('page', {
path: '/page/:page'
});
this.route('dataset', {
path: '/:dataset_id'
});
this.route('name', {
path: '/name/:name'
}, function () {
this.route('subpage', {
path: '/page/:page'
});
});
});
this.route('search');
this.route('advsearch');
this.route('metrics', function () {
this.route('metricspage', {
path: '/page/:page'
});
this.route('metric', {
path: '/:metric_id'
});
this.route('metricname', {
path: '/name/:metric_name'
}, function () {
this.route('metricnamepage', {
path: '/page/:page'
});
this.route('metricgroup', {
path: '/:metric_group'
}, function () {
this.route('metricnamesubpage', {
path: '/page/:page'
});
});
});
});
this.route('flows', function () {
this.route('flowspage', {
path: '/page/:page'
});
this.route('flowsname', {
path: '/name/:name'
}, function () {
this.route('flowssubpage', {
path: '/page/:page'
});
this.route('flow', {
path: '/:flow_id'
}, function () {
this.route('pagedflow', {
path: '/page/:page'
});
});
});
});
this.route('logout');
this.route('metadata', function () {
this.route('user', {
path: '/:user'
});
});
this.route('idpc', function () {
this.route('user', {
path: '/:user'
});
});
this.route('scripts', function () {
this.route('page', {
path: '/page/:page'
});
this.route('script', {
path: '/:script_id'
});
});
this.route('schemahistory', {
path: 'schemas'
}, function () {
this.route('page', {
path: '/page/:page'
});
this.route('schema', {
path: '/:schema'
});
});
this.route('lineage', function () {
this.route('dataset', {
path: '/dataset/:id'
});
});
this.route('login');
this.route('help', function () {
this.route('feedback');
});
2017-01-17 19:20:46 -08:00
});
export default AppRouter;