You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/01/09 21:18:11 UTC

git commit: AMBARI-4252. Mirroring: provide New Dataset Dialog. (alexantonenko)

Updated Branches:
  refs/heads/trunk 00ba34dfe -> 7349a5249


AMBARI-4252. Mirroring: provide New Dataset Dialog. (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 7349a52490ee4f9d9a58cbf936f9a97a378f9cab
Parents: 00ba34d
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Jan 9 20:35:55 2014 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Jan 9 22:18:09 2014 +0200

----------------------------------------------------------------------
 .../main/mirroring/dataset_controller.js        | 38 +++++++++++++++++---
 ambari-web/app/messages.js                      |  5 ++-
 .../app/templates/main/mirroring/dataset.hbs    | 16 ++++++++-
 .../app/templates/main/mirroring/datasets.hbs   |  2 +-
 .../app/views/main/mirroring/dataset_view.js    | 25 +++++++++++++
 .../app/views/main/mirroring/dropdown_view.js   |  2 +-
 6 files changed, 80 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7349a524/ambari-web/app/controllers/main/mirroring/dataset_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/mirroring/dataset_controller.js b/ambari-web/app/controllers/main/mirroring/dataset_controller.js
index e9ef6b5..445c329 100644
--- a/ambari-web/app/controllers/main/mirroring/dataset_controller.js
+++ b/ambari-web/app/controllers/main/mirroring/dataset_controller.js
@@ -44,6 +44,15 @@ App.MainMirroringDataSetController = Ember.Controller.extend({
         return isNameError;
       }.property('newDataSet.name', 'model.newDataSet.name'),
 
+      isTypeError: function (key, value) {
+        if (value) {
+          return value;
+        }
+        var controller = App.router.get('mainMirroringDataSetController');
+        var isTypeError = controller.checkNameErrors();
+        return isTypeError;
+      }.property('newDataSet.type', 'model.newDataSet.type'),
+
       isSourceDirError: function (key, value) {
         if (value) {
           return value;
@@ -107,6 +116,7 @@ App.MainMirroringDataSetController = Ember.Controller.extend({
 
   validate: function () {
     var isNameError = this.checkNameErrors();
+    var isTypeError = this.checkTypeErrors();
     var isSourceDirError = this.checkSourceDirErrors();
     var isTargetClusterError = this.checkTargetClusterErrors();
     var isTargetDirError = this.checkTargetDirErrors();
@@ -114,7 +124,7 @@ App.MainMirroringDataSetController = Ember.Controller.extend({
     var isEndDateError = this.checkEndDateErrors();
     var isFrequencyError = this.checkFrequencyErrors();
 
-    if (isNameError || isSourceDirError || isTargetClusterError || isTargetDirError || isStartDateError || isEndDateError || isFrequencyError) {
+    if (isNameError || isTypeError || isSourceDirError || isTargetClusterError || isTargetDirError || isStartDateError || isEndDateError || isFrequencyError) {
       return false;
     }
     return true;
@@ -138,6 +148,24 @@ App.MainMirroringDataSetController = Ember.Controller.extend({
 
   },
 
+  checkTypeErrors: function () {
+    if (!this.get('isSubmitted')){
+      this.set('typeErrorMessage', "");
+      return false;
+    }
+    var type = this.get('model.newDataSet.type');
+    if (!type || type.trim() === "") {
+      this.set('model.isTypeError', true);
+      this.set('typeErrorMessage', Em.I18n.t('mirroring.required.error'));
+      return true;
+    }
+    else {
+      this.set('typeErrorMessage', "");
+      return false;
+    }
+
+  },
+
   checkSourceDirErrors: function () {
     if (!this.get('isSubmitted')){
       this.set('sourceDirErrorMessage', "");
@@ -281,6 +309,7 @@ App.MainMirroringDataSetController = Ember.Controller.extend({
   },
 
   nameErrorMessage: null,
+  typeErrorMessage: null,
   sourceDirErrorMessage: null,
   targetClusterErrorMessage: null,
   targetDirErrorMessage: null,
@@ -301,6 +330,7 @@ App.MainMirroringDataSetController = Ember.Controller.extend({
   createNewDataSet: function () {
     var newDataSet = Ember.Object.create({
       name: null,
+      type: null,
       sourceDir: null,
       targetCluster: Ember.Object.create(),
       targetDir: null,
@@ -314,6 +344,7 @@ App.MainMirroringDataSetController = Ember.Controller.extend({
   setDataSet: function (dataset) {
     var newDataSet = Ember.Object.create({
       name: dataset.get('name'),
+      type: dataset.get('type'),
       sourceDir: dataset.get('sourceDir'),
       targetCluster: dataset.get('targetCluster'),
       targetDir: dataset.get('targetDir'),
@@ -334,9 +365,8 @@ App.MainMirroringDataSetController = Ember.Controller.extend({
   },
 
   createTargetCluster: function () {
-    var controller = App.router.get('mainMirroringTargetClusterController');
-    controller.set('returnRoute', App.get('router.currentState.path'));
-    App.router.transitionTo('addTargetClusterRoute');
+    var controller = App.router.get('mainMirroringController');
+    controller.manageClusters();
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/7349a524/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 9d6667b..cc30221 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1688,8 +1688,9 @@ Em.I18n.translations = {
   'mirroring.dataset.editDataset':'Edit Dataset',
   'mirroring.dataset.selectTargetClusters':'Select Target Cluster...',
   'mirroring.dataset.name':'Name',
+  'mirroring.dataset.type':'Type',
   'mirroring.dataset.save': 'Save & Run',
-  'mirroring.dataset.sourceDir':'Location',
+  'mirroring.dataset.sourceDir':'Source',
   'mirroring.dataset.target':'Target',
   'mirroring.dataset.source':'Source',
   'mirroring.dataset.filespec':'Spec',
@@ -1702,6 +1703,8 @@ Em.I18n.translations = {
   'mirroring.dataset.addTargetCluster':'Add Target Cluster',
   'mirroring.dataset.toggle.active':'Activate',
   'mirroring.dataset.toggle.suspended':'Suspend',
+  'mirroring.dataset.type.HDFS':'HDFS',
+  'mirroring.dataset.type.Hive':'Hive Tables',
 
   'mirroring.manageClusters.ambariServer':'Ambari Server',
   'mirroring.manageClusters.testConnection':'Test Connection',

http://git-wip-us.apache.org/repos/asf/ambari/blob/7349a524/ambari-web/app/templates/main/mirroring/dataset.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/mirroring/dataset.hbs b/ambari-web/app/templates/main/mirroring/dataset.hbs
index 7212386..fe6eca0 100644
--- a/ambari-web/app/templates/main/mirroring/dataset.hbs
+++ b/ambari-web/app/templates/main/mirroring/dataset.hbs
@@ -15,7 +15,7 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 }}
-<div class="pull-left dataset-form" autocomplete="off">
+<div class="row-fluid">
     <form class="form-horizontal">
         <div class="add-data-set">
             <table>
@@ -31,6 +31,20 @@
                 <tr>
                     <td class="spacer" colspan="3"></td>
                 </tr>
+
+                <tr {{bindAttr class="model.isTypeError:error"}}>
+                    <td class="percent25" colspan="1">
+                      {{t mirroring.dataset.type}}
+                    </td>
+                    <td colspan="2" style="text-align: left">
+                      {{view view.typeSelect }}
+                        <span class="help-inline">{{typeErrorMessage}}</span>
+                    </td>
+                </tr>
+                <tr>
+                    <td class="spacer" colspan="3"></td>
+                </tr>
+
                 <tr {{bindAttr class="model.isSourceDirError:error"}}>
                     <td colspan="1">
                       {{t mirroring.dataset.sourceDir}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/7349a524/ambari-web/app/templates/main/mirroring/datasets.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/mirroring/datasets.hbs b/ambari-web/app/templates/main/mirroring/datasets.hbs
index b3072cd..2c8c3d5 100644
--- a/ambari-web/app/templates/main/mirroring/datasets.hbs
+++ b/ambari-web/app/templates/main/mirroring/datasets.hbs
@@ -24,7 +24,7 @@
       </button>
       <ul class="dropdown-menu pull-left">
         <li>
-          <a href="javascript:void(null);">
+          <a  href="javascript:void(null);" {{action addNewDataset}}>
             <i class="icon-plus"></i>&nbsp;{{t mirroring.dataset.createDataset}}
           </a>
         </li>

http://git-wip-us.apache.org/repos/asf/ambari/blob/7349a524/ambari-web/app/views/main/mirroring/dataset_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/mirroring/dataset_view.js b/ambari-web/app/views/main/mirroring/dataset_view.js
index 82b45d4..3e677e0 100644
--- a/ambari-web/app/views/main/mirroring/dataset_view.js
+++ b/ambari-web/app/views/main/mirroring/dataset_view.js
@@ -130,6 +130,31 @@ App.MainMirroringDataSetView = Em.View.extend({
 
   }.property('controller.model.newDataSet'),
 
+  typeSelect: App.MainMirroringDropdownView.extend({
+
+    controller: App.get('router.mainMirroringDataSetController'),
+
+    select: function (event) {
+      var selected = event.context;
+      this.set('selected', selected);
+      this.set('controller.model.newDataSet.type', selected.value);
+    },
+
+    listOfOptions: function () {
+      return [
+        {
+          title: Em.I18n.t('mirroring.dataset.type.HDFS'),
+          value: 'HDFS'
+        },
+        {
+          title: Em.I18n.t('mirroring.dataset.type.Hive'),
+          value: 'Hive'
+        }
+      ]
+    }.property()
+
+  }),
+
   hourOptions: Ember.Object.create({
     selectedForStart: function (key, value) {
       if (value) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/7349a524/ambari-web/app/views/main/mirroring/dropdown_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/mirroring/dropdown_view.js b/ambari-web/app/views/main/mirroring/dropdown_view.js
index 15a1dab..114bb13 100644
--- a/ambari-web/app/views/main/mirroring/dropdown_view.js
+++ b/ambari-web/app/views/main/mirroring/dropdown_view.js
@@ -27,7 +27,7 @@ App.MainMirroringDropdownView = Em.View.extend({
 
   templateName:require('templates/main/mirroring/dropdown'),
 
-  selected: Ember.Object.create({title: 'Select', value: ''}),
+  selected: Ember.Object.create({title: 'Select type', value: ''}),
 
   listOfOptions : null,