Repository: ignite Updated Branches: refs/heads/ignite-843-rc2 478b984cb -> 5efe2ba0a
IGNITE-843 Use ui-sref-active. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/12f1006e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/12f1006e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/12f1006e Branch: refs/heads/ignite-843-rc2 Commit: 12f1006ea5c154d193fa769881cf6ce8a15e6d90 Parents: e8cdae5 Author: Andrey <[email protected]> Authored: Fri Dec 11 11:19:24 2015 +0700 Committer: Andrey <[email protected]> Committed: Fri Dec 11 11:19:24 2015 +0700 ---------------------------------------------------------------------- .../control-center-web/src/main/js/app/index.js | 7 ++- .../app/modules/configuration/sidebar/main.js | 10 ++-- .../src/main/js/app/modules/settings/main.js | 61 ++++++++++++++++++++ .../main/js/app/modules/states/admin/index.js | 2 +- .../main/js/app/modules/states/profile/index.js | 2 +- .../src/main/js/app/modules/userbar/main.js | 61 -------------------- .../src/main/js/controllers/common-module.js | 29 ++++------ .../src/main/js/public/stylesheets/style.scss | 30 ++++++---- .../main/js/views/configuration/sidebar.jade | 4 +- .../src/main/js/views/includes/header.jade | 23 ++++---- .../src/main/js/views/templates/dropdown.jade | 5 ++ 11 files changed, 121 insertions(+), 113 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/app/index.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/index.js b/modules/control-center-web/src/main/js/app/index.js index 2085352..867755e 100644 --- a/modules/control-center-web/src/main/js/app/index.js +++ b/modules/control-center-web/src/main/js/app/index.js @@ -65,7 +65,7 @@ import './modules/states/admin/index' // ignite:modules import './modules/navbar/main' -import './modules/userbar/main' +import './modules/settings/main' import './modules/configuration/sidebar/main' import './modules/terms/main' // endignite @@ -126,6 +126,11 @@ angular url: '', abstract: true, templateUrl: '/base.html' + }) + .state('settings', { + url: '/settings', + abstract: true, + templateUrl: '/base.html' }); $urlRouterProvider.when('/', '/configuration/clusters'); http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/app/modules/configuration/sidebar/main.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/configuration/sidebar/main.js b/modules/control-center-web/src/main/js/app/modules/configuration/sidebar/main.js index a8767e8..48bdfea 100644 --- a/modules/control-center-web/src/main/js/app/modules/configuration/sidebar/main.js +++ b/modules/control-center-web/src/main/js/app/modules/configuration/sidebar/main.js @@ -23,10 +23,10 @@ angular ]) .provider('igniteConfigurationSidebar', function() { var items = [ - { text: 'Clusters', href: '/configuration/clusters' }, - { text: 'Caches', href: '/configuration/caches' }, - { text: 'Metadata', href: '/configuration/metadata' }, - { text: 'IGFS', href: '/configuration/igfs' } + { text: 'Clusters', sref: 'base.configuration.clusters' }, + { text: 'Caches', sref: 'base.configuration.caches' }, + { text: 'Metadata', sref: 'base.configuration.metadata' }, + { text: 'IGFS', sref: 'base.configuration.igfs' } ]; this.push = function(data) { @@ -36,7 +36,7 @@ angular this.$get = [function() { var r = angular.copy(items); - r.push({ text: 'Summary', href: '/configuration/summary' }); + r.push({ text: 'Summary', sref: 'base.configuration.summary' }); return r; }] http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/app/modules/settings/main.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/settings/main.js b/modules/control-center-web/src/main/js/app/modules/settings/main.js new file mode 100644 index 0000000..7027fd6 --- /dev/null +++ b/modules/control-center-web/src/main/js/app/modules/settings/main.js @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +angular +.module('ignite-console.userbar', [ + +]) +.provider('igniteSettings', function() { + var items = []; + + this.push = function(data) { + items.push(data); + }; + + this.$get = [function() { + return items; + }] +}) +.directive('igniteSettings', function() { + return { + restrict: 'A', + controller: ['$rootScope', 'igniteSettings', function ($root, igniteSettings) { + var ctrl = this; + + ctrl.items = [{text: 'Profile', sref: 'settings.profile'}]; + ctrl.customItems = igniteSettings; + + var _rebuildSettings = function (event, user) { + ctrl.items.splice(1); + + if (!user.becomeUsed && user.admin) + ctrl.items.push({text: 'Admin Panel', sref: 'settings.admin'}); + + ctrl.items.push.apply(ctrl.items, ctrl.customItems); + + if (!user.becomeUsed) + ctrl.items.push({text: 'Log Out', sref: 'logout'}); + }; + + if ($root.user) + _rebuildSettings(undefined, $root.user); + + $root.$on('user', _rebuildSettings); + }], + controllerAs: 'settings' + } +}); http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/app/modules/states/admin/index.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/states/admin/index.js b/modules/control-center-web/src/main/js/app/modules/states/admin/index.js index d5f0578..e0ca86c 100644 --- a/modules/control-center-web/src/main/js/app/modules/states/admin/index.js +++ b/modules/control-center-web/src/main/js/app/modules/states/admin/index.js @@ -24,7 +24,7 @@ angular .config(['$stateProvider', function($stateProvider) { // set up the states $stateProvider - .state('base.admin', { + .state('settings.admin', { url: '/admin', templateUrl: '/settings/admin.html' }) http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/app/modules/states/profile/index.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/states/profile/index.js b/modules/control-center-web/src/main/js/app/modules/states/profile/index.js index 66f4be7..cefa13b 100644 --- a/modules/control-center-web/src/main/js/app/modules/states/profile/index.js +++ b/modules/control-center-web/src/main/js/app/modules/states/profile/index.js @@ -24,7 +24,7 @@ angular .config(['$stateProvider', function($stateProvider) { // set up the states $stateProvider - .state('base.profile', { + .state('settings.profile', { url: '/profile', templateUrl: '/settings/profile.html' }) http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/app/modules/userbar/main.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/app/modules/userbar/main.js b/modules/control-center-web/src/main/js/app/modules/userbar/main.js deleted file mode 100644 index c3ba4a1..0000000 --- a/modules/control-center-web/src/main/js/app/modules/userbar/main.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -angular -.module('ignite-console.userbar', [ - -]) -.provider('igniteUserbar', function() { - var items = []; - - this.push = function(data) { - items.push(data); - }; - - this.$get = [function() { - return items; - }] -}) -.directive('igniteUserbar', function() { - return { - restrict: 'A', - controller: ['$rootScope', 'igniteUserbar', function ($root, igniteUserbar) { - var ctrl = this; - - ctrl.items = [{text: 'Profile', href: '/profile'}]; - ctrl.customItems = igniteUserbar; - - var _rebuildUserbar = function (event, user) { - ctrl.items.splice(1); - - if (!user.becomeUsed && user.admin) - ctrl.items.push({text: 'Admin Panel', href: '/admin'}); - - ctrl.items.push.apply(ctrl.items, ctrl.customItems); - - if (!user.becomeUsed) - ctrl.items.push({text: 'Log Out', href: '/logout'}); - }; - - if ($root.user) - _rebuildUserbar(undefined, $root.user); - - $root.$on('user', _rebuildUserbar); - }], - controllerAs: 'userbar' - } -}); http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/controllers/common-module.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/controllers/common-module.js b/modules/control-center-web/src/main/js/controllers/common-module.js index 938e218..6f5ded7 100644 --- a/modules/control-center-web/src/main/js/controllers/common-module.js +++ b/modules/control-center-web/src/main/js/controllers/common-module.js @@ -103,6 +103,13 @@ consoleModule.config(function($modalProvider) { }); }); +// Dropdowns configuration. +consoleModule.config(function($dropdownProvider) { + angular.extend($dropdownProvider.defaults, { + templateUrl: 'templates/dropdown.html' + }); +}); + // Common functions to be used in controllers. consoleModule.service('$common', [ '$alert', '$popover', '$timeout', '$focus', '$window', function ($alert, $popover, $timeout, $focus, $window) { @@ -1884,22 +1891,6 @@ consoleModule.directive('onClickFocus', function ($focus) { }; }); -// Navigation bar controller. -consoleModule.controller('activeLink', [ - '$scope', function ($scope) { - $scope.configurationDropdown = [ - {"text": "Clusters", "href": "/configuration/clusters"}, - {"text": "Caches", "href": "/configuration/caches"}, - {"text": "Metadata", "href": "/configuration/metadata"}, - {"text": "IGFS", "href": "/configuration/igfs"}, - {"text": "Summary", "href": "/configuration/summary"} - ]; - - $scope.isActive = function (path) { - return new RegExp(path).test(window.location.pathname); - }; - }]); - consoleModule.controller('resetPassword', [ '$scope', '$modal', '$http', '$common', '$focus', 'Auth', '$state', function ($scope, $modal, $http, $common, $focus, Auth, $state) { @@ -2108,10 +2099,12 @@ consoleModule.controller('notebooks', ['$scope', '$modal', '$state', '$http', '$ $scope.$root.rebuildDropdown = function() { $scope.notebookDropdown = [ - {text: 'Create new notebook', click: 'inputNotebookName()'}, - {divider: true} + {text: 'Create new notebook', click: 'inputNotebookName()'} ]; + if ($scope.$root.notebooks.length > 0) + $scope.notebookDropdown.push({divider: true}); + _.forEach($scope.$root.notebooks, function (notebook) { $scope.notebookDropdown.push({ text: notebook.name, http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/public/stylesheets/style.scss ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/public/stylesheets/style.scss b/modules/control-center-web/src/main/js/public/stylesheets/style.scss index fe2431f..541bb00 100644 --- a/modules/control-center-web/src/main/js/public/stylesheets/style.scss +++ b/modules/control-center-web/src/main/js/public/stylesheets/style.scss @@ -48,11 +48,16 @@ hr { margin: 20px 0; } -a.active { +.theme-line a.active { font-weight: bold; font-size: 1.1em; } +.theme-line a:focus { + text-decoration: underline; + outline: none; +} + .navbar-default .navbar-brand, .navbar-default .navbar-brand:hover { position: absolute; width: 100%; @@ -87,7 +92,11 @@ a.active { } ul.navbar-nav, .sidebar-nav { - li > a.active:not(.dropdown-toggle) { + li.active > a { + color: $link-color; + } + + li.active > a:not(.dropdown-toggle) { cursor: default; pointer-events: none; } @@ -99,18 +108,11 @@ ul.navbar-nav, .sidebar-nav { ul { padding: 0; list-style: none; - font-size: $font-size-base; margin: 3px 0 0; li { line-height: $input-height; - span.fa-stack { - margin-right: 5px; - font-size: 12px; - height: 26px; - } - a { font-size: 18px; color: $ignite-header-color; @@ -119,12 +121,16 @@ ul.navbar-nav, .sidebar-nav { overflow: hidden; -o-text-overflow: ellipsis; text-overflow: ellipsis; - } - a:hover { - color: $link-hover-color; + span.fa-stack { + margin-right: 5px; + font-size: 12px; + height: 26px; + } } + a:hover { color: $link-hover-color; } + a.active { color: $link-color; } http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/views/configuration/sidebar.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/views/configuration/sidebar.jade b/modules/control-center-web/src/main/js/views/configuration/sidebar.jade index baf348d..a59bb9c 100644 --- a/modules/control-center-web/src/main/js/views/configuration/sidebar.jade +++ b/modules/control-center-web/src/main/js/views/configuration/sidebar.jade @@ -17,9 +17,9 @@ .row .col-xs-3.col-sm-3.col-md-2.border-right.section-left.greedy .sidebar-nav(bs-affix) - ul.menu(ignite-configuration-sidebar ng-controller='activeLink') + ul.menu(ignite-configuration-sidebar) li(ng-repeat='item in sidebar.items') - a(ng-class='{active: isActive("{{::item.href}}$")}' href='{{::item.href}}') + a(ui-sref-active='active' ui-sref='{{::item.sref}}') span.fa-stack i.fa.fa-circle-thin.fa-stack-2x i.fa.fa-stack-1x {{::$index + 1}} http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/views/includes/header.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/views/includes/header.jade b/modules/control-center-web/src/main/js/views/includes/header.jade index 497d963..857f7a4 100644 --- a/modules/control-center-web/src/main/js/views/includes/header.jade +++ b/modules/control-center-web/src/main/js/views/includes/header.jade @@ -22,21 +22,20 @@ header#header.header .container h1.navbar-brand a(href='/') Apache Ignite Web Console - .navbar-collapse.collapse(ng-if='$root.user' ng-controller='activeLink' ) - ul.nav.navbar-nav - li - a.dropdown-toggle(ignite-configuration-sidebar ng-class='{active: isActive("/configuration.*")}' data-toggle='dropdown' bs-dropdown='sidebar.items' data-placement='bottom-right') Configuration + .navbar-collapse.collapse(ng-if='$root.user') + ul.nav.navbar-nav(ignite-configuration-sidebar ignite-navbar) + li(ng-class='{active: $state.includes("base.configuration")}') + a.dropdown-toggle(data-toggle='dropdown' bs-dropdown='sidebar.items' data-placement='bottom-right') Configuration span.caret - li(ng-controller='notebooks') - a.dropdown-toggle(ng-hide='$root.notebooks.length == 0' ng-class='{active: isActive("/sql")}' data-toggle='dropdown' bs-dropdown='notebookDropdown' data-placement='bottom-left') SQL + li(ng-class='{active: $state.includes("base.sql")}' ng-controller='notebooks') + a.dropdown-toggle(data-toggle='dropdown' bs-dropdown='notebookDropdown' data-placement='bottom-left') SQL span.caret - a(ng-hide='$root.notebooks.length > 0' ng-click='inputNotebookName()') SQL - li(ignite-navbar ng-repeat='item in navbar.items') - a(ng-class='{active: isActive(item.href)}' ng-href='{{::item.href}}') {{::item.title}} + li(ui-sref-active='active' ng-repeat='item in navbar.items') + a(ui-sref='{{::item.sref}}') {{::item.text}} - ul.nav.navbar-nav.pull-right(ignite-userbar) - li - a.dropdown-toggle(data-toggle='dropdown' ng-class='{active: isActive("/profile") || isActive("/admin")}' bs-dropdown='userbar.items' data-placement='bottom-right') {{user.username}} + ul.nav.navbar-nav.pull-right(ignite-settings) + li(ng-class='{active: $state.includes("settings")}') + a.dropdown-toggle(data-toggle='dropdown' bs-dropdown='settings.items' data-placement='bottom-right') {{user.username}} span.caret http://git-wip-us.apache.org/repos/asf/ignite/blob/12f1006e/modules/control-center-web/src/main/js/views/templates/dropdown.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/views/templates/dropdown.jade b/modules/control-center-web/src/main/js/views/templates/dropdown.jade new file mode 100644 index 0000000..708695f --- /dev/null +++ b/modules/control-center-web/src/main/js/views/templates/dropdown.jade @@ -0,0 +1,5 @@ +ul.dropdown-menu(tabindex='-1' role='menu' ng-show='content && content.length') + li(role='presentation' ui-sref-active='active' ng-class='{divider: item.divider, active: item.active}' ng-repeat='item in content') + a(role='menuitem' tabindex='-1' ui-sref='{{item.sref}}' ng-if='!item.divider && item.sref' ng-bind='item.text') + a(role='menuitem' tabindex='-1' ng-href='{{item.href}}' ng-if='!item.divider && item.href' target="{{item.target || ''}}" ng-bind='item.text') + a(role='menuitem' tabindex='-1' href='javascript:void(0)' ng-if='!item.divider && item.click' ng-click='$eval(item.click);$hide()' ng-bind='item.text')
