From 7ecc382a710e069f9ddc2111bfd7785ab2f0de05 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Mon, 3 Feb 2014 14:59:17 -0500 Subject: [PATCH] AC-595 stop translating object name in breadcrumbs. --- awx/ui/static/js/lists/InventoryGroups.js | 2 +- awx/ui/static/js/widgets/Stream.js | 10 +-- awx/ui/static/less/ansible-ui.less | 3 +- awx/ui/static/lib/ansible/Utilities.js | 71 +++++++++++-------- awx/ui/static/lib/ansible/form-generator.js | 2 +- .../static/lib/ansible/generator-helpers.js | 2 +- awx/ui/static/lib/ansible/list-generator.js | 2 +- 7 files changed, 54 insertions(+), 38 deletions(-) diff --git a/awx/ui/static/js/lists/InventoryGroups.js b/awx/ui/static/js/lists/InventoryGroups.js index 0e6a9602cd..5e01320f42 100644 --- a/awx/ui/static/js/lists/InventoryGroups.js +++ b/awx/ui/static/js/lists/InventoryGroups.js @@ -10,7 +10,7 @@ angular.module('InventoryGroupsDefinition', []) name: 'groups', iterator: 'group', - editTitle: '{{ inventory_name | capitalize }}', + editTitle: '{{ inventory_name }}', showTitle: false, well: true, index: false, diff --git a/awx/ui/static/js/widgets/Stream.js b/awx/ui/static/js/widgets/Stream.js index 30ece9f089..540ae667eb 100644 --- a/awx/ui/static/js/widgets/Stream.js +++ b/awx/ui/static/js/widgets/Stream.js @@ -75,8 +75,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti $rootScope.breadcrumbs = []; var paths = $location.path().split('/'); paths.splice(0,1); - var path, title, j; - for (var i=0; i < paths.length; i++) { + var path, title, i, j; + for (i=0; i < paths.length; i++) { if (/^\d+/.test(paths[i])) { path=''; title=''; @@ -91,7 +91,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti } if (!title) { title = paths[i - 1].substr(0,paths[i - 1].length - 1); - title = (title == 'inventorie') ? 'inventory' : title; + title = title.charAt(0).toUpperCase() + title.slice(1); + title = (title == 'Inventorie') ? 'Inventory' : title; } } else { @@ -106,6 +107,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti path = '/' + paths[i]; } title = paths[i]; + title = title.charAt(0).toUpperCase() + title.slice(1); } $rootScope.breadcrumbs.push({ path: path, title: title, ngClick: "closeStream('" + path + "')" }); } @@ -345,7 +347,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti } // Add a container for the stream widget - $('#tab-content-container').append('
'); + $('#tab-content-container').append("
"); StreamBreadCrumbs(); diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index 770bd45be1..d01a070dc1 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -226,7 +226,8 @@ hr { .help-auto-off { margin-top: 15px; - margin-bottom: 15px; + margin-bottom: 15px; + margin-left: 10px; label { font-weight: normal; } diff --git a/awx/ui/static/lib/ansible/Utilities.js b/awx/ui/static/lib/ansible/Utilities.js index f82e639ba4..8024c33b28 100644 --- a/awx/ui/static/lib/ansible/Utilities.js +++ b/awx/ui/static/lib/ansible/Utilities.js @@ -41,6 +41,20 @@ angular.module('Utilities',['RestServices', 'Utilities']) } }]) + + /* Empty() + * + * Test if a value is 'empty'. Returns true if val is null | '' | undefined. + * Only works on non-Ojbect types. + * + */ + .factory('Empty', [ function() { + return function(val) { + return (val === null || val === undefined || val === '') ? true : false; + } + }]) + + .factory('ToggleClass', function() { return function(selector, cssClass) { // Toggles the existance of a css class on a given element @@ -53,6 +67,7 @@ angular.module('Utilities',['RestServices', 'Utilities']) } }) + .factory('Alert', ['$rootScope', '$location', function($rootScope, $location) { return function(hdr, msg, cls, action, secondAlert, disableButtons) { // Pass in the header and message you want displayed on TB modal dialog found in index.html. @@ -104,6 +119,7 @@ angular.module('Utilities',['RestServices', 'Utilities']) } }]) + .factory('ProcessErrors', ['$rootScope', '$cookieStore', '$log', '$location', 'Alert', 'Wait', function($rootScope, $cookieStore, $log, $location, Alert, Wait) { return function(scope, data, status, form, defaultMsg) { @@ -180,21 +196,25 @@ angular.module('Utilities',['RestServices', 'Utilities']) } }]) - .factory('LoadBreadCrumbs', ['$rootScope', '$routeParams', '$location', function($rootScope, $routeParams, $location, Rest) { + + .factory('LoadBreadCrumbs', ['$rootScope', '$routeParams', '$location', 'Empty', + function($rootScope, $routeParams, $location, Empty) { return function(crumb) { - + var title, found, j, i; + //Keep a list of path/title mappings. When we see /organizations/XX in the path, for example, //we'll know the actual organization name it maps to. - if (crumb !== null && crumb !== undefined) { - var found = false; - for (var i=0; i < $rootScope.crumbCache.length; i++) { + if (!Empty(crumb)) { + found = false; + //crumb.title = crumb.title.charAt(0).toUpperCase() + crumb.title.slice(1); + for (i=0; i < $rootScope.crumbCache.length; i++) { if ($rootScope.crumbCache[i].path == crumb.path) { found = true; $rootScope.crumbCache[i] = crumb; break; } } - if (found == false) { + if (!found) { $rootScope.crumbCache.push(crumb); } } @@ -207,42 +227,48 @@ angular.module('Utilities',['RestServices', 'Utilities']) if (i > 0 && paths[i].match(/\d+/)) { parent = paths[i-1]; if (parent == 'inventories') { - child = 'inventory'; + child = 'Inventory'; } else { child = parent.substring(0,parent.length - 1); //assumes parent ends with 's' + child = child.charAt(0).toUpperCase() + child.slice(1); } // find the correct title + found = false; for (var j=0; j < $rootScope.crumbCache.length; j++) { if ($rootScope.crumbCache[j].path == '/' + parent + '/' + paths[i]) { child = $rootScope.crumbCache[j].title; + found = true; break; } } - if ($rootScope.crumbCache[j] && $rootScope.crumbCache[j]['altPath'] !== undefined) { + + if (found && $rootScope.crumbCache[j]['altPath'] !== undefined) { // Use altPath to override default path construction $rootScope.breadcrumbs.push({ title: child, path: $rootScope.crumbCache[j].altPath }); } else { - if (paths[i - 1] == 'hosts') { + $rootScope.breadcrumbs.push({ title: child, path: ppath + '/' + paths[i] }); + /*if (paths[i - 1] == 'hosts') { // For hosts, there is no /hosts, so we need to link back to the inventory // We end up here when user has clicked refresh and the crumbcache is missing $rootScope.breadcrumbs.push({ title: child, path: '/inventories/' + $routeParams.inventory + '/hosts' }); } - else { - $rootScope.breadcrumbs.push({ title: child, path: ppath + '/' + paths[i] }); - } + else { */ + + //} } } else { - if (paths[i] == 'hosts') { + title = paths[i].charAt(0).toUpperCase() + paths[i].slice(1); + $rootScope.breadcrumbs.push({ title: title, path: ppath + '/' + paths[i] }); + /*if (paths[i] == 'hosts') { $rootScope.breadcrumbs.push({ title: paths[i], path: '/inventories/' + $routeParams.inventory + '/hosts' }); } - else { - $rootScope.breadcrumbs.push({ title: paths[i], path: ppath + '/' + paths[i] }); - } + else {*/ + //} } ppath += '/' + paths[i]; } @@ -564,19 +590,6 @@ angular.module('Utilities',['RestServices', 'Utilities']) console.log('form valid: ' + scope[form.name + '_form'].$valid); } }]) - - - /* Empty() - * - * Test if a value is 'empty'. Returns true if val is null | '' | undefined. - * Only works on non-Ojbect types. - * - */ - .factory('Empty', [ function() { - return function(val) { - return (val === null || val === undefined || val === '') ? true : false; - } - }]) /* Store diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index 780aae9e99..4c063dcb96 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -1025,7 +1025,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities']) var html = ''; html += "
\n"; html += "