From 0bf28ffed8064baf34080d0217caca6528a8c6e8 Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Wed, 10 May 2017 16:28:30 -0400 Subject: [PATCH 1/6] Filter revision hash to less than 7 characters --- .../client/src/projects/list/projects-list.controller.js | 7 +++++++ awx/ui/client/src/projects/projects.list.js | 3 ++- .../src/shared/list-generator/list-generator.factory.js | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/src/projects/list/projects-list.controller.js b/awx/ui/client/src/projects/list/projects-list.controller.js index e70c12f44d..4aef74979c 100644 --- a/awx/ui/client/src/projects/list/projects-list.controller.js +++ b/awx/ui/client/src/projects/list/projects-list.controller.js @@ -62,6 +62,13 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert', }); } + if (list.fields.scm_revision && $scope.options && + $scope.options.hasOwnProperty('scm_revision')) { + console.log(list.fields.scm_revision); + itm.scm_revision = $filter('limitTo')(itm.scm_revision, 7, 0); + + } + buildTooltips(itm); }); diff --git a/awx/ui/client/src/projects/projects.list.js b/awx/ui/client/src/projects/projects.list.js index a4700a3acf..c920afa801 100644 --- a/awx/ui/client/src/projects/projects.list.js +++ b/awx/ui/client/src/projects/projects.list.js @@ -49,7 +49,8 @@ export default ['i18n', function(i18n) { label: i18n._('Revision'), excludeModal: true, columnClass: 'col-lg-4 col-md-2 col-sm-3 hidden-xs', - class: 'List-staticColumnAdjacent--monospace' + class: 'List-staticColumnAdjacent--monospace', + ngBind: 'project.scm_revision' }, last_updated: { label: i18n._('Last Updated'), diff --git a/awx/ui/client/src/shared/list-generator/list-generator.factory.js b/awx/ui/client/src/shared/list-generator/list-generator.factory.js index dea1d2383c..eade5fe6da 100644 --- a/awx/ui/client/src/shared/list-generator/list-generator.factory.js +++ b/awx/ui/client/src/shared/list-generator/list-generator.factory.js @@ -72,10 +72,10 @@ * * ##Field Actions * - * A list contains a fieldActions object. Each icon found in the Actions column is defined as an object within the feildActions object. fieldActions can have a columnClass attribute, + * A list contains a fieldActions object. Each icon found in the Actions column is defined as an object within the fieldActions object. fieldActions can have a columnClass attribute, * which may contain a string of CSS class names to add to the action <td> element. It may also contain a label attribute, which can be set to false to suppress the Actions column header. * - * Feld action items can have the following attributes: + * Field action items can have the following attributes: * * | Attribute | Description | * | --------- | ----------- | From a27bd045de97a0ec98651919d06bbc46ba143ce0 Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Thu, 11 May 2017 10:07:44 -0400 Subject: [PATCH 2/6] WIP: First attempt with Badge Icons --- awx/ui/client/src/projects/projects.list.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/awx/ui/client/src/projects/projects.list.js b/awx/ui/client/src/projects/projects.list.js index c920afa801..3bff8e9825 100644 --- a/awx/ui/client/src/projects/projects.list.js +++ b/awx/ui/client/src/projects/projects.list.js @@ -50,7 +50,16 @@ export default ['i18n', function(i18n) { excludeModal: true, columnClass: 'col-lg-4 col-md-2 col-sm-3 hidden-xs', class: 'List-staticColumnAdjacent--monospace', - ngBind: 'project.scm_revision' + ngBind: 'project.scm_revision', + badgeCustom: true, + badgePlacement: 'right', + badgeIcon: `See More + See Less` }, last_updated: { label: i18n._('Last Updated'), From cc94d724ecf8914c3194485618f36a980361df84 Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Thu, 11 May 2017 14:18:36 -0400 Subject: [PATCH 3/6] Add SeeMore and SeeLess link actions --- .../projects/list/projects-list.controller.js | 7 ------ awx/ui/client/src/projects/main.js | 3 ++- awx/ui/client/src/projects/projects.list.js | 11 +-------- awx/ui/client/src/projects/revisions/main.js | 11 +++++++++ .../projects/revisions/revisions.directive.js | 24 +++++++++++++++++++ .../projects/revisions/revisions.partial.html | 9 +++++++ awx/ui/client/src/shared/generator-helpers.js | 7 +++++- 7 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 awx/ui/client/src/projects/revisions/main.js create mode 100644 awx/ui/client/src/projects/revisions/revisions.directive.js create mode 100644 awx/ui/client/src/projects/revisions/revisions.partial.html diff --git a/awx/ui/client/src/projects/list/projects-list.controller.js b/awx/ui/client/src/projects/list/projects-list.controller.js index 4aef74979c..e70c12f44d 100644 --- a/awx/ui/client/src/projects/list/projects-list.controller.js +++ b/awx/ui/client/src/projects/list/projects-list.controller.js @@ -62,13 +62,6 @@ export default ['$scope', '$rootScope', '$log', 'Rest', 'Alert', }); } - if (list.fields.scm_revision && $scope.options && - $scope.options.hasOwnProperty('scm_revision')) { - console.log(list.fields.scm_revision); - itm.scm_revision = $filter('limitTo')(itm.scm_revision, 7, 0); - - } - buildTooltips(itm); }); diff --git a/awx/ui/client/src/projects/main.js b/awx/ui/client/src/projects/main.js index b43d1d29a4..1b76213cd3 100644 --- a/awx/ui/client/src/projects/main.js +++ b/awx/ui/client/src/projects/main.js @@ -13,9 +13,10 @@ import { N_ } from '../i18n'; import GetProjectPath from './factories/get-project-path.factory'; import GetProjectIcon from './factories/get-project-icon.factory'; import GetProjectToolTip from './factories/get-project-tool-tip.factory'; +import revisions from './revisions/main'; export default -angular.module('Projects', []) +angular.module('Projects', [revisions.name]) .controller('ProjectsList', ProjectsList) .controller('ProjectsAdd', ProjectsAdd) .controller('ProjectsEdit', ProjectsEdit) diff --git a/awx/ui/client/src/projects/projects.list.js b/awx/ui/client/src/projects/projects.list.js index 3bff8e9825..eacfdb72d4 100644 --- a/awx/ui/client/src/projects/projects.list.js +++ b/awx/ui/client/src/projects/projects.list.js @@ -50,16 +50,7 @@ export default ['i18n', function(i18n) { excludeModal: true, columnClass: 'col-lg-4 col-md-2 col-sm-3 hidden-xs', class: 'List-staticColumnAdjacent--monospace', - ngBind: 'project.scm_revision', - badgeCustom: true, - badgePlacement: 'right', - badgeIcon: `See More - See Less` + type: 'revision' }, last_updated: { label: i18n._('Last Updated'), diff --git a/awx/ui/client/src/projects/revisions/main.js b/awx/ui/client/src/projects/revisions/main.js new file mode 100644 index 0000000000..592cc2c976 --- /dev/null +++ b/awx/ui/client/src/projects/revisions/main.js @@ -0,0 +1,11 @@ +/************************************************* + * Copyright (c) 2015 Ansible, Inc. + * + * All Rights Reserved + *************************************************/ + +import revisions from './revisions.directive'; + +export default + angular.module('revisions', []) + .directive('revisions', revisions); \ No newline at end of file diff --git a/awx/ui/client/src/projects/revisions/revisions.directive.js b/awx/ui/client/src/projects/revisions/revisions.directive.js new file mode 100644 index 0000000000..75f261e392 --- /dev/null +++ b/awx/ui/client/src/projects/revisions/revisions.directive.js @@ -0,0 +1,24 @@ +export default + [ 'templateUrl', + 'Rest', + '$q', + '$filter', + function(templateUrl, Rest, $q, $filter) { + return { + restrict: 'E', + scope: false, + templateUrl: templateUrl('projects/revisions/revisions'), + link: function(scope) { + var full_revision = scope.project.scm_revision; + console.log(scope.project.scm_revision); + scope.seeMoreInactive = true; + scope.count = scope.project.scm_revision.length; + scope.revisionHash = $filter('limitTo')(full_revision, 7, 0); + + scope.Copy = function() { + console.log('copy'); + }; + } + }; + } + ]; \ No newline at end of file diff --git a/awx/ui/client/src/projects/revisions/revisions.partial.html b/awx/ui/client/src/projects/revisions/revisions.partial.html new file mode 100644 index 0000000000..10f8b5ecfc --- /dev/null +++ b/awx/ui/client/src/projects/revisions/revisions.partial.html @@ -0,0 +1,9 @@ +
+ {{revisionHash}} +
+
+ View More +
+
+ View Less +
\ No newline at end of file diff --git a/awx/ui/client/src/shared/generator-helpers.js b/awx/ui/client/src/shared/generator-helpers.js index 6879e26552..d4c4a7ddc2 100644 --- a/awx/ui/client/src/shared/generator-helpers.js +++ b/awx/ui/client/src/shared/generator-helpers.js @@ -501,7 +501,12 @@ angular.module('GeneratorHelpers', [systemStatus.name]) `; - }else if (field.type === 'badgeCount') { + } else if (field.type === 'revision') { + html += ` + + + `; + } else if (field.type === 'badgeCount') { html = BadgeCount(params); } else if (field.type === 'badgeOnly') { html = Badge(field); From 65dd53ac5f89c048e313591c4f92ef497d14a801 Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Thu, 11 May 2017 15:27:10 -0400 Subject: [PATCH 4/6] Add ability to copy revision hash to clipboard *Update copy link styles to match app theme --- awx/ui/client/src/projects/projects.list.js | 3 +- .../projects/revisions/revisions.block.less | 22 +++++++++ .../projects/revisions/revisions.directive.js | 47 ++++++++++++++++--- .../projects/revisions/revisions.partial.html | 11 ++--- awx/ui/client/src/shared/generator-helpers.js | 6 ++- 5 files changed, 72 insertions(+), 17 deletions(-) create mode 100644 awx/ui/client/src/projects/revisions/revisions.block.less diff --git a/awx/ui/client/src/projects/projects.list.js b/awx/ui/client/src/projects/projects.list.js index eacfdb72d4..9d03e69d3a 100644 --- a/awx/ui/client/src/projects/projects.list.js +++ b/awx/ui/client/src/projects/projects.list.js @@ -48,8 +48,7 @@ export default ['i18n', function(i18n) { scm_revision: { label: i18n._('Revision'), excludeModal: true, - columnClass: 'col-lg-4 col-md-2 col-sm-3 hidden-xs', - class: 'List-staticColumnAdjacent--monospace', + columnClass: 'List-tableCell col-lg-4 col-md-2 col-sm-3 hidden-xs', type: 'revision' }, last_updated: { diff --git a/awx/ui/client/src/projects/revisions/revisions.block.less b/awx/ui/client/src/projects/revisions/revisions.block.less new file mode 100644 index 0000000000..ddfd44c305 --- /dev/null +++ b/awx/ui/client/src/projects/revisions/revisions.block.less @@ -0,0 +1,22 @@ +@import "./client/src/shared/branding/colors.default.less"; + +.RevisionHash { + display: flex; + align-items: center; +} + +.RevisionHash-name { + font-family: monospace; +} + +.RevisionHash-copy { + color: @default-link; + text-transform: uppercase; + cursor: pointer; + font-size: 11px; + margin-left: 5px; +} + +.RevisionHash-copy:hover { + color: @default-link-hov; +} \ No newline at end of file diff --git a/awx/ui/client/src/projects/revisions/revisions.directive.js b/awx/ui/client/src/projects/revisions/revisions.directive.js index 75f261e392..c470739108 100644 --- a/awx/ui/client/src/projects/revisions/revisions.directive.js +++ b/awx/ui/client/src/projects/revisions/revisions.directive.js @@ -9,14 +9,49 @@ export default scope: false, templateUrl: templateUrl('projects/revisions/revisions'), link: function(scope) { - var full_revision = scope.project.scm_revision; - console.log(scope.project.scm_revision); - scope.seeMoreInactive = true; - scope.count = scope.project.scm_revision.length; + let full_revision = scope.project.scm_revision; scope.revisionHash = $filter('limitTo')(full_revision, 7, 0); + scope.count = scope.project.scm_revision.length; - scope.Copy = function() { - console.log('copy'); + scope.copyRevisionHash = function() { + let textArea = document.createElement("textarea"); + + // Place in top-left corner of screen regardless of scroll position. + textArea.style.position = 'fixed'; + textArea.style.top = 0; + textArea.style.left = 0; + + // Ensure it has a small width and height. Setting to 1px / 1em + // doesn't work as this gives a negative w/h on some browsers. + textArea.style.width = '2em'; + textArea.style.height = '2em'; + + // We don't need padding, reducing the size if it does flash render. + textArea.style.padding = 0; + + // Clean up any borders. + textArea.style.border = 'none'; + textArea.style.outline = 'none'; + textArea.style.boxShadow = 'none'; + + // Avoid flash of white box if rendered for any reason. + textArea.style.background = 'transparent'; + + textArea.value = full_revision; + + document.body.appendChild(textArea); + + textArea.select(); + + try { + var successful = document.execCommand('copy'); + var msg = successful ? 'successful' : 'unsuccessful'; + console.log('Copying text command was ' + msg); + } catch (err) { + console.log('Oops, unable to copy'); + } + + document.body.removeChild(textArea); }; } }; diff --git a/awx/ui/client/src/projects/revisions/revisions.partial.html b/awx/ui/client/src/projects/revisions/revisions.partial.html index 10f8b5ecfc..a20f7a9317 100644 --- a/awx/ui/client/src/projects/revisions/revisions.partial.html +++ b/awx/ui/client/src/projects/revisions/revisions.partial.html @@ -1,9 +1,6 @@ -
- {{revisionHash}} +
+ {{revisionHash}}
-
- View More +
+ Copy
-
- View Less -
\ No newline at end of file diff --git a/awx/ui/client/src/shared/generator-helpers.js b/awx/ui/client/src/shared/generator-helpers.js index d4c4a7ddc2..7d5f6dac8b 100644 --- a/awx/ui/client/src/shared/generator-helpers.js +++ b/awx/ui/client/src/shared/generator-helpers.js @@ -502,9 +502,11 @@ angular.module('GeneratorHelpers', [systemStatus.name]) `; } else if (field.type === 'revision') { + classList = (field.columnClass) ? + Attr(field, 'columnClass') : ""; html += ` - - + + `; } else if (field.type === 'badgeCount') { html = BadgeCount(params); From 82683d423f7cf2adbcdd2022dc9f997034b39166 Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Thu, 11 May 2017 15:50:12 -0400 Subject: [PATCH 5/6] Add tooltip to revision copy link --- awx/ui/client/src/projects/revisions/revisions.block.less | 2 +- awx/ui/client/src/projects/revisions/revisions.partial.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/src/projects/revisions/revisions.block.less b/awx/ui/client/src/projects/revisions/revisions.block.less index ddfd44c305..1e518dc68a 100644 --- a/awx/ui/client/src/projects/revisions/revisions.block.less +++ b/awx/ui/client/src/projects/revisions/revisions.block.less @@ -14,7 +14,7 @@ text-transform: uppercase; cursor: pointer; font-size: 11px; - margin-left: 5px; + margin-left: 10px; } .RevisionHash-copy:hover { diff --git a/awx/ui/client/src/projects/revisions/revisions.partial.html b/awx/ui/client/src/projects/revisions/revisions.partial.html index a20f7a9317..6b72870994 100644 --- a/awx/ui/client/src/projects/revisions/revisions.partial.html +++ b/awx/ui/client/src/projects/revisions/revisions.partial.html @@ -1,6 +1,6 @@
{{revisionHash}}
-
+
Copy -
+
\ No newline at end of file From 62c4efe19bf4e76c9a6e2ddf55a1604c4402460d Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Fri, 12 May 2017 10:02:52 -0400 Subject: [PATCH 6/6] Remove try/catch block of copyRevisionHash() --- .../src/projects/revisions/revisions.block.less | 2 +- .../src/projects/revisions/revisions.directive.js | 14 +++----------- awx/ui/client/src/shared/generator-helpers.js | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/awx/ui/client/src/projects/revisions/revisions.block.less b/awx/ui/client/src/projects/revisions/revisions.block.less index 1e518dc68a..084a8ba553 100644 --- a/awx/ui/client/src/projects/revisions/revisions.block.less +++ b/awx/ui/client/src/projects/revisions/revisions.block.less @@ -6,7 +6,7 @@ } .RevisionHash-name { - font-family: monospace; + font-family: monospace; } .RevisionHash-copy { diff --git a/awx/ui/client/src/projects/revisions/revisions.directive.js b/awx/ui/client/src/projects/revisions/revisions.directive.js index c470739108..b5e7ef02c3 100644 --- a/awx/ui/client/src/projects/revisions/revisions.directive.js +++ b/awx/ui/client/src/projects/revisions/revisions.directive.js @@ -1,4 +1,4 @@ -export default +export default [ 'templateUrl', 'Rest', '$q', @@ -38,18 +38,10 @@ export default textArea.style.background = 'transparent'; textArea.value = full_revision; - document.body.appendChild(textArea); - textArea.select(); - - try { - var successful = document.execCommand('copy'); - var msg = successful ? 'successful' : 'unsuccessful'; - console.log('Copying text command was ' + msg); - } catch (err) { - console.log('Oops, unable to copy'); - } + + document.execCommand('copy'); document.body.removeChild(textArea); }; diff --git a/awx/ui/client/src/shared/generator-helpers.js b/awx/ui/client/src/shared/generator-helpers.js index 7d5f6dac8b..d6c8f03c6d 100644 --- a/awx/ui/client/src/shared/generator-helpers.js +++ b/awx/ui/client/src/shared/generator-helpers.js @@ -506,7 +506,7 @@ angular.module('GeneratorHelpers', [systemStatus.name]) Attr(field, 'columnClass') : ""; html += ` - + `; } else if (field.type === 'badgeCount') { html = BadgeCount(params);