Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.0 c2879de3f -> b8e87081a


AMBARI-5719. View: Files should not hardcode REST API with view name + instance 
name. (jaimin)


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

Branch: refs/heads/branch-1.6.0
Commit: b8e87081afc382cec7d44629b6ebe7cfb3661ad1
Parents: c2879de
Author: Jaimin Jetly <[email protected]>
Authored: Fri May 9 15:27:44 2014 -0700
Committer: Jaimin Jetly <[email protected]>
Committed: Fri May 9 15:28:31 2014 -0700

----------------------------------------------------------------------
 .../views/files/src/main/resources/ui/app/adapter.js | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b8e87081/contrib/views/files/src/main/resources/ui/app/adapter.js
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/resources/ui/app/adapter.js 
b/contrib/views/files/src/main/resources/ui/app/adapter.js
index 26be40b..9f7ca65 100644
--- a/contrib/views/files/src/main/resources/ui/app/adapter.js
+++ b/contrib/views/files/src/main/resources/ui/app/adapter.js
@@ -147,9 +147,22 @@ Ember.Inflector.inflector.uncountable('fileops');
 Ember.Inflector.inflector.uncountable('download');
 Ember.Inflector.inflector.uncountable('upload');
 
+function getNamespaceUrl() {
+  var parts = window.location.pathname.match(/\/[^\/]*/g);
+  var view = parts[1];
+  var version = '/versions' + parts[2];
+  var instance = parts[3];
+  if (parts.length == 4) { // version is not present
+    instance = parts[2];
+    version = '';
+  }
+  var namespaceUrl = 'api/v1/views' + view + version + '/instances' + instance 
+ '/';
+  return namespaceUrl;
+}
+
 App.Store = DS.Store.extend({
   adapter: DS.RESTAdapter.extend({
-    namespace:'api/v1/views/FILES/instances/FILES_1/resources/files',
+    namespace: getNamespaceUrl() + 'resources/files',
     headers: {
       'X-Requested-By': 'ambari'
     },

Reply via email to