Skip to content

Commit

Permalink
Add relaunch component to Job Results panel
Browse files Browse the repository at this point in the history
  • Loading branch information
marshmalien committed Nov 14, 2017
1 parent ee6beae commit 69ada03
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 35 deletions.
5 changes: 4 additions & 1 deletion awx/ui/client/lib/components/components.strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ function ComponentsStrings (BaseString) {

ns.relaunch = {
DEFAULT: t.s('Relaunch using the same parameters'),
HOSTS: t.s('Relaunch using host parameters')
HOSTS: t.s('Relaunch using host parameters'),
DROPDOWN_TITLE: t.s('Relaunch On'),
ALL: t.s('All'),
FAILED: t.s('Failed')
};
}

Expand Down
2 changes: 1 addition & 1 deletion awx/ui/client/lib/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import tab from '~components/tabs/tab.directive';
import tabGroup from '~components/tabs/group.directive';
import topNavItem from '~components/layout/top-nav-item.directive';
import truncate from '~components/truncate/truncate.directive';
import relaunch from '~components/relaunchButton/relaunchButton.directive';
import relaunch from '~components/relaunchButton/relaunchButton.component';

import BaseInputController from '~components/input/base.controller';
import ComponentsStrings from '~components/components.strings';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const atRelaunch = {
state: '<'
},
controller: ['RelaunchJob', 'InitiatePlaybookRun', 'ComponentsStrings', '$scope', atRelaunchCtrl],
controllerAs: 'vm',
replace: true
controllerAs: 'vm'
};

function atRelaunchCtrl (RelaunchJob, InitiatePlaybookRun, strings, $scope) {
Expand All @@ -19,6 +18,26 @@ function atRelaunchCtrl (RelaunchJob, InitiatePlaybookRun, strings, $scope) {
vm.showRelaunch = !(job.type === 'system_job') && job.summary_fields.user_capabilities.start;
vm.showDropdown = job.type === 'job' && job.failed === true;

vm.createDropdown();
vm.createTooltips();
};

vm.createDropdown = () => {
vm.icon = 'icon-launch';
vm.dropdownTitle = strings.get('relaunch.DROPDOWN_TITLE');
vm.dropdownOptions = [
{
name: strings.get('relaunch.ALL'),
icon: 'icon-host-all'
},
{
name: strings.get('relaunch.FAILED'),
icon: 'icon-host-failed'
}
];
};

vm.createTooltips = () => {
if (vm.showDropdown) {
vm.tooltip = strings.get('relaunch.HOSTS');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
data-toggle="dropdown"
aria-expanded="false"
id="relaunchDropdown">
<i class="{{ vm.state.icon }}"></i>
<i class="{{ vm.icon }}"></i>
</button>

<ul class="dropdown-menu pull-right" aria-labelledby="relaunchDropdown">
<li class="at-Relaunch--dropdownTitle">
<span>{{ vm.state.dropdownTitle }}</span>
<span>{{ vm.dropdownTitle }}</span>
</li>
<li ng-repeat="option in vm.state.dropdownOptions"
<li ng-repeat="option in vm.dropdownOptions"
class="at-Relaunch--dropdownOptions">
<a ng-click="vm.relaunchOn(option)">
<i class="fa {{ option.icon }}"></i>
Expand All @@ -28,6 +28,6 @@
<button class="at-Relaunch--button"
ng-click="vm.relaunchJob()"
ng-if="!vm.showDropdown">
<i class="{{ vm.state.icon }}"></i>
<i class="{{ vm.icon }}"></i>
</button>
</div>
4 changes: 4 additions & 0 deletions awx/ui/client/src/job-results/job-results.block.less
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
text-transform: uppercase;
}

.JobResults-panelHeaderButtonActions {
display: flex;
}

.JobResults-resultRow {
width: 100%;
display: flex;
Expand Down
12 changes: 2 additions & 10 deletions awx/ui/client/src/job-results/job-results.partial.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,10 @@
</div>

<!-- LEFT PANE HEADER ACTIONS -->
<div>
<div class="JobResults-panelHeaderButtonActions">

<!-- RELAUNCH ACTION -->
<button class="List-actionButton"
data-placement="top"
mode="all"
ng-click="relaunchJob()"
aw-tool-tip="{{'Relaunch using the same parameters' | translate}}"
data-original-title=""
title="">
<i class="icon-launch"></i>
</button>
<at-relaunch state="job"></at-relaunch>

<!-- CANCEL ACTION -->
<button class="List-actionButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,9 @@ export default
job_launch_data.diff_mode = scope.other_prompt_data.diff_mode;
}

if(scope.relaunchHostType) {
if(!Empty(scope.relaunchHostType)) {
job_launch_data.hosts = scope.relaunchHostType;
}
console.log(job_launch_data);
// if(_.get(scope, 'retry_counts.failed') === true) {
// job_launch_data.hosts = "failed";
// }

// If the extra_vars dict is empty, we don't want to include it if we didn't prompt for anything.
if(jQuery.isEmptyObject(job_launch_data.extra_vars)===true && scope.prompt_for_vars===false){
Expand Down
11 changes: 0 additions & 11 deletions awx/ui/client/src/jobs/all-jobs.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ export default ['i18n', function(i18n) {
dataPlacement: 'top',
ngShow: "!(job.type == 'system_job') && job.summary_fields.user_capabilities.start",
relaunch: true,
dropdownTitle: 'Relaunch On',
dropdownOptions: [
{
name: 'All',
icon: 'icon-host-all'
},
{
name: 'Failed',
icon: 'icon-host-failed'
}
],
},
cancel: {
mode: 'all',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ export default ['$compile', 'Attr', 'Icon',
}
// Plug in Dropdown Component
if (field_action === 'submit' && list.fieldActions[field_action].relaunch === true) {
innerTable += `<at-relaunch scope='$scope' state='list.fieldActions.submit'></at-relaunch>`
innerTable += `<at-relaunch></at-relaunch>`
} else {
fAction = list.fieldActions[field_action];
innerTable += "<button id=\"";
Expand Down

0 comments on commit 69ada03

Please sign in to comment.