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

feat(volumes): add a switch to use CIFS volumes (#3823)

* feat(volumes): add a switch to use CIFS volumes

* feat(volumes): switch between nfs and cifs

* feat(volumes): autofix sharepoint, hide driveroptions and allow to create unnammed volume

* feat(volumes): change cifs version select options

* feat(volumes): change few things
This commit is contained in:
Maxime Bajeux 2020-05-15 03:28:51 +02:00 committed by GitHub
parent 8eac1d2221
commit ebac85b462
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 220 additions and 79 deletions

View file

@ -1,5 +1,6 @@
import { AccessControlFormData } from '../../../../portainer/components/accessControlForm/porAccessControlFormModel';
import { VolumesNFSFormData } from '../../../components/volumesNFSForm/volumesNFSFormModel';
import { VolumesCIFSFormData } from '../../../components/volumesCIFSForm/volumesCifsFormModel';
angular.module('portainer.docker').controller('CreateVolumeController', [
'$q',
@ -19,6 +20,7 @@ angular.module('portainer.docker').controller('CreateVolumeController', [
AccessControlData: new AccessControlFormData(),
NodeName: null,
NFSData: new VolumesNFSFormData(),
CIFSData: new VolumesCIFSFormData(),
};
$scope.state = {
@ -48,6 +50,23 @@ angular.module('portainer.docker').controller('CreateVolumeController', [
return true;
}
function prepareCIFSConfiguration(driverOptions) {
const data = $scope.formValues.CIFSData;
driverOptions.push({ name: 'type', value: 'cifs' });
let share = data.share.replace('\\', '/');
if (share[0] !== '/') {
share = '/' + share;
}
const device = '//' + data.serverAddress + share;
driverOptions.push({ name: 'device', value: device });
const versionNumber = data.versionsNumber[data.versions.indexOf(data.version)];
const options = 'username=' + data.username + ',password=' + data.password + ',vers=' + versionNumber;
driverOptions.push({ name: 'o', value: options });
}
function prepareNFSConfiguration(driverOptions) {
var data = $scope.formValues.NFSData;
@ -74,6 +93,10 @@ angular.module('portainer.docker').controller('CreateVolumeController', [
prepareNFSConfiguration(driverOptions);
}
if ($scope.formValues.CIFSData.useCIFS) {
prepareCIFSConfiguration(driverOptions);
}
var volumeConfiguration = VolumeService.createVolumeConfiguration(name, driver, driverOptions);
var accessControlData = $scope.formValues.AccessControlData;
var userDetails = Authentication.getUserDetails();

View file

@ -31,7 +31,7 @@
</div>
<!-- !driver-input -->
<!-- driver-options -->
<div class="form-group">
<div class="form-group" ng-hide="formValues.CIFSData.useCIFS || formValues.NFSData.useNFS">
<div class="col-sm-12" style="margin-top: 5px;">
<label class="control-label text-left">
Driver options
@ -64,8 +64,35 @@
</div>
<!-- !driver-options -->
<!-- nfs-management -->
<div class="form-group col-md-12">
<label for="useNFS" class="control-label text-left">
Use NFS volume
</label>
<label class="switch" style="margin-left: 20px;">
<input type="checkbox" name="useNFS" ng-model="formValues.NFSData.useNFS" ng-click="formValues.CIFSData.useCIFS = false" />
<i></i>
</label>
<div ng-if="formValues.NFSData.useNFS" class="small text-muted" style="margin-top: 10px;">
Ensure <code>nfs-utils</code> are installed on your hosts.
</div>
</div>
<volumes-nfs-form data="formValues.NFSData" ng-show="formValues.Driver === 'local'"></volumes-nfs-form>
<!-- !nfs-management -->
<!-- cifs-management -->
<div class="form-group col-md-12">
<label for="useCIFS" class="control-label text-left">
Use CIFS volume
</label>
<label class="switch" style="margin-left: 20px;">
<input type="checkbox" name="useCIFS" ng-model="formValues.CIFSData.useCIFS" ng-click="formValues.NFSData.useNFS = false" />
<i></i>
</label>
<div ng-if="formValues.CIFSData.useCIFS" class="small text-muted" style="margin-top: 10px;">
Ensure <code>cifs-utils</code> are installed on your hosts.
</div>
</div>
<volumes-cifs-form data="formValues.CIFSData" ng-show="formValues.Driver === 'local'"></volumes-cifs-form>
<!-- !cifs-management -->
<!-- storidge -->
<div ng-if="formValues.Driver === 'cio:latest'">
<div class="col-sm-12 form-section-title">
@ -95,7 +122,7 @@
type="button"
class="btn btn-primary btn-sm"
ng-click="create()"
ng-disabled="state.actionInProgress || (formValues.NFSData.useNFS && !volumeCreationForm.$valid)"
ng-disabled="state.actionInProgress || (formValues.NFSData.useNFS && !volumeCreationForm.nfsInformationForm.$valid) || (formValues.CIFSData.useCIFS && !volumeCreationForm.cifsInformationForm.$valid)"
button-spinner="state.actionInProgress"
>
<span ng-hide="state.actionInProgress">Create the volume</span>