|
@@ -22,195 +22,285 @@ App.HostTableMenuView = Em.View.extend({
|
|
|
|
|
|
templateName: require('templates/main/host/bulk_operation_menu'),
|
|
|
|
|
|
+ menuItems: function () {
|
|
|
+ return {
|
|
|
+ s: {label: Em.I18n.t('hosts.table.menu.l1.selectedHosts')},
|
|
|
+ f: {label: Em.I18n.t('hosts.table.menu.l1.filteredHosts')},
|
|
|
+ a: {label: Em.I18n.t('hosts.table.menu.l1.allHosts')}
|
|
|
+ };
|
|
|
+ }.property('App.router.clusterController.isLoaded'),
|
|
|
+
|
|
|
+ components: function(){
|
|
|
+ var menuItems = [
|
|
|
+ Em.Object.create({
|
|
|
+ serviceName: 'HDFS',
|
|
|
+ componentName: 'DATANODE',
|
|
|
+ masterComponentName: 'NAMENODE',
|
|
|
+ componentNameFormatted: Em.I18n.t('dashboard.services.hdfs.datanodes')
|
|
|
+ }),
|
|
|
+ Em.Object.create({
|
|
|
+ serviceName: 'YARN',
|
|
|
+ componentName: 'NODEMANAGER',
|
|
|
+ masterComponentName: 'RESOURCEMANAGER',
|
|
|
+ componentNameFormatted: Em.I18n.t('dashboard.services.yarn.nodeManagers')
|
|
|
+ }),
|
|
|
+ Em.Object.create({
|
|
|
+ serviceName: 'HBASE',
|
|
|
+ componentName: 'HBASE_REGIONSERVER',
|
|
|
+ masterComponentName: 'HBASE_MASTER',
|
|
|
+ componentNameFormatted: Em.I18n.t('dashboard.services.hbase.regionServers')
|
|
|
+ }),
|
|
|
+ Em.Object.create({
|
|
|
+ serviceName: 'MAPREDUCE',
|
|
|
+ componentName: 'TASKTRACKER',
|
|
|
+ masterComponentName: 'JOBTRACKER',
|
|
|
+ componentNameFormatted: Em.I18n.t('dashboard.services.mapreduce.taskTrackers')
|
|
|
+ }),
|
|
|
+ Em.Object.create({
|
|
|
+ serviceName: 'STORM',
|
|
|
+ componentName: 'SUPERVISOR',
|
|
|
+ masterComponentName: 'SUPERVISOR',
|
|
|
+ componentNameFormatted: Em.I18n.t('dashboard.services.storm.supervisors')
|
|
|
+ })];
|
|
|
+
|
|
|
+ return menuItems.filter(function(item){
|
|
|
+ return App.Service.find().findProperty('serviceName',item.serviceName);
|
|
|
+ });
|
|
|
+ }.property(),
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
- * Get third-level menu items for slave components
|
|
|
- * @param {String} componentNameForDecommission for decommission and recommission used another component name
|
|
|
- * @param {String} componentNameForOtherActions host component name that should be processed
|
|
|
- * operationData format:
|
|
|
- * <code>
|
|
|
- * {
|
|
|
- * action: 'STARTED|INSTALLED|RESTART|DECOMMISSION|DECOMMISSION_OFF', // action for selected host components
|
|
|
- * message: 'some text', // just text to BG popup
|
|
|
- * componentName: 'DATANODE|NODEMANAGER...', //component name that should be processed
|
|
|
- * realComponentName: 'DATANODE|NODEMANAGER...', // used only for decommission(_off) actions
|
|
|
- * serviceName: 'HDFS|YARN|HBASE...', // service name of the processed component
|
|
|
- * componentNameFormatted: 'DataNodes|NodeManagers...' // "user-friendly" string with component name (used in BG popup)
|
|
|
- * }
|
|
|
- * </code>
|
|
|
- *
|
|
|
- * @returns {Array}
|
|
|
+ * slaveItemView build second-level menu
|
|
|
+ * for slave component
|
|
|
*/
|
|
|
- getSlaveItemsTemplate: function(componentNameForDecommission, componentNameForOtherActions) {
|
|
|
- var menuItems = Em.A([
|
|
|
- Em.Object.create({
|
|
|
- label: Em.I18n.t('common.start'),
|
|
|
- operationData: Em.Object.create({
|
|
|
- action: App.HostComponentStatus.started,
|
|
|
- message: Em.I18n.t('common.start'),
|
|
|
- componentName: componentNameForOtherActions
|
|
|
- })
|
|
|
- }),
|
|
|
- Em.Object.create({
|
|
|
- label: Em.I18n.t('common.stop'),
|
|
|
- operationData: Em.Object.create({
|
|
|
- action: App.HostComponentStatus.stopped,
|
|
|
- message: Em.I18n.t('common.stop'),
|
|
|
- componentName: componentNameForOtherActions
|
|
|
- })
|
|
|
- }),
|
|
|
- Em.Object.create({
|
|
|
- label: Em.I18n.t('common.restart'),
|
|
|
- operationData: Em.Object.create({
|
|
|
- action: 'RESTART',
|
|
|
- message: Em.I18n.t('common.restart'),
|
|
|
- componentName: componentNameForOtherActions
|
|
|
- })
|
|
|
- })
|
|
|
- ]);
|
|
|
- if(App.get('components.decommissionAllowed').contains(componentNameForOtherActions)) {
|
|
|
- menuItems.pushObject(Em.Object.create({
|
|
|
- label: Em.I18n.t('common.decommission'),
|
|
|
- operationData: Em.Object.create({
|
|
|
- action: 'DECOMMISSION',
|
|
|
- message: Em.I18n.t('common.decommission'),
|
|
|
- componentName: componentNameForDecommission,
|
|
|
- realComponentName: componentNameForOtherActions
|
|
|
- })
|
|
|
- }));
|
|
|
- menuItems.pushObject(Em.Object.create({
|
|
|
- label: Em.I18n.t('common.recommission'),
|
|
|
- operationData: Em.Object.create({
|
|
|
- action: 'DECOMMISSION_OFF',
|
|
|
- message: Em.I18n.t('common.recommission'),
|
|
|
- componentName: componentNameForDecommission,
|
|
|
- realComponentName: componentNameForOtherActions
|
|
|
+
|
|
|
+ slaveItemView: Em.View.extend({
|
|
|
+
|
|
|
+ tagName: 'li',
|
|
|
+
|
|
|
+ classNames: ['dropdown-submenu'],
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get third-level menu items ingo for slave components
|
|
|
+ * operationData format:
|
|
|
+ * <code>
|
|
|
+ * {
|
|
|
+ * action: 'STARTED|INSTALLED|RESTART|DECOMMISSION|DECOMMISSION_OFF', // action for selected host components
|
|
|
+ * message: 'some text', // just text to BG popup
|
|
|
+ * componentName: 'DATANODE|NODEMANAGER...', //component name that should be processed
|
|
|
+ * realComponentName: 'DATANODE|NODEMANAGER...', // used only for decommission(_off) actions
|
|
|
+ * serviceName: 'HDFS|YARN|HBASE...', // service name of the processed component
|
|
|
+ * componentNameFormatted: 'DataNodes|NodeManagers...' // "user-friendly" string with component name (used in BG popup)
|
|
|
+ * }
|
|
|
+ * </code>
|
|
|
+ *
|
|
|
+ * @returns {Array}
|
|
|
+ */
|
|
|
+
|
|
|
+ operationsInfo: function () {
|
|
|
+ var content = this.get('content');
|
|
|
+ var menuItems = Em.A([
|
|
|
+ Em.Object.create({
|
|
|
+ label: Em.I18n.t('common.start'),
|
|
|
+ operationData: Em.Object.create({
|
|
|
+ action: App.HostComponentStatus.started,
|
|
|
+ message: Em.I18n.t('common.start'),
|
|
|
+ componentName: content.componentName,
|
|
|
+ serviceName: content.serviceName,
|
|
|
+ componentNameFormatted: content.componentNameFormatted
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ Em.Object.create({
|
|
|
+ label: Em.I18n.t('common.stop'),
|
|
|
+ operationData: Em.Object.create({
|
|
|
+ action: App.HostComponentStatus.stopped,
|
|
|
+ message: Em.I18n.t('common.stop'),
|
|
|
+ componentName: content.componentName,
|
|
|
+ serviceName: content.serviceName,
|
|
|
+ componentNameFormatted: content.componentNameFormatted
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ Em.Object.create({
|
|
|
+ label: Em.I18n.t('common.restart'),
|
|
|
+ operationData: Em.Object.create({
|
|
|
+ action: 'RESTART',
|
|
|
+ message: Em.I18n.t('common.restart'),
|
|
|
+ componentName: content.componentName,
|
|
|
+ serviceName: content.serviceName,
|
|
|
+ componentNameFormatted: content.componentNameFormatted
|
|
|
+ })
|
|
|
})
|
|
|
- }));
|
|
|
- }
|
|
|
- return menuItems;
|
|
|
- },
|
|
|
+ ]);
|
|
|
+ if (App.get('components.decommissionAllowed').contains(content.componentName)) {
|
|
|
+ menuItems.pushObject(Em.Object.create({
|
|
|
+ label: Em.I18n.t('common.decommission'),
|
|
|
+ decommission: true,
|
|
|
+ operationData: Em.Object.create({
|
|
|
+ action: 'DECOMMISSION',
|
|
|
+ message: Em.I18n.t('common.decommission'),
|
|
|
+ componentName: content.masterComponentName,
|
|
|
+ realComponentName: content.componentName,
|
|
|
+ serviceName: content.serviceName,
|
|
|
+ componentNameFormatted: content.componentNameFormatted
|
|
|
+ })
|
|
|
+ }));
|
|
|
+ menuItems.pushObject(Em.Object.create({
|
|
|
+ label: Em.I18n.t('common.recommission'),
|
|
|
+ decommission: true,
|
|
|
+ operationData: Em.Object.create({
|
|
|
+ action: 'DECOMMISSION_OFF',
|
|
|
+ message: Em.I18n.t('common.recommission'),
|
|
|
+ componentName: content.masterComponentName,
|
|
|
+ realComponentName: content.componentName,
|
|
|
+ serviceName: content.serviceName,
|
|
|
+ componentNameFormatted: content.componentNameFormatted
|
|
|
+ })
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ return menuItems;
|
|
|
+ }.property("content"),
|
|
|
+
|
|
|
+ /**
|
|
|
+ * commonOperationView is used for third-level menu items
|
|
|
+ * for simple operations ('START','STOP','RESTART')
|
|
|
+ */
|
|
|
+ commonOperationView: Em.View.extend({
|
|
|
+ tagName: 'li',
|
|
|
+
|
|
|
+ /**
|
|
|
+ * click function use
|
|
|
+ * App.MainHostView as a thirl level parent
|
|
|
+ * and runs it's function
|
|
|
+ */
|
|
|
+ click: function () {
|
|
|
+ this.get('parentView.parentView.parentView').bulkOperationConfirm(this.get('content'), this.get('selection'));
|
|
|
+ }
|
|
|
+ }),
|
|
|
+
|
|
|
+ /**
|
|
|
+ * advancedOperationView is used for third level menu item
|
|
|
+ * for advanced operations ('RECOMMISSION','DECOMMISSION')
|
|
|
+ */
|
|
|
+ advancedOperationView: Em.View.extend({
|
|
|
+ tagName: 'li',
|
|
|
+ rel: 'menuTooltip',
|
|
|
+ classNameBindings: ['disabledElement'],
|
|
|
+ attributeBindings: ['tooltipMsg:data-original-title'],
|
|
|
+
|
|
|
+ service: function () {
|
|
|
+ return App.router.get('mainServiceController.content').findProperty('serviceName', this.get('content.serviceName'))
|
|
|
+ }.property('App.router.mainServiceController.content.@each', 'content'),
|
|
|
+
|
|
|
+ tooltipMsg: function () {
|
|
|
+ return (this.get('disabledElement') == 'disabled') ?
|
|
|
+ Em.I18n.t('hosts.decommission.tooltip.warning').format(this.get('content.message'), App.format.role(this.get('content.componentName'))) : '';
|
|
|
+ }.property('disabledElement','content.componentName'),
|
|
|
+
|
|
|
+ disabledElement: function () {
|
|
|
+ return (this.get('service.workStatus') != 'STARTED') ? 'disabled' : '';
|
|
|
+ }.property('service.workStatus'),
|
|
|
+
|
|
|
+ /**
|
|
|
+ * click function use
|
|
|
+ * App.MainHostView as a thirl level parent
|
|
|
+ * and runs it's function
|
|
|
+ */
|
|
|
+ click: function () {
|
|
|
+ if (this.get('disabledElement') == 'disabled') {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.get('parentView.parentView.parentView').bulkOperationConfirm(this.get('content'), this.get('selection'));
|
|
|
+ },
|
|
|
+
|
|
|
+ didInsertElement: function () {
|
|
|
+ App.tooltip($(this.get('element')));
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }),
|
|
|
|
|
|
/**
|
|
|
- * Get third-level menu items for Hosts
|
|
|
- * operationData format:
|
|
|
- * <code>
|
|
|
- * {
|
|
|
- * action: 'STARTED|INSTALLED|RESTART..', // action for selected hosts (will be applied for each host component in selected hosts)
|
|
|
- * actionToCheck: 'INSTALLED|STARTED..' // state to filter host components should be processed
|
|
|
- * message: 'some text', // just text to BG popup
|
|
|
- * }
|
|
|
- * </code>
|
|
|
- * @returns {Array}
|
|
|
+ * hostItemView build second-level menu
|
|
|
+ * for host
|
|
|
*/
|
|
|
- getHostItemsTemplate: function() {
|
|
|
- return Em.A([
|
|
|
- Em.Object.create({
|
|
|
- label: Em.I18n.t('hosts.host.details.startAllComponents'),
|
|
|
- operationData: Em.Object.create({
|
|
|
- action: 'STARTED',
|
|
|
- actionToCheck: 'INSTALLED',
|
|
|
- message: Em.I18n.t('hosts.host.details.startAllComponents')
|
|
|
- })
|
|
|
- }),
|
|
|
- Em.Object.create({
|
|
|
- label: Em.I18n.t('hosts.host.details.stopAllComponents'),
|
|
|
- operationData: Em.Object.create({
|
|
|
- action: 'INSTALLED',
|
|
|
- actionToCheck: 'STARTED',
|
|
|
- message: Em.I18n.t('hosts.host.details.stopAllComponents')
|
|
|
- })
|
|
|
- }),
|
|
|
- Em.Object.create({
|
|
|
- label: Em.I18n.t('hosts.table.menu.l2.restartAllComponents'),
|
|
|
- operationData: Em.Object.create({
|
|
|
- action: 'RESTART',
|
|
|
- message: Em.I18n.t('hosts.table.menu.l2.restartAllComponents')
|
|
|
- })
|
|
|
- }),
|
|
|
- Em.Object.create({
|
|
|
- label: Em.I18n.t('passiveState.turnOn'),
|
|
|
- operationData: Em.Object.create({
|
|
|
- state: 'ON',
|
|
|
- action: 'PASSIVE_STATE',
|
|
|
- message: Em.I18n.t('passiveState.turnOnFor').format('hosts')
|
|
|
- })
|
|
|
- }),
|
|
|
- Em.Object.create({
|
|
|
- label: Em.I18n.t('passiveState.turnOff'),
|
|
|
- operationData: Em.Object.create({
|
|
|
- state: 'OFF',
|
|
|
- action: 'PASSIVE_STATE',
|
|
|
- message: Em.I18n.t('passiveState.turnOffFor').format('hosts')
|
|
|
+
|
|
|
+ hostItemView: Em.View.extend({
|
|
|
+
|
|
|
+ tagName: 'li',
|
|
|
+
|
|
|
+ classNames: ['dropdown-submenu'],
|
|
|
+
|
|
|
+ label: Em.I18n.t('common.hosts'),
|
|
|
+
|
|
|
+ /** Get third-level menu items for Hosts
|
|
|
+ * operationData format:
|
|
|
+ * <code>
|
|
|
+ * {
|
|
|
+ * action: 'STARTED|INSTALLED|RESTART..', // action for selected hosts (will be applied for each host component in selected hosts)
|
|
|
+ * actionToCheck: 'INSTALLED|STARTED..' // state to filter host components should be processed
|
|
|
+ * message: 'some text', // just text to BG popup
|
|
|
+ * }
|
|
|
+ * </code>
|
|
|
+ * @returns {Array}
|
|
|
+ */
|
|
|
+ operationsInfo: function () {
|
|
|
+ return Em.A([
|
|
|
+ Em.Object.create({
|
|
|
+ label: Em.I18n.t('hosts.host.details.startAllComponents'),
|
|
|
+ operationData: Em.Object.create({
|
|
|
+ action: 'STARTED',
|
|
|
+ actionToCheck: 'INSTALLED',
|
|
|
+ message: Em.I18n.t('hosts.host.details.startAllComponents')
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ Em.Object.create({
|
|
|
+ label: Em.I18n.t('hosts.host.details.stopAllComponents'),
|
|
|
+ operationData: Em.Object.create({
|
|
|
+ action: 'INSTALLED',
|
|
|
+ actionToCheck: 'STARTED',
|
|
|
+ message: Em.I18n.t('hosts.host.details.stopAllComponents')
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ Em.Object.create({
|
|
|
+ label: Em.I18n.t('hosts.table.menu.l2.restartAllComponents'),
|
|
|
+ operationData: Em.Object.create({
|
|
|
+ action: 'RESTART',
|
|
|
+ message: Em.I18n.t('hosts.table.menu.l2.restartAllComponents')
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ Em.Object.create({
|
|
|
+ label: Em.I18n.t('passiveState.turnOn'),
|
|
|
+ operationData: Em.Object.create({
|
|
|
+ state: 'ON',
|
|
|
+ action: 'PASSIVE_STATE',
|
|
|
+ message: Em.I18n.t('passiveState.turnOnFor').format('hosts')
|
|
|
+ })
|
|
|
+ }),
|
|
|
+ Em.Object.create({
|
|
|
+ label: Em.I18n.t('passiveState.turnOff'),
|
|
|
+ operationData: Em.Object.create({
|
|
|
+ state: 'OFF',
|
|
|
+ action: 'PASSIVE_STATE',
|
|
|
+ message: Em.I18n.t('passiveState.turnOffFor').format('hosts')
|
|
|
+ })
|
|
|
})
|
|
|
- })
|
|
|
- ]);
|
|
|
- },
|
|
|
+ ]);
|
|
|
+ }.property(),
|
|
|
|
|
|
- /**
|
|
|
- * Get second-level menu
|
|
|
- * @param {String} selection
|
|
|
- * <code>
|
|
|
- * "s" - selected hosts
|
|
|
- * "a" - all hosts
|
|
|
- * "f" - filtered hosts
|
|
|
- * </code>
|
|
|
- * @returns {Array}
|
|
|
- */
|
|
|
- getSubMenuItemsTemplate: function(selection) {
|
|
|
- var submenu = Em.A([{label: Em.I18n.t('common.hosts'), submenu: this.getHostItemsTemplate()}]);
|
|
|
-
|
|
|
- if (!!App.HDFSService.find().content.length) {
|
|
|
- var slaveItemsForHdfs = this.getSlaveItemsTemplate('NAMENODE', 'DATANODE');
|
|
|
- slaveItemsForHdfs.setEach('operationData.serviceName', 'HDFS');
|
|
|
- slaveItemsForHdfs.setEach('operationData.componentNameFormatted', Em.I18n.t('dashboard.services.hdfs.datanodes'));
|
|
|
- submenu.push({label: Em.I18n.t('dashboard.services.hdfs.datanodes'), submenu: slaveItemsForHdfs});
|
|
|
- }
|
|
|
-
|
|
|
- if (!!App.YARNService.find().content.length) {
|
|
|
- var slaveItemsForYarn = this.getSlaveItemsTemplate('RESOURCEMANAGER', 'NODEMANAGER');
|
|
|
- slaveItemsForYarn.setEach('operationData.serviceName', 'YARN');
|
|
|
- slaveItemsForYarn.setEach('operationData.componentNameFormatted', Em.I18n.t('dashboard.services.yarn.nodeManagers'));
|
|
|
- submenu.push({label: Em.I18n.t('dashboard.services.yarn.nodeManagers'), submenu: slaveItemsForYarn});
|
|
|
- }
|
|
|
-
|
|
|
- if (!!App.HBaseService.find().content.length) {
|
|
|
- var slaveItemsForHBase = this.getSlaveItemsTemplate('HBASE_MASTER', 'HBASE_REGIONSERVER');
|
|
|
- slaveItemsForHBase.setEach('operationData.serviceName', 'HBASE');
|
|
|
- slaveItemsForHBase.setEach('operationData.componentNameFormatted', Em.I18n.t('dashboard.services.hbase.regionServers'));
|
|
|
- submenu.push({label: Em.I18n.t('dashboard.services.hbase.regionServers'), submenu: slaveItemsForHBase});
|
|
|
- }
|
|
|
-
|
|
|
- if (!!App.MapReduceService.find().content.length) {
|
|
|
- var slaveItemsForMapReduce = this.getSlaveItemsTemplate('JOBTRACKER', 'TASKTRACKER');
|
|
|
- slaveItemsForMapReduce.setEach('operationData.serviceName', 'MAPREDUCE');
|
|
|
- slaveItemsForMapReduce.setEach('operationData.componentNameFormatted', Em.I18n.t('dashboard.services.mapreduce.taskTrackers'));
|
|
|
- submenu.push({label: Em.I18n.t('dashboard.services.mapreduce.taskTrackers'), submenu: slaveItemsForMapReduce});
|
|
|
- }
|
|
|
-
|
|
|
- if (!!App.Service.find().filterProperty('serviceName', 'STORM').length) {
|
|
|
- var slaveItemsForStorm = this.getSlaveItemsTemplate('SUPERVISOR', 'SUPERVISOR');
|
|
|
- slaveItemsForStorm.setEach('operationData.serviceName', 'STORM');
|
|
|
- slaveItemsForStorm.setEach('operationData.componentNameFormatted', Em.I18n.t('dashboard.services.storm.supervisors'));
|
|
|
- submenu.push({label: Em.I18n.t('dashboard.services.storm.supervisors'), submenu: slaveItemsForStorm});
|
|
|
- }
|
|
|
-
|
|
|
- submenu.forEach(function(item) {
|
|
|
- item.submenu.forEach(function(subitem) {
|
|
|
- subitem.operationData.selection = selection;
|
|
|
- });
|
|
|
- });
|
|
|
- return submenu;
|
|
|
- },
|
|
|
+ /**
|
|
|
+ * commonOperationView is used for third-level menu items
|
|
|
+ * for all operations for host
|
|
|
+ */
|
|
|
+ operationView: Em.View.extend({
|
|
|
+ tagName: 'li',
|
|
|
|
|
|
- /**
|
|
|
- * Menu-items for Hosts table
|
|
|
- * @type {Object}
|
|
|
- */
|
|
|
- menuItems: function() {
|
|
|
- return {
|
|
|
- s: {label: Em.I18n.t('hosts.table.menu.l1.selectedHosts'), submenu: this.getSubMenuItemsTemplate('s')},
|
|
|
- f: {label: Em.I18n.t('hosts.table.menu.l1.filteredHosts'), submenu: this.getSubMenuItemsTemplate('f')},
|
|
|
- a: {label: Em.I18n.t('hosts.table.menu.l1.allHosts'), submenu: this.getSubMenuItemsTemplate('a')}
|
|
|
- };
|
|
|
- }.property('App.router.clusterController.isLoaded')
|
|
|
+ /**
|
|
|
+ * click function use
|
|
|
+ * App.MainHostView as a thirl level parent
|
|
|
+ * and runs it's function
|
|
|
+ */
|
|
|
+ click: function () {
|
|
|
+ this.get('parentView.parentView.parentView').bulkOperationConfirm(this.get('content'), this.get('selection'));
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
});
|