1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-07 23:05:26 +02:00

feat(app): add the capability to enable/disable host management features (#2472)

* feat(settings): add the capability to enable/disable the host management features

* feat(settings): remove the validation of EnableHostManagementFeatures in frontend

* feat(api): disable schedules API when HostManagementFeatures is false + DB migration

* style(settings): update host management settings tooltip

* refacot(schedules): update DBVersion to 15
This commit is contained in:
baron_l 2018-12-05 23:36:25 +01:00 committed by Anthony Lapenna
parent 101bb41587
commit a9b107dbb5
27 changed files with 128 additions and 9 deletions

View file

@ -8,6 +8,7 @@ function SettingsViewModel(data) {
this.SnapshotInterval = data.SnapshotInterval;
this.TemplatesURL = data.TemplatesURL;
this.ExternalTemplates = data.ExternalTemplates;
this.EnableHostManagementFeatures = data.EnableHostManagementFeatures;
}
function LDAPSettingsViewModel(data) {

View file

@ -43,6 +43,11 @@ function StateManagerFactory($q, SystemService, InfoHelper, LocalStorage, Settin
LocalStorage.storeApplicationState(state.application);
};
manager.updateEnableHostManagementFeatures = function(enableHostManagementFeatures) {
state.application.enableHostManagementFeatures = enableHostManagementFeatures;
LocalStorage.storeApplicationState(state.application);
};
function assignStateFromStatusAndSettings(status, settings) {
state.application.authentication = status.Authentication;
state.application.analytics = status.Analytics;
@ -51,6 +56,7 @@ function StateManagerFactory($q, SystemService, InfoHelper, LocalStorage, Settin
state.application.version = status.Version;
state.application.logo = settings.LogoURL;
state.application.snapshotInterval = settings.SnapshotInterval;
state.application.enableHostManagementFeatures = settings.EnableHostManagementFeatures;
state.application.validity = moment().unix();
}

View file

@ -101,6 +101,17 @@
</label>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<label for="toggle_enableHostManagementFeatures" class="control-label text-left">
Enable host management features
<portainer-tooltip position="bottom" message="Enables host management features: host scheduler, host browsing and command execution. Requires an agent setup."></portainer-tooltip>
</label>
<label class="switch" style="margin-left: 20px;">
<input type="checkbox" name="toggle_enableHostManagementFeatures" ng-model="formValues.enableHostManagementFeatures"><i></i>
</label>
</div>
</div>
<!-- security -->
<!-- actions -->
<div class="form-group">

View file

@ -12,7 +12,8 @@ function ($scope, $state, Notifications, SettingsService, StateManager) {
restrictBindMounts: false,
restrictPrivilegedMode: false,
labelName: '',
labelValue: ''
labelValue: '',
enableHostManagementFeatures: false
};
$scope.removeFilteredContainerLabel = function(index) {
@ -46,6 +47,7 @@ function ($scope, $state, Notifications, SettingsService, StateManager) {
settings.AllowBindMountsForRegularUsers = !$scope.formValues.restrictBindMounts;
settings.AllowPrivilegedModeForRegularUsers = !$scope.formValues.restrictPrivilegedMode;
settings.EnableHostManagementFeatures = $scope.formValues.enableHostManagementFeatures;
$scope.state.actionInProgress = true;
updateSettings(settings);
@ -57,6 +59,7 @@ function ($scope, $state, Notifications, SettingsService, StateManager) {
Notifications.success('Settings updated');
StateManager.updateLogo(settings.LogoURL);
StateManager.updateSnapshotInterval(settings.SnapshotInterval);
StateManager.updateEnableHostManagementFeatures(settings.EnableHostManagementFeatures);
$state.reload();
})
.catch(function error(err) {
@ -80,6 +83,7 @@ function ($scope, $state, Notifications, SettingsService, StateManager) {
}
$scope.formValues.restrictBindMounts = !settings.AllowBindMountsForRegularUsers;
$scope.formValues.restrictPrivilegedMode = !settings.AllowPrivilegedModeForRegularUsers;
$scope.formValues.enableHostManagementFeatures = settings.EnableHostManagementFeatures;
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve application settings');

View file

@ -36,10 +36,10 @@
<a ui-sref="storidge.profiles" ui-sref-active="active">Profiles</a>
</div>
</li>
<li class="sidebar-title" ng-if="!applicationState.application.authentication || isAdmin">
<li class="sidebar-title" ng-if="(!applicationState.application.authentication || isAdmin) && applicationState.application.enableHostManagementFeatures">
<span>Scheduler</span>
</li>
<li class="sidebar-list" ng-if="!applicationState.application.authentication || isAdmin">
<li class="sidebar-list" ng-if="(!applicationState.application.authentication || isAdmin) && applicationState.application.enableHostManagementFeatures">
<a ui-sref="portainer.schedules" ui-sref-active="active">Host jobs <span class="menu-icon fa fa-clock fa-fw"></span></a>
</li>
<li class="sidebar-title" ng-if="!applicationState.application.authentication || isAdmin || isTeamLeader">