You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2014/02/25 13:59:26 UTC
git commit: AMBARI-4816. Mixin for userPref. (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 5be623515 -> be70f78c4
AMBARI-4816. Mixin for userPref. (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/be70f78c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/be70f78c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/be70f78c
Branch: refs/heads/trunk
Commit: be70f78c4c3de55b871e52d9a1c43cc19b219541
Parents: 5be6235
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Tue Feb 25 14:57:23 2014 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Tue Feb 25 14:57:23 2014 +0200
----------------------------------------------------------------------
ambari-web/app/controllers/application.js | 34 +--
ambari-web/app/initialize.js | 1 +
ambari-web/app/mixins.js | 23 ++
ambari-web/app/mixins/common/userPref.js | 102 ++++++++
.../details/host_components/decommissionable.js | 253 +++++++++++++++++++
ambari-web/app/utils/ajax.js | 28 +-
ambari-web/app/views/common/table_view.js | 38 +--
ambari-web/app/views/main/dashboard.js | 38 +--
.../host_component_views/datanode_view.js | 1 -
.../host_component_views/decommissionable.js | 253 -------------------
.../host_component_views/nodemanager_view.js | 1 -
.../host_component_views/regionserver_view.js | 1 -
.../host_component_views/tasktracker_view.js | 1 -
13 files changed, 392 insertions(+), 382 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/controllers/application.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/application.js b/ambari-web/app/controllers/application.js
index ae329e4..0eea0cb 100644
--- a/ambari-web/app/controllers/application.js
+++ b/ambari-web/app/controllers/application.js
@@ -19,7 +19,7 @@
var App = require('app');
-App.ApplicationController = Em.Controller.extend({
+App.ApplicationController = Em.Controller.extend(App.UserPref, {
name: 'applicationController',
@@ -64,20 +64,6 @@ App.ApplicationController = Em.Controller.extend({
},
currentPrefObject: null,
- /**
- * get persist value from server with persistKey
- */
- getUserPref: function(key){
- return App.ajax.send({
- name: 'settings.get.user_pref',
- sender: this,
- data: {
- key: key
- },
- success: 'getUserPrefSuccessCallback',
- error: 'getUserPrefErrorCallback'
- });
- },
getUserPrefSuccessCallback: function (response, request, data) {
if (response != null) {
console.log('Got persist value from server with key ' + data.key + '. Value is: ' + response);
@@ -94,24 +80,6 @@ App.ApplicationController = Em.Controller.extend({
return true;
}
},
- /**
- * post persist key/value to server, value is object
- */
- postUserPref: function (key, value) {
- var keyValuePair = {};
- keyValuePair[key] = JSON.stringify(value);
- App.ajax.send({
- 'name': 'settings.post.user_pref',
- 'sender': this,
- 'beforeSend': 'postUserPrefBeforeSend',
- 'data': {
- 'keyValuePair': keyValuePair
- }
- });
- },
- postUserPrefBeforeSend: function(request, ajaxOptions, data){
- console.log('BeforeSend to persist: persistKeyValues', data.keyValuePair);
- },
showSettingsPopup: function() {
// Settings only for admins
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/initialize.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/initialize.js b/ambari-web/app/initialize.js
index c24e4b1..777779a 100644
--- a/ambari-web/app/initialize.js
+++ b/ambari-web/app/initialize.js
@@ -26,6 +26,7 @@ require('utils/base64');
require('utils/db');
require('utils/helper');
require('utils/config');
+require('mixins');
require('models');
require('controllers');
require('templates');
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/mixins.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js
new file mode 100644
index 0000000..c437c2a
--- /dev/null
+++ b/ambari-web/app/mixins.js
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+// load all mixins here
+
+require('mixins/common/userPref');
+require('mixins/main/host/details/host_components/decommissionable');
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/mixins/common/userPref.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/userPref.js b/ambari-web/app/mixins/common/userPref.js
new file mode 100644
index 0000000..ea8c358
--- /dev/null
+++ b/ambari-web/app/mixins/common/userPref.js
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+/**
+ * Small mixin for processing user preferences
+ * Provide methods to save/load some values in <code>persist</code> storage
+ * When using this mixin you should redeclare methods:
+ * <ul>
+ * <li>getUserPrefSuccessCallback</li>
+ * <li>getUserPrefErrorCallback</li>
+ * </ul>
+ * @type {Em.Mixin}
+ */
+App.UserPref = Em.Mixin.create({
+
+ /**
+ * Should <code>getUserPref</code> and <code>postUserPref</code> be async
+ * @type {bool}
+ */
+ makeRequestAsync: true,
+
+ /**
+ * Get persist value from server with persistKey
+ * @param {String} key
+ */
+ getUserPref: function(key) {
+ return App.ajax.send({
+ name: 'settings.get.user_pref',
+ sender: this,
+ data: {
+ key: key,
+ async: this.get('makeRequestAsync')
+ },
+ success: 'getUserPrefSuccessCallback',
+ error: 'getUserPrefErrorCallback'
+ });
+ },
+
+ /**
+ * Should be redeclared in objects that use this mixin
+ * @param {*} response
+ * @param {Object} request
+ * @param {Object} data
+ * @returns {*}
+ */
+ getUserPrefSuccessCallback: function (response, request, data) {},
+
+ /**
+ * Should be redeclared in objects that use this mixin
+ * @param {Object} request
+ * @param {Object} ajaxOptions
+ * @param {String} error
+ */
+ getUserPrefErrorCallback: function (request, ajaxOptions, error) {},
+
+ /**
+ * Post persist key/value to server, value is object
+ * @param {String} key
+ * @param {Object} value
+ */
+ postUserPref: function (key, value) {
+ var keyValuePair = {};
+ keyValuePair[key] = JSON.stringify(value);
+ App.ajax.send({
+ 'name': 'settings.post.user_pref',
+ 'sender': this,
+ 'beforeSend': 'postUserPrefBeforeSend',
+ 'data': {
+ 'async': this.get('makeRequestAsync'),
+ 'keyValuePair': keyValuePair
+ }
+ });
+ },
+
+ /**
+ * Little log before post request
+ * @param {Object} request
+ * @param {Object} ajaxOptions
+ * @param {Object} data
+ */
+ postUserPrefBeforeSend: function(request, ajaxOptions, data){
+ console.log('BeforeSend to persist: persistKeyValues', data.keyValuePair);
+ }
+
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js b/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
new file mode 100644
index 0000000..6da5d7c
--- /dev/null
+++ b/ambari-web/app/mixins/main/host/details/host_components/decommissionable.js
@@ -0,0 +1,253 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+var uiEffects = require('utils/ui_effects');
+
+/**
+ * Mixin for <code>App.HostComponentView</code>
+ * Contains code for processing components with allowed decommission
+ * @type {Em.Mixin}
+ */
+App.Decommissionable = Em.Mixin.create({
+
+ /**
+ * Should be redeclared in views that use this mixin
+ * @type {String}
+ */
+ componentForCheckDecommission: '',
+
+ /**
+ * Received from server object with data about decommission
+ * @type {Object}
+ */
+ decommissionedStatusObject: null,
+
+ /**
+ * Received from server desired_admin_state value
+ * @type {String}
+ */
+ desiredAdminState: null,
+
+ /**
+ * Is component in decommission process right know
+ * @type {bool}
+ */
+ isComponentDecommissioning: null,
+
+ /**
+ * May conponent be decommissioned
+ * @type {bool}
+ */
+ isComponentDecommissionAvailable: null,
+
+ /**
+ * May component be recommissioned
+ * @type {bool}
+ */
+ isComponentRecommissionAvailable: null,
+
+ /**
+ * Recalculated component status based on decommission
+ * @type {string}
+ */
+ statusClass: function () {
+
+ //Class when install failed
+ if (this.get('workStatus') === App.HostComponentStatus.install_failed) {
+ return 'health-status-color-red icon-cog';
+ }
+
+ //Class when installing
+ if (this.get('workStatus') === App.HostComponentStatus.installing) {
+ return 'health-status-color-blue icon-cog';
+ }
+
+ //Class when maintenance
+ if (this.get('content.passiveState') != "OFF") {
+ return 'icon-medkit';
+ }
+
+ if (this.get('isComponentRecommissionAvailable') && (this.get('isStart') || this.get('workStatus') == 'INSTALLED')) {
+ return 'health-status-DEAD-ORANGE';
+ }
+
+ //For all other cases
+ return 'health-status-' + App.HostComponentStatus.getKeyName(this.get('workStatus'));
+
+ }.property('content.passiveState','workStatus', 'isComponentRecommissionAvailable', 'isComponentDecommissioning'),
+
+ /**
+ * Return host component text status
+ * @type {String}
+ */
+ componentTextStatus: function () {
+ var componentTextStatus = this.get('content.componentTextStatus');
+ var hostComponent = this.get('hostComponent');
+ if (hostComponent) {
+ componentTextStatus = hostComponent.get('componentTextStatus');
+ if(this.get('isComponentRecommissionAvailable')){
+ if(this.get('isComponentDecommissioning')){
+ componentTextStatus = Em.I18n.t('hosts.host.decommissioning');
+ } else {
+ componentTextStatus = Em.I18n.t('hosts.host.decommissioned');
+ }
+ }
+ }
+ return componentTextStatus;
+ }.property('content.passiveState','workStatus','isComponentRecommissionAvailable','isComponentDecommissioning'),
+
+ /**
+ * For Stopping or Starting states, also for decommissioning
+ * @type {bool}
+ */
+ isInProgress: function () {
+ return (this.get('workStatus') === App.HostComponentStatus.stopping ||
+ this.get('workStatus') === App.HostComponentStatus.starting) ||
+ this.get('isDecommissioning');
+ }.property('workStatus', 'isDecommissioning'),
+
+ /**
+ * Get desired_admin_state status from server
+ */
+ getDesiredAdminState: function(){
+ return App.ajax.send({
+ name: 'host.host_component.slave_desired_admin_state',
+ sender: this,
+ data: {
+ hostName: this.get('content.host.hostName'),
+ componentName: this.get('content.componentName')
+ },
+ success: 'getDesiredAdminStateSuccessCallback',
+ error: 'getDesiredAdminStateErrorCallback'
+ });
+ },
+
+ /**
+ * Set received value or null to <code>desiredAdminState</code>
+ * @param {Object} response
+ * @returns {String|null}
+ */
+ getDesiredAdminStateSuccessCallback: function (response) {
+ var status = response.HostRoles.desired_admin_state;
+ if ( status != null) {
+ this.set('desiredAdminState', status);
+ return status;
+ }
+ return null;
+ },
+
+ /**
+ * Set null to <code>desiredAdminState</code> if server returns error
+ * @returns {null}
+ */
+ getDesiredAdminStateErrorCallback: function () {
+ this.set('desiredAdminState', null);
+ return null;
+ },
+
+ /**
+ * Get component decommission status from server
+ * @returns {$.ajax}
+ */
+ getDecommissionStatus: function() {
+ return App.ajax.send({
+ name: 'host.host_component.decommission_status',
+ sender: this,
+ data: {
+ hostName: this.get('content.host.hostName'),
+ componentName: this.get('componentForCheckDecommission'),
+ serviceName: this.get('content.service.serviceName')
+ },
+ success: 'getDecommissionStatusSuccessCallback',
+ error: 'getDecommissionStatusErrorCallback'
+ });
+ },
+
+ /**
+ * Set received value or null to <code>decommissionedStatusObject</code>
+ * @param {Object} response
+ * @returns {Object|null}
+ */
+ getDecommissionStatusSuccessCallback: function (response) {
+ var statusObject = response.ServiceComponentInfo;
+ if ( statusObject != null) {
+ this.set('decommissionedStatusObject', statusObject);
+ return statusObject;
+ }
+ return null;
+ },
+
+ /**
+ * Set null to <code>decommissionedStatusObject</code> if server returns error
+ * @returns {null}
+ */
+ getDecommissionStatusErrorCallback: function () {
+ this.set('decommissionedStatusObject', null);
+ return null;
+ },
+
+ /**
+ * Do blinking for 1 minute
+ */
+ doBlinking: function () {
+ var workStatus = this.get('workStatus');
+ var self = this;
+ var pulsate = [App.HostComponentStatus.starting, App.HostComponentStatus.stopping, App.HostComponentStatus.installing].contains(workStatus);
+ if (!pulsate) {
+ var component = this.get('content');
+ if (component && workStatus != "INSTALLED") {
+ pulsate = this.get('isDecommissioning');
+ }
+ }
+ if (pulsate && !self.get('isBlinking')) {
+ self.set('isBlinking', true);
+ uiEffects.pulsate(self.$('.components-health'), 1000, function () {
+ self.set('isBlinking', false);
+ self.doBlinking();
+ });
+ }
+ },
+
+ /**
+ * Start blinking when host component is starting/stopping/decommissioning
+ */
+ startBlinking: function () {
+ this.$('.components-health').stop(true, true);
+ this.$('.components-health').css({opacity: 1.0});
+ this.doBlinking();
+ }.observes('workStatus','isComponentRecommissionAvailable', 'isDecommissioning'),
+
+ /**
+ * Should be redeclared in views that use this mixin
+ */
+ loadComponentDecommissionStatus: function() {},
+
+ didInsertElement: function() {
+ this._super();
+ this.loadComponentDecommissionStatus();
+ },
+
+ /**
+ * Update Decommission status only one time when component was changed
+ */
+ updateDecommissionStatus: function() {
+ Em.run.once(this, 'loadComponentDecommissionStatus');
+ }.observes('content.workStatus', 'content.passiveState')
+
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index 396ad16..f7ea0f8 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/ambari-web/app/utils/ajax.js
@@ -756,7 +756,12 @@ var urls = {
},
'settings.get.user_pref': {
'real': '/persist/{key}',
- 'mock': '/data/user_settings/{key}.json'
+ 'mock': '/data/user_settings/{key}.json',
+ 'format': function(data) {
+ return {
+ async: data.async
+ };
+ }
},
'settings.post.user_pref': {
'real': '/persist',
@@ -764,6 +769,7 @@ var urls = {
'type': 'POST',
'format': function (data) {
return {
+ async: data.async,
data: JSON.stringify(data.keyValuePair)
}
}
@@ -1334,26 +1340,6 @@ var urls = {
'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock',
'mock': ''
},
- 'dashboard.get.user_pref': {
- 'real': '/persist/{key}',
- 'mock': '',
- 'format': function() {
- return {
- async: false
- };
- }
- },
- 'dashboard.post.user_pref': {
- 'real': '/persist',
- 'mock': '',
- 'type': 'POST',
- 'format': function (data) {
- return {
- async: false,
- data: JSON.stringify(data.keyValuePair)
- }
- }
- },
'config_groups.create': {
'real': '/clusters/{clusterName}/config_groups',
'mock': '',
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/views/common/table_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/table_view.js b/ambari-web/app/views/common/table_view.js
index 19aa3cd..73e7797 100644
--- a/ambari-web/app/views/common/table_view.js
+++ b/ambari-web/app/views/common/table_view.js
@@ -20,7 +20,7 @@ var App = require('app');
var filters = require('views/common/filter_view');
var sort = require('views/common/sort_view');
-App.TableView = Em.View.extend({
+App.TableView = Em.View.extend(App.UserPref, {
/**
* Shows if all data is loaded and filtered
@@ -110,28 +110,13 @@ App.TableView = Em.View.extend({
},
/**
- * get display length persist value from server with displayLengthKey
- */
- getUserPref: function(key){
- return App.ajax.send({
- name: 'settings.get.user_pref',
- sender: this,
- data: {
- key: key
- },
- success: 'getDisplayLengthSuccessCallback',
- error: 'getDisplayLengthErrorCallback'
- });
- },
-
- /**
* Set received from server value to <code>displayLengthOnLoad</code>
* @param {Number} response
* @param {Object} request
* @param {Object} data
* @returns {*}
*/
- getDisplayLengthSuccessCallback: function (response, request, data) {
+ getUserPrefSuccessCallback: function (response, request, data) {
console.log('Got DisplayLength value from server with key ' + data.key + '. Value is: ' + response);
this.set('displayLengthOnLoad', response);
return response;
@@ -141,7 +126,7 @@ App.TableView = Em.View.extend({
* Set default value to <code>displayLengthOnLoad</code> (and send it on server) if value wasn't found on server
* @returns {Number}
*/
- getDisplayLengthErrorCallback: function () {
+ getUserPrefErrorCallback: function () {
// this user is first time login
console.log('Persist did NOT find the key');
var displayLengthDefault = "10";
@@ -153,23 +138,6 @@ App.TableView = Em.View.extend({
},
/**
- * Post display length persist key/value to server
- * @param {String} key
- * @param {Object} value
- */
- postUserPref: function (key, value) {
- var keyValuePair = {};
- keyValuePair[key] = JSON.stringify(value);
- App.ajax.send({
- name: 'settings.post.user_pref',
- sender: this,
- data: {
- keyValuePair: keyValuePair
- }
- });
- },
-
- /**
* Do pagination after filtering and sorting
* Don't call this method! It's already used where it's need
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/views/main/dashboard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard.js b/ambari-web/app/views/main/dashboard.js
index 33cd2bd..ad49d27 100644
--- a/ambari-web/app/views/main/dashboard.js
+++ b/ambari-web/app/views/main/dashboard.js
@@ -19,7 +19,7 @@
var App = require('app');
var filters = require('views/common/filter_view');
-App.MainDashboardView = Em.View.extend({
+App.MainDashboardView = Em.View.extend(App.UserPref, {
templateName:require('templates/main/dashboard'),
didInsertElement:function () {
this.services();
@@ -404,20 +404,7 @@ App.MainDashboardView = Em.View.extend({
return 'user-pref-' + loginName + '-dashboard';
}.property(''),
- /**
- * get persist value from server with persistKey
- */
- getUserPref: function(key){
- App.ajax.send({
- name: 'dashboard.get.user_pref',
- sender: this,
- data: {
- key: key
- },
- success: 'getUserPrefSuccessCallback',
- error: 'getUserPrefErrorCallback'
- });
- },
+ makeRequestAsync: false,
getUserPrefSuccessCallback: function (response, request, data) {
if (response) {
@@ -434,27 +421,6 @@ App.MainDashboardView = Em.View.extend({
}
},
- /**
- * post persist key/value to server, value is object
- */
- postUserPref: function (key, value) {
- var keyValuePair = {};
- keyValuePair[key] = JSON.stringify(value);
-
- App.ajax.send({
- 'name': 'dashboard.post.user_pref',
- 'sender': this,
- 'beforeSend': 'postUserPrefBeforeSend',
- 'data': {
- 'keyValuePair': keyValuePair
- }
- });
- },
-
- postUserPrefBeforeSend: function(request, ajaxOptions, data){
- console.log('BeforeSend to persist: persistKeyValues', data.keyValuePair);
- },
-
resetAllWidgets: function(){
var self = this;
App.showConfirmationPopup(function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/views/main/host/details/host_component_views/datanode_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/details/host_component_views/datanode_view.js b/ambari-web/app/views/main/host/details/host_component_views/datanode_view.js
index a2b1c04..e0ee4f0 100644
--- a/ambari-web/app/views/main/host/details/host_component_views/datanode_view.js
+++ b/ambari-web/app/views/main/host/details/host_component_views/datanode_view.js
@@ -17,7 +17,6 @@
*/
var App = require('app');
-require('views/main/host/details/host_component_views/decommissionable');
App.DataNodeComponentView = App.HostComponentView.extend(App.Decommissionable, {
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/views/main/host/details/host_component_views/decommissionable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/details/host_component_views/decommissionable.js b/ambari-web/app/views/main/host/details/host_component_views/decommissionable.js
deleted file mode 100644
index 6da5d7c..0000000
--- a/ambari-web/app/views/main/host/details/host_component_views/decommissionable.js
+++ /dev/null
@@ -1,253 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var App = require('app');
-var uiEffects = require('utils/ui_effects');
-
-/**
- * Mixin for <code>App.HostComponentView</code>
- * Contains code for processing components with allowed decommission
- * @type {Em.Mixin}
- */
-App.Decommissionable = Em.Mixin.create({
-
- /**
- * Should be redeclared in views that use this mixin
- * @type {String}
- */
- componentForCheckDecommission: '',
-
- /**
- * Received from server object with data about decommission
- * @type {Object}
- */
- decommissionedStatusObject: null,
-
- /**
- * Received from server desired_admin_state value
- * @type {String}
- */
- desiredAdminState: null,
-
- /**
- * Is component in decommission process right know
- * @type {bool}
- */
- isComponentDecommissioning: null,
-
- /**
- * May conponent be decommissioned
- * @type {bool}
- */
- isComponentDecommissionAvailable: null,
-
- /**
- * May component be recommissioned
- * @type {bool}
- */
- isComponentRecommissionAvailable: null,
-
- /**
- * Recalculated component status based on decommission
- * @type {string}
- */
- statusClass: function () {
-
- //Class when install failed
- if (this.get('workStatus') === App.HostComponentStatus.install_failed) {
- return 'health-status-color-red icon-cog';
- }
-
- //Class when installing
- if (this.get('workStatus') === App.HostComponentStatus.installing) {
- return 'health-status-color-blue icon-cog';
- }
-
- //Class when maintenance
- if (this.get('content.passiveState') != "OFF") {
- return 'icon-medkit';
- }
-
- if (this.get('isComponentRecommissionAvailable') && (this.get('isStart') || this.get('workStatus') == 'INSTALLED')) {
- return 'health-status-DEAD-ORANGE';
- }
-
- //For all other cases
- return 'health-status-' + App.HostComponentStatus.getKeyName(this.get('workStatus'));
-
- }.property('content.passiveState','workStatus', 'isComponentRecommissionAvailable', 'isComponentDecommissioning'),
-
- /**
- * Return host component text status
- * @type {String}
- */
- componentTextStatus: function () {
- var componentTextStatus = this.get('content.componentTextStatus');
- var hostComponent = this.get('hostComponent');
- if (hostComponent) {
- componentTextStatus = hostComponent.get('componentTextStatus');
- if(this.get('isComponentRecommissionAvailable')){
- if(this.get('isComponentDecommissioning')){
- componentTextStatus = Em.I18n.t('hosts.host.decommissioning');
- } else {
- componentTextStatus = Em.I18n.t('hosts.host.decommissioned');
- }
- }
- }
- return componentTextStatus;
- }.property('content.passiveState','workStatus','isComponentRecommissionAvailable','isComponentDecommissioning'),
-
- /**
- * For Stopping or Starting states, also for decommissioning
- * @type {bool}
- */
- isInProgress: function () {
- return (this.get('workStatus') === App.HostComponentStatus.stopping ||
- this.get('workStatus') === App.HostComponentStatus.starting) ||
- this.get('isDecommissioning');
- }.property('workStatus', 'isDecommissioning'),
-
- /**
- * Get desired_admin_state status from server
- */
- getDesiredAdminState: function(){
- return App.ajax.send({
- name: 'host.host_component.slave_desired_admin_state',
- sender: this,
- data: {
- hostName: this.get('content.host.hostName'),
- componentName: this.get('content.componentName')
- },
- success: 'getDesiredAdminStateSuccessCallback',
- error: 'getDesiredAdminStateErrorCallback'
- });
- },
-
- /**
- * Set received value or null to <code>desiredAdminState</code>
- * @param {Object} response
- * @returns {String|null}
- */
- getDesiredAdminStateSuccessCallback: function (response) {
- var status = response.HostRoles.desired_admin_state;
- if ( status != null) {
- this.set('desiredAdminState', status);
- return status;
- }
- return null;
- },
-
- /**
- * Set null to <code>desiredAdminState</code> if server returns error
- * @returns {null}
- */
- getDesiredAdminStateErrorCallback: function () {
- this.set('desiredAdminState', null);
- return null;
- },
-
- /**
- * Get component decommission status from server
- * @returns {$.ajax}
- */
- getDecommissionStatus: function() {
- return App.ajax.send({
- name: 'host.host_component.decommission_status',
- sender: this,
- data: {
- hostName: this.get('content.host.hostName'),
- componentName: this.get('componentForCheckDecommission'),
- serviceName: this.get('content.service.serviceName')
- },
- success: 'getDecommissionStatusSuccessCallback',
- error: 'getDecommissionStatusErrorCallback'
- });
- },
-
- /**
- * Set received value or null to <code>decommissionedStatusObject</code>
- * @param {Object} response
- * @returns {Object|null}
- */
- getDecommissionStatusSuccessCallback: function (response) {
- var statusObject = response.ServiceComponentInfo;
- if ( statusObject != null) {
- this.set('decommissionedStatusObject', statusObject);
- return statusObject;
- }
- return null;
- },
-
- /**
- * Set null to <code>decommissionedStatusObject</code> if server returns error
- * @returns {null}
- */
- getDecommissionStatusErrorCallback: function () {
- this.set('decommissionedStatusObject', null);
- return null;
- },
-
- /**
- * Do blinking for 1 minute
- */
- doBlinking: function () {
- var workStatus = this.get('workStatus');
- var self = this;
- var pulsate = [App.HostComponentStatus.starting, App.HostComponentStatus.stopping, App.HostComponentStatus.installing].contains(workStatus);
- if (!pulsate) {
- var component = this.get('content');
- if (component && workStatus != "INSTALLED") {
- pulsate = this.get('isDecommissioning');
- }
- }
- if (pulsate && !self.get('isBlinking')) {
- self.set('isBlinking', true);
- uiEffects.pulsate(self.$('.components-health'), 1000, function () {
- self.set('isBlinking', false);
- self.doBlinking();
- });
- }
- },
-
- /**
- * Start blinking when host component is starting/stopping/decommissioning
- */
- startBlinking: function () {
- this.$('.components-health').stop(true, true);
- this.$('.components-health').css({opacity: 1.0});
- this.doBlinking();
- }.observes('workStatus','isComponentRecommissionAvailable', 'isDecommissioning'),
-
- /**
- * Should be redeclared in views that use this mixin
- */
- loadComponentDecommissionStatus: function() {},
-
- didInsertElement: function() {
- this._super();
- this.loadComponentDecommissionStatus();
- },
-
- /**
- * Update Decommission status only one time when component was changed
- */
- updateDecommissionStatus: function() {
- Em.run.once(this, 'loadComponentDecommissionStatus');
- }.observes('content.workStatus', 'content.passiveState')
-
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/views/main/host/details/host_component_views/nodemanager_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/details/host_component_views/nodemanager_view.js b/ambari-web/app/views/main/host/details/host_component_views/nodemanager_view.js
index 16fadc9..37e360b 100644
--- a/ambari-web/app/views/main/host/details/host_component_views/nodemanager_view.js
+++ b/ambari-web/app/views/main/host/details/host_component_views/nodemanager_view.js
@@ -17,7 +17,6 @@
*/
var App = require('app');
-require('views/main/host/details/host_component_views/decommissionable');
App.NodeManagerComponentView = App.HostComponentView.extend(App.Decommissionable, {
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/views/main/host/details/host_component_views/regionserver_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/details/host_component_views/regionserver_view.js b/ambari-web/app/views/main/host/details/host_component_views/regionserver_view.js
index 0d166dd..3d3720b 100644
--- a/ambari-web/app/views/main/host/details/host_component_views/regionserver_view.js
+++ b/ambari-web/app/views/main/host/details/host_component_views/regionserver_view.js
@@ -17,7 +17,6 @@
*/
var App = require('app');
-require('views/main/host/details/host_component_views/decommissionable');
App.RegionServerComponentView = App.HostComponentView.extend(App.Decommissionable, {
http://git-wip-us.apache.org/repos/asf/ambari/blob/be70f78c/ambari-web/app/views/main/host/details/host_component_views/tasktracker_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/details/host_component_views/tasktracker_view.js b/ambari-web/app/views/main/host/details/host_component_views/tasktracker_view.js
index 7948ef4..991ed6f 100644
--- a/ambari-web/app/views/main/host/details/host_component_views/tasktracker_view.js
+++ b/ambari-web/app/views/main/host/details/host_component_views/tasktracker_view.js
@@ -17,7 +17,6 @@
*/
var App = require('app');
-require('views/main/host/details/host_component_views/decommissionable');
App.TaskTrackerComponentView = App.HostComponentView.extend(App.Decommissionable, {