diff --git a/ambari-web/app/controllers/wizard/downloadMpacks_controller.js b/ambari-web/app/controllers/wizard/downloadMpacks_controller.js
index 717357e2949..08e85c14f2f 100644
--- a/ambari-web/app/controllers/wizard/downloadMpacks_controller.js
+++ b/ambari-web/app/controllers/wizard/downloadMpacks_controller.js
@@ -36,7 +36,8 @@ App.WizardDownloadMpacksController = App.WizardStepController.extend({
url: mpack.downloadUrl,
inProgress: true,
failed: false,
- succeeded: false
+ succeeded: false,
+ failureMessage: null
}));
}, this);
},
@@ -76,15 +77,45 @@ App.WizardDownloadMpacksController = App.WizardStepController.extend({
this.get('mpacks').findProperty('name', params.name).set('succeeded', false);
this.get('mpacks').findProperty('name', params.name).set('failed', true);
this.get('mpacks').findProperty('name', params.name).set('inProgress', false);
+
+ let failureMessage;
+ switch (request.status) {
+ case 400:
+ case 500:
+ failureMessage = request.statusText;
+ break;
+ default:
+ failureMessage = Em.i18n.t('installer.downloadMpacks.failure.default');
+ }
+
+ this.get('mpacks').findProperty('name', params.name).set('failureMessage', failureMessage);
}
},
retryDownload: function (event) {
- var mpack = event.context;
- mpack.set('inProgress', true);
- mpack.set('succeeded', false);
- mpack.set('failed', false);
- this.downloadMpack(mpack);
+ const mpack = event.context;
+
+ if (mpack.get('failed')) {
+ mpack.set('inProgress', true);
+ mpack.set('succeeded', false);
+ mpack.set('failed', false);
+ this.downloadMpack(mpack);
+ }
+ },
+
+ showError: function (event) {
+ const mpack = event.context;
+
+ if (mpack.get('failed')) {
+ const error = mpack.get('failureMessage');
+
+ App.ModalPopup.show({
+ header: `${Em.I18n.t('common.download')} ${Em.I18n.t('common.failed')}`,
+ primary: Em.I18n.t('common.close'),
+ secondary: false,
+ body: error
+ });
+ }
},
getRegisteredMpacks: function () {
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index acf2a002eb3..abcc600d3ab 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -360,6 +360,7 @@ Em.I18n.translations = {
'common.version':'Version',
'common.versions':'Versions',
'common.view': 'View',
+ 'common.viewLog': 'View Log',
'common.views': 'Views',
'common.warn.message': '
{0}
',
'common.warning': 'Warning',
@@ -663,6 +664,7 @@ Em.I18n.translations = {
'installer.downloadMpacks.header': 'Download Management Packs',
'installer.downloadMpacks.body.title': 'Download and validate management packs',
'installer.downloadMpacks.body.description': 'Ambari is downloading the management packs and validating their contents.',
+ 'installer.downloadMpacks.failure.default': 'Downloading management pack failed for unknown reasons.',
'installer.customProductRepos.header': 'Set Product Locations',
'installer.customProductRepos.body.title': 'Customize product locations',
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 535223c6be9..c5d2243cb03 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -2920,11 +2920,15 @@ td .no-data {
}
[data-toggle="tooltip"] [disabled] {
- pointer-events: none;
+ pointer-events: none;
}
.retry-button:after {
- content: '\f01e';
+ content: '\f01e';
+}
+
+.viewLog-button:after {
+ content: '\f0f6';
}
.more-info {
diff --git a/ambari-web/app/templates/wizard/downloadMpacks.hbs b/ambari-web/app/templates/wizard/downloadMpacks.hbs
index 0f46c28cfed..3eb8e0d4ff2 100644
--- a/ambari-web/app/templates/wizard/downloadMpacks.hbs
+++ b/ambari-web/app/templates/wizard/downloadMpacks.hbs
@@ -60,6 +60,13 @@
{{/if}}
+
+ {{#if mpack.failed}}
+
+ {{else}}
+
+ {{/if}}
+
{{/each}}
diff --git a/ambari-web/test/controllers/wizard/downloadMpacks_test.js b/ambari-web/test/controllers/wizard/downloadMpacks_test.js
index 953445eb857..0fcc9c4d5a3 100644
--- a/ambari-web/test/controllers/wizard/downloadMpacks_test.js
+++ b/ambari-web/test/controllers/wizard/downloadMpacks_test.js
@@ -67,7 +67,7 @@ describe('App.WizardConfigureDownloadController', function () {
controller.downloadMpackError({ status: 500 }, null, null, null, { name: 'alpha' });
var actual = controller.get('mpacks').objectAt(0);
- expect(actual).to.deep.equal(expected);
+ expect(actual).to.deep.include(expected);
});
it('Sets succeeded to true, failed to false, and inProgress to false on 409 response', function () {
@@ -84,4 +84,45 @@ describe('App.WizardConfigureDownloadController', function () {
expect(actual).to.deep.equal(expected);
});
});
+
+ describe('#retryDownload', function () {
+ it('Retries the download and sets the status flags correctly if the download failed.', function () {
+ var expected = Em.Object.create({
+ succeeded: false,
+ failed: false,
+ inProgress: true
+ });
+
+ var actual = Em.Object.create({
+ succeeded: false,
+ failed: true,
+ inProgress: false
+ });
+
+ sinon.stub(controller, 'downloadMpack');
+
+ controller.retryDownload({ context: actual });
+
+ expect(actual).to.deep.equal(expected);
+ expect(controller.downloadMpack).to.be.called;
+
+ controller.downloadMpack.restore();
+ })
+ });
+
+ describe('#showError', function () {
+ it('Displays the error if the download failed.', function () {
+ var mpack = Em.Object.create({
+ failed: true
+ });
+
+ sinon.stub(App.ModalPopup, 'show');
+
+ controller.showError({ context: mpack });
+
+ expect(App.ModalPopup.show).to.be.called;
+
+ App.ModalPopup.show.restore();
+ })
+ });
});
\ No newline at end of file