Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions ambari-web/app/controllers/wizard/downloadMpacks_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ App.WizardDownloadMpacksController = App.WizardStepController.extend({
url: mpack.downloadUrl,
inProgress: true,
failed: false,
succeeded: false
succeeded: false,
failureMessage: null
}));
}, this);
},
Expand Down Expand Up @@ -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 () {
Expand Down
2 changes: 2 additions & 0 deletions ambari-web/app/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': '<div class="alert alert-warning">{0}</div>',
'common.warning': 'Warning',
Expand Down Expand Up @@ -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',
Expand Down
8 changes: 6 additions & 2 deletions ambari-web/app/styles/application.less
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions ambari-web/app/templates/wizard/downloadMpacks.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
<button type="button" class="icon-button retry-button" disabled="disabled"></button>
{{/if}}
</span>
<span data-toggle="tooltip" data-placement="bottom" {{translateAttr title="common.viewLog" }}>
{{#if mpack.failed}}
<button type="button" class="icon-button viewLog-button" {{action showError mpack target="controller" }}></button>
{{else}}
<button type="button" class="icon-button viewLog-button" disabled="disabled"></button>
{{/if}}
</span>
</td>
</tr>
{{/each}}
Expand Down
43 changes: 42 additions & 1 deletion ambari-web/test/controllers/wizard/downloadMpacks_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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();
})
});
});