1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 20:35:25 +02:00

feat(templates): fix an issue with templates initialization and update settings view

This commit is contained in:
Anthony Lapenna 2020-04-16 12:22:08 +12:00
parent 5563ff60fc
commit f371dc5402
6 changed files with 91 additions and 104 deletions

View file

@ -46,16 +46,7 @@
<div class="col-sm-12 form-section-title">
App Templates
</div>
<div class="form-group">
<div class="col-sm-12">
<label for="toggle_templates" class="control-label text-left">
Use external templates
<portainer-tooltip position="bottom" message="When using external templates, in-app template management will be disabled."></portainer-tooltip>
</label>
<label class="switch" style="margin-left: 20px;"> <input type="checkbox" name="toggle_templates" ng-model="formValues.externalTemplates" /><i></i> </label>
</div>
</div>
<div ng-if="formValues.externalTemplates">
<div>
<div class="form-group">
<span class="col-sm-12 text-muted small">
You can specify the URL to your own template definitions file here. See
@ -67,7 +58,7 @@
URL
</label>
<div class="col-sm-11">
<input type="text" class="form-control" ng-model="settings.TemplatesURL" id="templates_url" placeholder="https://myserver.mydomain/templates.json" />
<input type="text" class="form-control" ng-model="settings.TemplatesURL" id="templates_url" placeholder="https://myserver.mydomain/templates.json" required/>
</div>
</div>
</div>
@ -157,7 +148,7 @@
type="button"
class="btn btn-primary btn-sm"
ng-click="saveApplicationSettings()"
ng-disabled="state.actionInProgress"
ng-disabled="state.actionInProgress || !settings.TemplatesURL"
button-spinner="state.actionInProgress"
>
<span ng-hide="state.actionInProgress">Save settings</span>

View file

@ -25,7 +25,6 @@ angular.module('portainer.app').controller('SettingsController', [
$scope.formValues = {
customLogo: false,
externalTemplates: false,
restrictBindMounts: false,
restrictPrivilegedMode: false,
labelName: '',
@ -60,10 +59,6 @@ angular.module('portainer.app').controller('SettingsController', [
settings.LogoURL = '';
}
if (!$scope.formValues.externalTemplates) {
settings.TemplatesURL = '';
}
settings.AllowBindMountsForRegularUsers = !$scope.formValues.restrictBindMounts;
settings.AllowPrivilegedModeForRegularUsers = !$scope.formValues.restrictPrivilegedMode;
settings.AllowVolumeBrowserForRegularUsers = $scope.formValues.enableVolumeBrowser;
@ -98,12 +93,10 @@ angular.module('portainer.app').controller('SettingsController', [
.then(function success(data) {
var settings = data;
$scope.settings = settings;
if (settings.LogoURL !== '') {
$scope.formValues.customLogo = true;
}
if (settings.TemplatesURL !== '') {
$scope.formValues.externalTemplates = true;
}
$scope.formValues.restrictBindMounts = !settings.AllowBindMountsForRegularUsers;
$scope.formValues.restrictPrivilegedMode = !settings.AllowPrivilegedModeForRegularUsers;
$scope.formValues.enableVolumeBrowser = settings.AllowVolumeBrowserForRegularUsers;