瀏覽代碼

AMBARI-1468. Stack Upgrade Wizard - Step 1 (show services and versions). (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1448923 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 年之前
父節點
當前提交
6d35b529d8

+ 67 - 0
ambari-web/app/controllers/main/admin/stack_upgrade_controller.js

@@ -0,0 +1,67 @@
+/**
+ * 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');
+
+App.StackUpgradeController = App.WizardController.extend({
+  name: 'stackUpgradeController',
+
+  totalSteps: 3,
+
+  /**
+   * All wizards data will be stored in this variable
+   *
+   * cluster - cluster name
+   * upgradeOptions - upgrade options
+   */
+  content: Em.Object.create({
+    cluster: null,
+    upgradeOptions: null,
+    servicesInfo: function(){
+      return App.router.get('mainAdminClusterController.services');
+    }.property('App.router.mainAdminClusterController.services'),
+    upgradeVersion: function(){
+      return App.router.get('mainAdminClusterController.upgradeVersion');
+    }.property('App.router.mainAdminClusterController.upgradeVersion'),
+    controllerName: 'stackUpgradeController',
+    isWizard: true
+  }),
+
+  /**
+   * return new object extended from clusterStatusTemplate
+   * @return Object
+   */
+  getCluster: function(){
+    return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.get('ClusterName')});
+  },
+  /**
+   * Load data for all steps until <code>current step</code>
+   */
+  loadAllPriorSteps: function () {
+    this.load('cluster');
+  },
+
+  /**
+   * Finish upgrade
+   */
+  finish: function () {
+    this.setCurrentStep('1');
+    App.router.get('updateController').updateAll();
+  }
+});

+ 23 - 0
ambari-web/app/controllers/wizard/stack_upgrade/step1_controller.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.
+ */
+
+var App = require('app');
+
+App.StackUpgradeStep1Controller = Em.Controller.extend({
+  name: 'stackUpgradeStep1Controller'
+});

+ 127 - 0
ambari-web/app/routes/stack_upgrade.js

@@ -0,0 +1,127 @@
+/**
+ * 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.
+ */
+
+module.exports = Em.Route.extend({
+  route: 'admin/cluster/upgrade',
+
+  enter: function (router) {
+    console.log('in /admin/cluster/upgrade:enter');
+    var self = this;
+    Ember.run.next(function () {
+      var stackUpgradeController = router.get('stackUpgradeController');
+      App.router.get('updateController').set('isWorking', false);
+      App.ModalPopup.show({
+        classNames: ['full-width-modal'],
+        header:Em.I18n.t('installer.stackUpgrade.header'),
+        bodyClass:  App.StackUpgradeView.extend({
+          controllerBinding: 'App.router.stackUpgradeController'
+        }),
+        showFooter: false,
+        onClose: function() {
+          this.hide();
+          App.router.get('updateController').set('isWorking', true);
+          router.transitionTo('admin.adminCluster');
+        },
+        didInsertElement: function(){
+          this.fitHeight();
+        }
+      });
+
+
+     /* App.clusterStatus.updateFromServer();
+       var currentClusterStatus = App.clusterStatus.get('value');
+
+       if (currentClusterStatus) {
+       switch (currentClusterStatus.clusterState) {
+       case 'STACK_UPGRADING' :
+       case 'STACK_UPGRADED' :
+       stackUpgradeController.setCurrentStep('3');
+       App.db.data = currentClusterStatus.localdb;
+       break;
+       default:
+       break;
+       }
+       }*/
+
+      router.transitionTo('step' + stackUpgradeController.get('currentStep'));
+    });
+  },
+
+  step1: Em.Route.extend({
+    route: '/step1',
+    connectOutlets: function (router) {
+      console.log('in stackUpgrade.step1:connectOutlets');
+      var controller = router.get('stackUpgradeController');
+      controller.setCurrentStep('1');
+      controller.loadAllPriorSteps();
+      controller.connectOutlet('stackUpgradeStep1', controller.get('content'));
+    },
+    next: function(router){
+      //Em.Router.transitionTo('step2');
+    }
+  }),
+
+  step2: Em.Route.extend({
+    route: '/step2',
+    connectOutlets: function (router) {
+      console.log('in stackUpgrade.step2:connectOutlets');
+      var controller = router.get('stackUpgradeController');
+      controller.setCurrentStep('2');
+      controller.connectOutlet('stackUpgradeStep2', controller.get('content'));
+    },
+    back: Em.Router.transitionTo('step1'),
+    next: function (router, context) {
+      router.transitionTo('step3');
+    }
+  }),
+
+  step3: Em.Route.extend({
+    route: '/step3',
+    connectOutlets: function (router, context) {
+      console.log('in stackUpgrade.step3:connectOutlets');
+      var controller = router.get('stackUpgradeController');
+      controller.setCurrentStep('3');
+      controller.setLowerStepsDisable(3);
+      controller.connectOutlet('stackUpgradeStep3', controller.get('content'));
+    },
+    back: Em.Router.transitionTo('step2'),
+    complete: function (router, context) {
+      App.router.get('updateController').set('isWorking', true);
+      $(context.currentTarget).parents("#modal").find(".close").trigger('click');
+
+      // We need to do recovery based on whether we are in Add Host or Installer wizard
+     /* App.clusterStatus.setClusterStatus({
+        clusterName: this.get('clusterName'),
+        clusterState: 'STACK_UPGRADED',
+        wizardControllerName: App.router.get('stackUpgradeController.name'),
+        localdb: App.db.data
+      });*/
+
+    }
+  }),
+  backToCluster: function(router, context){
+    $(context.currentTarget).parents("#modal").find(".close").trigger('click');
+  },
+
+  gotoStep1: Em.Router.transitionTo('step1'),
+
+  gotoStep2: Em.Router.transitionTo('step2'),
+
+  gotoStep3: Em.Router.transitionTo('step3')
+
+});

+ 39 - 0
ambari-web/app/templates/main/admin/stack_upgrade.hbs

@@ -0,0 +1,39 @@
+{{!
+* 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.
+}}
+
+<div id="stack-upgrade">
+  <div class="container">
+    <div class="container-fluid">
+      <div class="row-fluid">
+        <div class="span3">
+          <!--Sidebar content-->
+          <div class="well">
+            <ul class="nav nav-pills nav-stacked">
+              <li {{bindAttr class="isStep1:active view.isStep1Disabled:disabled"}}><a href="javascript:void(null);"  {{action gotoStep1 target="controller"}}>{{t common.start}}</a></li>
+              <li {{bindAttr class="isStep2:active view.isStep2Disabled:disabled"}}><a href="javascript:void(null);"  {{action gotoStep2 target="controller"}}>{{t common.confirm}}</a></li>
+              <li {{bindAttr class="isStep3:active view.isStep3Disabled:disabled"}}><a href="javascript:void(null);"  {{action gotoStep3 target="controller"}}>{{t common.upgrade}}</a></li>
+            </ul>
+          </div>
+        </div>
+        <div class="content well span9">
+          {{outlet}}
+        </div>
+      </div>
+    </div>
+  </div>
+</div>

+ 59 - 0
ambari-web/app/templates/wizard/stack_upgrade/step1.hbs

@@ -0,0 +1,59 @@
+{{!
+* 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.
+}}
+
+<div class="box alert-info">
+  <div>
+  {{t installer.stackUpgrade.step1.description}}
+  </div>
+  <br/>
+  <div>
+    <div>{{t installer.stackUpgrade.step1.installedStackVersion}}: {{App.currentStackVersion}}</div>
+    <div>{{t installer.stackUpgrade.step1.upgradeStackVersion}}: {{content.upgradeVersion}}</div>
+  </div>
+</div>
+<div>
+    <table class="table table-bordered table-striped">
+      <thead>
+      <tr>
+        <th>{{t common.service}}</th>
+        <th>{{t installer.stackUpgrade.step1.installedVersion}}</th>
+        <th>{{t installer.stackUpgrade.step1.newVersion}}</th>
+        <th>{{t common.description}}</th>
+      </tr>
+      </thead>
+      <tbody>
+        {{#each service in content.servicesInfo}}
+        {{#unless service.isHidden}}
+          <tr>
+            <td>{{service.displayName}}</td>
+            <td>{{service.version}}</td>
+            <td>{{service.newVersion}}</td>
+            <td>{{service.description}}</td>
+          </tr>
+        {{/unless}}
+        {{/each}}
+      </tbody>
+    </table>
+</div>
+<div class="btn-area">
+  <a class="btn pull-left" {{action backToCluster}}>{{t common.cancel}}</a>
+  <a class="btn btn-success pull-right" {{action next}}>{{t common.next}}</a>
+</div>
+
+
+

+ 40 - 0
ambari-web/app/views/main/admin/stack_upgrade.js

@@ -0,0 +1,40 @@
+/**
+ * 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');
+
+App.StackUpgradeView = Em.View.extend({
+  templateName: require('templates/main/admin/stack_upgrade'),
+
+  isStep1Disabled: function () {
+    return this.isStepDisabled(1);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep2Disabled: function () {
+    return this.isStepDisabled(2);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep3Disabled: function () {
+    return this.isStepDisabled(3);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStepDisabled: function (index) {
+    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
+  }
+});

+ 24 - 0
ambari-web/app/views/wizard/stack_upgrade/step1_view.js

@@ -0,0 +1,24 @@
+/**
+ * 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');
+
+App.StackUpgradeStep1View = Em.View.extend({
+  templateName: require('templates/wizard/stack_upgrade/step1')
+});