mirror of
https://github.com/ansible/awx.git
synced 2026-02-25 15:06:02 -03:30
Add relaunchButton component and styles
This commit is contained in:
39
awx/ui/client/lib/components/relaunchButton/_index.less
Normal file
39
awx/ui/client/lib/components/relaunchButton/_index.less
Normal file
@@ -0,0 +1,39 @@
|
||||
.at-Relaunch {
|
||||
margin-left: 15px;
|
||||
|
||||
&--button {
|
||||
font-size: 16px;
|
||||
height: 30px;
|
||||
min-width: 30px;
|
||||
color: #848992;
|
||||
background-color: inherit;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
}
|
||||
&--button:hover {
|
||||
background-color: @at-blue;
|
||||
color: white;
|
||||
}
|
||||
&--dropdownTitle {
|
||||
color: #707070;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
padding: 3px 10px;
|
||||
}
|
||||
&--dropdownOptions {
|
||||
i {
|
||||
padding-right: 5px;
|
||||
}
|
||||
a:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.open {
|
||||
.at-Relaunch--button {
|
||||
background-color: @at-blue;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import templateUrl from './relaunchButton.partial.html';
|
||||
|
||||
const atRelaunch = {
|
||||
templateUrl,
|
||||
bindings: {
|
||||
state: '<'
|
||||
},
|
||||
controller: ['RelaunchJob', 'InitiatePlaybookRun', 'ComponentsStrings', '$scope', atRelaunchCtrl],
|
||||
controllerAs: 'vm',
|
||||
replace: true
|
||||
};
|
||||
|
||||
function atRelaunchCtrl (RelaunchJob, InitiatePlaybookRun, strings, $scope) {
|
||||
const vm = this;
|
||||
const scope = $scope.$parent;
|
||||
const { job } = $scope.$parent;
|
||||
|
||||
vm.$onInit = () => {
|
||||
vm.showRelaunch = !(job.type === 'system_job') && job.summary_fields.user_capabilities.start;
|
||||
vm.showDropdown = job.type === 'job' && job.failed === true;
|
||||
|
||||
if (vm.showDropdown) {
|
||||
vm.tooltip = strings.get('relaunch.HOSTS');
|
||||
} else {
|
||||
vm.tooltip = strings.get('relaunch.DEFAULT');
|
||||
}
|
||||
};
|
||||
|
||||
vm.relaunchJob = () => {
|
||||
let typeId;
|
||||
|
||||
if (job.type === 'inventory_update') {
|
||||
typeId = job.inventory_source;
|
||||
} else if (job.type === 'project_update') {
|
||||
typeId = job.project;
|
||||
} else if (job.type === 'job' || job.type === 'system_job'
|
||||
|| job.type === 'ad_hoc_command' || job.type === 'workflow_job') {
|
||||
typeId = job.id;
|
||||
}
|
||||
|
||||
RelaunchJob({ scope, id: typeId, type: job.type, name: job.name });
|
||||
};
|
||||
|
||||
vm.relaunchOn = (option) => {
|
||||
InitiatePlaybookRun({
|
||||
scope,
|
||||
id: job.id,
|
||||
relaunch: true,
|
||||
job_type: job.type,
|
||||
host_type: (option.name).toLowerCase()
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export default atRelaunch;
|
||||
@@ -0,0 +1,33 @@
|
||||
<div ng-if="vm.showRelaunch"
|
||||
class="at-Relaunch"
|
||||
aw-tool-tip="{{ vm.tooltip }}"
|
||||
data-placement="top">
|
||||
|
||||
<div class="btn-group" role="group" ng-if="vm.showDropdown">
|
||||
<button class="at-Relaunch--button"
|
||||
data-toggle="dropdown"
|
||||
aria-expanded="false"
|
||||
id="relaunchDropdown">
|
||||
<i class="{{ vm.state.icon }}"></i>
|
||||
</button>
|
||||
|
||||
<ul class="dropdown-menu pull-right" aria-labelledby="relaunchDropdown">
|
||||
<li class="at-Relaunch--dropdownTitle">
|
||||
<span>{{ vm.state.dropdownTitle }}</span>
|
||||
</li>
|
||||
<li ng-repeat="option in vm.state.dropdownOptions"
|
||||
class="at-Relaunch--dropdownOptions">
|
||||
<a ng-click="vm.relaunchOn(option)">
|
||||
<i class="fa {{ option.icon }}"></i>
|
||||
{{ option.name }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<button class="at-Relaunch--button"
|
||||
ng-click="vm.relaunchJob()"
|
||||
ng-if="!vm.showDropdown">
|
||||
<i class="{{ vm.state.icon }}"></i>
|
||||
</button>
|
||||
</div>
|
||||
Reference in New Issue
Block a user