AMBARI-3842 Host configs page should properly order services. (ababiichuk)
diff --git a/ambari-web/app/mappers/service_mapper.js b/ambari-web/app/mappers/service_mapper.js
index f6b8713..a255855 100644
--- a/ambari-web/app/mappers/service_mapper.js
+++ b/ambari-web/app/mappers/service_mapper.js
@@ -16,37 +16,9 @@
*/
var App = require('app');
+var misc = require('utils/misc');
App.servicesMapper = App.QuickDataMapper.create({
- servicesSortOrder: [
- 'HDFS',
- 'YARN',
- 'MAPREDUCE',
- 'MAPREDUCE2',
- 'TEZ',
- 'HBASE',
- 'HIVE',
- 'HCATALOG',
- 'WEBHCAT',
- 'FLUME',
- 'OOZIE',
- 'GANGLIA',
- 'NAGIOS',
- 'ZOOKEEPER',
- 'PIG',
- 'SQOOP',
- 'HUE'
- ],
- sortByOrder: function (sortOrder, array) {
- var sorted = [];
- for (var i = 0; i < sortOrder.length; i++)
- for (var j = 0; j < array.length; j++) {
- if (sortOrder[i] == array[j].id) {
- sorted.push(array[j]);
- }
- }
- return sorted;
- },
model: App.Service,
config: {
@@ -262,7 +234,7 @@
}
}, this);
- result = this.sortByOrder(this.get('servicesSortOrder'), result);
+ result = misc.sortByOrder(App.Service.servicesSortOrder, result);
//load services to model
App.store.loadMany(this.get('model'), result);
diff --git a/ambari-web/app/models/service.js b/ambari-web/app/models/service.js
index 328279b..0e53378 100644
--- a/ambari-web/app/models/service.js
+++ b/ambari-web/app/models/service.js
@@ -165,4 +165,24 @@
'FLUME': 'Flume'
};
+App.Service.servicesSortOrder = [
+ 'HDFS',
+ 'YARN',
+ 'MAPREDUCE',
+ 'MAPREDUCE2',
+ 'TEZ',
+ 'HBASE',
+ 'HIVE',
+ 'HCATALOG',
+ 'WEBHCAT',
+ 'FLUME',
+ 'OOZIE',
+ 'GANGLIA',
+ 'NAGIOS',
+ 'ZOOKEEPER',
+ 'PIG',
+ 'SQOOP',
+ 'HUE'
+];
+
App.Service.FIXTURES = [];
diff --git a/ambari-web/app/utils/misc.js b/ambari-web/app/utils/misc.js
index e1a0070..008345b 100644
--- a/ambari-web/app/utils/misc.js
+++ b/ambari-web/app/utils/misc.js
@@ -52,6 +52,17 @@
// Reuse ip variable for component counter.
var d = ip.split('.');
return ((((((+d[0])*256)+(+d[1]))*256)+(+d[2]))*256)+(+d[3]);
+ },
+
+ sortByOrder: function (sortOrder, array) {
+ var sorted = [];
+ for (var i = 0; i < sortOrder.length; i++)
+ for (var j = 0; j < array.length; j++) {
+ if (sortOrder[i] == ('get' in array[j] ? array[j].get('id') : array[j].id)) {
+ sorted.push(array[j]);
+ }
+ }
+ return sorted;
}
};
diff --git a/ambari-web/app/views/main/host/configs_service_menu.js b/ambari-web/app/views/main/host/configs_service_menu.js
index 300fb3a..03a2658 100644
--- a/ambari-web/app/views/main/host/configs_service_menu.js
+++ b/ambari-web/app/views/main/host/configs_service_menu.js
@@ -17,6 +17,7 @@
*/
var App = require('app');
+var misc = require('utils/misc');
App.MainHostServiceMenuView = Em.CollectionView.extend({
content:function () {
@@ -27,14 +28,18 @@
hostComponents.forEach(function (hc) {
var service = hc.get('service');
var serviceName = service.get('serviceName');
- if(!['PIG', 'SQOOP', 'HCATALOG', 'GANGLIA'].contains(serviceName)){
- if (!services.findProperty('serviceName', serviceName)) {
- services.push(service);
+ if (serviceName) {
+ if(!['PIG', 'SQOOP', 'HCATALOG', 'GANGLIA'].contains(serviceName)){
+ if (!services.findProperty('serviceName', serviceName)) {
+ services.push(service);
+ }
}
+ } else {
+ console.warn("serviceName not found for " + hc.get('componentName'));
}
});
}
- return services;
+ return misc.sortByOrder(App.Service.servicesSortOrder, services);
}.property('host'),
host: function(){
diff --git a/ambari-web/app/views/main/service/menu.js b/ambari-web/app/views/main/service/menu.js
index a71c72c..ab89d68 100644
--- a/ambari-web/app/views/main/service/menu.js
+++ b/ambari-web/app/views/main/service/menu.js
@@ -17,6 +17,7 @@
*/
var App = require('app');
+var misc = require('utils/misc');
App.MainServiceMenuView = Em.CollectionView.extend({
content:function () {
@@ -26,39 +27,9 @@
}
return true;
});
- return this.sortByOrder(this.get('servicesSortOrder'), items);
+ return misc.sortByOrder(App.Service.servicesSortOrder, items);
}.property('App.router.mainServiceController.content', 'App.router.mainServiceController.content.length'),
- servicesSortOrder: [
- 'HDFS',
- 'YARN',
- 'MAPREDUCE',
- 'MAPREDUCE2',
- 'TEZ',
- 'HBASE',
- 'HIVE',
- 'HCATALOG',
- 'WEBHCAT',
- 'FLUME',
- 'OOZIE',
- 'GANGLIA',
- 'NAGIOS',
- 'ZOOKEEPER',
- 'PIG',
- 'SQOOP',
- 'HUE'
- ],
- sortByOrder: function (sortOrder, array) {
- var sorted = [];
- for (var i = 0; i < sortOrder.length; i++)
- for (var j = 0; j < array.length; j++) {
- if (sortOrder[i] == array[j].get('id')) {
- sorted.push(array[j]);
- }
- }
- return sorted;
- },
-
didInsertElement:function () {
App.router.location.addObserver('lastSetURL', this, 'renderOnRoute');
this.renderOnRoute();