diff --git a/api/http/proxy/factory/docker/volumes.go b/api/http/proxy/factory/docker/volumes.go index 8923c996a..5727d0157 100644 --- a/api/http/proxy/factory/docker/volumes.go +++ b/api/http/proxy/factory/docker/volumes.go @@ -121,7 +121,7 @@ func (transport *Transport) decorateVolumeResourceCreationOperation(request *htt return response, err } - if response.StatusCode == http.StatusCreated && volumeID != "" { + if response.StatusCode == http.StatusCreated { err = transport.decorateGenericResourceCreationResponse(response, resourceIdentifierAttribute, resourceType, tokenData.ID) } return response, err diff --git a/app/docker/components/volumesCIFSForm/volumesCifsForm.html b/app/docker/components/volumesCIFSForm/volumesCifsForm.html new file mode 100644 index 000000000..f95455491 --- /dev/null +++ b/app/docker/components/volumesCIFSForm/volumesCifsForm.html @@ -0,0 +1,84 @@ + +
+ +
+ CIFS Settings +
+ +
+ +
+ +
+
+
+
+
+

This field is required.

+
+
+
+ + +
+ +
+ +
+
+
+
+
+

This field is required.

+
+
+
+ + +
+ +
+ +
+
+
+
+
+

This field is required.

+
+
+
+ + +
+ +
+ +
+
+
+
+
+

This field is required.

+
+
+
+ + +
+ +
+ +
+
+
+
+
+

This field is required.

+
+
+
+ +
+
+ diff --git a/app/docker/components/volumesCIFSForm/volumesCifsForm.js b/app/docker/components/volumesCIFSForm/volumesCifsForm.js new file mode 100644 index 000000000..5d349574f --- /dev/null +++ b/app/docker/components/volumesCIFSForm/volumesCifsForm.js @@ -0,0 +1,6 @@ +angular.module('portainer.docker').component('volumesCifsForm', { + templateUrl: './volumesCifsForm.html', + bindings: { + data: '=', + }, +}); diff --git a/app/docker/components/volumesCIFSForm/volumesCifsFormModel.js b/app/docker/components/volumesCIFSForm/volumesCifsFormModel.js new file mode 100644 index 000000000..db51e413f --- /dev/null +++ b/app/docker/components/volumesCIFSForm/volumesCifsFormModel.js @@ -0,0 +1,15 @@ +export function VolumesCIFSFormData() { + this.useCIFS = false; + this.serverAddress = ''; + this.share = ''; + this.version = 'CIFS v2.0 (Used by Windows Vista / Server 2008)'; + this.versions = [ + 'CIFS v1.0 (Used by Windows XP / Server 2003 and earlier)', + 'CIFS v2.0 (Used by Windows Vista / Server 2008)', + 'CIFS v2.1 (Used by Windows 7 / Server 2008 R2)', + 'CIFS 3.0 (Used by Windows 8 / Server 2012 and newer)', + ]; + this.versionsNumber = ['1.0', '2.0', '2.1', '3.0']; + this.username = ''; + this.password = ''; +} diff --git a/app/docker/components/volumesNFSForm/volumesnfsForm.html b/app/docker/components/volumesNFSForm/volumesnfsForm.html index 65e5e2b7a..3a197ebcd 100644 --- a/app/docker/components/volumesNFSForm/volumesnfsForm.html +++ b/app/docker/components/volumesNFSForm/volumesnfsForm.html @@ -1,86 +1,72 @@ -
-
- - -
- Ensure nfs-utils are installed on your hosts. + +
+ +
+ NFS Settings
-
- -
- -
- NFS Settings + +
+ +
+
- -
- -
- -
-
-
-
-
-

This field is required.

-
+
+
+
+
+

This field is required.

- - -
- -
- -
+
+ + +
+ +
+
-
-
-
-

This field is required.

-
+
+
+
+
+

This field is required.

- - -
- -
- -
+
+ + +
+ +
+
-
-
-
-

This field is required.

-
+
+
+
+
+

This field is required.

- - -
- -
- -
+
+ + +
+ +
+
-
-
-
-

This field is required.

-
+
+
+
+
+

This field is required.

- - -
- +
+ +
+ diff --git a/app/docker/rest/volume.js b/app/docker/rest/volume.js index e37f1b6c0..dd35f793b 100644 --- a/app/docker/rest/volume.js +++ b/app/docker/rest/volume.js @@ -9,7 +9,7 @@ angular.module('portainer.docker').factory('Volume', [ 'use strict'; function addVolumeNameToHeader(config) { - return config.data.Name; + return config.data.Name || ''; } return $resource( diff --git a/app/docker/views/volumes/create/createVolumeController.js b/app/docker/views/volumes/create/createVolumeController.js index 3667bc26c..781200e3f 100644 --- a/app/docker/views/volumes/create/createVolumeController.js +++ b/app/docker/views/volumes/create/createVolumeController.js @@ -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(); diff --git a/app/docker/views/volumes/create/createvolume.html b/app/docker/views/volumes/create/createvolume.html index 63405fe4a..d3985b68c 100644 --- a/app/docker/views/volumes/create/createvolume.html +++ b/app/docker/views/volumes/create/createvolume.html @@ -31,7 +31,7 @@
-
+
+
+ + +
+ Ensure nfs-utils are installed on your hosts. +
+
+ +
+ + +
+ Ensure cifs-utils are installed on your hosts. +
+
+ +
@@ -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" > Create the volume