Skip to content

Commit

Permalink
Denote invalid job templates and scheduled jobs by displaying a red i…
Browse files Browse the repository at this point in the history
…nvalid bar
  • Loading branch information
marshmalien committed Mar 5, 2018
1 parent 44f6423 commit 18f3c79
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 6 deletions.
17 changes: 17 additions & 0 deletions awx/ui/client/features/templates/list-templates.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ function ListTemplatesController(
vm.strings = strings;
vm.templateTypes = mapChoices(choices);
vm.activeId = parseInt($state.params.job_template_id || $state.params.workflow_template_id);
vm.invalidTooltip = {
popover: {
text: strings.get('error.INVALID'),
on: 'mouseenter',
icon: 'fa-exclamation',
position: 'right',
arrowHeight: 15
}
}

$scope.canAddJobTemplate = jobTemplate.options('actions.POST');
$scope.canAddWorkflowJobTemplate = workflowTemplate.options('actions.POST');
Expand All @@ -53,6 +62,14 @@ function ListTemplatesController(
$scope[name] = dataset.results;
});

vm.isInvalid = (template) => {
if(isJobTemplate(template)) {
return (template.inventory === null || template.project == null)
} else {
return false;
}
};

vm.runTemplate = template => {
if (!template) {
Alert(strings.get('error.LAUNCH'), strings.get('alert.MISSING_PARAMETER'));
Expand Down
3 changes: 3 additions & 0 deletions awx/ui/client/features/templates/list.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<at-row ng-repeat="template in templates"
ng-class="{'at-Row--active': (template.id === vm.activeId)}"
template-id="{{ template.id }}">
<div class="at-Row--invalid" ng-show="vm.isInvalid(template)">
<at-popover state="vm.invalidTooltip"></at-popover>
</div>
<div class="at-Row-items">
<at-row-item
header-value="{{ template.name }}"
Expand Down
3 changes: 2 additions & 1 deletion awx/ui/client/features/templates/templates.strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function TemplatesStrings (BaseString) {
VALID_DECIMAL: t.s('Please enter an answer that is a decimal number.'),
PLAYBOOK_RUN: t.s('Playbook Run'),
CHECK: t.s('Check'),
NO_CREDS_MATCHING_TYPE: t.s('No Credentials Matching This Type Have Been Created'),
NO_CREDS_MATCHING_TYPE: t.s('No Credentials Matching This Type Have Been Created'),
};

ns.alert = {
Expand All @@ -81,6 +81,7 @@ function TemplatesStrings (BaseString) {
UNKNOWN: t.s('Unable to determine template type.'),
SCHEDULE: t.s('Unable to schedule job.'),
COPY: t.s('Unable to copy template.'),
INVALID: t.s('Resources are missing from this template.')
};

ns.warnings = {
Expand Down
28 changes: 24 additions & 4 deletions awx/ui/client/legacy/styles/lists.less
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ table, tbody {
border-left: 5px solid @list-row-select-bord;
}

.List-tableRow--selected > :first-child {
padding-left: 10px;
}

.List-tableRow--disabled {
.List-tableCell, .List-tableCell * {
color: @b7grey;
Expand All @@ -98,6 +94,25 @@ table, tbody {
}
}

.List-tableRow--invalid {
height: 40px;
}

.List-tableRow--invalidBar {
align-items: center;
border-left: solid @at-space-2x @at-color-error;
color: @at-white;
display: flex;
height: 100%;
justify-content: center;
position: relative;

i {
position: absolute;
left: -7px;
}
}

.List-tableCell {
padding: 7px 15px;
border-top:0px!important;
Expand Down Expand Up @@ -387,6 +402,11 @@ table, tbody {
max-width: 164px;
}

.List-staticColumn--invalidBar {
width: 10px;
padding-right: 0px!important;
}

.List-staticColumnAdjacent {
padding-left: 10px!important;
}
Expand Down
24 changes: 24 additions & 0 deletions awx/ui/client/lib/components/list/_index.less
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
justify-content: space-between;
align-items: center;
padding: @at-padding-list-row;
position: relative;
}

.at-Row--active {
Expand All @@ -80,6 +81,29 @@
border-top-right-radius: @at-border-radius;
}

.at-Row--invalid {
align-items: center;
background: @at-color-error;
display: flex;
height: 100%;
justify-content: center;
left: 0;
position: absolute;
width: @at-space-2x;

.at-Popover {
padding: 0;

&-icon i {
color: @at-white;
}

&-icon i:hover {
color: @at-white;
}
}
}

.at-Row ~ .at-Row {
border-top-left-radius: 0px;
border-top-right-radius: 0px;
Expand Down
14 changes: 14 additions & 0 deletions awx/ui/client/src/scheduler/schedulerList.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ export default [
// _.forEach($scope[list.name], buildTooltips);
}

$scope.isValid = (schedule) => {
let type = schedule.summary_fields.unified_job_template.unified_job_type;
switch(type){
case 'job':
return _.every(['project', 'inventory'], _.partial(_.has, schedule.related));
case 'project_update':
return _.has(schedule, 'related.project');
case 'inventory_update':
return _.has(schedule, 'related.inventory');
default:
return true;
}
};

$scope.$on(`${list.iterator}_options`, function(event, data){
$scope.options = data.data.actions.GET;
optionsRequestDataProcessing();
Expand Down
10 changes: 9 additions & 1 deletion awx/ui/client/src/scheduler/schedules.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* All Rights Reserved
*************************************************/


export default ['i18n', function(i18n) {
return {

Expand All @@ -17,6 +16,15 @@ export default ['i18n', function(i18n) {
hover: true,

fields: {
invalid: {
columnClass: "List-staticColumn--invalidBar",
label: '',
type: 'invalid',
nosort: true,
awToolTip: i18n._("Resources are missing from this template."),
dataPlacement: 'right',
ngShow: '!isValid(schedule)'
},
toggleSchedule: {
ngDisabled: "!schedule.summary_fields.user_capabilities.edit",
label: '',
Expand Down
5 changes: 5 additions & 0 deletions awx/ui/client/src/shared/generator-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,11 @@ angular.module('GeneratorHelpers', [systemStatus.name])
html += "ng-show='!" + list.iterator + "." ;
html += (field.flag) ? field.flag : "enabled";
html += "' class='ScheduleToggle-switch' ng-click='" + field.ngClick + "'>" + i18n._("OFF") + "</button></div></td>";
} else if (field.type === 'invalid') {
html += `<td class='List-tableRow--invalid'><div class='List-tableRow--invalidBar' ng-show="${field.ngShow}"`;
html += `aw-tool-tip="${field.awToolTip}" data-placement=${field.dataPlacement}>`;
html += "<i class='fa fa-exclamation'></i>";
html += "</div></td>";
} else {
html += "<td class=\"List-tableCell " + fld + "-column";
html += (field['class']) ? " " + field['class'] : "";
Expand Down

0 comments on commit 18f3c79

Please sign in to comment.