Repository: ambari Updated Branches: refs/heads/trunk b5a072f3a -> b0fc3ada9
AMBARI-5227. Front-end changes to support the latest_url. (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b0fc3ada Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b0fc3ada Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b0fc3ada Branch: refs/heads/trunk Commit: b0fc3ada9ce9ed15370b1f839af06593dee36227 Parents: b5a072f Author: Oleg Nechiporenko <[email protected]> Authored: Wed Mar 26 16:07:30 2014 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Wed Mar 26 16:12:46 2014 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/installer.js | 14 ++-- ambari-web/app/views/wizard/step1_view.js | 97 ++++++++++++++++++++++++-- 2 files changed, 102 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b0fc3ada/ambari-web/app/controllers/installer.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js index 033e3ff..b43b0bc 100644 --- a/ambari-web/app/controllers/installer.js +++ b/ambari-web/app/controllers/installer.js @@ -188,6 +188,7 @@ App.InstallerController = App.WizardController.extend({ * baseUrl: 'http://...', * originalBaseUrl: 'http://...', * defaultBaseUrl: 'http://...', + * latestBaseUrl: 'http://...', * mirrorsList: ''; * }, * { @@ -195,6 +196,7 @@ App.InstallerController = App.WizardController.extend({ * baseUrl: 'http://...', * originalBaseUrl: 'http://...', * defaultBaseUrl: 'http://...', + * latestBaseUrl: 'http://...', * mirrorsList: ''; * }, * ] @@ -204,13 +206,15 @@ App.InstallerController = App.WizardController.extend({ version.operatingSystems.forEach(function (os) { if (os.repositories) { os.repositories.forEach(function (repo) { - if(repo.Repositories.repo_name == version.Versions.stack_name){ + if(repo.Repositories.repo_name == version.Versions.stack_name) { + var defaultBaseUrl = repo.Repositories.default_base_url || repo.Repositories.base_url; + var latestBaseUrl = repo.Repositories.latest_base_url || defaultBaseUrl; oses.push({ osType: os.OperatingSystems.os_type, - baseUrl: repo.Repositories.base_url, + baseUrl: latestBaseUrl, + originalLatestBaseUrl: latestBaseUrl, originalBaseUrl: repo.Repositories.base_url, - defaultBaseUrl: repo.Repositories.default_base_url ? - repo.Repositories.default_base_url : repo.Repositories.base_url, + defaultBaseUrl: defaultBaseUrl, mirrorsList: repo.Repositories.mirrors_list }); } @@ -219,7 +223,7 @@ App.InstallerController = App.WizardController.extend({ }); } result.push( - Ember.Object.create({ + Em.Object.create({ name: version.Versions.stack_name + "-" + version.Versions.stack_version, isSelected: false, operatingSystems: oses http://git-wip-us.apache.org/repos/asf/ambari/blob/b0fc3ada/ambari-web/app/views/wizard/step1_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/step1_view.js b/ambari-web/app/views/wizard/step1_view.js index c2900ee..75e71fc 100644 --- a/ambari-web/app/views/wizard/step1_view.js +++ b/ambari-web/app/views/wizard/step1_view.js @@ -18,8 +18,13 @@ var App = require('app'); App.WizardStep1View = Em.View.extend({ + templateName: require('templates/wizard/step1'), + /** + * List of available stacks + * @type {Em.Object[]} + */ stacks: function () { var stacks = []; this.get('controller.content.stacks').forEach(function (stack) { @@ -31,7 +36,11 @@ App.WizardStep1View = Em.View.extend({ return stacks; }.property('[email protected]'), - stackRadioButton: Ember.Checkbox.extend({ + /** + * Checkbox for each stack + * @type {Em.Checkbox} + */ + stackRadioButton: Em.Checkbox.extend({ tagName: 'input', attributeBindings: [ 'type', 'checked' ], checked: function () { @@ -45,21 +54,50 @@ App.WizardStep1View = Em.View.extend({ } }), + /** + * List of all repo-groups + * @type {Object[][]} + */ allRepositoriesGroup: [[],[],[]], + + /** + * Verify if some repo has empty base-url + * @type {bool} + */ emptyRepoExist: function () { return (this.get('allRepositoriesGroup').filterProperty('empty-error', true).length != 0); }.property('[email protected]'), + + /** + * Disable submit button flag + * @type {bool} + */ isSubmitDisabled: function() { return this.get('emptyRepoExist') || this.get('allRepoUnchecked') || this.get('invalidUrlExist') ; }.property('emptyRepoExist', 'allRepoUnchecked', 'invalidUrlExist'), + + /** + * Verify if some invalid repo-urls exist + * @type {bool} + */ invalidUrlExist: function () { var selectedStack = this.get('controller.content.stacks').findProperty('isSelected', true); var invalidExist = this.get('allRepositoriesGroup').filterProperty('validation', 'icon-exclamation-sign').length != 0; return (selectedStack.get('invalidCnt') > 0) && invalidExist; }.property('[email protected]', '[email protected]'), + + /** + * If all repo links are unchecked + * @type {bool} + */ allRepoUnchecked: function () { return (!this.get('allRepositoriesGroup').filterProperty('checked', true).length); }.property('[email protected]'), + + /** + * Overall errors count + * @type {number} + */ totalErrorCnt: function () { var emptyCnt = this.get('allRepositoriesGroup').filterProperty('empty-error', true).length; var invalidCnt = this.get('allRepositoriesGroup').filterProperty('validation', 'icon-exclamation-sign').length; @@ -79,7 +117,13 @@ App.WizardStep1View = Em.View.extend({ this.$('.accordion-body').toggle('blind', 500); this.set('isRLCollapsed', !this.get('isRLCollapsed')); }, + + /** + * Is Repositories Accordion collapsed + * @type {bool} + */ isRLCollapsed: true, + didInsertElement: function () { if (this.get('isRLCollapsed')) { this.$('.accordion-body').hide(); @@ -87,6 +131,10 @@ App.WizardStep1View = Em.View.extend({ $("[rel=skip-validation-tooltip]").tooltip({ placement: 'right'}); }, + /** + * Popover for repo-url error indicator + * @type {Em.View} + */ popoverView: Em.View.extend({ tagName: 'i', classNameBindings: ['repoGroup.validation'], @@ -96,6 +144,9 @@ App.WizardStep1View = Em.View.extend({ } }), + /** + * Format repo-group values and set it to <code>allRepositoriesGroup</code> + */ loadRepositories: function () { var selectedStack = this.get('controller.content.stacks').findProperty('isSelected', true); var reposGroup = [[],[],[]]; @@ -149,10 +200,18 @@ App.WizardStep1View = Em.View.extend({ } this.set('allRepositoriesGroup', reposGroup); }.observes('[email protected]', '[email protected]'), + + /** + * Set group parameters according to operation system + * @param {Em.Object} group + * @param {Object} os + * @param {number} groupNumber + */ setGroupByOs: function (group, os, groupNumber) { var isChecked = this.get('allGroupsCheckbox')[groupNumber]; group.set('checked', isChecked); group.set('baseUrl', os.baseUrl); + group.set('latestBaseUrl', os.latestBaseUrl); group.set('defaultBaseUrl', os.defaultBaseUrl); group.set('empty-error', !os.baseUrl); group.set('invalid-error', os.validation == 'icon-exclamation-sign'); @@ -163,6 +222,7 @@ App.WizardStep1View = Em.View.extend({ group.set('errorContent', os.errorContent); group.set('group-number', groupNumber); }, + /** * Onclick handler for checkbox of each repo group */ @@ -176,10 +236,10 @@ App.WizardStep1View = Em.View.extend({ var groupNumber = self.osTypeToGroup(os.osType); var targetGroup = groups.findProperty('group-number', groupNumber); if (!targetGroup.get('checked')) { - os.baseUrl = os.defaultBaseUrl; + os.baseUrl = os.latestBaseUrl; os.validation = null; os.selected = false; - targetGroup.set('baseUrl', os.defaultBaseUrl); + targetGroup.set('baseUrl', os.latestBaseUrl); targetGroup.set('undo', targetGroup.get('baseUrl') != targetGroup.get('defaultBaseUrl')); targetGroup.set('invalid-error', false); targetGroup.set('validation', null); @@ -202,8 +262,18 @@ App.WizardStep1View = Em.View.extend({ } }.observes('[email protected]', 'skipValidationChecked'), + /** + * Checked flags for each repo-checkbox + * @type {bool[]} + */ allGroupsCheckbox: [true, true, true], + + /** + * Skip repo-validation + * @type {bool} + */ skipValidationChecked: false, + /** * Onclick handler for undo action of each repo group */ @@ -213,11 +283,16 @@ App.WizardStep1View = Em.View.extend({ var selectedStack = this.get('controller.content.stacks').findProperty('isSelected', true); osTypes.forEach( function (os) { var cos = selectedStack.operatingSystems.findProperty('osType', os ); - cos.baseUrl = cos.defaultBaseUrl; + cos.baseUrl = cos.latestBaseUrl; cos.validation = null; }); this.loadRepositories(); }, + + /** + * Handler for clear icon click + * @param {object} event + */ clearGroupLocalRepository: function (event) { var group = event.context; var osTypes = this.groupToOsType(group.get('group-number')); @@ -229,8 +304,10 @@ App.WizardStep1View = Em.View.extend({ }); this.loadRepositories(); }, + /** * Handler when editing any repo group BaseUrl + * @param {object} event */ editGroupLocalRepository: function (event) { //upload to content @@ -252,6 +329,12 @@ App.WizardStep1View = Em.View.extend({ }); } }.observes('[email protected]'), + + /** + * Get list of OS for provided group number + * @param {number} groupNumber + * @returns {Array} + */ groupToOsType: function (groupNumber) { switch (groupNumber) { case 0: @@ -263,6 +346,12 @@ App.WizardStep1View = Em.View.extend({ } return []; }, + + /** + * Get group number for provided OS + * @param {string} osType + * @returns {number} + */ osTypeToGroup: function (osType) { switch(osType) { case 'redhat5':
