You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/12/22 17:08:11 UTC
[07/26] ambari git commit: AMBARI-19117. Implement Create Alerts:
PORT alert configs page (step 2) (xiwang)
AMBARI-19117. Implement Create Alerts: PORT alert configs page (step 2) (xiwang)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/688830c6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/688830c6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/688830c6
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 688830c63f784588aa4c0b47a68c884df5fd5516
Parents: d48b8d9
Author: Xi Wang <xi...@apache.org>
Authored: Tue Nov 29 15:11:13 2016 -0800
Committer: Xi Wang <xi...@apache.org>
Committed: Tue Dec 20 10:31:10 2016 -0800
----------------------------------------------------------------------
ambari-web/app/config.js | 1 +
.../alert_definitions_actions_controller.js | 48 ++---
.../alerts/definition_configs_controller.js | 182 +++++++++++--------
ambari-web/app/models/alerts/alert_config.js | 34 ++--
ambari-web/app/styles/alerts.less | 2 +-
.../definitions_configs_controller_test.js | 76 +-------
6 files changed, 155 insertions(+), 188 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/688830c6/ambari-web/app/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js
index 130cb39..c7b41e6 100644
--- a/ambari-web/app/config.js
+++ b/ambari-web/app/config.js
@@ -90,6 +90,7 @@ App.supports = {
kerberosStackAdvisor: true,
logCountVizualization: false,
manageJournalNode: true,
+ createAlerts: false,
enabledWizardForHostOrderedUpgrade: true
};
http://git-wip-us.apache.org/repos/asf/ambari/blob/688830c6/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js b/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js
index 7fb4b2d..a397b7b 100644
--- a/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js
+++ b/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js
@@ -26,32 +26,36 @@ App.MainAlertDefinitionActionsController = Em.ArrayController.extend({
* List of available actions for alert definitions
* @type {{title: string, icon: string, action: string, showDivider: boolean}[]}
*/
- content: [
- {
- title: Em.I18n.t('alerts.actions.create'),
- icon: 'glyphicon glyphicon-plus',
- action: 'createNewAlertDefinition',
- showDivider: true
- },
- {
+ content: function() {
+ var content = [];
+ if (App.supports.createAlerts) {
+ content = [{
+ title: Em.I18n.t('alerts.actions.create'),
+ icon: 'glyphicon glyphicon-plus',
+ action: 'createNewAlertDefinition',
+ showDivider: true
+ }];
+ }
+ content = content.concat([{
title: Em.I18n.t('alerts.actions.manageGroups'),
icon: 'glyphicon glyphicon-th-large',
action: 'manageAlertGroups',
showDivider: false
- },
- {
- title: Em.I18n.t('alerts.actions.manageNotifications'),
- icon: 'glyphicon glyphicon-envelope',
- action: 'manageNotifications',
- showDivider: false
- },
- {
- title: Em.I18n.t('alerts.actions.manageSettings'),
- icon: 'glyphicon glyphicon-cog',
- action: 'manageSettings',
- showDivider: false
- }
- ],
+ },
+ {
+ title: Em.I18n.t('alerts.actions.manageNotifications'),
+ icon: 'glyphicon glyphicon-envelope',
+ action: 'manageNotifications',
+ showDivider: false
+ },
+ {
+ title: Em.I18n.t('alerts.actions.manageSettings'),
+ icon: 'glyphicon glyphicon-cog',
+ action: 'manageSettings',
+ showDivider: false
+ }]);
+ return content;
+ }.property('App.supports.createAlerts'),
/**
* Common handler for menu item click
http://git-wip-us.apache.org/repos/asf/ambari/blob/688830c6/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
index 138aaa4..31e34a9 100644
--- a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
+++ b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
@@ -54,7 +54,7 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
* @type {Array}
*/
allServices: function () {
- return App.Service.find().mapProperty('displayName');
+ return App.Service.find().mapProperty('displayName').concat('CUSTOM');
}.property(),
/**
@@ -72,57 +72,60 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
}.property(),
/**
- * Change options of "Component", after changing value of "Service" config
+ * If any service selected, show related components, hide PORT and HOST field
+ * If CUSTOM was selected, show no component, and show PORT and HOST field
* @method onServiceSelect
*/
onServiceSelect: function () {
var serviceProperty = this.get('configs').findProperty('name', 'service');
- if (serviceProperty && serviceProperty.get('value') !== 'Ambari') {
- var componentsProperty = this.get('configs').findProperty('name', 'component');
+ var componentsProperty = this.get('configs').findProperty('name', 'component');
+ var defaultPortProperty = this.get('configs').findProperty('name', 'default_port');
+ var uriProperty = this.get('configs').findProperty('name', 'uri');
+ if (serviceProperty && serviceProperty.get('value') == 'CUSTOM') {
+ componentsProperty.set('options', ['No component']);
+ componentsProperty.set('canEdit', false);
+ var results = this.get('configs');
+ if (defaultPortProperty && uriProperty) {
+ results = results.filter(function (config) {
+ return config.name != 'default_port' && config.name != 'uri';
+ });
+ }
+ if (!defaultPortProperty) {
+ results = results.concat([
+ App.AlertConfigProperties.DefaultPort.create({
+ value: '8050'
+ }),
+ App.AlertConfigProperties.URI.create({
+ value: ''
+ })
+ ]);
+ this.set('configs', results);
+ }
+ } else if (serviceProperty && serviceProperty.get('value') !== 'CUSTOM' && componentsProperty.get('value') && componentsProperty.get('value') != 'No component') {
+ componentsProperty.set('options', ['No component'].concat(App.HostComponent.find().filterProperty('service.displayName', serviceProperty.get('value')).mapProperty('displayName').uniq()));
+ if (!defaultPortProperty) {
+ var results = this.get('configs').concat([
+ App.AlertConfigProperties.DefaultPort.create({
+ value: '8060'
+ }),
+ App.AlertConfigProperties.URI.create({
+ value: ''
+ })
+ ]);
+ this.set('configs', results);
+ }
+ } else if (serviceProperty && serviceProperty.get('value') !== 'CUSTOM') {
componentsProperty.set('options', ['No component'].concat(App.HostComponent.find().filterProperty('service.displayName', serviceProperty.get('value')).mapProperty('displayName').uniq()));
+ if (defaultPortProperty && uriProperty) {
+ var results = this.get('configs').filter(function (config) {
+ return config.name != 'default_port' && config.name != 'uri';
+ });
+ this.set('configs', results);
+ }
}
}.observes('configs.@each.value'),
/**
- * OnSelect handler for <code>select_type</code> property
- * disable fields related to definition type and set options to select lists
- */
- changeType: function (selectedType) {
- if (selectedType === 'alert_type_service') {
- this.get('configs').findProperty('name', 'service').setProperties({
- isDisabled: false,
- options: this.get('allServices'),
- value: this.get('allServices')[0]
- });
- this.get('configs').findProperty('name', 'component').setProperties({
- isDisabled: false,
- value: 'No component'
- });
- this.get('configs').findProperty('name', 'scope').setProperties({
- isDisabled: false,
- options: this.get('allScopes'),
- value: this.get('allScopes')[0]
- });
- } else {
- this.get('configs').findProperty('name', 'service').setProperties({
- isDisabled: true,
- options: ['Ambari'],
- value: 'Ambari'
- });
- this.get('configs').findProperty('name', 'component').setProperties({
- isDisabled: true,
- options: ['Ambari Agent'],
- value: 'Ambari Agent'
- });
- this.get('configs').findProperty('name', 'scope').setProperties({
- isDisabled: true,
- options: ['Host'],
- value: 'Host'
- });
- }
- },
-
- /**
* @return {string|Null}
* @method getThresholdsProperty
*/
@@ -185,34 +188,69 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
var isWizard = this.get('isWizard');
if (this.get('isWizard')) {
- result = result.concat(this.renderCommonWizardConfigs());
+ result = result.concat([
+ App.AlertConfigProperties.AlertName.create({
+ value: ''
+ }),
+ App.AlertConfigProperties.Service.create({
+ options: this.get('allServices'),
+ value: this.get('allServices')[0],
+ isShifted: true
+ }),
+ App.AlertConfigProperties.Component.create({
+ options: this.get('allComponents'),
+ value: 'No component',
+ isShifted: true
+ }),
+
+ //should be on next step
+ App.AlertConfigProperties.Interval.create({
+ value: isWizard ? '' : alertDefinition.get('interval')
+ }),
+ App.AlertConfigProperties.Thresholds.OkThreshold.create({
+ label: 'Thresholds',
+ showInputForValue: false,
+ text: isWizard ? '' : this.getThresholdsProperty('ok', 'text'),
+ value: isWizard ? '' : this.getThresholdsProperty('ok', 'value')
+ }),
+ App.AlertConfigProperties.Thresholds.WarningThreshold.create(App.AlertConfigProperties.Thresholds.PositiveMixin, {
+ valueMetric: 'Seconds',
+ text: isWizard ? '' : this.getThresholdsProperty('warning', 'text'),
+ value: isWizard ? '' : this.getThresholdsProperty('warning', 'value')
+ }),
+ App.AlertConfigProperties.Thresholds.CriticalThreshold.create(App.AlertConfigProperties.Thresholds.PositiveMixin, {
+ valueMetric: 'Seconds',
+ text: isWizard ? '' : this.getThresholdsProperty('critical', 'text'),
+ value: isWizard ? '' : this.getThresholdsProperty('critical', 'value')
+ })
+ ]);
+ } else {
+ result = result.concat([
+ App.AlertConfigProperties.Description.create({
+ value: isWizard ? '' : alertDefinition.get('description')
+ }),
+ App.AlertConfigProperties.Interval.create({
+ value: isWizard ? '' : alertDefinition.get('interval')
+ }),
+ App.AlertConfigProperties.Thresholds.OkThreshold.create({
+ label: 'Thresholds',
+ showInputForValue: false,
+ text: isWizard ? '' : this.getThresholdsProperty('ok', 'text'),
+ value: isWizard ? '' : this.getThresholdsProperty('ok', 'value')
+ }),
+ App.AlertConfigProperties.Thresholds.WarningThreshold.create(App.AlertConfigProperties.Thresholds.PositiveMixin, {
+ valueMetric: 'Seconds',
+ text: isWizard ? '' : this.getThresholdsProperty('warning', 'text'),
+ value: isWizard ? '' : this.getThresholdsProperty('warning', 'value')
+ }),
+ App.AlertConfigProperties.Thresholds.CriticalThreshold.create(App.AlertConfigProperties.Thresholds.PositiveMixin, {
+ valueMetric: 'Seconds',
+ text: isWizard ? '' : this.getThresholdsProperty('critical', 'text'),
+ value: isWizard ? '' : this.getThresholdsProperty('critical', 'value')
+ })
+ ]);
}
- result = result.concat([
- App.AlertConfigProperties.Description.create({
- value: isWizard ? '' : alertDefinition.get('description')
- }),
- App.AlertConfigProperties.Interval.create({
- value: isWizard ? '' : alertDefinition.get('interval')
- }),
- App.AlertConfigProperties.Thresholds.OkThreshold.create({
- label: 'Thresholds',
- showInputForValue: false,
- text: isWizard ? '' : this.getThresholdsProperty('ok', 'text'),
- value: isWizard ? '' : this.getThresholdsProperty('ok', 'value')
- }),
- App.AlertConfigProperties.Thresholds.WarningThreshold.create(App.AlertConfigProperties.Thresholds.PositiveMixin, {
- valueMetric: 'Seconds',
- text: isWizard ? '' : this.getThresholdsProperty('warning', 'text'),
- value: isWizard ? '' : this.getThresholdsProperty('warning', 'value')
- }),
- App.AlertConfigProperties.Thresholds.CriticalThreshold.create(App.AlertConfigProperties.Thresholds.PositiveMixin, {
- valueMetric: 'Seconds',
- text: isWizard ? '' : this.getThresholdsProperty('critical', 'text'),
- value: isWizard ? '' : this.getThresholdsProperty('critical', 'value')
- })
- ]);
-
return result;
},
@@ -558,9 +596,6 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
App.AlertConfigProperties.AlertName.create({
value: ''
}),
- App.AlertConfigProperties.ServiceAlertType.create({
- value: true
- }),
App.AlertConfigProperties.Service.create({
options: this.get('allServices'),
value: this.get('allServices')[0],
@@ -574,9 +609,6 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
App.AlertConfigProperties.Scope.create({
options: this.get('allScopes'),
isShifted: true
- }),
- App.AlertConfigProperties.HostAlertType.create({
- value: false
})
];
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/688830c6/ambari-web/app/models/alerts/alert_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alerts/alert_config.js b/ambari-web/app/models/alerts/alert_config.js
index 980dfe5..1af02fc 100644
--- a/ambari-web/app/models/alerts/alert_config.js
+++ b/ambari-web/app/models/alerts/alert_config.js
@@ -173,28 +173,18 @@ App.AlertConfigProperties = {
apiProperty: 'name'
}),
- ServiceAlertType: App.AlertConfigProperty.extend({
- name: 'alert_type_service',
- label: 'Service Alert Definition',
- displayType: 'radioButton',
- group: 'alert_type'
- }),
-
- HostAlertType: App.AlertConfigProperty.extend({
- name: 'alert_type_host',
- label: 'Host Alert Definition',
- displayType: 'radioButton',
- group: 'alert_type'
- }),
-
Service: App.AlertConfigProperty.extend({
name: 'service',
label: 'Service',
displayType: 'select',
apiProperty: 'service_name',
apiFormattedValue: function () {
- return App.StackService.find().findProperty('displayName', this.get('value')).get('serviceName');
- }.property('value')
+ return this.get('value') == 'CUSTOM' ? this.get('value') : App.StackService.find().findProperty('displayName', this.get('value')).get('serviceName');
+ }.property('value'),
+ change: function () {
+ this.set('property.value', true);
+ this.get('parentView.controller').changeService(this.get('property.name'));
+ }
}),
Component: App.AlertConfigProperty.extend({
@@ -203,7 +193,7 @@ App.AlertConfigProperties = {
displayType: 'select',
apiProperty: 'component_name',
apiFormattedValue: function () {
- return App.StackServiceComponent.find().findProperty('displayName', this.get('value')).get('componentName');
+ return this.get('value') == 'No component' ? this.get('value') : App.StackServiceComponent.find().findProperty('displayName', this.get('value')).get('componentName');
}.property('value')
}),
@@ -404,7 +394,7 @@ App.AlertConfigProperties = {
URI: App.AlertConfigProperty.extend({
name: 'uri',
- label: 'URI',
+ label: 'Host',
displayType: 'textField',
apiProperty: 'source.uri'
}),
@@ -429,7 +419,13 @@ App.AlertConfigProperties = {
name: 'default_port',
label: 'Default Port',
displayType: 'textField',
- apiProperty: 'source.default_port'
+ classNames: 'alert-port-input',
+ apiProperty: 'source.default_port',
+ isValid: function () {
+ var value = this.get('value');
+ if (!value) return false;
+ return String(value) === String(parseInt(value, 10)) && value >= 1;
+ }.property('value')
}),
Path: App.AlertConfigProperty.extend({
http://git-wip-us.apache.org/repos/asf/ambari/blob/688830c6/ambari-web/app/styles/alerts.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/alerts.less b/ambari-web/app/styles/alerts.less
index 77cc13c..a04db8a 100644
--- a/ambari-web/app/styles/alerts.less
+++ b/ambari-web/app/styles/alerts.less
@@ -524,7 +524,7 @@
.alert-type {
height: 150px;
width: 32%;
- margin: 5px;
+ margin: 0px 5px 10px 5px;
padding: 10px;
background: white;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/688830c6/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js b/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js
index 2ea42f7..d3294f9 100644
--- a/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js
@@ -123,7 +123,7 @@ describe('App.MainAlertDefinitionConfigsController', function () {
it('isWizard = true', function () {
controller.set('isWizard', true);
var result = controller.renderPortConfigs();
- expect(result.length).to.equal(11);
+ expect(result.length).to.equal(7);
});
it('isWizard = false', function () {
@@ -180,7 +180,7 @@ describe('App.MainAlertDefinitionConfigsController', function () {
it('isWizard = true', function () {
controller.set('isWizard', true);
var result = controller.renderMetricConfigs();
- expect(result.length).to.equal(12);
+ expect(result.length).to.equal(10);
});
it('isWizard = false', function () {
@@ -229,7 +229,7 @@ describe('App.MainAlertDefinitionConfigsController', function () {
it('isWizard = true', function () {
controller.set('isWizard', true);
var result = controller.renderWebConfigs();
- expect(result.length).to.equal(12);
+ expect(result.length).to.equal(10);
});
it('isWizard = false', function () {
@@ -275,7 +275,7 @@ describe('App.MainAlertDefinitionConfigsController', function () {
it('isWizard = true', function () {
controller.set('isWizard', true);
var result = controller.renderScriptConfigs();
- expect(result.length).to.equal(10);
+ expect(result.length).to.equal(8);
});
it('isWizard = false', function () {
@@ -546,79 +546,13 @@ describe('App.MainAlertDefinitionConfigsController', function () {
});
- describe('#changeType()', function () {
-
- beforeEach(function () {
- controller.set('allServices', ['service1', 'service2']);
- controller.set('allScopes', ['scope1', 'scope2']);
-
- controller.set('configs', [
- Em.Object.create({name: 'service', isDisabled: false}),
- Em.Object.create({name: 'component', isDisabled: false}),
- Em.Object.create({name: 'scope', isDisabled: false})
- ]);
- });
-
- describe('Host Alert Definition', function () {
-
- beforeEach(function () {
- controller.changeType('Host Alert Definition');
- });
-
- it('all configs are disabled', function () {
- expect(controller.get('configs').everyProperty('isDisabled', true)).to.be.true;
- });
- it('service.options = ["Ambari"]', function () {
- expect(controller.get('configs').findProperty('name', 'service').get('options')).to.eql(['Ambari']);
- });
- it('service.value = "Ambari"', function () {
- expect(controller.get('configs').findProperty('name', 'service').get('value')).to.equal('Ambari');
- });
- it('component.value = "Ambari Agent"', function () {
- expect(controller.get('configs').findProperty('name', 'component').get('value')).to.equal('Ambari Agent');
- });
- it('scope.options = ["Host"]', function () {
- expect(controller.get('configs').findProperty('name', 'scope').get('options')).to.eql(['Host']);
- });
- it('isDisabled.value = "Host"', function () {
- expect(controller.get('configs').findProperty('name', 'scope').get('value')).to.equal('Host');
- });
- });
-
- describe('alert_type_service', function () {
-
- beforeEach(function () {
- controller.changeType('alert_type_service');
- });
- it('all configs are not disabled', function () {
- expect(controller.get('configs').everyProperty('isDisabled', false)).to.be.true;
- });
- it('service.options = ["service1", "service2"]', function () {
- expect(controller.get('configs').findProperty('name', 'service').get('options')).to.eql(['service1', 'service2']);
- });
- it('service.value = "service1"', function () {
- expect(controller.get('configs').findProperty('name', 'service').get('value')).to.equal('service1');
- });
- it('component.value = "No component"', function () {
- expect(controller.get('configs').findProperty('name', 'component').get('value')).to.equal('No component');
- });
- it('scope.options = ["scope1", "scope2"]', function () {
- expect(controller.get('configs').findProperty('name', 'scope').get('options')).to.eql(['scope1', 'scope2']);
- });
- it('scope.value = "scope1"', function () {
- expect(controller.get('configs').findProperty('name', 'scope').get('value')).to.equal('scope1');
- });
- });
-
- });
-
describe('#renderCommonWizardConfigs()', function () {
it('should return correct number of configs', function () {
var result = controller.renderCommonWizardConfigs();
- expect(result.length).to.equal(6);
+ expect(result.length).to.equal(4);
});