You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2014/02/19 13:00:36 UTC
git commit: AMBARI-4735. Fix UI. (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk c6e459251 -> 4f996e435
AMBARI-4735. Fix UI. (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4f996e43
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4f996e43
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4f996e43
Branch: refs/heads/trunk
Commit: 4f996e435944fa54cffcb34dd4817893a8b295d4
Parents: c6e4592
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Wed Feb 19 13:58:30 2014 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Wed Feb 19 13:58:30 2014 +0200
----------------------------------------------------------------------
ambari-web/app/app.js | 74 +-------------------
ambari-web/app/utils/ajax.js | 3 +-
ambari-web/app/utils/helper.js | 72 +++++++++++++++++++
.../test/controllers/main/app_contoller_test.js | 1 +
4 files changed, 76 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4f996e43/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index 8f88ed2..3516be7 100644
--- a/ambari-web/app/app.js
+++ b/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;
- }
-};
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/4f996e43/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index a46f32f..b8ce8dd 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/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}',
http://git-wip-us.apache.org/repos/asf/ambari/blob/4f996e43/ambari-web/app/utils/helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js
index d538a32..c13eae2 100644
--- a/ambari-web/app/utils/helper.js
+++ b/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;
+ }
+};
http://git-wip-us.apache.org/repos/asf/ambari/blob/4f996e43/ambari-web/test/controllers/main/app_contoller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/app_contoller_test.js b/ambari-web/test/controllers/main/app_contoller_test.js
index bc91aab..1499b41 100644
--- a/ambari-web/test/controllers/main/app_contoller_test.js
+++ b/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 () {