diff --git a/openstack_dashboard/static/app/core/images/actions/create.action.service.js b/openstack_dashboard/static/app/core/images/actions/create.action.service.js index 454ff08197..b19d2e6ef3 100644 --- a/openstack_dashboard/static/app/core/images/actions/create.action.service.js +++ b/openstack_dashboard/static/app/core/images/actions/create.action.service.js @@ -115,7 +115,10 @@ } else { delete finalModel.image_url; } - return glance.createImage(finalModel).then(onCreateImage); + function onProgress(progress) { + scope.$broadcast(events.IMAGE_UPLOAD_PROGRESS, progress); + } + return glance.createImage(finalModel, onProgress).then(onCreateImage); } function onCreateImage(response) { diff --git a/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js b/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js index 3e5eb37fa0..97b8af7c44 100644 --- a/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js +++ b/openstack_dashboard/static/app/core/images/actions/create.action.service.spec.js @@ -115,8 +115,8 @@ modalArgs.submit(); $scope.$apply(); - expect(glanceAPI.createImage).toHaveBeenCalledWith({ name: 'Test', - id: '2', prop1: '11', prop3: '3'}); + expect(glanceAPI.createImage.calls.argsFor(0)[0]).toEqual( + {name: 'Test', id: '2', prop1: '11', prop3: '3'}); }); it('does not pass location to create image if source_type is NOT url', function() { @@ -135,7 +135,7 @@ var modalArgs = wizardModalService.modal.calls.argsFor(0)[0]; modalArgs.submit(); - expect(glanceAPI.createImage).toHaveBeenCalledWith({ name: 'Test', + expect(glanceAPI.createImage.calls.argsFor(0)[0]).toEqual({ name: 'Test', source_type: 'file-direct', data: {name: 'test_file'}}); }); @@ -155,7 +155,7 @@ var modalArgs = wizardModalService.modal.calls.argsFor(0)[0]; modalArgs.submit(); - expect(glanceAPI.createImage).toHaveBeenCalledWith({ name: 'Test', + expect(glanceAPI.createImage.calls.argsFor(0)[0]).toEqual({ name: 'Test', source_type: 'url', image_url: 'http://somewhere'}); }); @@ -175,7 +175,7 @@ var modalArgs = wizardModalService.modal.calls.argsFor(0)[0]; modalArgs.submit(); - expect(glanceAPI.createImage).toHaveBeenCalledWith({ name: 'Test', + expect(glanceAPI.createImage.calls.argsFor(0)[0]).toEqual({ name: 'Test', source_type: 'file-direct', data: {name: 'test_file'}}); }); @@ -195,7 +195,7 @@ var modalArgs = wizardModalService.modal.calls.argsFor(0)[0]; modalArgs.submit(); - expect(glanceAPI.createImage).toHaveBeenCalledWith({ name: 'Test', + expect(glanceAPI.createImage.calls.argsFor(0)[0]).toEqual({ name: 'Test', source_type: 'url', image_url: 'http://somewhere'}); }); @@ -247,7 +247,7 @@ modalArgs.submit(); $scope.$apply(); - expect(glanceAPI.createImage).toHaveBeenCalledWith({}); + expect(glanceAPI.createImage.calls.argsFor(0)[0]).toEqual({}); }); }); diff --git a/openstack_dashboard/static/app/core/images/images.module.js b/openstack_dashboard/static/app/core/images/images.module.js index d6df4ade2c..50b1c18b83 100644 --- a/openstack_dashboard/static/app/core/images/images.module.js +++ b/openstack_dashboard/static/app/core/images/images.module.js @@ -280,7 +280,8 @@ return { VOLUME_CHANGED: 'horizon.app.core.images.VOLUME_CHANGED', IMAGE_CHANGED: 'horizon.app.core.images.IMAGE_CHANGED', - IMAGE_METADATA_CHANGED: 'horizon.app.core.images.IMAGE_METADATA_CHANGED' + IMAGE_METADATA_CHANGED: 'horizon.app.core.images.IMAGE_METADATA_CHANGED', + IMAGE_UPLOAD_PROGRESS: 'horizon.app.core.images.IMAGE_UPLOAD_PROGRESS' }; } diff --git a/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.js b/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.js index 145a26b29d..7a0e0f3287 100644 --- a/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.js +++ b/openstack_dashboard/static/app/core/images/steps/create-image/create-image.controller.js @@ -65,6 +65,8 @@ visibility: 'public' }; + ctrl.uploadProgress = -1; + ctrl.imageProtectedOptions = [ { label: gettext('Yes'), value: true }, { label: gettext('No'), value: false } @@ -93,9 +95,11 @@ init(); var imageChangedWatcher = $scope.$watchCollection('ctrl.image', watchImageCollection); + var watchUploadProgress = $scope.$on(events.IMAGE_UPLOAD_PROGRESS, watchImageUpload); $scope.$on('$destroy', function() { imageChangedWatcher(); + watchUploadProgress(); }); /////////////////////////// @@ -104,6 +108,10 @@ ctrl.image.data = file; } + function watchImageUpload(event, progress) { + ctrl.uploadProgress = progress; + } + function getConfiguredFormatsAndModes(response) { var settingsFormats = response.OPENSTACK_IMAGE_FORMATS; var uploadMode = response.HORIZON_IMAGES_UPLOAD_MODE; diff --git a/openstack_dashboard/static/app/core/images/steps/create-image/create-image.html b/openstack_dashboard/static/app/core/images/steps/create-image/create-image.html index f6c1536d17..dc18aabf5f 100644 --- a/openstack_dashboard/static/app/core/images/steps/create-image/create-image.html +++ b/openstack_dashboard/static/app/core/images/steps/create-image/create-image.html @@ -70,19 +70,23 @@