diff --git a/awx/ui/client/features/output/details.component.js b/awx/ui/client/features/output/details.component.js index 97e3a1a8db..18a64c86ec 100644 --- a/awx/ui/client/features/output/details.component.js +++ b/awx/ui/client/features/output/details.component.js @@ -525,10 +525,12 @@ function getLabelDetails () { const label = strings.get('labels.LABELS'); const more = false; - const value = jobLabels.map(({ name }) => name).map($filter('sanitize')); + const truncate = true; + const truncateLength = 5; + const hasMoreToShow = jobLabels.length > truncateLength; - return { label, more, value }; + return { label, more, hasMoreToShow, value, truncate, truncateLength }; } function createErrorHandler (path, action) { @@ -546,6 +548,32 @@ const ELEMENT_SKIP_TAGS = '#job-results-skip-tags'; const ELEMENT_PROMPT_MODAL = '#prompt-modal'; const TAGS_SLIDE_DISTANCE = 200; +function showLabels () { + this.labels.truncate = !this.labels.truncate; + + const jobLabelsCount = _.get(resource.model.get('summary_fields.labels'), 'count'); + const maxCount = 50; + + if (this.labels.value.length === jobLabelsCount || this.labels.value.length >= maxCount) { + return; + } + + const config = { + params: { + page_size: maxCount + } + }; + + wait('start'); + resource.model.extend('get', 'labels', config) + .then((model) => { + const jobLabels = _.get(model.get('related.labels'), 'results', []); + this.labels.value = jobLabels.map(({ name }) => name).map($filter('sanitize')); + }) + .catch(createErrorHandler('get labels', 'GET')) + .finally(() => wait('stop')); +} + function toggleLabels () { if (!this.labels.more) { $(ELEMENT_LABELS).slideUp(TAGS_SLIDE_DISTANCE); @@ -705,6 +733,7 @@ function JobDetailsController ( vm.toggleJobTags = toggleJobTags; vm.toggleSkipTags = toggleSkipTags; vm.toggleLabels = toggleLabels; + vm.showLabels = showLabels; unsubscribe = subscribe(({ status, started, finished, scm }) => { vm.started = getStartDetails(started); diff --git a/awx/ui/client/features/output/details.partial.html b/awx/ui/client/features/output/details.partial.html index 82cc2c1ff2..fb1829def2 100644 --- a/awx/ui/client/features/output/details.partial.html +++ b/awx/ui/client/features/output/details.partial.html @@ -315,9 +315,26 @@ -
-
-
{{ label }}
+
+
+
+
{{ label }}
+
+ + {{:: vm.strings.get('details.SHOW_MORE') }} + +
+
+
+
{{ label }}
+
+ + {{:: vm.strings.get('details.SHOW_LESS') }} +