You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/11/28 17:52:33 UTC
[3/3] ambari git commit: AMBARI-8470. Slider View: error message
after clicking Start (or Stop) button second time (alexantonenko)
AMBARI-8470. Slider View: error message after clicking Start (or Stop) button second time (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0fc4e7f0
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0fc4e7f0
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0fc4e7f0
Branch: refs/heads/trunk
Commit: 0fc4e7f0e50135906205e58bfd07acdeec053f05
Parents: 10f4afc
Author: Alex Antonenko <hi...@gmail.com>
Authored: Fri Nov 28 18:35:54 2014 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Fri Nov 28 18:52:17 2014 +0200
----------------------------------------------------------------------
.../ui/app/controllers/slider_app_controller.js | 19 +++++++++----------
.../src/main/resources/ui/app/helpers/ajax.js | 2 +-
.../ui/app/mappers/slider_apps_mapper.js | 6 ++++--
.../main/resources/ui/app/models/slider_app.js | 13 +++++++++++++
.../controllers/slider_app_controller_test.js | 10 +++++++---
.../test/unit/mappers/slider_apps_mapper_test.js | 6 +++---
6 files changed, 37 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc4e7f0/contrib/views/slider/src/main/resources/ui/app/controllers/slider_app_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_app_controller.js b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_app_controller.js
index 5c521c2..0684e53 100644
--- a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_app_controller.js
+++ b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_app_controller.js
@@ -115,7 +115,7 @@ App.SliderAppController = Ember.ObjectController.extend(App.AjaxErrorHandler, {
statusActionsMap = this.get('statusActionsMap'),
status = this.get('model.status');
- this.get('model').set('isActionPerformed', false);
+ if (this.get('model.isActionFinished')) this.get('model').set('isActionPerformed', false);
statusActionsMap[status].forEach(function(action) {
if ('destroy' === action) {
advanced.pushObject(appActions[action]);
@@ -167,12 +167,6 @@ App.SliderAppController = Ember.ObjectController.extend(App.AjaxErrorHandler, {
groupedComponentsHaveErrors: false,
/**
- * Action is performed.
- * @type {Bool}
- **/
- isActionRunning: false,
-
- /**
* Custom popup for "Destroy"-action
* @method destroyConfirm
*/
@@ -209,7 +203,7 @@ App.SliderAppController = Ember.ObjectController.extend(App.AjaxErrorHandler, {
*/
thaw: function() {
var model = this.get('model');
- this.get('model').set('isActionPerformed', true);
+ this.setStartAction();
return App.ajax.send({
name: 'changeAppState',
sender: this,
@@ -241,7 +235,7 @@ App.SliderAppController = Ember.ObjectController.extend(App.AjaxErrorHandler, {
*/
freeze: function() {
var model = this.get('model');
- this.get('model').set('isActionPerformed', true);
+ this.setStartAction();
return App.ajax.send({
name: 'changeAppState',
sender: this,
@@ -351,7 +345,7 @@ App.SliderAppController = Ember.ObjectController.extend(App.AjaxErrorHandler, {
* @method destroy
*/
destroy: function() {
- this.get('model').set('isActionPerformed', true);
+ this.setStartAction();
return App.ajax.send({
name: 'destroyApp',
sender: this,
@@ -465,6 +459,11 @@ App.SliderAppController = Ember.ObjectController.extend(App.AjaxErrorHandler, {
}
}
}
+ },
+
+ setStartAction: function() {
+ this.get('model').set('isActionPerformed' , true);
+ this.get('model').set('statusBeforeAction' , this.get('model.status'));
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc4e7f0/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js b/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
index b622992..bfb976d 100644
--- a/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
+++ b/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
@@ -99,7 +99,7 @@ var urls = {
},
'mapper.applicationApps': {
- real: 'apps/?fields=*',
+ real: '?fields=apps/*',
mock: '/data/apps/apps.json',
headers: {
Accept: "text/plain; charset=utf-8",
http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc4e7f0/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js b/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js
index 4718654..4b3fae2 100644
--- a/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js
+++ b/contrib/views/slider/src/main/resources/ui/app/mappers/slider_apps_mapper.js
@@ -239,7 +239,7 @@ App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, {
this.set('isWarningPopupShown', false);
}
- data.items.forEach(function (app) {
+ data.apps.forEach(function (app) {
var componentsId = app.components ? self.parseComponents(app) : [],
configs = app.configs ? self.parseConfigs(app) : {},
quickLinks = self.parseQuickLinks(app),
@@ -285,6 +285,8 @@ App.SliderAppsMapper = App.Mapper.createWithMixins(App.RunPeriodically, {
appRecord.destroyRecord();
}
});
- App.SliderApp.store.pushMany('sliderApp', apps);
+ apps.forEach(function(app) {
+ App.SliderApp.store.push('sliderApp', app, true);
+ });
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc4e7f0/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js b/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js
index 3338534..c669744 100644
--- a/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js
+++ b/contrib/views/slider/src/main/resources/ui/app/models/slider_app.js
@@ -34,6 +34,12 @@ App.SliderApp = DS.Model.extend({
status: DS.attr('string'),
/**
+ * Status before performed action
+ * @type {string}
+ */
+ statusBeforeAction: DS.attr('string'),
+
+ /**
* @type {displayStatus}
*/
displayStatus: DS.attr('string'),
@@ -54,6 +60,13 @@ App.SliderApp = DS.Model.extend({
isActionPerformed: DS.attr('boolean'),
/**
+ * @type {boolean}
+ */
+ isActionFinished: function() {
+ return this.get('status') != this.get('statusBeforeAction');
+ }.property('statusBeforeAction', 'status'),
+
+ /**
* @type {String}
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc4e7f0/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_app_controller_test.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_app_controller_test.js b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_app_controller_test.js
index 7437a4f..1dd8b70 100644
--- a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_app_controller_test.js
+++ b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/slider_app_controller_test.js
@@ -562,12 +562,16 @@ test('quickLinksOrdered', function() {
test('Disable Action Button', function() {
expect(6);
-
var controller = this.subject({
- model: Em.Object.create({
+ model: Em.Object.extend({
+ isActionFinished: function() {
+ return this.get('status') != this.get('statusBeforeAction');
+ }.property('statusBeforeAction', 'status')
+ }).create({
id: 'someId',
name: 'SomeName',
- status: 'ACCEPTED'
+ status: 'ACCEPTED',
+ statusBeforeAction: ''
}),
defaultErrorHandler: function() { return true; }
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc4e7f0/contrib/views/slider/src/main/resources/ui/test/unit/mappers/slider_apps_mapper_test.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/test/unit/mappers/slider_apps_mapper_test.js b/contrib/views/slider/src/main/resources/ui/test/unit/mappers/slider_apps_mapper_test.js
index 012951f..3e34c953 100644
--- a/contrib/views/slider/src/main/resources/ui/test/unit/mappers/slider_apps_mapper_test.js
+++ b/contrib/views/slider/src/main/resources/ui/test/unit/mappers/slider_apps_mapper_test.js
@@ -59,7 +59,7 @@ test('parse | add/remove apps', function () {
Em.run(function () {
App.SliderAppsMapper.parse({
- items: [
+ apps: [
{id: '1', type: 't1'},
{id: '2', type: 't2'}
]
@@ -72,7 +72,7 @@ test('parse | add/remove apps', function () {
Em.run(function () {
App.SliderAppsMapper.parse({
- items: [
+ apps: [
{id: '2', type: 't2'},
{id: '3', type: 't3'}
]
@@ -82,4 +82,4 @@ test('parse | add/remove apps', function () {
deepEqual(App.SliderApp.store.all('sliderApp').mapBy('id'), ['2', '3'], 'Delete not-existing app and add new');
-});
\ No newline at end of file
+});