How to use states - 10 common examples

To help you get started, we’ve selected a few states 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 alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / _ref / admin / controllers / admin.js View on Github external
define(function (require) {
  'use strict';

  // create the alien4cloud-admin module for angular
  var modules = require('modules');
  var states = require('states');

  // register admin root state
  states.state('admin', {
    url: '/admin',
    templateUrl: 'views/_ref/admin/admin.html',
    controller: 'LayoutCtrl',
    menu: {
      id: 'menu.admin',
      state: 'admin',
      key: 'NAVBAR.MENU_ADMIN',
      icon: 'fa fa-wrench',
      priority: 10000,
      roles: ['ADMIN']
    }
  });
  // register admin default home page
  states.state('admin.home', {
    url: '/',
    templateUrl: 'views/_ref/admin/admin_home.html',
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / alien4cloud.js View on Github external
$scope.isAdmin = false;
      var isAdmin = authService.hasRole('ADMIN');
      if (_.defined(isAdmin.then)) {
        authService.hasRole('ADMIN').then(function(result) {
          $scope.isAdmin = result;
        });
      } else {
        $scope.isAdmin = isAdmin;
      }
      $scope.adminTour = function() {
        $state.go('admin');
        hopscotchService.startTour('admin.home');
      };
    }]
  });
  states.state('restricted', {
    url: '/restricted',
    templateUrl: 'views/authentication/restricted.html'
  });

  require('scripts/common/services/rest_technical_error_interceptor');
  var templateInjector = require('a4c-templates');

  alien4cloud.startup = function(configuration) {
    // Path initialization for ace ide so it find modules after minification
    var config = window.ace.require('ace/config');
    config.set('basePath', 'bower_components/ace-builds/src-min-noconflict');

    // add requirements to alien4cloud
    modules.link(alien4cloud);

    alien4cloud.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', '$qProvider',
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / _ref / admin / controllers / admin.js View on Github external
// register admin root state
  states.state('admin', {
    url: '/admin',
    templateUrl: 'views/_ref/admin/admin.html',
    controller: 'LayoutCtrl',
    menu: {
      id: 'menu.admin',
      state: 'admin',
      key: 'NAVBAR.MENU_ADMIN',
      icon: 'fa fa-wrench',
      priority: 10000,
      roles: ['ADMIN']
    }
  });
  // register admin default home page
  states.state('admin.home', {
    url: '/',
    templateUrl: 'views/_ref/admin/admin_home.html',
    controller: 'LayoutCtrl'
  });
  states.forward('admin', 'admin.home');

  var admin = modules.get('alien4cloud-admin');

  // require admin modules
  require('scripts/_ref/admin/controllers/admin_plugins');
  require('scripts/_ref/admin/controllers/admin_server');
  require('scripts/_ref/admin/controllers/admin_audit');
  require('scripts/meta-props/controllers/meta_props_list');
  require('scripts/_ref/admin/controllers/admin_repositories');

  return admin;
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / users / controllers / users.js View on Github external
define(function (require) {
  'use strict';
  
  var modules = require('modules');
  var states = require('states');
  var _ = require('lodash');
  require('scripts/users/directives/groups');
  require('scripts/users/directives/users');
  require('scripts/common/directives/delete_confirm');

  // register state for user management.
  states.state('admin.users', {
    url: '/users',
    templateUrl: 'views/users/user_list.html',
    controller: 'UsersCtrl',
    menu: {
      id: 'am.admin.users',
      state: 'admin.users',
      key: 'NAVADMIN.MENU_USERS',
      icon: 'fa fa-users',
      priority: 100
    }
  });

  modules.get('a4c-security', ['a4c-common']).controller('UsersCtrl', ['$scope', '$rootScope', 'userServices', 'groupServices',
    function($scope, $rootScope, userServices, groupServices) {

      $scope.tabSelected = function(tabName) {
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / _ref / applications / services / deployment_detail_register_service.js View on Github external
}
        });
      }],
      params: {
        // optional deploymentDTO object related to this state. Will save a backend request
        deploymentDTO: null
      }
    });

    states.forward(detailState, detailState + '.info');

    /*
    * detail info state
    */
    var detailInfoState = detailState + '.info';
    states.state(detailInfoState, {
      url: '/info',
      templateUrl: 'views/_ref/applications/deployment_history/deployment_detail_info.html',
      controller: 'DeploymentDetailInfoCtrl',
      menu: {
        id: detailInfoState,
        state: detailInfoState,
        key: 'NAVAPPLICATIONS.MENU_DEPLOY_CURRENT_INFO',
        icon: 'fa fa-info',
        priority: 100
      }
    });
  };
});
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / components / controllers / component_list.js View on Github external
  'use strict';

  var modules = require('modules');
  var states = require('states');

  require('scripts/common/services/resize_services');
  // make sure that required directives are loaded
  require('scripts/components/directives/search_node_type');
  require('scripts/common/directives/upload');

  // load other locations to manage components
  require('scripts/components/controllers/component_details');
  require('scripts/components/controllers/csar_list');

  // register components root state
  states.state('components', {
    url: '/components',
    templateUrl: 'views/layout/vertical_menu_layout.html',
    controller: 'LayoutCtrl',
    menu: {
      id: 'menu.components',
      state: 'components',
      key: 'NAVBAR.MENU_COMPONENTS',
      icon: 'fa fa-cubes',
      priority: 30,
      roles: ['COMPONENTS_MANAGER', 'COMPONENTS_BROWSER']
    }
  });
  states.state('components.components', {
    url: '/components/list',
    templateUrl: 'views/components/component_list.html',
    controller: 'SearchComponentCtrl',
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / _ref / catalog / controllers / catalog.js View on Github external
  'use strict';

  var states = require('states');

  require('scripts/_ref/common/directives/breadcrumbs');
  require('scripts/_ref/common/services/breadcrumbs_service');

  // load other locations to manage catalog contain
  require('scripts/_ref/catalog/controllers/archives/archives');
  require('scripts/_ref/catalog/controllers/components/components');
  require('scripts/_ref/catalog/controllers/components/policies');

  require('scripts/_ref/catalog/controllers/topologies/topologies');

  // register catalog root state
  states.state('catalog', {
    url: '/catalog',
    templateUrl: 'views/_ref/layout/tab_menu_with_breadcrumbs_layout.html',
    controller: 'LayoutCtrl',
    menu: {
      id: 'menu.catalog',
      state: 'catalog',
      key: 'NAVBAR.MENU_CATALOG',
      icon: 'fa fa-cubes',
      priority: 60,
    }
  });
  states.forward('catalog', 'catalog.components');
});
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / alien4cloud.js View on Github external
'ui.router',
    'pascalprecht.translate',
    'xeditable',
    'angularMoment'
  ]);

  require(['clipboard'], function(Clipboard) {
    new Clipboard('.btn-cb', {
        text: function(trigger) {
            return trigger.getAttribute("uib-tooltip");
        }
    });
  });

  // bootstrap angular js application
  states.state('home', {
    url: '/',
    templateUrl: 'views/main.html',
    controller: ['$scope', 'authService', 'hopscotchService', '$state', function($scope, authService, hopscotchService, $state) {
      $scope.isAdmin = false;
      var isAdmin = authService.hasRole('ADMIN');
      if (_.defined(isAdmin.then)) {
        authService.hasRole('ADMIN').then(function(result) {
          $scope.isAdmin = result;
        });
      } else {
        $scope.isAdmin = isAdmin;
      }
      $scope.adminTour = function() {
        $state.go('admin');
        hopscotchService.startTour('admin.home');
      };
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / _ref / applications / services / deployment_detail_register_service.js View on Github external
return function(prefix, getSearchParam) {

    /*
    * list state
    */
    states.state(prefix+'.list', {
      url: '',
      templateUrl: 'views/_ref/applications/deployment_history/deployment_history_list.html',
      controller: 'DeploymentHistoryCtrl',
      resolve: {
        historyConf: ['$stateParams',
          function($stateParams) {
            return {
              rootState: prefix,
              searchParam: getSearchParam($stateParams)
            };
          }
        ]
      }
    });

    states.forward(prefix, prefix + '.list');
github alien4cloud / alien4cloud / alien4cloud-ui / src / main / webapp / scripts / topology / editor_register_service.js View on Github external
return function(prefix, menuOverrides) {
    states.state(prefix + '.editor', {
      url: '/editor',
      templateUrl: 'views/topology/topology_editor.html',
      controller: 'TopologyCtrl',
      resolve: {
        defaultFilters: [function(){return {};}],
        badges: [function(){return[];}]
      },
      menu: override(menuOverrides, 'editor',{
        id: 'am.' + prefix + '.editor',
        state: prefix + '.editor',
        key: 'EDITOR.MENU_TOPOLOGY',
        icon: 'fa fa-sitemap',
        show: true,
        priority: 10
      })
    });

states

Add simple state machine to Javascript objects

Unknown
Latest version published 13 years ago

Package Health Score

36 / 100
Full package analysis

Popular states functions