|
@@ -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;
|
|
|
- }
|
|
|
-};
|
|
|
+});
|