ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [18/30] git commit: AMBARI-7280. Slider View: View should use existing parameters if set. (onechiporenko)
Date Fri, 12 Sep 2014 23:53:46 GMT
AMBARI-7280. Slider View: View should use existing parameters if set. (onechiporenko)


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

Branch: refs/heads/branch-alerts-dev
Commit: 2fbbfb370155ef9adb69fc43362dd0ad1c1448a9
Parents: 941b56a
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Fri Sep 12 17:22:31 2014 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Fri Sep 12 17:22:31 2014 +0300

----------------------------------------------------------------------
 .../assets/data/resource/slider-properties.json |  64 ++++
 .../app/controllers/slider_apps_controller.js   | 187 ------------
 .../ui/app/controllers/slider_controller.js     | 294 +++++++++++++++++++
 .../src/main/resources/ui/app/helpers/ajax.js   |  44 +--
 .../src/main/resources/ui/app/initialize.js     |  16 +-
 .../ui/app/mappers/application_status.js        |  52 +++-
 6 files changed, 434 insertions(+), 223 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2fbbfb37/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/slider-properties.json
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/slider-properties.json
b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/slider-properties.json
new file mode 100644
index 0000000..53a3331
--- /dev/null
+++ b/contrib/views/slider/src/main/resources/ui/app/assets/data/resource/slider-properties.json
@@ -0,0 +1,64 @@
+{
+  "href" : "http://host:8080/api/v1/views/SLIDER/versions/1.0.0/instances/MySliderName",
+  "ViewInstanceInfo" : {
+    "context_path" : "/views/SLIDER/1.0.0/MySliderName",
+    "description" : "MySliderDescription",
+    "icon64_path" : null,
+    "icon_path" : null,
+    "instance_name" : "MySliderName",
+    "label" : "MySliderDisplay",
+    "static" : false,
+    "version" : "1.0.0",
+    "view_name" : "SLIDER",
+    "visible" : true,
+    "instance_data" : { },
+    "properties" : {
+      "hdfs.address" : "hdfs://slider-1.c.pramod-thangali.internal:8020",
+      "yarn.resourcemanager.address" : "slider-2.c.pramod-thangali.internal:8050",
+      "yarn.resourcemanager.scheduler.address" : "slider-2.c.pramod-thangali.internal:8030",
+      "zookeeper.quorum" : "slider-1.c.pramod-thangali.internal:2181,slider-2.c.pramod-thangali.internal:2181,slider-3.c.pramod-thangali.internal:2181"
+    }
+  },
+  "resources" : [
+    {
+      "href" : "http://host:8080/api/v1/views/SLIDER/versions/1.0.0/instances/MySliderName/resources/status",
+      "instance_name" : "MySliderName",
+      "name" : "status",
+      "version" : "1.0.0",
+      "view_name" : "SLIDER"
+    }
+  ],
+  "apps" : [
+    {
+      "href" : "http://host:8080/api/v1/views/SLIDER/versions/1.0.0/instances/MySliderName/apps/1410332504508_1",
+      "id" : "1410332504508_1",
+      "instance_name" : "MySliderName",
+      "version" : "1.0.0",
+      "view_name" : "SLIDER"
+    },
+    {
+      "href" : "http://host:8080/api/v1/views/SLIDER/versions/1.0.0/instances/MySliderName/apps/1410332504508_2",
+      "id" : "1410332504508_2",
+      "instance_name" : "MySliderName",
+      "version" : "1.0.0",
+      "view_name" : "SLIDER"
+    }
+  ],
+  "privileges" : [ ],
+  "apptypes" : [
+    {
+      "href" : "http://host:8080/api/v1/views/SLIDER/versions/1.0.0/instances/MySliderName/apptypes/HBASE",
+      "id" : "HBASE",
+      "instance_name" : "MySliderName",
+      "version" : "1.0.0",
+      "view_name" : "SLIDER"
+    },
+    {
+      "href" : "http://host:8080/api/v1/views/SLIDER/versions/1.0.0/instances/MySliderName/apptypes/STORM",
+      "id" : "STORM",
+      "instance_name" : "MySliderName",
+      "version" : "1.0.0",
+      "view_name" : "SLIDER"
+    }
+  ]
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/2fbbfb37/contrib/views/slider/src/main/resources/ui/app/controllers/slider_apps_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_apps_controller.js
b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_apps_controller.js
index 2f422f1..1bca7e4 100644
--- a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_apps_controller.js
+++ b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_apps_controller.js
@@ -18,191 +18,4 @@
 
 App.SliderAppsController = Ember.ArrayController.extend({
 
-  /**
-   *  Load resources on controller initialization
-   * @method initResources
-   */
-  initResources:function () {
-    this.getClusterName();
-  },
-
-  initialValuesToLoad: Em.Object.create({
-    ambariAddress: null,
-    clusterName: null,
-    hdfsAddress: null,
-    yarnRMAddress: null,
-    yarnRMSchedulerAddress: null,
-    zookeeperQuorum: null
-  }),
-
-  zookeeperHosts: [],
-
-  /**
-   * Get cluster name from server
-   * @returns {$.ajax}
-   * @method getClusterName
-   */
-  getClusterName: function() {
-    return App.ajax.send({
-      name: 'cluster_name',
-      sender: this,
-      data: {
-        urlPrefix: '/api/v1/'
-      },
-      success: 'getClusterNameSuccessCallback'
-    });
-  },
-
-  /**
-   * Success callback for clusterName-request
-   * @param {object} data
-   * @method getClusterNameSuccessCallback
-   */
-  getClusterNameSuccessCallback: function(data) {
-    var clusterName = Em.get(data.items[0], 'Clusters.cluster_name');
-    App.set('clusterName', clusterName);
-    App.ApplicationStatusMapper.loop('load');
-    this.loadConfigsTags();
-    this.loadComponentHost({componentName:"GANGLIA_SERVER",callback:"loadGangliaHostSuccessCallback"});
-    this.loadComponentHost({componentName:"NAGIOS_SERVER",callback:"loadNagiosHostSuccessCallback"});
-    this.loadComponentHost({componentName:"ZOOKEEPER_SERVER",callback:"setZookeeperQuorum"});
-  },
-
-  loadConfigsTags: function () {
-    App.ajax.send({
-      name: 'config.tags',
-      sender: this,
-      data: {
-        urlPrefix: '/api/v1/'
-      },
-      success: 'onLoadConfigsTags'
-    });
-  },
-
-  onLoadConfigsTags: function (data) {
-    var urlParams = [];
-    if(data.Clusters.desired_configs['yarn-site'] && data.Clusters.desired_configs['zookeeper-env']){
-      var coreSiteTag = data.Clusters.desired_configs['core-site'].tag;
-      var yarnSiteTag = data.Clusters.desired_configs['yarn-site'].tag;
-      var zookeeperTag = data.Clusters.desired_configs['zookeeper-env'].tag;
-      urlParams.push('(type=core-site&tag=' + coreSiteTag + ')');
-      urlParams.push('(type=yarn-site&tag=' + yarnSiteTag + ')');
-      urlParams.push('(type=zookeeper-env&tag=' + zookeeperTag + ')');
-
-      App.ajax.send({
-        name: 'get_all_configurations',
-        sender: this,
-        data: {
-          urlParams: urlParams.join('|'),
-          urlPrefix: '/api/v1/'
-        },
-        success: 'onLoadConfigs'
-      });
-    }
-  },
-
-  onLoadConfigs: function (data) {
-    var hdfs = data.items.findProperty('type', 'core-site'),
-    yarn = data.items.findProperty('type', 'yarn-site'),
-    zookeeper = data.items.findProperty('type', 'zookeeper-env'),
-    initialValuesToLoad = this.get('initialValuesToLoad');
-    initialValuesToLoad.set('ambariAddress', location.protocol+"//"+document.location.host);
-    initialValuesToLoad.set('clusterName', App.get('clusterName'));
-    initialValuesToLoad.set('hdfsAddress', hdfs.properties['fs.defaultFS']);
-    initialValuesToLoad.set('yarnRMAddress', yarn.properties['yarn.resourcemanager.address']);
-    initialValuesToLoad.set('yarnRMSchedulerAddress', yarn.properties['yarn.resourcemanager.scheduler.address']);
-    initialValuesToLoad.set('zookeeperQuorum', zookeeper.properties.clientPort);
-    this.setZookeeperQuorum();
-  },
-
-  setZookeeperQuorum: function (data){
-    var zookeeperHosts = this.get('zookeeperHosts'),
-    hosts = [],
-    initialValuesToLoad = this.get('initialValuesToLoad');
-
-    //done
-    if(initialValuesToLoad.zookeeperQuorum !== null){
-      if(data){
-        hosts = data.items.map(function(item) {
-          return item.Hosts.host_name + ":" + initialValuesToLoad.zookeeperQuorum;
-        });
-        initialValuesToLoad.set('zookeeperQuorum', hosts.join(','));
-        this.sendInitialValues();
-      }else if(zookeeperHosts.length > 0){
-        hosts = zookeeperHosts.map(function(host) {
-          return host + ":" + initialValuesToLoad.zookeeperQuorum;
-        });
-        initialValuesToLoad.set('zookeeperQuorum', hosts.join(','));
-        this.sendInitialValues();
-      }
-    }else{
-      this.set('zookeeperHosts', data.items.mapProperty('Hosts.host_name'));
-    }
-  },
-
-  /**
-   * Send request to server to save initialValues
-   * @return {$.ajax}
-   * @method sendInitialValues
-   */
-  sendInitialValues: function () {
-    var initialValues = this.get('initialValuesToLoad');
-    return App.ajax.send({
-      name: 'saveInitialValues',
-      sender: this,
-      data: {
-        data:  {
-          ViewInstanceInfo: {
-            properties: {
-              'hdfs.address': initialValues.get('hdfsAddress'),
-              'yarn.resourcemanager.address': initialValues.get('yarnRMAddress'),
-              'yarn.resourcemanager.scheduler.address': initialValues.get('yarnRMSchedulerAddress'),
-              'zookeeper.quorum': initialValues.get('zookeeperQuorum')
-            }
-          }
-        }
-      }
-    });
-  },
-
-  /**
-   * Load ganglia server host
-   * @method loadGangliaHost
-   */
-  loadComponentHost: function (params) {
-    return App.ajax.send({
-      name: 'components_hosts',
-      sender: this,
-      data: {
-        componentName: params.componentName,
-        urlPrefix: '/api/v1/'
-      },
-      success: params.callback
-    });
-
-  },
-
-  /**
-   * Success callback for hosts-request
-   * Save host name to gangliaHost
-   * @param {Object} data
-   * @method loadGangliaHostSuccessCallback
-   */
-  loadGangliaHostSuccessCallback: function (data) {
-    if(data.items[0]){
-      App.set('gangliaHost', Em.get(data.items[0], 'Hosts.host_name'));
-    }
-  },
-
-  /**
-   * Success callback for hosts-request
-   * Save host name to nagiosHost
-   * @param {Object} data
-   * @method loadGangliaHostSuccessCallback
-   */
-  loadNagiosHostSuccessCallback: function (data) {
-    if(data.items[0]){
-      App.set('nagiosHost', Em.get(data.items[0], 'Hosts.host_name'));
-    }
-  }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/2fbbfb37/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js
b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js
new file mode 100644
index 0000000..8283de1
--- /dev/null
+++ b/contrib/views/slider/src/main/resources/ui/app/controllers/slider_controller.js
@@ -0,0 +1,294 @@
+/**
+ * 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.
+ */
+
+/**
+ * Checks Slider-properties.
+ * If they are not available, uses Ambari-configs to populate them:
+ *  - Load cluster name
+ *  - Load hostName for GANGLIA_SERVER
+ *  - Load hostName for NAGIOS_SERVER
+ *  - Load hostNames for ZOOKEEPER_SERVER
+ *  - Load config tags
+ *  - Load configs
+ *  - Save Slider-properties
+ * If Slider-properties exists:
+ *  - Load cluster name
+ *  - Load hostNames
+ * @type {Ember.Controller}
+ */
+App.SliderController = Ember.Controller.extend({
+
+  /**
+   *  Load resources on controller initialization
+   * @method initResources
+   */
+  initResources: function () {
+    this.getParametersFromViewProperties();
+  },
+
+  /**
+   * List of Slider-properties mapped from Ambari-configs
+   * @type {Em.Object}
+   */
+  initialValuesToLoad: Em.Object.create({
+    ambariAddress: null,
+    clusterName: null,
+    hdfsAddress: null,
+    yarnRMAddress: null,
+    yarnRMSchedulerAddress: null,
+    zookeeperQuorum: null
+  }),
+
+  /**
+   * List of host names with ZOOKEEPER_SERVER installed
+   * @type {string[]}
+   */
+  zookeeperHosts: [],
+
+  /**
+   * Get Slider properties from View-parameters (set in the Ambari Admin View)
+   * If parameters can't be found, use Ambari-configs to populate Slider properties
+   * @returns {$.ajax}
+   * @method getParametersFromViewProperties
+   */
+  getParametersFromViewProperties: function() {
+    return App.ajax.send({
+      name: 'slider.getViewParams',
+      sender: this,
+      success: 'getParametersFromViewPropertiesSuccessCallback',
+      error: 'getClusterName'
+    });
+  },
+
+  /**
+   * Check if Slider-properties exist
+   * If not - get Ambari configs to populate Slider properties
+   * @param {object} data
+   * @method getParametersFromViewPropertiesSuccessCallback
+   */
+  getParametersFromViewPropertiesSuccessCallback: function(data) {
+    var properties = Em.get(data, 'ViewInstanceInfo.properties'),
+      loadConfigs = Em.isNone(properties);
+      this.getClusterName(loadConfigs);
+  },
+
+  /**
+   * Get cluster name from server
+   * @returns {$.ajax}
+   * @method getClusterName
+   */
+  getClusterName: function (loadConfigs) {
+    if (Em.isNone(loadConfigs)) loadConfigs = true;
+    return App.ajax.send({
+      name: 'cluster_name',
+      sender: this,
+      data: {
+        urlPrefix: '/api/v1/',
+        loadConfigs: loadConfigs
+      },
+      success: 'getClusterNameSuccessCallback'
+    });
+  },
+
+  /**
+   * Success callback for clusterName-request
+   * @param {object} data
+   * @param {object} opt
+   * @param {object} params
+   * @method getClusterNameSuccessCallback
+   */
+  getClusterNameSuccessCallback: function (data, opt, params) {
+    var clusterName = Em.get(data.items[0], 'Clusters.cluster_name');
+    App.set('clusterName', clusterName);
+    App.ApplicationStatusMapper.loop('load');
+    this.loadComponentHost({componentName: "GANGLIA_SERVER", callback: "loadGangliaHostSuccessCallback"});
+    this.loadComponentHost({componentName: "NAGIOS_SERVER", callback: "loadNagiosHostSuccessCallback"});
+    this.loadComponentHost({componentName: "ZOOKEEPER_SERVER", callback: "setZookeeperQuorum"});
+    if(params.loadConfigs) {
+      this.loadConfigsTags();
+    }
+  },
+
+  /**
+   * Load config tags from server
+   * @returns {$.ajax}
+   * @method loadConfigsTags
+   */
+  loadConfigsTags: function () {
+    return App.ajax.send({
+      name: 'config.tags',
+      sender: this,
+      data: {
+        urlPrefix: '/api/v1/'
+      },
+      success: 'onLoadConfigsTags'
+    });
+  },
+
+  /**
+   * Success callback for <code>loadConfigsTags</code>
+   * Get configs for selected tags
+   * @param {object} data
+   * @method onLoadConfigsTags
+   */
+  onLoadConfigsTags: function (data) {
+    var urlParams = [];
+    if (data.Clusters.desired_configs['yarn-site'] && data.Clusters.desired_configs['zookeeper-env'])
{
+      var coreSiteTag = data.Clusters.desired_configs['core-site'].tag;
+      var yarnSiteTag = data.Clusters.desired_configs['yarn-site'].tag;
+      var zookeeperTag = data.Clusters.desired_configs['zookeeper-env'].tag;
+      urlParams.push('(type=core-site&tag=' + coreSiteTag + ')');
+      urlParams.push('(type=yarn-site&tag=' + yarnSiteTag + ')');
+      urlParams.push('(type=zookeeper-env&tag=' + zookeeperTag + ')');
+
+      App.ajax.send({
+        name: 'get_all_configurations',
+        sender: this,
+        data: {
+          urlParams: urlParams.join('|'),
+          urlPrefix: '/api/v1/'
+        },
+        success: 'onLoadConfigs'
+      });
+    }
+  },
+
+  /**
+   * Success callback for <code>onLoadConfigs</code>
+   * Set properties for <code>initialValuesToLoad</code> using loaded configs
+   * @param {object} data
+   * @method onLoadConfigs
+   */
+  onLoadConfigs: function (data) {
+    var hdfs = data.items.findProperty('type', 'core-site'),
+      yarn = data.items.findProperty('type', 'yarn-site'),
+      zookeeper = data.items.findProperty('type', 'zookeeper-env'),
+      initialValuesToLoad = this.get('initialValuesToLoad');
+    initialValuesToLoad.set('ambariAddress', location.protocol + "//" + document.location.host);
+    initialValuesToLoad.set('clusterName', App.get('clusterName'));
+    initialValuesToLoad.set('hdfsAddress', hdfs.properties['fs.defaultFS']);
+    initialValuesToLoad.set('yarnRMAddress', yarn.properties['yarn.resourcemanager.address']);
+    initialValuesToLoad.set('yarnRMSchedulerAddress', yarn.properties['yarn.resourcemanager.scheduler.address']);
+    initialValuesToLoad.set('zookeeperQuorum', zookeeper.properties.clientPort);
+    this.setZookeeperQuorum();
+  },
+
+  /**
+   * Set value for <code>initialValuesToLoad.zookeeperQuorum</code>
+   * Also do request to save Slider-properties
+   * @param {object} data
+   * @method setZookeeperQuorum
+   */
+  setZookeeperQuorum: function (data) {
+    var zookeeperHosts = this.get('zookeeperHosts'),
+      hosts = [],
+      initialValuesToLoad = this.get('initialValuesToLoad');
+
+    //done
+    if (!Em.isNone(initialValuesToLoad.zookeeperQuorum)) {
+      if (data) {
+        hosts = data.items.map(function (item) {
+          return item.Hosts.host_name + ":" + initialValuesToLoad.zookeeperQuorum;
+        });
+        initialValuesToLoad.set('zookeeperQuorum', hosts.join(','));
+        this.sendInitialValues();
+      }
+      else {
+        if (zookeeperHosts.length > 0) {
+          hosts = zookeeperHosts.map(function (host) {
+            return host + ":" + initialValuesToLoad.zookeeperQuorum;
+          });
+          initialValuesToLoad.set('zookeeperQuorum', hosts.join(','));
+          this.sendInitialValues();
+        }
+      }
+    }
+    else {
+      this.set('zookeeperHosts', data.items.mapProperty('Hosts.host_name'));
+    }
+  },
+
+  /**
+   * Send request to server to save initialValues
+   * @return {$.ajax}
+   * @method sendInitialValues
+   */
+  sendInitialValues: function () {
+    var initialValues = this.get('initialValuesToLoad');
+    return App.ajax.send({
+      name: 'saveInitialValues',
+      sender: this,
+      data: {
+        data: {
+          ViewInstanceInfo: {
+            properties: {
+              'hdfs.address': initialValues.get('hdfsAddress'),
+              'yarn.resourcemanager.address': initialValues.get('yarnRMAddress'),
+              'yarn.resourcemanager.scheduler.address': initialValues.get('yarnRMSchedulerAddress'),
+              'zookeeper.quorum': initialValues.get('zookeeperQuorum')
+            }
+          }
+        }
+      }
+    });
+  },
+
+  /**
+   * Load host for component
+   * @param {{componentName: string, callback: string}} params
+   * @return {$.ajax}
+   * @method loadGangliaHost
+   */
+  loadComponentHost: function (params) {
+    return App.ajax.send({
+      name: 'components_hosts',
+      sender: this,
+      data: {
+        componentName: params.componentName,
+        urlPrefix: '/api/v1/'
+      },
+      success: params.callback
+    });
+
+  },
+
+  /**
+   * Success callback for hosts-request
+   * Save host name to GANGLIA_SERVER (set in <code>App.gangliaHost</code>)
+   * @param {Object} data
+   * @method loadGangliaHostSuccessCallback
+   */
+  loadGangliaHostSuccessCallback: function (data) {
+    if (data.items[0]) {
+      App.set('gangliaHost', Em.get(data.items[0], 'Hosts.host_name'));
+    }
+  },
+
+  /**
+   * Success callback for hosts-request
+   * Save host name to NAGIOS_SERVER (set in <code>App.nagiosHost</code>)
+   * @param {Object} data
+   * @method loadGangliaHostSuccessCallback
+   */
+  loadNagiosHostSuccessCallback: function (data) {
+    if (data.items[0]) {
+      App.set('nagiosHost', Em.get(data.items[0], 'Hosts.host_name'));
+    }
+  }
+
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/2fbbfb37/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js b/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
index 6d7e4a1..3da0624 100644
--- a/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
+++ b/contrib/views/slider/src/main/resources/ui/app/helpers/ajax.js
@@ -30,11 +30,16 @@
  */
 var urls = {
 
+  'slider.getViewParams': {
+    real: '',
+    mock: '/data/resource/slider-properties.json'
+  },
+
   'mapper.applicationTypes': {
     real: 'apptypes?fields=*',
     mock: '/data/apptypes/all_fields.json',
     headers: {
-      Accept : "text/plain; charset=utf-8",
+      Accept: "text/plain; charset=utf-8",
       "Content-Type": "text/plain; charset=utf-8"
     }
   },
@@ -43,7 +48,7 @@ var urls = {
     real: 'apps/?fields=*',
     mock: '/data/apps/apps.json',
     headers: {
-      Accept : "text/plain; charset=utf-8",
+      Accept: "text/plain; charset=utf-8",
       "Content-Type": "text/plain; charset=utf-8"
     }
   },
@@ -58,7 +63,7 @@ var urls = {
     headers: {
       "Content-Type": "text/plain; charset=utf-8"
     },
-    format: function(data) {
+    format: function (data) {
       return {
         type: 'PUT',
         data: JSON.stringify(data.data)
@@ -72,7 +77,7 @@ var urls = {
     headers: {
       "Content-Type": "text/plain; charset=utf-8"
     },
-    format: function(data) {
+    format: function (data) {
       return {
         type: 'POST',
         data: JSON.stringify(data.data)
@@ -83,7 +88,7 @@ var urls = {
   'destroyApp': {
     real: 'apps/{id}',
     mock: '',
-    format: function() {
+    format: function () {
       return {
         method: 'DELETE'
       }
@@ -96,7 +101,7 @@ var urls = {
     headers: {
       "Content-Type": "text/plain; charset=utf-8"
     },
-    format: function(data) {
+    format: function (data) {
       return {
         method: 'PUT',
         data: JSON.stringify(data.data)
@@ -109,7 +114,7 @@ var urls = {
     headers: {
       "Content-Type": "text/plain; charset=utf-8"
     },
-    format: function(data) {
+    format: function (data) {
       return {
         method: 'PUT',
         data: JSON.stringify(data.data)
@@ -119,18 +124,18 @@ var urls = {
 
   'service_status': {
     real: 'clusters/{clusterName}/services?fields=ServiceInfo/state&minimal_response=true',
-    mock:'/data/resource/service_status.json',
+    mock: '/data/resource/service_status.json',
     headers: {
-      Accept : "text/plain; charset=utf-8",
+      Accept: "text/plain; charset=utf-8",
       "Content-Type": "text/plain; charset=utf-8"
     }
   },
 
   'components_hosts': {
     real: 'clusters/{clusterName}/hosts?host_components/HostRoles/component_name={componentName}&minimal_response=true',
-    mock:'/data/resource/components_hosts.json',
+    mock: '/data/resource/components_hosts.json',
     headers: {
-      Accept : "text/plain; charset=utf-8",
+      Accept: "text/plain; charset=utf-8",
       "Content-Type": "text/plain; charset=utf-8"
     }
   },
@@ -139,7 +144,7 @@ var urls = {
     real: 'clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&is_current=true',
     mock: '/data/resource/service_configs.json',
     headers: {
-      Accept : "text/plain; charset=utf-8",
+      Accept: "text/plain; charset=utf-8",
       "Content-Type": "text/plain; charset=utf-8"
     }
   },
@@ -147,7 +152,7 @@ var urls = {
   'config.tags': {
     'real': 'clusters/{clusterName}?fields=Clusters/desired_configs',
     headers: {
-      Accept : "text/plain; charset=utf-8",
+      Accept: "text/plain; charset=utf-8",
       "Content-Type": "text/plain; charset=utf-8"
     }
   },
@@ -155,16 +160,16 @@ var urls = {
   'get_all_configurations': {
     'real': 'clusters/{clusterName}/configurations?{urlParams}',
     headers: {
-      Accept : "text/plain; charset=utf-8",
+      Accept: "text/plain; charset=utf-8",
       "Content-Type": "text/plain; charset=utf-8"
     }
   },
 
   'cluster_name': {
     real: 'clusters',
-    mock:'/data/resource/cluster_name.json',
+    mock: '/data/resource/cluster_name.json',
     headers: {
-      Accept : "text/plain; charset=utf-8",
+      Accept: "text/plain; charset=utf-8",
       "Content-Type": "text/plain; charset=utf-8"
     }
   },
@@ -234,10 +239,11 @@ var formatRequest = function (data) {
   }
   else {
     var prefix = App.get('urlPrefix');
-    if(Em.get(data, 'urlPrefix')){
-      var prefix = Em.get(data, 'urlPrefix');
+    if (Em.get(data, 'urlPrefix')) {
+      prefix = Em.get(data, 'urlPrefix');
     }
-    opt.url = prefix + (formatUrl(this.real, data) ? formatUrl(this.real, data) : "");
+    var url = formatUrl(this.real, data);
+    opt.url = prefix + (url ? url : '');
   }
 
   if (this.format) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/2fbbfb37/contrib/views/slider/src/main/resources/ui/app/initialize.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/initialize.js b/contrib/views/slider/src/main/resources/ui/app/initialize.js
index 4fc797a..c9b53d7 100755
--- a/contrib/views/slider/src/main/resources/ui/app/initialize.js
+++ b/contrib/views/slider/src/main/resources/ui/app/initialize.js
@@ -90,10 +90,22 @@ App.initializer({
        * List of errors
        * @type {string[]}
        */
-      viewErrors: []
+      viewErrors: [],
+
+      /**
+       * Host with Nagios Server
+       * @type {string|null}
+       */
+      nagiosHost: null,
+
+      /**
+       * Host with Ganglia Server
+       * @type {string|null}
+       */
+      gangliaHost: null
 
     });
-    application.SliderAppsController.proto().initResources();
+    application.SliderController.proto().initResources();
     application.ApplicationTypeMapper.loop('load');
     application.SliderAppsMapper.loop('load');
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/2fbbfb37/contrib/views/slider/src/main/resources/ui/app/mappers/application_status.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/mappers/application_status.js
b/contrib/views/slider/src/main/resources/ui/app/mappers/application_status.js
index f3d3968..21e4c55 100644
--- a/contrib/views/slider/src/main/resources/ui/app/mappers/application_status.js
+++ b/contrib/views/slider/src/main/resources/ui/app/mappers/application_status.js
@@ -38,7 +38,7 @@ App.ApplicationStatusMapper = App.Mapper.createWithMixins(App.RunPeriodically,
{
    * @method load
    * @return {$.ajax}
    */
-  load: function() {
+  load: function () {
     return App.ajax.send({
       name: 'mapper.applicationStatus',
       sender: this,
@@ -51,13 +51,18 @@ App.ApplicationStatusMapper = App.Mapper.createWithMixins(App.RunPeriodically,
{
    * @param {object} data received from server data
    * @method setResourcesVersion
    */
-  setResourcesVersion: function(data) {
-    App.set('resourcesVersion', Em.get(data, "version") ? Em.get(data, "version") : "version"
);
-    if(App.get('clusterName')){
+  setResourcesVersion: function (data) {
+    App.set('resourcesVersion', Em.getWithDefault(data, "version", 'version'));
+    if (App.get('clusterName')) {
       this.loadServicesStatus();
     }
   },
 
+  /**
+   * Get Services status from Ambari-server
+   * @returns {$.ajax}
+   * @method loadServicesStatus
+   */
   loadServicesStatus: function () {
     return App.ajax.send({
       name: 'service_status',
@@ -69,25 +74,42 @@ App.ApplicationStatusMapper = App.Mapper.createWithMixins(App.RunPeriodically,
{
     });
   },
 
+  /**
+   * Success-callback for load services status
+   * Set Slider state basing on <code>ServiceInfo.state</code>
+   * @param {object} data
+   * @method setErrors
+   */
   setErrors: function (data) {
     var self = this,
-    errors = [];
-    this.get('servicesWeNeed').forEach( function (serviceName) {
-      self.findError(data.items.findProperty("ServiceInfo.service_name", serviceName), errors);
+      errors = [];
+    this.get('servicesWeNeed').forEach(function (serviceName) {
+      var e = self.findError(data.items.findProperty("ServiceInfo.service_name", serviceName));
+      if (!Em.isNone(e)) {
+        errors.push(e);
+      }
     });
 
-    App.set('viewEnabled', (errors.length > 0 ? false : true));
+    App.set('viewEnabled', errors.length === 0);
     App.set('viewErrors', errors);
   },
 
-  findError: function (data, errors){
-    var name = Em.get(data, "ServiceInfo.service_name")
-    if(data){
-      if(Em.get(data, "ServiceInfo.state") != "STARTED")
-        errors.push(Em.I18n.t('error.start'+name));
-    }else{
-      errors.push(Em.I18n.t('error.no'+name));
+  /**
+   * Get error for service (missed or not started)
+   * @param {object} data
+   * @returns {string|null}
+   */
+  findError: function (data) {
+    var name = Em.get(data, "ServiceInfo.service_name"),
+      error = null;
+    if (data) {
+      if (Em.get(data, "ServiceInfo.state") != "STARTED")
+        error = Em.I18n.t('error.start' + name);
+    }
+    else {
+      error = Em.I18n.t('error.no' + name);
     }
+    return error;
   }
 
 });
\ No newline at end of file


Mime
View raw message