@ducna01120/fleetops-engine
Version:
Fleet & Transport Management Extension for Fleetbase
30 lines (25 loc) • 1.11 kB
JavaScript
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import getResourceNameFromTransition from '@fleetbase/ember-core/utils/get-resource-name-from-transition';
export default class ApplicationRoute extends Route {
loader;
intl;
location;
abilities;
hostRouter;
notifications;
loading(transition) {
const resourceName = getResourceNameFromTransition(transition, { humanize: true });
this.loader.showOnInitialTransition(transition, 'section.next-view-section', {
loadingMessage: resourceName ? this.intl.t('fleet-ops.common.loading-resource', { resourceName }) : this.intl.t('fleet-ops.common.loading'),
});
}
beforeModel() {
if (this.abilities.cannot('fleet-ops see extension')) {
this.notifications.warning(this.intl.t('common.unauthorized-access'));
return this.hostRouter.transitionTo('console');
}
this.location.getUserLocation();
}
}