How to use the routes.when function in routes

To help you get started, we’ve selected a few routes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenSOC / opensoc-ui / src / kibana / plugins / settings / sections / indices / _field_editor.js View on Github external
define(function (require) {
  require('components/field_editor/field_editor');
  require('plugins/settings/sections/indices/_index_header');

  require('routes')
  .when('/settings/indices/:indexPatternId/field/:fieldName', { mode: 'edit' })
  .when('/settings/indices/:indexPatternId/create-field/', { mode: 'create' })
  .defaults(/settings\/indices\/[^\/]+\/(field|create-field)(\/|$)/, {
    template: require('text!plugins/settings/sections/indices/_field_editor.html'),
    resolve: {
      indexPattern: function ($route, courier) {
        return courier.indexPatterns.get($route.current.params.indexPatternId)
        .catch(courier.redirectWhenMissing('/settings/indices'));
      }
    },
    controllerAs: 'fieldSettings',
    controller: function FieldEditorPageController($route, Private, Notifier, docTitle) {
      var Field = Private(require('components/index_patterns/_field'));
      var notify = new Notifier({ location: 'Field Editor' });
      var kbnUrl = Private(require('components/url/url'));
github OpenSOC / opensoc-ui / src / kibana / plugins / field_editor / index.js View on Github external
define(function (require) {

  var _ = require('lodash');
  require('plugins/field_editor/field_editor');

  require('routes')
  .when('/settings/indices/:indexPatternId/field/:fieldName', {
    mode: 'edit',
    template: require('text!plugins/field_editor/index.html'),
    resolve: {
      indexPattern: function ($route, courier) {
        return courier.indexPatterns.get($route.current.params.indexPatternId)
        .catch(courier.redirectWhenMissing('/settings/indices'));
      }
    },
    controllerAs: 'fieldEditorPage',
    controller: FieldEditorPageController
  })
  .when('/settings/indices/:indexPatternId/create-scripted-field', {
    mode: 'create-scripted',
    template: require('text!plugins/field_editor/index.html'),
    resolve: {
github OpenSOC / opensoc-ui / src / kibana / plugins / dashboard / index.js View on Github external
require('plugins/dashboard/directives/grid');
  require('plugins/dashboard/components/panel/panel');
  require('plugins/dashboard/services/saved_dashboards');
  require('css!plugins/dashboard/styles/main.css');

  var app = require('modules').get('app/dashboard', [
    'elasticsearch',
    'ngRoute',
    'kibana/courier',
    'kibana/config',
    'kibana/notify',
    'kibana/typeahead'
  ]);

  require('routes')
  .when('/dashboard', {
    template: require('text!plugins/dashboard/index.html'),
    resolve: {
      dash: function (savedDashboards) {
        return savedDashboards.get();
      }
    }
  })
  .when('/dashboard/:id', {
    template: require('text!plugins/dashboard/index.html'),
    resolve: {
      dash: function (savedDashboards, Notifier, $route, $location, courier) {
        return savedDashboards.get($route.current.params.id)
        .catch(courier.redirectWhenMissing({
          'dashboard' : '/dashboard'
        }));
github OpenSOC / opensoc-ui / src / kibana / plugins / dashboard / index.js View on Github external
require('plugins/dashboard/directives/grid');
  require('plugins/dashboard/components/panel/panel');
  require('plugins/dashboard/services/saved_dashboards');
  require('css!plugins/dashboard/styles/main.css');

  var app = require('modules').get('app/dashboard', [
    'elasticsearch',
    'ngRoute',
    'kibana/courier',
    'kibana/config',
    'kibana/notify',
    'kibana/typeahead'
  ]);

  require('routes')
  .when('/dashboard', {
    template: require('text!plugins/dashboard/index.html'),
    resolve: {
      dash: function (savedDashboards) {
        return savedDashboards.get();
      }
    }
  })
  .when('/dashboard/:id', {
    template: require('text!plugins/dashboard/index.html'),
    resolve: {
      dash: function (savedDashboards, Notifier, $route, $location, courier) {
        return savedDashboards.get($route.current.params.id)
        .catch(courier.redirectWhenMissing({
          'dashboard' : '/dashboard'
        }));
github elastic / kibana / src / kibana / plugins / dashboard / index.js View on Github external
require('plugins/dashboard/directives/grid');
  require('plugins/dashboard/components/panel/panel');
  require('plugins/dashboard/services/saved_dashboards');
  require('css!plugins/dashboard/styles/main.css');

  var app = require('modules').get('app/dashboard', [
    'elasticsearch',
    'ngRoute',
    'kibana/courier',
    'kibana/config',
    'kibana/notify',
    'kibana/typeahead'
  ]);

  require('routes')
  .when('/dashboard', {
    template: require('text!plugins/dashboard/index.html'),
    resolve: {
      dash: function (savedDashboards) {
        return savedDashboards.get();
      }
    }
  })
  .when('/dashboard/:id', {
    template: require('text!plugins/dashboard/index.html'),
    resolve: {
      dash: function (savedDashboards, Notifier, $route, $location, courier) {
        return savedDashboards.get($route.current.params.id)
        .catch(courier.redirectWhenMissing({
          'dashboard' : '/dashboard'
        }));

routes

Minimalist route matching for javascript

Unknown
Latest version published 9 years ago

Package Health Score

51 / 100
Full package analysis