Procházet zdrojové kódy

AMBARI-4735. Fix UI. (onechiporenko)

Oleg Nechiporenko před 11 roky
rodič
revize
4f996e4359

+ 1 - 73
ambari-web/app/app.js

@@ -241,76 +241,4 @@ Em.View.reopen({
       console.debug('Calling set on destroyed view');
     }
   }
-});
-
-/**
- * Ambari overrides the default date transformer.
- * This is done because of the non-standard data
- * sent. For example Nagios sends date as "12345678".
- * The problem is that it is a String and is represented
- * only in seconds whereas Javascript's Date needs
- * milliseconds representation.
- */
-var App = require('app');
-DS.attr.transforms.date = {
-  from: function (serialized) {
-    var type = typeof serialized;
-    if (type === "string") {
-      serialized = parseInt(serialized);
-      type = typeof serialized;
-    }
-    if (type === "number") {
-      // The number could be seconds or milliseconds.
-      // If seconds, then multiplying with 1000 should still
-      // keep it below the current time.
-      if (serialized * 1000 < App.dateTime()) {
-        serialized = serialized * 1000;
-      }
-      return new Date(serialized);
-    } else if (serialized === null || serialized === undefined) {
-      // if the value is not present in the data,
-      // return undefined, not null.
-      return serialized;
-    } else {
-      return null;
-    }
-  },
-  to: function (deserialized) {
-    if (deserialized instanceof Date) {
-      return deserialized.getTime();
-    } else if (deserialized === undefined) {
-      return undefined;
-    } else {
-      return null;
-    }
-  }
-};
-
-DS.attr.transforms.object = {
-  from: function(serialized) {
-    return Ember.none(serialized) ? null : Object(serialized);
-  },
-
-  to: function(deserialized) {
-    return Ember.none(deserialized) ? null : Object(deserialized);
-  }
-};
-
-/**
- * Allows EmberData models to have array properties.
- *
- * Declare the property as <code>
- *  operations: DS.attr('array'),
- * </code> and
- * during load provide a JSON array for value.
- *
- * This transform simply assigns the same array in both directions.
- */
-DS.attr.transforms.array = {
-  from : function(serialized) {
-    return serialized;
-  },
-  to : function(deserialized) {
-    return deserialized;
-  }
-};
+});

+ 2 - 1
ambari-web/app/utils/ajax.js

@@ -1322,7 +1322,8 @@ var urls = {
     'mock': ''
   },
   'ambari.service.load_server_clock': {
-    'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock'
+    'real': '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/server_clock',
+    'mock': ''
   },
   'dashboard.get.user_pref': {
     'real': '/persist/{key}',

+ 72 - 0
ambari-web/app/utils/helper.js

@@ -362,3 +362,75 @@ App.registerBoundHelper('pluralize', Em.View.extend({
   }
   })
 );
+
+
+/**
+ * Ambari overrides the default date transformer.
+ * This is done because of the non-standard data
+ * sent. For example Nagios sends date as "12345678".
+ * The problem is that it is a String and is represented
+ * only in seconds whereas Javascript's Date needs
+ * milliseconds representation.
+ */
+DS.attr.transforms.date = {
+  from: function (serialized) {
+    var type = typeof serialized;
+    if (type === "string") {
+      serialized = parseInt(serialized);
+      type = typeof serialized;
+    }
+    if (type === "number") {
+      // The number could be seconds or milliseconds.
+      // If seconds, then multiplying with 1000 should still
+      // keep it below the current time.
+      if (serialized * 1000 < App.dateTime()) {
+        serialized = serialized * 1000;
+      }
+      return new Date(serialized);
+    } else if (serialized === null || serialized === undefined) {
+      // if the value is not present in the data,
+      // return undefined, not null.
+      return serialized;
+    } else {
+      return null;
+    }
+  },
+  to: function (deserialized) {
+    if (deserialized instanceof Date) {
+      return deserialized.getTime();
+    } else if (deserialized === undefined) {
+      return undefined;
+    } else {
+      return null;
+    }
+  }
+};
+
+DS.attr.transforms.object = {
+  from: function(serialized) {
+    return Ember.none(serialized) ? null : Object(serialized);
+  },
+
+  to: function(deserialized) {
+    return Ember.none(deserialized) ? null : Object(deserialized);
+  }
+};
+
+/**
+ * Allows EmberData models to have array properties.
+ *
+ * Declare the property as <code>
+ *  operations: DS.attr('array'),
+ * </code> and
+ * during load provide a JSON array for value.
+ *
+ * This transform simply assigns the same array in both directions.
+ */
+DS.attr.transforms.array = {
+  from : function(serialized) {
+    return serialized;
+  },
+  to : function(deserialized) {
+    return deserialized;
+  }
+};

+ 1 - 0
ambari-web/test/controllers/main/app_contoller_test.js

@@ -18,6 +18,7 @@
 
 
 var App = require('app');
+require('utils/helper');
 require('controllers/main/apps_controller');
 
 describe('MainAppsController', function () {