/* * * 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. * */ /* Declarations of global data. */ var fetchClusterServicesPoller; var clusterServices; // Storing globally for the sake of multiple screens in reconfigure var localReconfigureServiceData = {}; var remoteReconfigureServiceData = {}; var confirmationDataPanelBodyContent = ''; var confirmationDataPanel; var panelNoButton = { value: 'Cancel', action: function (e) { e.preventDefault(); hideAndDestroyPanel(); }, section: 'footer' }; var panelYesButton; // Only one service can be reconfigured at a time. var reconfigLevelOneYesButton; var reconfigLevelTwoNoButton; function showPanel() { showPanel(function() {}); } function showPanel(postShowFn) { confirmationDataPanel.set('y', 200); confirmationDataPanel.set('x', (globalYui.one('body').get('region').width - confirmationDataPanel.get('width'))/2); confirmationDataPanel.show(); if (postShowFn != null) { postShowFn.call(); } } function hidePanel(postHideFn) { if (postHideFn != null) { postHideFn.call(); } } function hideAndDestroyPanel() { hidePanel(function() { confirmationDataPanel.hide(); destroyInformationalPanel(confirmationDataPanel); }); } function getTitleForReconfiguration(serviceName) { return 'Make Configuration Changes for ' + serviceName; } function setupReconfigureFirstScreen(serviceName) { var panelTitle = getTitleForReconfiguration(serviceName); confirmationDataPanel.set( 'headerContent', panelTitle); confirmationDataPanel.set( 'bodyContent', confirmationDataPanelBodyContent); // Remove buttons from previous stage confirmationDataPanel.removeButton(0); confirmationDataPanel.removeButton(0); confirmationDataPanel.addButton( panelNoButton ); confirmationDataPanel.addButton( reconfigLevelOneYesButton ); } function setupReconfigureSecondScreen(serviceName) { var affectedServices = clusterServices[serviceName].dependencies; var dependents = clusterServices[serviceName].dependents; for (dep in dependents) { affectedServices.push(dependents[dep]); } var panelContent = 'Affected services:' + getAffectedDependenciesMarkup(affectedServices, serviceName, 'reconfigure'); var panelTitle = 'Review changes to ' + serviceName + '\'s configuration'; confirmationDataPanel.set( 'headerContent', panelTitle); confirmationDataPanel.set( 'bodyContent', panelContent); // Remove buttons from previous stage confirmationDataPanel.removeButton(0); confirmationDataPanel.removeButton(0); confirmationDataPanel.addButton( reconfigLevelTwoNoButton ); confirmationDataPanel.addButton( panelYesButton ); } // Clean up the affected-services list to only include appropriate installed long-running services function getAffectedDependenciesMarkup(affectedServices, serviceName, action) { var affectedDependenciesMarkup = ''; var serviceDisplayName = clusterServices[serviceName].displayName; var deps = affectedServices; affectedServices = []; for (dep in deps) { var svc = deps[dep]; if (clusterServices.hasOwnProperty(svc) && (clusterServices[svc].isEnabled == 1) && clusterServices[svc].attributes.runnable ) { affectedServices.push(svc); } } var dependencyMarkup = ""; for (affectedSrvc in affectedServices) { if (clusterServices[affectedServices[affectedSrvc]].attributes.runnable) { dependencyMarkup += '
Service name | Current state |
---|---|
' + serviceDisplayName + ' | ' + titleCase(clusterServices[serviceName].state) + ' |
There is nothing to reconfigure for this service.
'; } else { /* Augment confirmationDataPanel with the relevant buttons only if there * is something of value to show. */ confirmationDataPanel.addButton( panelNoButton ); confirmationDataPanel.addButton( reconfigLevelOneYesButton ); } /* XXX Note that this must be kept in-sync with the corresponding markup * on the InstallationWizard page. */ confirmationDataPanelBodyContent = ' ' + '