You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2014/02/05 18:46:50 UTC

git commit: AMBARI-4536. Mirroring: Manage Clusters and Add Dataset dialogs cleanup. (akovalenko)

Updated Branches:
  refs/heads/trunk d0eeac994 -> 804a8c5ce


AMBARI-4536. Mirroring: Manage Clusters and Add Dataset dialogs cleanup. (akovalenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/804a8c5c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/804a8c5c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/804a8c5c

Branch: refs/heads/trunk
Commit: 804a8c5ce6595144898434ad025944d3253f7319
Parents: d0eeac9
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Wed Feb 5 19:45:27 2014 +0200
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Wed Feb 5 19:45:27 2014 +0200

----------------------------------------------------------------------
 .../mirroring/manage_clusters_controller.js     | 40 ++++-------
 ambari-web/app/messages.js                      |  9 ++-
 ambari-web/app/styles/application.less          | 10 +++
 .../app/templates/common/prompt_popup.hbs       | 27 +++++++
 .../templates/main/mirroring/edit_dataset.hbs   | 14 +++-
 .../main/mirroring/manage_clusters.hbs          | 55 ++-------------
 ambari-web/app/views/common/modal_popup.js      | 35 ++++++++-
 .../main/mirroring/manage_clusters_view.js      | 74 ++++----------------
 8 files changed, 122 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/804a8c5c/ambari-web/app/controllers/main/mirroring/manage_clusters_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/mirroring/manage_clusters_controller.js b/ambari-web/app/controllers/main/mirroring/manage_clusters_controller.js
index 0f62cc0..938c157 100644
--- a/ambari-web/app/controllers/main/mirroring/manage_clusters_controller.js
+++ b/ambari-web/app/controllers/main/mirroring/manage_clusters_controller.js
@@ -21,33 +21,23 @@ var App = require('app');
 App.MainMirroringManageClustersController = Em.ArrayController.extend({
   name: 'mainMirroringManageClustersController',
 
-  ambariSelected: true,
+  clusters: [],
 
-  ambariServerSelected: false,
+  selectedCluster: null,
 
-  interfacesSelected: false,
-
-  ambariDisabled: function () {
-    return !this.get('ambariSelected');
-  }.property('ambariSelected'),
-
-  ambariServerDisabled: function () {
-    return !this.get('ambariServerSelected');
-  }.property('ambariServerSelected'),
-
-  interfacesDisabled: function () {
-    return !this.get('interfacesSelected');
-  }.property('interfacesSelected'),
-
-  clearStep: function () {
-    this.set('ambariSelected', true);
-    this.set('ambariServerSelected', false);
-    this.set('interfacesSelected', false);
+  addCluster: function () {
+    var self = this;
+    App.showPromptPopup(Em.I18n.t('mirroring.manageClusters.specifyName'),
+        function (clusterName) {
+          self.get('clusters').pushObject(clusterName);
+        }
+    );
   },
 
-  addCluster: function() {},
-
-  removeCluster: function() {},
-
-  testConnection: function() {}
+  removeCluster: function () {
+    var self = this;
+    App.showConfirmationPopup(function () {
+      self.set('clusters', self.get('clusters').without(self.get('selectedCluster')));
+    })
+  }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/804a8c5c/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 31a8a8d..59aac75 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -224,6 +224,7 @@ Em.I18n.translations = {
 
   'popup.highlight':'click to highlight',
   'popup.confirmation.commonHeader':'Confirmation',
+  'popup.prompt.commonHeader':'Prompt',
 
   'router.hadoopClusterNotSetUp':'Your administrator has not set up a Hadoop cluster yet.',
 
@@ -1760,10 +1761,12 @@ Em.I18n.translations = {
   'mirroring.dataset.name':'Name',
   'mirroring.dataset.type':'Type',
   'mirroring.dataset.save': 'Save & Schedule',
-  'mirroring.dataset.sourceDir':'Source',
+  'mirroring.dataset.sourceDir':'Source Directory',
+  'mirroring.dataset.sourceCluster':'Source Cluster',
   'mirroring.dataset.target':'Target',
   'mirroring.dataset.source':'Source',
-  'mirroring.dataset.targetDir':'Target Cluster Directory',
+  'mirroring.dataset.targetCluster':'Target Cluster',
+  'mirroring.dataset.targetDir':'Target Directory',
   'mirroring.dataset.schedule':'Schedule',
   'mirroring.dataset.suspend':'Suspend',
   'mirroring.dataset.suspendInstance':'Suspend Instance',
@@ -1782,8 +1785,8 @@ Em.I18n.translations = {
   'mirroring.dataset.middayPeriod.pm':'PM',
 
   'mirroring.manageClusters.ambariServer':'Ambari Server',
-  'mirroring.manageClusters.testConnection':'Test Connection',
   'mirroring.manageClusters.interfaces':'Interfaces',
+  'mirroring.manageClusters.specifyName':'Specify name for new target cluster:',
   'mirroring.manageClusters.execute':'Execute',
   'mirroring.manageClusters.readonly':'Readonly',
   'mirroring.manageClusters.workflow':'Workflow',

http://git-wip-us.apache.org/repos/asf/ambari/blob/804a8c5c/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 1ffcfb9..03344d9 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -5406,4 +5406,14 @@ i.icon-asterisks {
       margin-left: 10px;
     }
   }
+}
+
+
+.prompt-popup {
+  form {
+    margin-top: 20px;
+  }
+  .prompt-input {
+    width: 520px;
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/804a8c5c/ambari-web/app/templates/common/prompt_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/prompt_popup.hbs b/ambari-web/app/templates/common/prompt_popup.hbs
new file mode 100644
index 0000000..6ca40a9
--- /dev/null
+++ b/ambari-web/app/templates/common/prompt_popup.hbs
@@ -0,0 +1,27 @@
+{{!
+* 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="prompt-popup">
+  <form>
+    <div class="control-group">
+      <label class="control-label">{{view.text}}</label>
+      <div class="controls">
+        {{view Em.TextField class="prompt-input" valueBinding="view.parentView.inputValue"}}
+      </div>
+    </div>
+  </form>
+</div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/804a8c5c/ambari-web/app/templates/main/mirroring/edit_dataset.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/mirroring/edit_dataset.hbs b/ambari-web/app/templates/main/mirroring/edit_dataset.hbs
index 48b11dd..d0cabff 100644
--- a/ambari-web/app/templates/main/mirroring/edit_dataset.hbs
+++ b/ambari-web/app/templates/main/mirroring/edit_dataset.hbs
@@ -45,6 +45,18 @@
           <td class="spacer" colspan="3"></td>
         </tr>
 
+        <tr>
+          <td class="percent25" colspan="1">
+            {{t mirroring.dataset.sourceCluster}}
+          </td>
+          <td colspan="2" style="text-align: left">
+            {{App.clusterName}}
+          </td>
+        </tr>
+        <tr>
+          <td class="spacer" colspan="3"></td>
+        </tr>
+
         <tr {{bindAttr class="errors.isSourceDirError:error"}}>
           <td colspan="1">
             {{t mirroring.dataset.sourceDir}}
@@ -59,7 +71,7 @@
         </tr>
         <tr {{bindAttr class="errors.isTargetClusterError:error"}}>
           <td colspan="1">
-            {{t mirroring.dataset.target}}
+            {{t mirroring.dataset.targetCluster}}
           </td>
           <td colspan="2" style="text-align: left">
             {{view view.targetClusterSelect selectionBinding="formFields.datasetTargetClusterName"}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/804a8c5c/ambari-web/app/templates/main/mirroring/manage_clusters.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/mirroring/manage_clusters.hbs b/ambari-web/app/templates/main/mirroring/manage_clusters.hbs
index f5f4d03..06ee7c7 100644
--- a/ambari-web/app/templates/main/mirroring/manage_clusters.hbs
+++ b/ambari-web/app/templates/main/mirroring/manage_clusters.hbs
@@ -21,67 +21,24 @@
       {{view view.clusterSelect}}
       <div class="btn-toolbar pull-right">
         <button class="btn" {{action addCluster target="controller"}}><i class="icon-plus"></i></button>
-        <button class="btn" {{action removeCluster target="controller"}}><i class="icon-minus"></i></button>
-        <button class="btn"><i class="icon-cog"></i></button>
+        <button class="btn" {{action removeCluster target="controller"}} {{bindAttr disabled="view.removeDisabled"}}><i class="icon-minus"></i></button>
       </div>
     </div>
     <div class="span7" style="padding-left: 15px">
       <form class="form-horizontal">
         <div class="control-group">
-          <label class="control-label-manage-clusters">{{t common.name}}</label>
-          {{view Ember.TextField class="span8"}}
-        </div>
-        <div class="control-group">
-          <label class="radio">
-            {{view view.ambariRadioButton checkedBinding="controller.ambariSelected"}}
-            {{t app.name}}
-          </label>
-
-          <div class="control-group">
-            <label class="control-label-manage-clusters">{{t common.name}}</label>
-            {{view view.ambariClusterSelect disabledBinding="controller.ambariDisabled"}}
-          </div>
-        </div>
-        <div class="control-group">
-          <label class="radio">
-            {{view view.ambariServerRadioButton checkedBinding="controller.ambariServerSelected"}}
-            {{t mirroring.manageClusters.ambariServer}}
-          </label>
-
-          <div class="control-group">
-            <label class="control-label-manage-clusters">{{t common.url}}</label>
-            {{view Ember.TextField class="span8" disabledBinding="controller.ambariServerDisabled"}}
-          </div>
-          <div class="control-group">
-            <label class="control-label-manage-clusters">{{t common.user}}</label>
-            {{view Ember.TextField class="span8" disabledBinding="controller.ambariServerDisabled"}}
-          </div>
-          <div class="control-group">
-            <label class="control-label-manage-clusters">{{t common.password}}</label>
-            {{view Ember.TextField class="span4" type="password" disabledBinding="controller.ambariServerDisabled"}}
-            {{view Ember.TextField class="span4" type="password" disabledBinding="controller.ambariServerDisabled"}}
-          </div>
-          <div class="control-group text-center">
-            <button class="btn btn-success" {{action testConnection target="controller"}} {{bindAttr disabled="controller.ambariServerDisabled"}}>{{t mirroring.manageClusters.testConnection}}</button>
-          </div>
-        </div>
-        <div class="control-group">
-          <label class="radio">
-            {{view view.interfacesRadioButton checkedBinding="controller.interfacesSelected"}}
-            {{t mirroring.manageClusters.interfaces}}
-          </label>
-
+          <div style="margin-bottom: 15px">{{t mirroring.manageClusters.interfaces}}</div>
           <div class="control-group">
             <label class="control-label-manage-clusters">{{t mirroring.manageClusters.execute}}</label>
-            {{view Ember.TextField class="span8" disabledBinding="controller.interfacesDisabled"}}
+            {{view Ember.TextField class="span8"}}
           </div>
           <div class="control-group">
             <label class="control-label-manage-clusters">{{t mirroring.manageClusters.readonly}}</label>
-            {{view Ember.TextField class="span8" disabledBinding="controller.interfacesDisabled"}}
+            {{view Ember.TextField class="span8"}}
           </div>
           <div class="control-group">
             <label class="control-label-manage-clusters">{{t mirroring.manageClusters.workflow}}</label>
-            {{view Ember.TextField class="span8" disabledBinding="controller.interfacesDisabled"}}
+            {{view Ember.TextField class="span8"}}
           </div>
         </div>
         <div class="accordion control-group" id="advanced-fields">
@@ -91,7 +48,7 @@
                 <i class="icon-caret-down"></i> {{t common.advanced}}
               </a>
             </div>
-            <div id="collapse-fields" class="accordion-body collapse">
+            <div id="collapse-fields" class="accordion-body collapse in">
               <div class="accordion-inner">
                 <div class="control-group">
                   <label class="control-label-manage-clusters">{{t mirroring.manageClusters.staging}}</label>

http://git-wip-us.apache.org/repos/asf/ambari/blob/804a8c5c/ambari-web/app/views/common/modal_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popup.js b/ambari-web/app/views/common/modal_popup.js
index fe87d66..f9c944c 100644
--- a/ambari-web/app/views/common/modal_popup.js
+++ b/ambari-web/app/views/common/modal_popup.js
@@ -121,9 +121,7 @@ App.showConfirmationPopup = function (primary, body, secondary) {
     return false;
   }
   return App.ModalPopup.show({
-    primary: Em.I18n.t('ok'),
     encodeBody: false,
-    secondary: Em.I18n.t('common.cancel'),
     header: Em.I18n.t('popup.confirmation.commonHeader'),
     body: body || Em.I18n.t('question.sure'),
     onPrimary: function () {
@@ -160,4 +158,37 @@ App.showAlertPopup = function (header, body, primary) {
       }
     }
   });
+};
+
+/**
+ * Show prompt popup
+ *
+ * @param {String} text - additional text constant. Will be placed on the top of the input field
+ * @param {Function} primary - "OK" button click handler
+ * @param {String} defaultValue - additional text constant. Will be default value for input field
+ * @param {Function} secondary
+ * @return {*}
+ */
+App.showPromptPopup = function (text, primary, defaultValue, secondary) {
+  if (!primary) {
+    return false;
+  }
+  return App.ModalPopup.show({
+    header: Em.I18n.t('popup.prompt.commonHeader'),
+    bodyClass: Em.View.extend({
+      templateName: require('templates/common/prompt_popup'),
+      text: text
+    }),
+    inputValue: defaultValue || '',
+    onPrimary: function () {
+      this.hide();
+      primary(this.get('inputValue'));
+    },
+    onSecondary: function () {
+      this.hide();
+      if (secondary) {
+        secondary();
+      }
+    }
+  });
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/804a8c5c/ambari-web/app/views/main/mirroring/manage_clusters_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/mirroring/manage_clusters_view.js b/ambari-web/app/views/main/mirroring/manage_clusters_view.js
index 898ba8c..80c7a6c 100644
--- a/ambari-web/app/views/main/mirroring/manage_clusters_view.js
+++ b/ambari-web/app/views/main/mirroring/manage_clusters_view.js
@@ -22,82 +22,32 @@ App.MainMirroringManageClusterstView = Em.View.extend({
   name: 'mainMirroringManageClustersView',
   templateName: require('templates/main/mirroring/manage_clusters'),
 
-  didInsertElement: function () {
-    this.get('controller').clearStep();
-  },
-
   clusterSelect: Ember.Select.extend({
     classNames: ['cluster-select'],
     multiple: true,
     content: function () {
-      return App.TargetCluster.find().mapProperty('clusterName');
-    }.property(),
-    selectedCluster: null,
+      var clusters = this.get('controller.clusters').slice();
+      clusters.unshift(App.get('clusterName'));
+      return clusters;
+    }.property('controller.clusters.@each', 'App.clusterName'),
+
     onSelect: function () {
       if (this.get('selection.length')) {
         if (this.get('selection').length === 1) {
-          this.set('selectedCluster', this.get('selection')[0]);
+          this.set('controller.selectedCluster', this.get('selection')[0]);
         } else {
-          this.set('selection', [this.get('selectedCluster')]);
+          this.set('selection', [this.get('controller.selectedCluster')]);
         }
       } else {
-        this.set('selectedCluster', null);
+        this.set('controller.selectedCluster', null);
       }
     }.observes('selection')
   }),
 
-  ambariClusterSelect: Ember.Select.extend({
-    attributeBindings: ['disabled'],
-    classNames: ['span5'],
-    content: function () {
-      return [App.get('clusterName')];
-    }.property()
-  }),
-
-  ambariRadioButton: Ember.Checkbox.extend({
-    tagName: 'input',
-    attributeBindings: ['type', 'checked'],
-    checked: function () {
-      return this.get('controller.ambariSelected');
-    }.property('controller.ambariSelected'),
-    type: 'radio',
-
-    click: function () {
-      this.set('controller.ambariSelected', true);
-      this.set('controller.ambariServerSelected', false);
-      this.set('controller.interfacesSelected', false);
-    }
-  }),
-
-  ambariServerRadioButton: Ember.Checkbox.extend({
-    tagName: 'input',
-    attributeBindings: ['type', 'checked'],
-    checked: function () {
-      return this.get('controller.ambariServerSelected');
-    }.property('controller.ambariServerSelected'),
-    type: 'radio',
-
-    click: function () {
-      this.set('controller.ambariSelected', false);
-      this.set('controller.ambariServerSelected', true);
-      this.set('controller.interfacesSelected', false);
-    }
-  }),
-
-  interfacesRadioButton: Ember.Checkbox.extend({
-    tagName: 'input',
-    attributeBindings: ['type', 'checked'],
-    checked: function () {
-      return this.get('controller.interfacesSelected');
-    }.property('controller.interfacesSelected'),
-    type: 'radio',
-
-    click: function () {
-      this.set('controller.ambariSelected', false);
-      this.set('controller.ambariServerSelected', false);
-      this.set('controller.interfacesSelected', true);
-    }
-  })
+  removeDisabled: function () {
+    var selectedCluster = this.get('controller.selectedCluster');
+    return !selectedCluster || selectedCluster === App.get('clusterName');
+  }.property('controller.selectedCluster', 'App.clusterName')
 });