|
@@ -45,75 +45,205 @@ App.WizardStep1View = Em.View.extend({
|
|
|
}
|
|
|
}),
|
|
|
|
|
|
- allRepositories: [],
|
|
|
- repoErrorCnt: function () {
|
|
|
- return this.get('allRepositories').filterProperty('empty-error', true).length;
|
|
|
- }.property('allRepositories.@each.empty-error'),
|
|
|
+ allRepositoriesGroup: [[],[],[]],
|
|
|
+ emptyRepoExist: function () {
|
|
|
+ return (this.get('allRepositoriesGroup').filterProperty('empty-error', true).length != 0);
|
|
|
+ }.property('allRepositoriesGroup.@each.empty-error'),
|
|
|
+ isSubmitDisabled: function() {
|
|
|
+ return this.get('emptyRepoExist') || this.get('allRepoUnchecked') ;
|
|
|
+ }.property('emptyRepoExist', 'allRepoUnchecked'),
|
|
|
+ invalidUrlExist: function () {
|
|
|
+ var selectedStack = this.get('controller.content.stacks').findProperty('isSelected', true);
|
|
|
+ return (selectedStack.get('invalidCnt') > 0);
|
|
|
+ }.property('controller.content.stacks.@each.invalidCnt'),
|
|
|
+ allRepoUnchecked: function () {
|
|
|
+ return (!this.get('allRepositoriesGroup').filterProperty('checked', true).length);
|
|
|
+ }.property('allRepositoriesGroup.@each.checked'),
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Onclick handler for Config Group Header. Used to show/hide block
|
|
|
+ */
|
|
|
+ onToggleBlock: function () {
|
|
|
+ this.$('.accordion-body').toggle('blind', 500);
|
|
|
+ this.set('isRLCollapsed', !this.get('isRLCollapsed'));
|
|
|
+ },
|
|
|
+ isRLCollapsed: true,
|
|
|
+ didInsertElement: function () {
|
|
|
+ if (this.get('isRLCollapsed')) {
|
|
|
+ this.$('.accordion-body').hide();
|
|
|
+ }
|
|
|
+ },
|
|
|
loadRepositories: function () {
|
|
|
var selectedStack = this.get('controller.content.stacks').findProperty('isSelected', true);
|
|
|
- var repos = [];
|
|
|
+ var reposGroup = [[],[],[]];
|
|
|
+ var self = this;
|
|
|
if (selectedStack && selectedStack.operatingSystems) {
|
|
|
selectedStack.operatingSystems.forEach(function (os) {
|
|
|
- var cur_repo = Em.Object.create({
|
|
|
- baseUrl: os.baseUrl,
|
|
|
- defaultBaseUrl: os.defaultBaseUrl,
|
|
|
- osType: os.osType,
|
|
|
- validation: os.validation
|
|
|
- });
|
|
|
- cur_repo.set('empty-error', !os.baseUrl);
|
|
|
- cur_repo.set('invalid-error', os.validation == 'icon-remove');
|
|
|
- cur_repo.set('undo', os.baseUrl != os.defaultBaseUrl);
|
|
|
- repos.pushObject(cur_repo);
|
|
|
+ var cur_repo = Em.Object.create({
|
|
|
+ baseUrl: os.baseUrl
|
|
|
+ });
|
|
|
+ switch(os.osType) {
|
|
|
+ case 'redhat5':
|
|
|
+ cur_repo.set('osType', 'Red Hat 5');
|
|
|
+ reposGroup[0][0] = cur_repo;
|
|
|
+ // set group 0 properties by redhat5 (any of the three is ok)
|
|
|
+ self.setGroupByOs(reposGroup[0], os, 0);
|
|
|
+ break;
|
|
|
+ case 'centos5':
|
|
|
+ cur_repo.set('osType', 'CentOS 5');
|
|
|
+ reposGroup[0][1] = cur_repo;
|
|
|
+ break;
|
|
|
+ case 'oraclelinux5':
|
|
|
+ cur_repo.set('osType', 'Oracle Linux 5');
|
|
|
+ reposGroup[0][2] = cur_repo;
|
|
|
+ break;
|
|
|
+ case 'redhat6':
|
|
|
+ cur_repo.set('osType', 'Red Hat 6');
|
|
|
+ reposGroup[1][0] = cur_repo;
|
|
|
+ // set group 1 properties by redhat6 (any of the three is ok)
|
|
|
+ self.setGroupByOs(reposGroup[1], os, 1);
|
|
|
+ break;
|
|
|
+ case 'centos6':
|
|
|
+ cur_repo.set('osType', 'CentOS 6');
|
|
|
+ reposGroup[1][1] = cur_repo;
|
|
|
+ break;
|
|
|
+ case 'oraclelinux6':
|
|
|
+ cur_repo.set('osType', 'Oracle Linux 6');
|
|
|
+ reposGroup[1][2] = cur_repo;
|
|
|
+ break;
|
|
|
+ case 'sles11':
|
|
|
+ cur_repo.set('osType', 'SLES 11');
|
|
|
+ reposGroup[2][0] = cur_repo;
|
|
|
+ // set group 2 properties by sles11 (any of the twe is ok)
|
|
|
+ self.setGroupByOs(reposGroup[2], os, 2);
|
|
|
+ break;
|
|
|
+ case 'suse11':
|
|
|
+ cur_repo.set('osType', 'SUSE 11');
|
|
|
+ reposGroup[2][1] = cur_repo;
|
|
|
+ break;
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
- this.set('allRepositories', repos);
|
|
|
+ this.set('allRepositoriesGroup', reposGroup);
|
|
|
}.observes('controller.content.stacks.@each.isSelected', 'controller.content.stacks.@each.reload'),
|
|
|
-
|
|
|
- undoLocalRepository: function (event) {
|
|
|
- var localRepo = event.context;
|
|
|
- var selectedStack = this.get('controller.content.stacks').findProperty('isSelected', true);
|
|
|
- var cos = selectedStack.operatingSystems.findProperty('osType', localRepo.osType);
|
|
|
- cos.baseUrl = cos.defaultBaseUrl;
|
|
|
- cos.validation = null;
|
|
|
- this.loadRepositories();
|
|
|
+ setGroupByOs: function (group, os, groupNumber) {
|
|
|
+ var isChecked = this.get('allGroupsCheckbox')[groupNumber];
|
|
|
+ group.set('checked', isChecked);
|
|
|
+ group.set('baseUrl', os.baseUrl);
|
|
|
+ group.set('defaultBaseUrl', os.defaultBaseUrl);
|
|
|
+ group.set('empty-error', !os.baseUrl);
|
|
|
+ group.set('invalid-error', os.validation == 'icon-remove');
|
|
|
+ group.set('validation', os.validation);
|
|
|
+ group.set('undo', os.baseUrl != os.defaultBaseUrl);
|
|
|
+ group.set('clearAll', os.baseUrl);
|
|
|
+ group.set('group-number', groupNumber);
|
|
|
},
|
|
|
- editLocalRepository: function (event) {
|
|
|
+ /**
|
|
|
+ * Onclick handler for checkbox of each repo group
|
|
|
+ */
|
|
|
+ updateByCheckbox: function () {
|
|
|
//upload to content
|
|
|
- var repos = this.get('allRepositories');
|
|
|
+ var groups = this.get('allRepositoriesGroup');
|
|
|
+ var self = this;
|
|
|
var selectedStack = this.get('controller.content.stacks').findProperty('isSelected', true);
|
|
|
if (selectedStack && selectedStack.operatingSystems) {
|
|
|
selectedStack.operatingSystems.forEach(function (os) {
|
|
|
- var target = repos.findProperty('osType', os.osType);
|
|
|
- if ( os.baseUrl != target.get('baseUrl')) {
|
|
|
- os.baseUrl = target.get('baseUrl');
|
|
|
+ var groupNumber = self.osTypeToGroup(os.osType);
|
|
|
+ var targetGroup = groups.findProperty('group-number', groupNumber);
|
|
|
+ if (!targetGroup.get('checked')) {
|
|
|
+ os.baseUrl = os.defaultBaseUrl;
|
|
|
os.validation = null;
|
|
|
- target.set('undo', target.get('baseUrl') != target.get('defaultBaseUrl'));
|
|
|
- target.set('invalid-error', false);
|
|
|
- target.set('validation', null);
|
|
|
- target.set('empty-error',!target.get('baseUrl'));
|
|
|
+ os.selected = false;
|
|
|
+ targetGroup.set('baseUrl', os.defaultBaseUrl);
|
|
|
+ targetGroup.set('undo', targetGroup.get('baseUrl') != targetGroup.get('defaultBaseUrl'));
|
|
|
+ targetGroup.set('invalid-error', false);
|
|
|
+ targetGroup.set('validation', null);
|
|
|
+ targetGroup.set('clearAll', false);
|
|
|
+ targetGroup.set('empty-error',!targetGroup.get('baseUrl'));
|
|
|
+ self.get('allGroupsCheckbox')[groupNumber] = false;
|
|
|
+ self.set('allGroupsCheckbox', self.get('allGroupsCheckbox'));
|
|
|
+ } else {
|
|
|
+ os.selected = true;
|
|
|
+ targetGroup.set('clearAll', targetGroup.get('baseUrl'));
|
|
|
+ targetGroup.set('empty-error',!targetGroup.get('baseUrl'));
|
|
|
+ self.get('allGroupsCheckbox')[groupNumber] = true;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- }.observes('allRepositories.@each.baseUrl'),
|
|
|
- isSubmitDisabled: function() {
|
|
|
- return this.get('repoErrorCnt') != 0;
|
|
|
- }.property('repoErrorCnt'),
|
|
|
- invalidUrlExist: function () {
|
|
|
- var selectedStack = this.get('controller.content.stacks').findProperty('isSelected', true);
|
|
|
- return (selectedStack.get('invalidCnt') > 0);
|
|
|
- }.property('controller.content.stacks.@each.invalidCnt'),
|
|
|
+ }.observes('allRepositoriesGroup.@each.checked'),
|
|
|
|
|
|
+ allGroupsCheckbox: [true, true, true],
|
|
|
/**
|
|
|
- * Onclick handler for Config Group Header. Used to show/hide block
|
|
|
+ * Onclick handler for undo action of each repo group
|
|
|
*/
|
|
|
- onToggleBlock: function () {
|
|
|
- this.$('.accordion-body').toggle('blind', 500);
|
|
|
- this.set('isRLCollapsed', !this.get('isRLCollapsed'));
|
|
|
+ undoGroupLocalRepository: function (event) {
|
|
|
+ var group = event.context;
|
|
|
+ var osTypes = this.groupToOsType(group.get('group-number'));
|
|
|
+ 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.validation = null;
|
|
|
+ });
|
|
|
+ this.loadRepositories();
|
|
|
},
|
|
|
- isRLCollapsed: true,
|
|
|
- didInsertElement: function () {
|
|
|
- if (this.get('isRLCollapsed')) {
|
|
|
- this.$('.accordion-body').hide();
|
|
|
+ clearGroupLocalRepository: function (event) {
|
|
|
+ var group = event.context;
|
|
|
+ var osTypes = this.groupToOsType(group.get('group-number'));
|
|
|
+ var selectedStack = this.get('controller.content.stacks').findProperty('isSelected', true);
|
|
|
+ osTypes.forEach( function (os) {
|
|
|
+ var cos = selectedStack.operatingSystems.findProperty('osType', os );
|
|
|
+ cos.baseUrl = '';
|
|
|
+ cos.validation = null;
|
|
|
+ });
|
|
|
+ this.loadRepositories();
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Handler when editing any repo group BaseUrl
|
|
|
+ */
|
|
|
+ editGroupLocalRepository: function (event) {
|
|
|
+ //upload to content
|
|
|
+ var groups = this.get('allRepositoriesGroup');
|
|
|
+ var self = this;
|
|
|
+ var selectedStack = this.get('controller.content.stacks').findProperty('isSelected', true);
|
|
|
+ if (selectedStack && selectedStack.operatingSystems) {
|
|
|
+ selectedStack.operatingSystems.forEach(function (os) {
|
|
|
+ var targetGroup = groups.findProperty('group-number', self.osTypeToGroup(os.osType));
|
|
|
+ if (os.baseUrl != targetGroup.get('baseUrl')) {
|
|
|
+ os.baseUrl = targetGroup.get('baseUrl');
|
|
|
+ os.validation = null;
|
|
|
+ targetGroup.set('undo', targetGroup.get('baseUrl') != targetGroup.get('defaultBaseUrl'));
|
|
|
+ targetGroup.set('invalid-error', false);
|
|
|
+ targetGroup.set('validation', null);
|
|
|
+ targetGroup.set('clearAll', os.baseUrl);
|
|
|
+ targetGroup.set('empty-error',!targetGroup.get('baseUrl'));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }.observes('allRepositoriesGroup.@each.baseUrl'),
|
|
|
+ groupToOsType: function (groupNumber) {
|
|
|
+ switch (groupNumber) {
|
|
|
+ case 0:
|
|
|
+ return ['redhat5', 'centos5', 'oraclelinux5'];
|
|
|
+ case 1:
|
|
|
+ return ['redhat6', 'centos6', 'oraclelinux6'];
|
|
|
+ case 2:
|
|
|
+ return ['sles11', 'suse11'];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ osTypeToGroup: function (osType) {
|
|
|
+ switch(osType) {
|
|
|
+ case 'redhat5':
|
|
|
+ case 'centos5':
|
|
|
+ case 'oraclelinux5':
|
|
|
+ return 0;
|
|
|
+ case 'redhat6':
|
|
|
+ case 'centos6':
|
|
|
+ case 'oraclelinux6':
|
|
|
+ return 1;
|
|
|
+ case 'sles11':
|
|
|
+ case 'suse11':
|
|
|
+ return 2;
|
|
|
}
|
|
|
}
|
|
|
});
|