Author: srimanth
Date: Mon Jan 28 23:35:41 2013
New Revision: 1439695
URL: http://svn.apache.org/viewvc?rev=1439695&view=rev
Log:
AMBARI-1272. Controller javascripts need comments. (srimanth)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-web/app/controllers/main/admin/authentication.js
incubator/ambari/trunk/ambari-web/app/controllers/main/admin/user.js
incubator/ambari/trunk/ambari-web/app/controllers/main/host.js
incubator/ambari/trunk/ambari-web/app/controllers/main/host/add_controller.js
incubator/ambari/trunk/ambari-web/app/controllers/main/host/details.js
incubator/ambari/trunk/ambari-web/app/controllers/main/service/add_controller.js
incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js
incubator/ambari/trunk/ambari-web/app/controllers/main/service/item.js
Modified: incubator/ambari/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1439695&r1=1439694&r2=1439695&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Mon Jan 28 23:35:41 2013
@@ -34,6 +34,8 @@ Trunk (unreleased changes):
IMPROVEMENTS
+ AMBARI-1272. Controller javascripts need comments. (srimanth)
+
AMBARI-1271. On Confirm Hosts page, add a link to show the Host Checks popup
in the success message. (yusaku via srimanth)
Modified:
incubator/ambari/trunk/ambari-web/app/controllers/main/admin/authentication.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/authentication.js?rev=1439695&r1=1439694&r2=1439695&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-web/app/controllers/main/admin/authentication.js
(original)
+++
incubator/ambari/trunk/ambari-web/app/controllers/main/admin/authentication.js
Mon Jan 28 23:35:41 2013
@@ -20,6 +20,10 @@ var App = require('app');
App.MainAdminAuthenticationController = Em.Controller.extend({
name:'mainAdminAuthenticationController',
+ /**
+ * save user form after editing
+ * @param event
+ */
save:function (event) {
var form = event.context;
if (form.isValid()) {
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/user.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/user.js?rev=1439695&r1=1439694&r2=1439695&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/user.js
(original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/user.js Mon
Jan 28 23:35:41 2013
@@ -20,6 +20,11 @@ var App = require('app');
App.MainAdminUserController = Em.Controller.extend({
name:'mainAdminUserController',
+
+ /**
+ * send request to the server to delete user if selected user is not current
user
+ * @param event
+ */
deleteRecord:function (event) {
var self = this;
if (event.context.get('userName') == App.get('router').getLoginName()) {
@@ -65,6 +70,14 @@ App.MainAdminUserController = Em.Control
}
});
},
+
+ /**
+ * send request to the server and call callback function with true if
request was success or false if request was failed
+ * @param url
+ * @param method
+ * @param postData
+ * @param callback
+ */
sendCommandToServer : function(url, method, postData, callback){
var url = (App.testMode) ?
'/data/wizard/deploy/poll_1.json' : //content is the same as ours
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/host.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/host.js?rev=1439695&r1=1439694&r2=1439695&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/host.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/host.js Mon Jan 28
23:35:41 2013
@@ -59,6 +59,10 @@ App.MainHostController = Em.ArrayControl
this.set('comeWithFilter', true);
},
+ /**
+ * On click callback for decommission button
+ * @param event
+ */
decommissionButtonPopup:function () {
var self = this;
App.ModalPopup.show({
@@ -75,6 +79,11 @@ App.MainHostController = Em.ArrayControl
}
});
},
+
+ /**
+ * On click callback for delete button
+ * @param event
+ */
deleteButtonPopup:function () {
var self = this;
App.ModalPopup.show({
@@ -91,6 +100,10 @@ App.MainHostController = Em.ArrayControl
}
});
},
+
+ /**
+ * remove selected hosts
+ */
removeHosts:function () {
var hosts = this.get('content');
var selectedHosts = hosts.filterProperty('isChecked', true);
@@ -100,6 +113,10 @@ App.MainHostController = Em.ArrayControl
this.get('fullContent').removeObjects(selectedHosts);
},
+ /**
+ * remove hosts with id equal host_id
+ * @param host_id
+ */
checkRemoved:function (host_id) {
var hosts = this.get('content');
var selectedHosts = hosts.filterProperty('id', host_id);
Modified:
incubator/ambari/trunk/ambari-web/app/controllers/main/host/add_controller.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/host/add_controller.js?rev=1439695&r1=1439694&r2=1439695&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-web/app/controllers/main/host/add_controller.js
(original)
+++
incubator/ambari/trunk/ambari-web/app/controllers/main/host/add_controller.js
Mon Jan 28 23:35:41 2013
@@ -54,13 +54,26 @@ App.AddHostController = App.WizardContro
isWizard: true
}),
+ /**
+ * return new object extended from clusterStatusTemplate
+ * @return Object
+ */
getCluster: function(){
return jQuery.extend({}, this.get('clusterStatusTemplate'), {name:
App.router.getClusterName()});
},
+
+ /**
+ * return new object extended from installOptionsTemplate
+ * @return Object
+ */
getInstallOptions: function(){
return jQuery.extend({}, this.get('installOptionsTemplate'));
},
+ /**
+ * return empty hosts array
+ * @return Array
+ */
getHosts: function(){
return [];
},
@@ -121,6 +134,9 @@ App.AddHostController = App.WizardContro
console.log('addHostController:saveInstalledHosts: save hosts ', hostInfo);
},
+ /**
+ * Load services data from server.
+ */
loadServicesFromServer: function() {
var displayOrderConfig = require('data/services');
var apiUrl = '/stacks/HDP/version/1.2.0';
@@ -248,6 +264,7 @@ App.AddHostController = App.WizardContro
console.log('addHostController.slaveComponentHosts: saved hosts',
slaveComponentHosts);
this.set('content.slaveComponentHosts', slaveComponentHosts);
},
+
/**
* return slaveComponents bound to hosts
* @return {Array}
@@ -317,6 +334,7 @@ App.AddHostController = App.WizardContro
return result;
},
+
/**
* Load master component hosts data for using in required step controllers
*/
@@ -399,6 +417,10 @@ App.AddHostController = App.WizardContro
this.set('content.clients', clients);
console.log("AddHostController.loadClients: loaded list ", clients);
},
+
+ /**
+ * return true if cluster data is loaded and false otherwise
+ */
dataLoading: function () {
var dfd = $.Deferred();
this.connectOutlet('loading');
@@ -410,6 +432,7 @@ App.AddHostController = App.WizardContro
}, 50);
return dfd.promise();
},
+
/**
* Generate clients list for selected services and save it to model
* @param stepController step4WizardController
@@ -462,16 +485,19 @@ App.AddHostController = App.WizardContro
}
},
+ /**
+ * load advanced configs for all selected services
+ */
loadAdvancedConfigs: function () {
this.get('content.services').filterProperty('isSelected',
true).mapProperty('serviceName').forEach(function (_serviceName) {
this.loadAdvancedConfig(_serviceName);
}, this);
},
+
/**
- * Generate serviceProperties save it to localdata
- * called form stepController step6WizardController
+ * load advanced config for one service
+ * @param serviceName
*/
-
loadAdvancedConfig: function (serviceName) {
var self = this;
var url = (App.testMode) ? '/data/wizard/stack/hdp/version01/' +
serviceName + '.json' : App.apiPrefix + '/stacks/HDP/version/1.2.0/services/' +
serviceName; // TODO: get this url from the stack selected by the user in
Install Options page
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/host/details.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/host/details.js?rev=1439695&r1=1439694&r2=1439695&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/host/details.js
(original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/host/details.js Mon
Jan 28 23:35:41 2013
@@ -23,14 +23,26 @@ App.MainHostDetailsController = Em.Contr
content: null,
isFromHosts: false,
+ /**
+ * open dashboard page
+ */
routeHome: function () {
App.router.transitionTo('main.dashboard');
},
+
+ /**
+ * open summary page of the selected service
+ * @param event
+ */
routeToService: function(event){
var service = event.context;
App.router.transitionTo('main.services.service.summary',service);
},
+ /**
+ * set new value to isFromHosts property
+ * @param isFromHosts new value
+ */
setBack: function(isFromHosts){
this.set('isFromHosts', isFromHosts);
},
@@ -72,6 +84,10 @@ App.MainHostDetailsController = Em.Contr
});
},
+ /**
+ * send command to server to start selected host component
+ * @param event
+ */
startComponent: function (event) {
var self = this;
App.ModalPopup.show({
@@ -124,6 +140,11 @@ App.MainHostDetailsController = Em.Contr
}
});
},
+
+ /**
+ * send command to server to stop selected host component
+ * @param event
+ */
stopComponent: function (event) {
var self = this;
App.ModalPopup.show({
@@ -176,6 +197,10 @@ App.MainHostDetailsController = Em.Contr
});
},
+ /**
+ * send command to server to run decommission on DATANODE
+ * @param event
+ */
decommission: function(event){
var self = this;
var decommissionHostNames = this.get('view.decommissionDataNodeHostNames');
@@ -280,6 +305,10 @@ App.MainHostDetailsController = Em.Contr
jQuery.ajax(configsAjax);
},
+ /**
+ * send command to server to run recommission on DATANODE
+ * @param event
+ */
recommission: function(event){
var self = this;
var decommissionHostNames = this.get('view.decommissionDataNodeHostNames');
@@ -354,6 +383,9 @@ App.MainHostDetailsController = Em.Contr
})
},
+ /**
+ * show confirmation popup to delete host
+ */
deleteButtonPopup: function() {
var self = this;
App.ModalPopup.show({
@@ -370,6 +402,10 @@ App.MainHostDetailsController = Em.Contr
}
});
},
+
+ /**
+ * remove host and open hosts page
+ */
removeHost: function () {
App.router.get('mainHostController').checkRemoved(this.get('content.id'));
App.router.transitionTo('hosts');
Modified:
incubator/ambari/trunk/ambari-web/app/controllers/main/service/add_controller.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/service/add_controller.js?rev=1439695&r1=1439694&r2=1439695&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-web/app/controllers/main/service/add_controller.js
(original)
+++
incubator/ambari/trunk/ambari-web/app/controllers/main/service/add_controller.js
Mon Jan 28 23:35:41 2013
@@ -54,6 +54,10 @@ App.AddServiceController = App.WizardCon
isWizard: true
}),
+ /**
+ * return new object extended from clusterStatusTemplate
+ * @return Object
+ */
getCluster: function(){
return jQuery.extend({}, this.get('clusterStatusTemplate'), {name:
App.router.getClusterName()});
},
@@ -106,6 +110,9 @@ App.AddServiceController = App.WizardCon
console.log('AddServiceController:saveInstalledHosts: save hosts ',
hostInfo);
},
+ /**
+ * Load services data from server.
+ */
loadServicesFromServer: function() {
var displayOrderConfig = require('data/services');
var apiUrl = '/stacks/HDP/version/1.2.0';
@@ -279,6 +286,7 @@ App.AddServiceController = App.WizardCon
console.log('addServiceController.slaveComponentHosts: saved hosts',
slaveComponentHosts);
this.set('content.slaveComponentHosts', slaveComponentHosts);
},
+
/**
* return slaveComponents bound to hosts
* @return {Array}
@@ -354,6 +362,7 @@ App.AddServiceController = App.WizardCon
return result;
},
+
/**
* Load master component hosts data for using in required step controllers
*/
@@ -436,6 +445,10 @@ App.AddServiceController = App.WizardCon
this.set('content.clients', clients);
console.log("AddServiceController.loadClients: loaded list ", clients);
},
+
+ /**
+ * return true if cluster data is loaded and false otherwise
+ */
dataLoading: function(){
var dfd = $.Deferred();
this.connectOutlet('loading');
@@ -451,6 +464,7 @@ App.AddServiceController = App.WizardCon
}
return dfd.promise();
},
+
/**
* Generate clients list for selected services and save it to model
* @param stepController step4WizardController
@@ -500,16 +514,19 @@ App.AddServiceController = App.WizardCon
}
},
+ /**
+ * load advanced configs for all selected services
+ */
loadAdvancedConfigs: function () {
App.db.getSelectedServiceNames().forEach(function (_serviceName) {
this.loadAdvancedConfig(_serviceName);
}, this);
},
+
/**
- * Generate serviceProperties save it to localdata
- * called form stepController step6WizardController
+ * load advanced config for one service
+ * @param serviceName
*/
-
loadAdvancedConfig: function (serviceName) {
var self = this;
var url = (App.testMode) ? '/data/wizard/stack/hdp/version01/' +
serviceName + '.json' : App.apiPrefix + '/stacks/HDP/version/1.2.0/services/' +
serviceName; // TODO: get this url from the stack selected by the user in
Install Options page
Modified:
incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js?rev=1439695&r1=1439694&r2=1439695&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js
(original)
+++
incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js
Mon Jan 28 23:35:41 2013
@@ -40,6 +40,9 @@ App.MainServiceInfoConfigsController = E
slaveComponentGroups: null,
+ /**
+ * clear and set properties to default value
+ */
clearStep: function () {
this.set('dataIsLoaded', false);
this.get('stepConfigs').clear();
@@ -339,7 +342,12 @@ App.MainServiceInfoConfigsController = E
return serviceConfigs;
},
-
+ /**
+ * return site config properties
+ * @param sitename
+ * @param tagname
+ * @return {Object}
+ */
getSiteConfigProperties: function (sitename, tagname) {
var self = this;
var properties = {};
@@ -425,6 +433,9 @@ App.MainServiceInfoConfigsController = E
}, this);
},
+ /**
+ * open popup with appropriate message
+ */
restartServicePopup: function (event) {
var header;
var message;
@@ -551,6 +562,10 @@ App.MainServiceInfoConfigsController = E
return result;
},
+ /**
+ * save new or change exist configs in global configs
+ * @param configs
+ */
saveGlobalConfigs: function (configs) {
var globalConfigs = this.get('globalConfigs');
configs.filterProperty('id', 'puppet var').forEach(function (_config) {
@@ -568,6 +583,10 @@ App.MainServiceInfoConfigsController = E
this.set('globalConfigs', globalConfigs);
},
+ /**
+ * set hive hostnames in global configs
+ * @param globals
+ */
setHiveHostName: function (globals) {
if (globals.someProperty('name', 'hive_database')) {
//TODO: Hive host depends on the type of db selected. Change puppet
variable name if postgres is not the default db
@@ -586,12 +605,20 @@ App.MainServiceInfoConfigsController = E
}
},
+ /**
+ * save site configs
+ * @param configs
+ */
saveSiteConfigs: function (configs) {
var storedConfigs = configs.filterProperty('id', 'site
property').filterProperty('value');
var uiConfigs = this.loadUiSideConfigs();
this.set('uiConfigs', storedConfigs.concat(uiConfigs));
},
+ /**
+ * return configs from the UI side
+ * @return {Array}
+ */
loadUiSideConfigs: function () {
var uiConfig = [];
var configs = this.get('configMapping').filterProperty('foreignKey', null);
@@ -618,10 +645,14 @@ App.MainServiceInfoConfigsController = E
}, this);
return uiConfig;
},
+
/**
- * Set all site property that are derived from other puppet-variable
+ * return global config value
+ * @param templateName
+ * @param expression
+ * @param name
+ * @return {*}
*/
-
getGlobConfigValue: function (templateName, expression, name) {
var express = expression.match(/<(.*?)>/g);
var value = expression;
@@ -724,6 +755,11 @@ App.MainServiceInfoConfigsController = E
}, this);
}
},
+
+ /**
+ * try to create configuration and return true for success or false for
failure
+ * @return {Boolean}
+ */
createConfigurations: function () {
var result = true;
var serviceConfigTags = this.get('serviceConfigTags');
@@ -744,6 +780,10 @@ App.MainServiceInfoConfigsController = E
return result;
},
+ /**
+ * add newTagName property to each config in serviceConfigs
+ * @param serviceConfigs
+ */
setNewTagNames: function (serviceConfigs) {
var time = (new Date).getTime();
serviceConfigs.forEach(function (_serviceConfigs) {
@@ -751,6 +791,11 @@ App.MainServiceInfoConfigsController = E
}, this);
},
+ /**
+ * send request to the server to create configs and return true for success
and false for failure
+ * @param data
+ * @return {*}
+ */
createConfigSite: function (data) {
var result;
var realData = data;
@@ -787,6 +832,11 @@ App.MainServiceInfoConfigsController = E
return result;
},
+ /**
+ * create global site object
+ * @param tagName
+ * @return {Object}
+ */
createGlobalSiteObj: function (tagName) {
var globalSiteProperties = {};
this.get('globalConfigs').forEach(function (_globalSiteObj) {
@@ -804,6 +854,11 @@ App.MainServiceInfoConfigsController = E
return {"type": "global", "tag": tagName, "properties":
globalSiteProperties};
},
+ /**
+ * create core site object
+ * @param tagName
+ * @return {Object}
+ */
createCoreSiteObj: function (tagName) {
var coreSiteObj = this.get('uiConfigs').filterProperty('filename',
'core-site.xml');
var coreSiteProperties = {};
@@ -824,6 +879,12 @@ App.MainServiceInfoConfigsController = E
return {"type": "core-site", "tag": tagName, "properties":
coreSiteProperties};
},
+ /**
+ * create site object
+ * @param siteName
+ * @param tagName
+ * @return {Object}
+ */
createSiteObj: function (siteName, tagName) {
var siteObj = this.get('uiConfigs').filterProperty('filename', siteName +
'.xml');
var siteProperties = {};
@@ -833,6 +894,11 @@ App.MainServiceInfoConfigsController = E
return {"type": siteName, "tag": tagName, "properties": siteProperties};
},
+ /**
+ * apply created configs to service and return true for success and false
for failure
+ * @param serviceName
+ * @return {*}
+ */
applyCreatedConfToService: function (serviceName) {
var result;
var clusterName = App.router.getClusterName();
@@ -867,6 +933,11 @@ App.MainServiceInfoConfigsController = E
return result;
},
+ /**
+ * return config for service
+ * @param serviceName
+ * @return {Object}
+ */
getConfigForService: function (serviceName) {
var data = {config: {}};
this.get('serviceConfigTags').forEach(function (_serviceTag) {
@@ -883,6 +954,10 @@ App.MainServiceInfoConfigsController = E
return data;
},
+ /**
+ * return custom comfig
+ * @return {Object}
+ */
setCustomConfigs: function () {
var site = this.get('stepConfigs').findProperty('serviceName',
this.get('content.serviceName')).get('configs').filterProperty('id',
'conf-site');
var siteProperties = [];
@@ -961,6 +1036,12 @@ App.MainServiceInfoConfigsController = E
});
},
+ /**
+ * return either specific url for request if testMode is false or testUrl
+ * @param testUrl
+ * @param url
+ * @return {*}
+ */
getUrl: function (testUrl, url) {
return (App.testMode) ? testUrl : App.apiPrefix + '/clusters/' +
App.router.getClusterName() + url;
},
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/service/item.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/service/item.js?rev=1439695&r1=1439694&r2=1439695&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/service/item.js
(original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/service/item.js Mon
Jan 28 23:35:41 2013
@@ -173,6 +173,11 @@ App.MainServiceItemController = Em.Contr
}
});
},
+
+ /**
+ * On click callback for <code>run rebalancer</code> button
+ * @param event
+ */
runRebalancer: function (event) {
var self = this;
App.ModalPopup.show({
@@ -190,6 +195,11 @@ App.MainServiceItemController = Em.Contr
}
});
},
+
+ /**
+ * On click callback for <code>run compaction</code> button
+ * @param event
+ */
runCompaction: function (event) {
var self = this;
App.ModalPopup.show({
@@ -207,6 +217,11 @@ App.MainServiceItemController = Em.Contr
}
});
},
+
+ /**
+ * On click callback for <code>run smoke test</code> button
+ * @param event
+ */
runSmokeTest: function (event) {
var self = this;
App.ModalPopup.show({
@@ -236,6 +251,11 @@ App.MainServiceItemController = Em.Contr
}
});
},
+
+ /**
+ * On click callback for <code>action</code> dropdown menu
+ * @param event
+ */
doAction: function (event) {
if ($(event.target).hasClass('disabled') ||
$(event.target.parentElement).hasClass('disabled')) {
return;