Merge pull request #5454 from ryanpetrello/fix-5420

disable the on/off toggle button for hosts from dynamic inventory.
This commit is contained in:
Ryan Petrello 2017-02-21 16:30:43 -05:00 committed by GitHub
commit e9a9a79d94
10 changed files with 29 additions and 2 deletions

View File

@ -12,6 +12,9 @@
$state.go('^', null, {reload: true});
};
$scope.toggleHostEnabled = function(){
if ($scope.host.has_inventory_sources){
return;
}
$scope.host.enabled = !$scope.host.enabled;
};
$scope.toggleEnabled = function(){

View File

@ -43,6 +43,9 @@ export default ['$scope', '$state', '$stateParams', 'GetBasePath', 'DashboardHos
};
$scope.toggleHostEnabled = function(host) {
if (host.has_inventory_sources){
return;
}
DashboardHostService.setHostStatus(host, !host.enabled)
.then(function(res) {
var index = _.findIndex($scope.hosts, function(o) {

View File

@ -19,7 +19,6 @@ export default ['i18n', function(i18n){
class: 'Form-header-field',
ngClick: 'toggleHostEnabled()',
type: 'toggle',
awToolTip: "<p>" +
i18n._("Indicates if a host is available and should be included in running jobs.") +
"</p><p>" +
@ -28,6 +27,7 @@ export default ['i18n', function(i18n){
" sync process.") +
"</p>",
dataTitle: i18n._('Host Enabled'),
ngDisabled: 'host.has_inventory_sources'
}
},
fields: {

View File

@ -52,6 +52,7 @@ export default [ 'i18n', function(i18n){
nosort: true,
awToolTip: "<p>" + i18n._("Indicates if a host is available and should be included in running jobs.") + "</p><p>" + i18n._("For hosts that are part of an external inventory, this flag cannot be changed. It will be set by the inventory sync process.") + "</p>",
dataTitle: i18n._('Host Enabled'),
ngDisabled: 'host.has_inventory_sources'
}
},

View File

@ -36,6 +36,7 @@ export default
" set by the inventory sync process.") +
"</p>",
dataTitle: i18n._('Host Enabled'),
ngDisabled: 'host.has_inventory_sources'
}
},
fields: {

View File

@ -34,6 +34,9 @@ export default ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange
$state.go('^');
};
$scope.toggleHostEnabled = function() {
if ($scope.host.has_inventory_sources){
return;
}
$scope.host.enabled = !$scope.host.enabled;
};
$scope.formSave = function(){

View File

@ -63,6 +63,9 @@
$state.go('^');
};
$scope.toggleHostEnabled = function(){
if ($scope.host.has_inventory_sources){
return;
}
$scope.host.enabled = !$scope.host.enabled;
};
$scope.formSave = function(){

View File

@ -11,12 +11,21 @@
cursor: pointer;
display: flex;
height: 18px;
&.ScheduleToggle--disabled {
cursor: not-allowed;
border-color: @b7grey !important;
.ScheduleToggle-switch {
background-color: @b7grey !important;
cursor: not-allowed;
}
}
}
.ScheduleToggle-switch {
color: @default-interface-txt;
background-color: @default-bg;
margin-left: 4px;
margin-left: 7px;
border-left: 1px solid @default-icon;
margin-right: 0px;
text-align: center;
@ -28,6 +37,7 @@
margin-top: 0px;
border-top: 0px;
border-bottom: 0px;
border-right: 0px;
}
.ScheduleToggle.is-on {

View File

@ -545,6 +545,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += " " + field.columnClass;
html += "\"><div class='ScheduleToggle' ng-class='{\"is-on\": " + form.iterator + ".";
html += (field.flag) ? field.flag : "enabled";
html += (field.ngDisabled) ? ', "ScheduleToggle--disabled": ' + field.ngDisabled : '';
html += "\}' aw-tool-tip='" + field.awToolTip + "' data-placement='" + field.dataPlacement + "' data-tip-watch='" + field.dataTipWatch + "'><button ng-show='" + form.iterator + "." ;
html += (field.flag) ? field.flag : 'enabled';
html += "' class='ScheduleToggle-switch is-on' ng-click='" + field.ngClick + "'>" + i18n._("ON") + "</button><button ng-show='!" + form.iterator + "." ;
@ -693,6 +694,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += " " + field.columnClass;
html += "\"><div class='ScheduleToggle' ng-class='{\"is-on\": " + form.iterator + ".";
html += (field.flag) ? field.flag : "enabled";
html += (field.ngDisabled) ? ', "ScheduleToggle--disabled": ' + field.ngDisabled : '';
html += "\}' aw-tool-tip='" + field.awToolTip + "' data-placement='" + field.dataPlacement + "' data-tip-watch='" + field.dataTipWatch + "'><div ng-show='" + form.iterator + "." ;
html += (field.flag) ? field.flag : 'enabled';
html += "' class='ScheduleToggle-switch is-on' ng-click='" + field.ngClick + "'>ON</div><div ng-show='!" + form.iterator + "." ;

View File

@ -510,6 +510,7 @@ angular.module('GeneratorHelpers', [systemStatus.name])
html += field.columnClass ? " " + field.columnClass : "";
html += "\"><div class='ScheduleToggle' ng-class='{\"is-on\": " + list.iterator + ".";
html += (field.flag) ? field.flag : "enabled";
html += (field.ngDisabled) ? ', "ScheduleToggle--disabled": ' + field.ngDisabled : '';
html += "\}' aw-tool-tip='" + field.awToolTip + "' data-placement='" + field.dataPlacement + "' data-tip-watch='" + field.dataTipWatch + "'><button ";
html += (field.ngDisabled) ? `ng-disabled="${field.ngDisabled}" ` : "";
html += "ng-show='" + list.iterator + "." ;