From 090647f118ce1836346fd6427ed35ec5b338486d Mon Sep 17 00:00:00 2001 From: Tomasz Wawrzyniak Date: Thu, 8 Oct 2015 12:03:30 +0200 Subject: [PATCH 1/2] Added a growl warning when user has no access for the state --- app/main/i18n/locale-de.json | 3 ++- app/main/i18n/locale-en.json | 3 ++- .../oasp-security/oasp-authorization-service.service.js | 5 ++--- app/oasp/oasp-security/oasp-security.module.js | 6 ++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/main/i18n/locale-de.json b/app/main/i18n/locale-de.json index 489bef4..75b8806 100644 --- a/app/main/i18n/locale-de.json +++ b/app/main/i18n/locale-de.json @@ -11,6 +11,7 @@ "TABLES": "Tische", "KITCHEN": "Küche", "LOADING": "Landung...", - "CORP": "© OASP 2015" + "CORP": "© OASP 2015", + "ACCESS_DENIED": "Zugriff verweigert. Jede Rolle der {{requestedRoles}} erforderlich, um diesen Zustand zu gehen" } } diff --git a/app/main/i18n/locale-en.json b/app/main/i18n/locale-en.json index 0ccab8c..4b36cc0 100644 --- a/app/main/i18n/locale-en.json +++ b/app/main/i18n/locale-en.json @@ -11,6 +11,7 @@ "TABLES": "Tables", "KITCHEN": "Kitchen", "LOADING": "Loading ...", - "CORP": "© OASP 2015" + "CORP": "© OASP 2015", + "ACCESS_DENIED": "Access denied. Any role of {{requestedRoles}} required to go to this state" } } diff --git a/app/oasp/oasp-security/oasp-authorization-service.service.js b/app/oasp/oasp-security/oasp-authorization-service.service.js index a57bdc8..5963a67 100644 --- a/app/oasp/oasp-security/oasp-authorization-service.service.js +++ b/app/oasp/oasp-security/oasp-authorization-service.service.js @@ -43,7 +43,7 @@ angular.module('oasp.oaspSecurity') } }; }, - $get: function ($q, $log, $injector) { + $get: function ($q, $log, $injector, growl, $filter) { var getAppContextService = function () { return $injector.get(config.appContextServiceName); }, @@ -80,14 +80,13 @@ angular.module('oasp.oaspSecurity') if (authorized) { deferredAuthorizationCheck.resolve(true); } else { - $log.warn('Access denied. Any role of \'' + requestedRoles + '\' required to go to this state'); deferredAuthorizationCheck.reject(); + growl.warning($filter('translate')('OASP.ACCESS_DENIED', {requestedRoles: requestedRoles})); } }); return deferredAuthorizationCheck.promise; }, - /** * @ngdoc method * @name oaspSecurity.oaspAuthorizationService#userHasAnyRole diff --git a/app/oasp/oasp-security/oasp-security.module.js b/app/oasp/oasp-security/oasp-security.module.js index 67a9fdd..356350c 100644 --- a/app/oasp/oasp-security/oasp-security.module.js +++ b/app/oasp/oasp-security/oasp-security.module.js @@ -3,10 +3,12 @@ * @name oasp.oaspSecurity * @module oasp */ -angular.module('oasp.oaspSecurity', []) - .config(function ($httpProvider) { +angular.module('oasp.oaspSecurity', ['angular-growl', 'oasp.oaspI18n']) + .config(function ($httpProvider, oaspTranslationProvider) { 'use strict'; $httpProvider.interceptors.push('oaspSecurityInterceptor'); + + oaspTranslationProvider.enableTranslationForModule('oaspSecurity'); }) .run(function (oaspSecurityService) { 'use strict'; From a256b4a6e63097f946874f837209c759a00b91c8 Mon Sep 17 00:00:00 2001 From: Tomasz Wawrzyniak Date: Mon, 26 Oct 2015 12:43:39 +0100 Subject: [PATCH 2/2] Added ncy-breadcrumb module. --- .../form-samples-mgmt.module.js | 3 + app/main/app/container.controller.js | 8 ++ app/main/app/container.controller.spec.js | 39 ++++++++ app/main/layout/breadcrumb.html | 5 + app/main/layout/container.html | 3 +- app/main/layout/css/breadcrumb.less | 94 +++++++++++++++++++ app/main/layout/css/mixins.less | 3 +- app/main/main.less | 1 + app/main/main.module.js | 8 +- app/sales-mgmt/sales-mgmt.module.js | 8 +- app/table-mgmt/table-mgmt.module.js | 14 ++- bower.json | 57 +++++------ 12 files changed, 208 insertions(+), 35 deletions(-) create mode 100644 app/main/app/container.controller.js create mode 100644 app/main/app/container.controller.spec.js create mode 100644 app/main/layout/breadcrumb.html create mode 100644 app/main/layout/css/breadcrumb.less diff --git a/app/form-samples-mgmt/form-samples-mgmt.module.js b/app/form-samples-mgmt/form-samples-mgmt.module.js index 33faf34..6f65181 100644 --- a/app/form-samples-mgmt/form-samples-mgmt.module.js +++ b/app/form-samples-mgmt/form-samples-mgmt.module.js @@ -23,6 +23,9 @@ angular.module('app.form-samples-mgmt', ['oasp.validation', 'oasp.oaspI18n', 'ui } return $translate.use(); } + }, + ncyBreadcrumb: { + label: 'Validation showcase' } } ); diff --git a/app/main/app/container.controller.js b/app/main/app/container.controller.js new file mode 100644 index 0000000..088491d --- /dev/null +++ b/app/main/app/container.controller.js @@ -0,0 +1,8 @@ +angular.module('app.main').controller('ContainerCntl', function ($scope, appContext, $state) { + 'use strict'; + + appContext.getCurrentUser().then(function (currentUser) { + $scope.currentUser = currentUser; + }); + $scope.state = $state; +}); diff --git a/app/main/app/container.controller.spec.js b/app/main/app/container.controller.spec.js new file mode 100644 index 0000000..3ac95ca --- /dev/null +++ b/app/main/app/container.controller.spec.js @@ -0,0 +1,39 @@ +describe('Controller: ContainerCntl', function () { + 'use strict'; + + var $scope, $window, security; + beforeEach(module('app.main')); + beforeEach(inject(function ($rootScope, $controller, $q) { + security = { + getCurrentUser: function () { + return $q.when({ + isLoggedIn: function () { + return false; + }, + getUserName: function () { + return ''; + } + }); + } + }; + $scope = $rootScope; + $window = { + location: jasmine.createSpyObj('location', ['href', 'reload']) + }; + + $controller('AppCntl', + {$scope: $scope, oaspSecurityService: security, $window: $window}); + })); + + it('exposes currentUser.isLoggedIn() on $scope which returns false for anonymous user', function () { + // then + $scope.$apply(); + expect($scope.currentUser.isLoggedIn()).toBeFalsy(); + }); + + it('exposes currentUser.getName() on $scope which returns empty string for anonymous users', function () { + // then + $scope.$apply(); + expect($scope.currentUser.getUserName()).toEqual(''); + }); +}); diff --git a/app/main/layout/breadcrumb.html b/app/main/layout/breadcrumb.html new file mode 100644 index 0000000..443a556 --- /dev/null +++ b/app/main/layout/breadcrumb.html @@ -0,0 +1,5 @@ + diff --git a/app/main/layout/container.html b/app/main/layout/container.html index 83d756d..1324f29 100644 --- a/app/main/layout/container.html +++ b/app/main/layout/container.html @@ -1,4 +1,5 @@ -
+
+

OASP.LOADING

diff --git a/app/main/layout/css/breadcrumb.less b/app/main/layout/css/breadcrumb.less new file mode 100644 index 0000000..64b73e8 --- /dev/null +++ b/app/main/layout/css/breadcrumb.less @@ -0,0 +1,94 @@ +#breadcrumb { + list-style: none; + display: inline-block; + margin-top: 10px; + padding: 0px; + .icon { + font-size: 14px; + } + li { + float: left; + a { + color: #FFF; + display: block; + background: #3498db; + text-decoration: none; + position: relative; + height: 40px; + line-height: 40px; + padding: 0 10px 0 5px; + text-align: center; + margin-right: 23px; + } + &:nth-child(even) { + a { + background-color: #2980b9; + &:before { + border-color: #2980b9; + border-left-color: transparent; + } + &:after { + border-left-color: #2980b9; + } + } + } + &:first-child { + a { + padding-left: 15px; + border-radius: 4px 0 0 4px; + &:before { + border: none; + } + } + } + &:last-child { + a { + padding-right: 15px; + border-radius: 0 4px 4px 0; + &:after { + border: none; + } + } + } + a { + &:before, &:after { + content: ""; + position: absolute; + top: 0; + border: 0 solid #3498db; + border-width: 20px 10px; + width: 0; + height: 0; + } + &:before { + left: -20px; + border-left-color: transparent; + } + &:after { + left: 100%; + border-color: transparent; + border-left-color: #3498db; + } + &:hover { + background-color: #1abc9c; + &:before { + border-color: #1abc9c; + border-left-color: transparent; + } + &:after { + border-left-color: #1abc9c; + } + } + &:active { + background-color: #16a085; + &:before { + border-color: #16a085; + border-left-color: transparent; + } + &:after { + border-left-color: #16a085; + } + } + } + } +} diff --git a/app/main/layout/css/mixins.less b/app/main/layout/css/mixins.less index 9cf6b74..e2969d2 100644 --- a/app/main/layout/css/mixins.less +++ b/app/main/layout/css/mixins.less @@ -5,4 +5,5 @@ -moz-user-select: @val; -ms-user-select: @val; user-select: @val; -} \ No newline at end of file +} + diff --git a/app/main/main.less b/app/main/main.less index 8f73b73..890f091 100644 --- a/app/main/main.less +++ b/app/main/main.less @@ -1,5 +1,6 @@ @import "main/layout/css/variables"; @import "main/layout/css/mixins"; +@import "main/layout/css/breadcrumb"; body { padding-top: 50px; diff --git a/app/main/main.module.js b/app/main/main.module.js index d831b53..599adb3 100644 --- a/app/main/main.module.js +++ b/app/main/main.module.js @@ -9,15 +9,19 @@ * @requires oasp.oaspI18n * @requires ui.bootstrap */ -angular.module('app.main', ['ui.router', 'oasp.oaspUi', 'oasp.oaspSecurity', 'app.main.templates', 'oasp.validation', 'oasp.oaspI18n', 'ui.bootstrap']) +angular.module('app.main', ['ui.router', 'ncy-angular-breadcrumb', 'oasp.oaspUi', 'oasp.oaspSecurity', 'app.main.templates', 'oasp.validation', 'oasp.oaspI18n', 'ui.bootstrap']) .constant('SIGN_IN_DLG_PATH', '/main/sign-in') .constant('ROLES', { COOK: 'COOK', WAITER: 'WAITER' }) - .config(function (SIGN_IN_DLG_PATH, $stateProvider, $urlRouterProvider, $urlMatcherFactoryProvider, oaspTranslationProvider, valdrProvider) { + .config(function (SIGN_IN_DLG_PATH, $breadcrumbProvider, $stateProvider, $urlRouterProvider, $urlMatcherFactoryProvider, oaspTranslationProvider, valdrProvider) { 'use strict'; + $breadcrumbProvider.setOptions({ + includeAbstract: true, + templateUrl: 'main/layout/breadcrumb.html' + }); // --------- Routing --------- diff --git a/app/sales-mgmt/sales-mgmt.module.js b/app/sales-mgmt/sales-mgmt.module.js index 2641b60..bd25ef5 100644 --- a/app/sales-mgmt/sales-mgmt.module.js +++ b/app/sales-mgmt/sales-mgmt.module.js @@ -14,7 +14,10 @@ angular.module('app.sales-mgmt', ['app.main', 'app.offer-mgmt', 'app.sales-mgmt. $stateProvider.state('salesMgmt', { abstract: true, url: '/sales-mgmt', - template: '' + template: '', + ncyBreadcrumb: { + label: 'Sales Management' + } }); $stateProvider.state('salesMgmt.cookPositions', @@ -28,6 +31,9 @@ angular.module('app.sales-mgmt', ['app.main', 'app.offer-mgmt', 'app.sales-mgmt. currentPositions: ['positions', function (positions) { return positions.get(); }] + }, + ncyBreadcrumb: { + label: 'Cook Positions' } } ) diff --git a/app/table-mgmt/table-mgmt.module.js b/app/table-mgmt/table-mgmt.module.js index 9a81b6a..52367bb 100644 --- a/app/table-mgmt/table-mgmt.module.js +++ b/app/table-mgmt/table-mgmt.module.js @@ -14,7 +14,10 @@ angular.module('app.table-mgmt', ['app.offer-mgmt', 'app.sales-mgmt', 'app.main' $stateProvider.state('tableMgmt', { abstract: true, url: '/table-mgmt', - template: '' + template: '', + ncyBreadcrumb: { + label: 'Table Management' + } }); $stateProvider.state('tableMgmt.search', { @@ -28,6 +31,9 @@ angular.module('app.table-mgmt', ['app.offer-mgmt', 'app.sales-mgmt', 'app.main' return paginatedTables; }); }] + }, + ncyBreadcrumb: { + label: 'Search' } }); @@ -35,6 +41,10 @@ angular.module('app.table-mgmt', ['app.offer-mgmt', 'app.sales-mgmt', 'app.main' url: '/table-details/:tableId', templateUrl: 'table-mgmt/table-details/table-details.html', controller: 'TableDetailsCntl', - controllerAs: 'TDC' + controllerAs: 'TDC', + ncyBreadcrumb: { + parent:'tableMgmt.search', + label: 'Details' + } }); }); diff --git a/bower.json b/bower.json index 04ddc7f..7a4aa38 100644 --- a/bower.json +++ b/bower.json @@ -1,30 +1,31 @@ { - "name": "oasp-js", - "version": "0.0.1", - "dependencies": { - "modernizr": "2.6.x", - "respond": "1.1.x", - "bootstrap": "3.3.x", - "angular": "1.3.x", - "angular-ui-select": "0.8.x", - "autofill-event": "1.0.x", - "angular-ui-bootstrap-bower": "0.13.x", - "angular-translate": "2.5.x", - "angular-translate-loader-partial": "2.5.x", - "angular-spinner": "0.5.x", - "angular-growl-v2": "0.7.x", - "angular-animate": "1.3.x", - "trNgGrid": "3.0.x", - "sockjs-client": "0.3.x", - "stomp-websocket": "2.3.x", - "angular-ui-router": "0.2.x", - "valdr": "1.1.x", - "angular-ui-validate": "1.2.x" - }, - "devDependencies": { - "angular-mocks": "1.3.x" - }, - "resolutions": { - "angular": ">=1.3" - } + "name": "oasp-js", + "version": "0.0.1", + "dependencies": { + "modernizr": "2.6.x", + "respond": "1.1.x", + "bootstrap": "3.3.x", + "angular": "1.3.x", + "angular-ui-select": "0.8.x", + "autofill-event": "1.0.x", + "angular-ui-bootstrap-bower": "0.13.x", + "angular-translate": "2.5.x", + "angular-translate-loader-partial": "2.5.x", + "angular-spinner": "0.5.x", + "angular-growl-v2": "0.7.x", + "angular-animate": "1.3.x", + "trNgGrid": "3.0.x", + "sockjs-client": "0.3.x", + "stomp-websocket": "2.3.x", + "angular-ui-router": "0.2.x", + "angular-breadcrumb": "0.4.1", + "valdr": "1.1.x", + "angular-ui-validate": "1.2.x" + }, + "devDependencies": { + "angular-mocks": "1.3.x" + }, + "resolutions": { + "angular": ">=1.3" + } }