mirror of
https://github.com/ansible/awx.git
synced 2026-03-03 01:38:50 -03:30
Merge pull request #2009 from kialam/fix/1063-multiple-creds-tags
View More Component with Credential Tags in Template List View
This commit is contained in:
@@ -164,6 +164,17 @@ function ListTemplatesController(
|
|||||||
|
|
||||||
return html;
|
return html;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm.buildCredentialTags = (credentials) => {
|
||||||
|
return credentials.map(credential => {
|
||||||
|
const icon = `${credential.kind}`;
|
||||||
|
const link = `/#/credentials/${credential.id}`;
|
||||||
|
const tooltip = strings.get('tooltips.VIEW_THE_CREDENTIAL');
|
||||||
|
const value = $filter('sanitize')(credential.name);
|
||||||
|
|
||||||
|
return { icon, link, tooltip, value };
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
vm.getLastRan = template => {
|
vm.getLastRan = template => {
|
||||||
const lastJobRun = _.get(template, 'last_job_run');
|
const lastJobRun = _.get(template, 'last_job_run');
|
||||||
|
|||||||
@@ -68,11 +68,11 @@
|
|||||||
value="{{ template.summary_fields.project.name }}"
|
value="{{ template.summary_fields.project.name }}"
|
||||||
value-link="/#/projects/{{ template.summary_fields.project.id }}">
|
value-link="/#/projects/{{ template.summary_fields.project.id }}">
|
||||||
</at-row-item>
|
</at-row-item>
|
||||||
<!-- TODO: add see more for creds -->
|
|
||||||
<at-row-item
|
<at-row-item
|
||||||
label-value="{{:: vm.strings.get('list.ROW_ITEM_LABEL_CREDENTIALS') }}"
|
label-value="{{:: vm.strings.get('list.ROW_ITEM_LABEL_CREDENTIALS') }}"
|
||||||
tag-values="template.summary_fields.credentials"
|
tag-values="template.summary_fields.credentials"
|
||||||
tags-are-creds="true">
|
tags-are-creds="true">
|
||||||
|
<at-toggle-tag ng-init="credTags=vm.buildCredentialTags(template.summary_fields.credentials)" tags="credTags"></at-toggle-tag>
|
||||||
</at-row-item>
|
</at-row-item>
|
||||||
<at-row-item
|
<at-row-item
|
||||||
label-value="{{:: vm.strings.get('list.ROW_ITEM_LABEL_MODIFIED') }}"
|
label-value="{{:: vm.strings.get('list.ROW_ITEM_LABEL_MODIFIED') }}"
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
@import 'relaunchButton/_index';
|
@import 'relaunchButton/_index';
|
||||||
@import 'tabs/_index';
|
@import 'tabs/_index';
|
||||||
@import 'tag/_index';
|
@import 'tag/_index';
|
||||||
|
@import 'toggle-tag/_index';
|
||||||
@import 'truncate/_index';
|
@import 'truncate/_index';
|
||||||
@import 'utility/_index';
|
@import 'utility/_index';
|
||||||
@import 'code-mirror/_index';
|
@import 'code-mirror/_index';
|
||||||
|
|||||||
@@ -52,6 +52,15 @@ function ComponentsStrings (BaseString) {
|
|||||||
COPIED: t.s('Copied to clipboard.')
|
COPIED: t.s('Copied to clipboard.')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ns.toggle = {
|
||||||
|
VIEW_MORE: t.s('VIEW MORE'),
|
||||||
|
VIEW_LESS: t.s('VIEW LESS')
|
||||||
|
};
|
||||||
|
|
||||||
|
ns.tooltips = {
|
||||||
|
VIEW_THE_CREDENTIAL: t.s('View the Credential'),
|
||||||
|
};
|
||||||
|
|
||||||
ns.layout = {
|
ns.layout = {
|
||||||
CURRENT_USER_LABEL: t.s('Logged in as'),
|
CURRENT_USER_LABEL: t.s('Logged in as'),
|
||||||
VIEW_DOCS: t.s('View Documentation'),
|
VIEW_DOCS: t.s('View Documentation'),
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import sideNavItem from '~components/layout/side-nav-item.directive';
|
|||||||
import tab from '~components/tabs/tab.directive';
|
import tab from '~components/tabs/tab.directive';
|
||||||
import tabGroup from '~components/tabs/group.directive';
|
import tabGroup from '~components/tabs/group.directive';
|
||||||
import tag from '~components/tag/tag.directive';
|
import tag from '~components/tag/tag.directive';
|
||||||
|
import toggleTag from '~components/toggle-tag/toggle-tag.directive';
|
||||||
import topNavItem from '~components/layout/top-nav-item.directive';
|
import topNavItem from '~components/layout/top-nav-item.directive';
|
||||||
import truncate from '~components/truncate/truncate.directive';
|
import truncate from '~components/truncate/truncate.directive';
|
||||||
import atCodeMirror from '~components/code-mirror';
|
import atCodeMirror from '~components/code-mirror';
|
||||||
@@ -80,6 +81,7 @@ angular
|
|||||||
.directive('atTab', tab)
|
.directive('atTab', tab)
|
||||||
.directive('atTabGroup', tabGroup)
|
.directive('atTabGroup', tabGroup)
|
||||||
.directive('atTag', tag)
|
.directive('atTag', tag)
|
||||||
|
.directive('atToggleTag', toggleTag)
|
||||||
.directive('atTopNavItem', topNavItem)
|
.directive('atTopNavItem', topNavItem)
|
||||||
.directive('atTruncate', truncate)
|
.directive('atTruncate', truncate)
|
||||||
.service('BaseInputController', BaseInputController)
|
.service('BaseInputController', BaseInputController)
|
||||||
|
|||||||
@@ -167,6 +167,8 @@
|
|||||||
.at-RowItem-tagContainer {
|
.at-RowItem-tagContainer {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-left: @at-margin-left-list-row-item-tag-container;
|
margin-left: @at-margin-left-list-row-item-tag-container;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
line-height: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
.at-RowItem-tag {
|
.at-RowItem-tag {
|
||||||
@@ -175,8 +177,7 @@
|
|||||||
border-radius: @at-border-radius;
|
border-radius: @at-border-radius;
|
||||||
color: @at-color-list-row-item-tag;
|
color: @at-color-list-row-item-tag;
|
||||||
font-size: @at-font-size-list-row-item-tag;
|
font-size: @at-font-size-list-row-item-tag;
|
||||||
margin-left: @at-margin-left-list-row-item-tag;
|
margin: @at-space;
|
||||||
margin-top: @at-margin-top-list-row-item-tag;
|
|
||||||
padding: @at-padding-list-row-item-tag;
|
padding: @at-padding-list-row-item-tag;
|
||||||
line-height: @at-line-height-list-row-item-tag;
|
line-height: @at-line-height-list-row-item-tag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,17 +42,6 @@
|
|||||||
template-type="smartStatus.type" ng-if="smartStatus">
|
template-type="smartStatus.type" ng-if="smartStatus">
|
||||||
</aw-smart-status>
|
</aw-smart-status>
|
||||||
<div class="at-RowItem-tagContainer" ng-if="tagValues && tagValues.length">
|
<div class="at-RowItem-tagContainer" ng-if="tagValues && tagValues.length">
|
||||||
<div ng-repeat="tag in tagValues" class="at-RowItem-tag at-RowItem-tag--primary">
|
<ng-transclude></ng-transclude>
|
||||||
<span ng-switch="tag.kind" class="at-RowItem-tagIcon"
|
|
||||||
ng-if="tagsAreCreds">
|
|
||||||
<span class="fa fa-cloud" ng-switch-when="cloud"></span>
|
|
||||||
<span class="fa fa-info" ng-switch-when="insights"></span>
|
|
||||||
<span class="fa fa-sitemap" ng-switch-when="net"></span>
|
|
||||||
<span class="fa fa-code-fork" ng-switch-when="scm"></span>
|
|
||||||
<span class="fa fa-key" ng-switch-when="ssh"></span>
|
|
||||||
<span class="fa fa-archive" ng-switch-when="vault"></span>
|
|
||||||
</span>
|
|
||||||
{{ tag.name }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -27,10 +27,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.TagComponent-icon {
|
.TagComponent-icon {
|
||||||
|
.at-mixin-VerticallyCenter();
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
margin-left: @at-space-2x;
|
margin-left: @at-space-2x;
|
||||||
|
|
||||||
&--cloud:before {
|
&--cloud:before,
|
||||||
|
&--aws:before,
|
||||||
|
&--tower:before,
|
||||||
|
&--azure_rm:before,
|
||||||
|
{
|
||||||
content: '\f0c2';
|
content: '\f0c2';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
awx/ui/client/lib/components/toggle-tag/_index.less
Normal file
19
awx/ui/client/lib/components/toggle-tag/_index.less
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
.ToggleComponent-wrapper {
|
||||||
|
line-height: initial;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ToggleComponent-container {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ToggleComponent-button {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
color: @at-blue;
|
||||||
|
font-size: @at-font-size;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: @at-blue-hover;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
awx/ui/client/lib/components/toggle-tag/constants.js
Normal file
2
awx/ui/client/lib/components/toggle-tag/constants.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export const TRUNCATE_LENGTH = 5;
|
||||||
|
export const IS_TRUNCATED = true;
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { IS_TRUNCATED, TRUNCATE_LENGTH } from './constants';
|
||||||
|
|
||||||
|
const templateUrl = require('~components/toggle-tag/toggle-tag.partial.html');
|
||||||
|
|
||||||
|
function controller (strings) {
|
||||||
|
const vm = this;
|
||||||
|
vm.truncatedLength = TRUNCATE_LENGTH;
|
||||||
|
vm.isTruncated = IS_TRUNCATED;
|
||||||
|
vm.strings = strings;
|
||||||
|
|
||||||
|
vm.toggle = () => {
|
||||||
|
vm.isTruncated = !vm.isTruncated;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.$inject = ['ComponentsStrings'];
|
||||||
|
|
||||||
|
function atToggleTag () {
|
||||||
|
return {
|
||||||
|
restrict: 'E',
|
||||||
|
replace: true,
|
||||||
|
transclude: true,
|
||||||
|
controller,
|
||||||
|
controllerAs: 'vm',
|
||||||
|
templateUrl,
|
||||||
|
scope: {
|
||||||
|
tags: '=',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default atToggleTag;
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<div class="ToggleComponent-wrapper">
|
||||||
|
<div ng-if="tags.length > vm.truncatedLength">
|
||||||
|
<div ng-show="vm.isTruncated" class="ToggleComponent-container">
|
||||||
|
<div ng-repeat="tag in tags | limitTo: vm.truncatedLength">
|
||||||
|
<at-tag tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag>
|
||||||
|
</div>
|
||||||
|
<button class="ToggleComponent-button" ng-click="vm.toggle()">{{:: vm.strings.get('toggle.VIEW_MORE') }}</button>
|
||||||
|
</div>
|
||||||
|
<div ng-show="!vm.isTruncated" class="ToggleComponent-container">
|
||||||
|
<div ng-repeat="tag in tags">
|
||||||
|
<at-tag tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag>
|
||||||
|
</div>
|
||||||
|
<button class="ToggleComponent-button" ng-click="vm.toggle()">{{:: vm.strings.get('toggle.VIEW_LESS') }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div ng-if="tags.length <= vm.truncatedLength" class="ToggleComponent-container">
|
||||||
|
<div ng-repeat="tag in tags">
|
||||||
|
<at-tag tag="tag.value" icon="{{ tag.icon }}" link="{{ tag.link }}"></at-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user