rhoconnect 3.2.1 → 3.3.1.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. data/CHANGELOG.md +24 -5
  2. data/Gemfile +2 -2
  3. data/Gemfile.lock +20 -20
  4. data/bench/benchapp/Gemfile +17 -20
  5. data/bench/benchapp/config.ru +2 -2
  6. data/bench/benchapp/settings/settings.yml +3 -3
  7. data/bench/blobapp/Gemfile +16 -13
  8. data/bench/blobapp/config.ru +2 -2
  9. data/bench/blobapp/settings/settings.yml +5 -3
  10. data/bench/lib/bench.rb +35 -32
  11. data/bench/lib/bench/session.rb +9 -1
  12. data/bench/scripts/blob_cud_script.rb +13 -17
  13. data/bench/scripts/cud_script.rb +11 -12
  14. data/bench/scripts/helpers.rb +5 -7
  15. data/bench/scripts/query_md_script.rb +18 -12
  16. data/bench/scripts/query_only_script.rb +19 -11
  17. data/bench/scripts/query_script.rb +17 -13
  18. data/bench/scripts/test_query_script.rb +46 -17
  19. data/bench/scripts/test_source_script.rb +7 -7
  20. data/commands/commands/dtach_commands/dtach_install.rb +44 -16
  21. data/commands/commands/rhoconnect/spec.rb +13 -9
  22. data/commands/commands/rhoconnect/version.rb +6 -0
  23. data/commands/execute.rb +10 -6
  24. data/doc/deploying.txt +75 -13
  25. data/doc/install.txt +3 -3
  26. data/doc/push-client-setup.txt +1 -1
  27. data/doc/rest-api.txt +4 -23
  28. data/doc/rhoconnect-redis-stack.txt +26 -7
  29. data/doc/settings.txt +9 -3
  30. data/examples/simple/Gemfile +3 -1
  31. data/examples/simple/application.rb +5 -0
  32. data/examples/simple/config.ru +3 -2
  33. data/examples/simple/my_server.rb +14 -0
  34. data/examples/simple/settings/settings.yml +1 -0
  35. data/generators/templates/application/Gemfile +4 -4
  36. data/generators/templates/application/application.rb +4 -0
  37. data/generators/templates/application/settings/settings.yml +4 -1
  38. data/installer/unix-like/create_texts.rb +39 -1
  39. data/installer/unix-like/rho_connect_install_constants.rb +1 -1
  40. data/installer/utils/package_upload/repos.rake +7 -5
  41. data/lib/rhoconnect.rb +3 -2
  42. data/lib/rhoconnect/api/app/ans_login.rb +3 -0
  43. data/lib/rhoconnect/api/app/bulk_data.rb +6 -0
  44. data/lib/rhoconnect/api/{source → app}/fast_delete.rb +1 -1
  45. data/lib/rhoconnect/api/{source → app}/fast_insert.rb +2 -2
  46. data/lib/rhoconnect/api/{source → app}/fast_update.rb +2 -2
  47. data/lib/rhoconnect/api/app/login.rb +5 -0
  48. data/lib/rhoconnect/api/{source → app}/push_deletes.rb +1 -1
  49. data/lib/rhoconnect/api/{source → app}/push_objects.rb +1 -1
  50. data/lib/rhoconnect/api/app/query.rb +4 -0
  51. data/lib/rhoconnect/api/app/queue_updates.rb +94 -0
  52. data/lib/rhoconnect/api/app/search.rb +4 -0
  53. data/lib/rhoconnect/api/client/client_get_db_doc.rb +5 -0
  54. data/lib/rhoconnect/api/client/client_set_db_doc.rb +8 -0
  55. data/lib/rhoconnect/api/client/create.rb +7 -0
  56. data/lib/rhoconnect/api/client/get_client_params.rb +2 -1
  57. data/lib/rhoconnect/api/client/list_client_docs.rb +2 -1
  58. data/lib/rhoconnect/api/client/register.rb +12 -0
  59. data/lib/rhoconnect/api/client/reset.rb +5 -0
  60. data/lib/rhoconnect/api/{source → readstate}/set_refresh_time.rb +2 -1
  61. data/lib/rhoconnect/api/source/get_source_params.rb +3 -2
  62. data/lib/rhoconnect/api/source/list_sources.rb +2 -1
  63. data/lib/rhoconnect/api/source/update_source_params.rb +3 -3
  64. data/lib/rhoconnect/api/store/get_db_doc.rb +4 -0
  65. data/lib/rhoconnect/api/store/set_db_doc.rb +7 -0
  66. data/lib/rhoconnect/api/system/get_adapter.rb +4 -0
  67. data/lib/rhoconnect/api/{admin → system}/get_license_info.rb +2 -1
  68. data/lib/rhoconnect/api/system/login.rb +15 -0
  69. data/lib/rhoconnect/api/{admin → system}/reset.rb +3 -2
  70. data/lib/rhoconnect/api/system/save_adapter.rb +4 -0
  71. data/lib/rhoconnect/api/{admin → system}/stats.rb +2 -1
  72. data/lib/rhoconnect/api/user/create_user.rb +2 -2
  73. data/lib/rhoconnect/api/user/delete_client.rb +6 -0
  74. data/lib/rhoconnect/api/user/delete_user.rb +2 -1
  75. data/lib/rhoconnect/api/user/list_clients.rb +4 -0
  76. data/lib/rhoconnect/api/user/list_source_docs.rb +11 -0
  77. data/lib/rhoconnect/api/user/list_users.rb +1 -1
  78. data/lib/rhoconnect/api/user/ping.rb +7 -0
  79. data/lib/rhoconnect/api/user/show_user.rb +3 -0
  80. data/lib/rhoconnect/api/user/update_user.rb +3 -2
  81. data/lib/rhoconnect/api/user/user_get_db_doc.rb +5 -0
  82. data/lib/rhoconnect/api/user/user_set_db_doc.rb +10 -0
  83. data/lib/rhoconnect/app.rb +12 -2
  84. data/lib/rhoconnect/async.rb +6 -10
  85. data/lib/rhoconnect/bulk_data/bulk_data.rb +4 -4
  86. data/lib/rhoconnect/client.rb +10 -9
  87. data/lib/rhoconnect/client_sync.rb +24 -19
  88. data/lib/rhoconnect/document.rb +18 -4
  89. data/lib/rhoconnect/graph_helper.rb +4 -2
  90. data/lib/rhoconnect/jobs/bulk_data_job.rb +1 -1
  91. data/lib/rhoconnect/jobs/ping_job.rb +39 -29
  92. data/lib/rhoconnect/middleware/admin_user.rb +23 -0
  93. data/lib/rhoconnect/middleware/body_content_type_parser.rb +35 -0
  94. data/lib/rhoconnect/{cors.rb → middleware/cors.rb} +1 -0
  95. data/lib/rhoconnect/middleware/current_app.rb +16 -0
  96. data/lib/rhoconnect/middleware/current_request.rb +16 -0
  97. data/lib/rhoconnect/middleware/current_user.rb +17 -0
  98. data/lib/rhoconnect/middleware/helpers.rb +105 -0
  99. data/lib/rhoconnect/middleware/login_required.rb +22 -0
  100. data/lib/rhoconnect/{stats/middleware.rb → middleware/stats.rb} +5 -3
  101. data/lib/rhoconnect/middleware/x_domain_session_wrapper.rb +58 -0
  102. data/lib/rhoconnect/ping.rb +1 -0
  103. data/lib/rhoconnect/ping/apple.rb +18 -16
  104. data/lib/rhoconnect/ping/blackberry.rb +9 -9
  105. data/lib/rhoconnect/ping/rhoconnect_push.rb +45 -0
  106. data/lib/rhoconnect/server.rb +98 -91
  107. data/lib/rhoconnect/source.rb +5 -1
  108. data/lib/rhoconnect/source_sync.rb +4 -3
  109. data/lib/rhoconnect/stats/record.rb +15 -15
  110. data/lib/rhoconnect/store.rb +253 -75
  111. data/lib/rhoconnect/tasks.rb +3 -3
  112. data/lib/rhoconnect/version.rb +1 -1
  113. data/lib/rhoconnect/web-console/controllers/admins.js +1 -14
  114. data/lib/rhoconnect/web-console/models/adapter.js +18 -8
  115. data/lib/rhoconnect/web-console/models/client.js +15 -9
  116. data/lib/rhoconnect/web-console/models/doc.js +7 -11
  117. data/lib/rhoconnect/web-console/models/session.js +5 -2
  118. data/lib/rhoconnect/web-console/models/source.js +55 -36
  119. data/lib/rhoconnect/web-console/models/user.js +20 -11
  120. data/lib/rhoconnect/web-console/public/backbone.js +8 -2
  121. data/lib/rhoconnect/web-console/templates/index.erb +11 -5
  122. data/lib/rhoconnect/web-console/views/doc.js +6 -8
  123. data/lib/rhoconnect/web-console/views/edit_user.js +6 -3
  124. data/lib/rhoconnect/web-console/views/home.js +98 -25
  125. data/lib/rhoconnect/web-console/views/index.js +1 -1
  126. data/lib/rhoconnect/web-console/views/new_ping.js +6 -3
  127. data/lib/rhoconnect/web-console/views/server_doc.js +12 -4
  128. data/lib/rhoconnect/web-console/views/show_device.js +6 -3
  129. data/rhoconnect.gemspec +1 -2
  130. data/spec/api/{source → app}/fast_delete_spec.rb +4 -4
  131. data/spec/api/{source → app}/fast_insert_spec.rb +4 -4
  132. data/spec/api/{source → app}/fast_update_spec.rb +22 -6
  133. data/spec/api/{source → app}/push_deletes_spec.rb +2 -2
  134. data/spec/api/app/push_objects_spec.rb +45 -0
  135. data/spec/api/client/client_get_db_doc_spec.rb +31 -0
  136. data/spec/api/client/client_set_db_doc_spec.rb +14 -0
  137. data/spec/api/client/get_client_params_spec.rb +3 -2
  138. data/spec/api/client/list_client_docs_spec.rb +2 -2
  139. data/spec/api/{source → readstate}/set_refresh_time_spec.rb +15 -9
  140. data/spec/api/source/get_source_params_spec.rb +3 -2
  141. data/spec/api/source/list_sources_spec.rb +3 -9
  142. data/spec/api/source/update_source_params_spec.rb +4 -4
  143. data/spec/api/store/get_db_doc_spec.rb +32 -0
  144. data/spec/api/store/set_db_doc_spec.rb +43 -0
  145. data/spec/api/system/adapter_spec.rb +33 -0
  146. data/spec/api/{admin → system}/get_license_info_spec.rb +2 -5
  147. data/spec/api/{admin/get_api_token_spec.rb → system/login_spec.rb} +4 -11
  148. data/spec/api/{admin → system}/reset_spec.rb +2 -2
  149. data/spec/api/{admin → system}/stats_spec.rb +19 -13
  150. data/spec/api/user/create_user_spec.rb +15 -8
  151. data/spec/api/{client → user}/delete_client_spec.rb +3 -4
  152. data/spec/api/user/delete_user_spec.rb +33 -4
  153. data/spec/api/user/list_clients_spec.rb +30 -0
  154. data/spec/api/user/list_source_docs_spec.rb +35 -0
  155. data/spec/api/user/list_users_spec.rb +5 -6
  156. data/spec/api/{client → user}/ping_spec.rb +4 -6
  157. data/spec/api/user/show_user_spec.rb +14 -0
  158. data/spec/api/user/update_user_spec.rb +28 -10
  159. data/spec/api/user/user_get_db_doc_spec.rb +16 -0
  160. data/spec/api/user/user_set_db_doc_spec.rb +41 -0
  161. data/spec/apps/rhotestapp/application.rb +4 -0
  162. data/spec/apps/rhotestapp/settings/settings.yml +3 -1
  163. data/spec/bulk_data/bulk_data_spec.rb +13 -0
  164. data/spec/client_sync_spec.rb +41 -59
  165. data/spec/document_spec.rb +23 -0
  166. data/spec/javascripts/doc_view_spec.js +1 -1
  167. data/spec/javascripts/home_view_spec.js +10 -5
  168. data/spec/javascripts/index_view_spec.js +1 -1
  169. data/spec/jobs/ping_job_spec.rb +26 -0
  170. data/spec/perf/store_perf_spec.rb +1 -1
  171. data/spec/ping/android_spec.rb +0 -7
  172. data/spec/ping/apple_spec.rb +7 -0
  173. data/spec/ping/blackberry_spec.rb +10 -0
  174. data/spec/ping/rhoconnect_push_spec.rb +58 -0
  175. data/spec/server/cors_spec.rb +1 -1
  176. data/spec/server/server_spec.rb +152 -104
  177. data/spec/{stats/middleware_spec.rb → server/stats_spec.rb} +4 -5
  178. data/spec/server/x_domain_session_wrapper_spec.rb +3 -3
  179. data/spec/source_spec.rb +2 -2
  180. data/spec/source_sync_spec.rb +2 -0
  181. data/spec/spec_helper.rb +17 -3
  182. data/spec/stats/record_spec.rb +18 -19
  183. data/spec/store_spec.rb +51 -26
  184. data/spec/support/shared_examples.rb +4 -0
  185. data/spec/sync_states_spec.rb +2 -2
  186. metadata +104 -88
  187. data/bench/benchapp/Gemfile.lock +0 -87
  188. data/bench/blobapp/Gemfile.lock +0 -107
  189. data/bench/lib/testdata/5-data.txt +0 -8
  190. data/doc/release.txt +0 -41
  191. data/lib/rhoconnect/api/admin/get_api_token.rb +0 -14
  192. data/lib/rhoconnect/api/admin/login.rb +0 -6
  193. data/lib/rhoconnect/api/application/bulk_data.rb +0 -7
  194. data/lib/rhoconnect/api/application/clientcreate.rb +0 -8
  195. data/lib/rhoconnect/api/application/clientlogin.rb +0 -6
  196. data/lib/rhoconnect/api/application/clientregister.rb +0 -13
  197. data/lib/rhoconnect/api/application/clientreset.rb +0 -6
  198. data/lib/rhoconnect/api/application/query.rb +0 -7
  199. data/lib/rhoconnect/api/application/queue_updates.rb +0 -20
  200. data/lib/rhoconnect/api/application/search.rb +0 -6
  201. data/lib/rhoconnect/api/client/create_client.rb +0 -3
  202. data/lib/rhoconnect/api/client/delete_client.rb +0 -5
  203. data/lib/rhoconnect/api/client/list_clients.rb +0 -3
  204. data/lib/rhoconnect/api/client/ping.rb +0 -7
  205. data/lib/rhoconnect/api/source/get_adapter.rb +0 -3
  206. data/lib/rhoconnect/api/source/get_db_doc.rb +0 -7
  207. data/lib/rhoconnect/api/source/list_source_docs.rb +0 -10
  208. data/lib/rhoconnect/api/source/save_adapter.rb +0 -3
  209. data/lib/rhoconnect/api/source/set_db_doc.rb +0 -10
  210. data/lib/rhoconnect/api/source/upload_file.rb +0 -4
  211. data/lib/rhoconnect/body_content_type_parser.rb +0 -32
  212. data/lib/rhoconnect/x_domain_session_wrapper.rb +0 -53
  213. data/spec/api/admin/api_token_spec.rb +0 -13
  214. data/spec/api/client/create_client_spec.rb +0 -13
  215. data/spec/api/client/list_clients_spec.rb +0 -22
  216. data/spec/api/source/adapter_spec.rb +0 -29
  217. data/spec/api/source/get_db_doc_spec.rb +0 -21
  218. data/spec/api/source/list_source_docs_spec.rb +0 -25
  219. data/spec/api/source/push_objects_spec.rb +0 -27
  220. data/spec/api/source/set_db_doc_spec.rb +0 -32
  221. data/spec/api/source/upload_file_spec.rb +0 -26
@@ -13,9 +13,12 @@ App.Views.EditUser = Backbone.View.extend({
13
13
  var session = new Session()
14
14
  var password = $("#password2").val();
15
15
  $.ajax({
16
- type: 'POST',
17
- url: '/api/user/update_user',
18
- data: {api_token : session.getApiKey(), attributes : {login : 'rhoadmin', password : password}},
16
+ type: 'PUT',
17
+ url: '/rc/v1/users/' + 'rhoadmin',
18
+ data: {attributes : {login : 'rhoadmin', password : password}},
19
+ beforeSend: function (HttpRequest) {
20
+ HttpRequest.setRequestHeader("X-RhoConnect-API-TOKEN", session.getApiKey());
21
+ },
19
22
  success: function(){
20
23
  //router.navigate("users", true);
21
24
  },
@@ -1,20 +1,16 @@
1
1
  App.Views.Home = Backbone.View.extend({
2
2
 
3
3
  events: {
4
- "click a#reset" : "reset"
4
+ "click a#reset" : "reset",
5
+ "click #app_url" : "set_adapter",
6
+ "submit form" : "edit",
7
+ "click #api_btn" : "toggle_api_token"
5
8
  },
6
9
 
7
10
  initialize: function() {
8
11
  var domain = $('input#domain').val();
12
+ this.model.get_license_info();
9
13
  this.model.set('partition_type','app')
10
- this.model.save({
11
- error: function(model,resp)
12
- {
13
- if(resp.status == 422){
14
- new App.Views.Index()
15
- }
16
- }
17
- });
18
14
  this.model.fetch({
19
15
  error: function(model,resp)
20
16
  {
@@ -24,6 +20,7 @@ App.Views.Home = Backbone.View.extend({
24
20
  }
25
21
  });
26
22
  this.render(domain);
23
+ this.options.model2.get_adapter();
27
24
  },
28
25
 
29
26
  reset: function(){
@@ -32,23 +29,99 @@ App.Views.Home = Backbone.View.extend({
32
29
  session.reset()
33
30
  }
34
31
  },
32
+
33
+ edit: function(e){
34
+ e.preventDefault();
35
+ var session = new Session()
36
+ var password = $("#password2").val();
37
+ $(".edituser-status")[0].firstChild.className = "label label-warning";
38
+ $(".edituser-status")[0].firstChild.innerHTML = "loading...";
39
+ $(".edituser-status").css("visibility","visible");
40
+ $.ajax({
41
+ type: 'PUT',
42
+ url: '/rc/v1/users/' + 'rhoadmin',
43
+ data: {attributes : {login : 'rhoadmin', password : password}},
44
+ beforeSend: function (HttpRequest) {
45
+ HttpRequest.setRequestHeader("X-RhoConnect-API-TOKEN", session.getApiKey());
46
+ },
47
+ success: function(){
48
+ //router.navigate("users", true);
49
+ $(".edituser-status")[0].firstChild.className = "label label-success";
50
+ $(".edituser-status")[0].firstChild.innerHTML = "success";
51
+ },
52
+ error: function(resp){
53
+ if(resp.status == 422){
54
+ new App.Views.Index()
55
+ }
56
+ $(".edituser-status")[0].firstChild.className = "label label-important";
57
+ $(".edituser-status")[0].firstChild.innerHTML = "error";
58
+ $('#home-alert')[0].innerHTML = resp.responseText;
59
+ $('#home-alert').css('display','block');
60
+ }
61
+ })
62
+ return false;
63
+ },
64
+
65
+ set_adapter: function(e){
66
+ e.preventDefault();
67
+ var adapter_url = $('#input_adapter').val();
68
+ //this.render();
69
+ $(".setadapter-status")[0].firstChild.className = "label label-warning";
70
+ $(".setadapter-status")[0].firstChild.innerHTML = "loading...";
71
+ $(".setadapter-status").css("visibility","visible");
72
+ this.delegateEvents();
73
+ this.options.model2.set_adapter(adapter_url);
74
+ return false;
75
+ },
76
+
77
+ toggle_api_token: function(e){
78
+ e.preventDefault();
79
+ if ($("#api_btn").attr("value") == "Show"){
80
+ $("#api_token").css('display','inline');
81
+ $("#api_btn").attr("value","Hide");
82
+ }
83
+ else {
84
+ $("#api_token").css('display','none');
85
+ $("#api_btn").attr("value","Show");
86
+ }
87
+ },
35
88
 
36
89
  render: function(domain) {
90
+ session = new Session();
37
91
  $('#secondary-nav').css('display','block');
38
- //out = "<div class='page-header well'><h1>Home</h1></div>"
39
92
  out = "<div id='home-alert' class='alert alert-error' style='display:none'></div>"
40
93
  out += "<div class='alert alert-info' style='padding:10px 0 30px 0'>"
41
- //out += "<div class='container'>"
42
94
  out += "<div id='license' style='padding-left:5px' class='pull-left'></div>"
43
- out += "<div class='pull-right'>"
44
- out += "<div class='reset-status' style='display:inline;'><span class='' style='margin-right:5px'></span></div>"
45
- out += "<a id='reset' class='btn btn-danger'>Reset</a>"
46
- out += "</div></div>"
47
- out += "<div class='span4'>"
48
- out += "<table id='source-table' class='table table-bordered'><thead><tr><th><h3>App partition sources</h3></th></tr></thead>"
95
+ out += "</div>";
96
+ out += "<div class='span4' style='margin-left:0'>"
97
+ out += "<table id='source-table' class='table table-bordered'><thead><tr><th><h3>App partition sources</h3>";
98
+ out += "</th></tr></thead>"
49
99
  out += "</table></div>"
50
- out += "<div class='span4 pull-right'><h3>Sync Server URL</h3><code style='margin:0'>http://"+domain+"</code></br>";
51
- out += "<em style='margin-top:5px'>Paste this url into your client app configuration to sync with this RhoConnect instance.</em></div>";
100
+
101
+ out += "<table class='table table-bordered'>";
102
+ out += "<tr><td><p style='margin-top:10px'>Sync Server</p></td>";
103
+ out += "<td><p style='margin-top:10px'><code style='margin:0'>http://"+domain+"</code></p></td>";
104
+ out += "<td><p style='margin-top:10px'>Paste this url into your client app configuration to sync with this RhoConnect instance.</p></td>"
105
+ out += "<form>"
106
+ out += "<tr>"
107
+ out += "<td width='20%'><p style='margin-top:10px'>Change Admin Password</p></td>"
108
+ out += "<td width='40%'><p style='margin-top:10px'><input id='password2' type='password' name='password' value='' class='input-xlarge' placeholder='Enter new password' style='margin:0'/>"
109
+ out += "<input type='submit' class='btn btn-primary' value='Save' style='margin-left:10px'/><div class='edituser-status' style='display:inline;margin-left:10px;visibility:hidden'><span class=''></span></div></p></td>"
110
+ out += "<td width='40%'><p style='margin-top:10px'>By default the admin password is blank.</p></td>"
111
+ out += "</form>"
112
+ out += "<tr>"
113
+ out += "<td width='20%'><p style='margin-top:10px'>API Token</p></td>"
114
+ out += "<td width='40%'><p id='api_token' style='margin-top:10px;display:none'><code>"+ session.getApiKey() +"</code></p>";
115
+ out += "<input type='button' id='api_btn' class='btn' value='Show' style='display:inline;margin-left:10px'/></td>"
116
+ out += "<td width='40%'><p style='margin-top:10px'>Include this token in all API calls made to RhoConnect.</p></td></tr>"
117
+ out += "<tr>";
118
+ out += "<td width='20%'><p style='margin-top:10px'>Backend App URL</p></td>";
119
+ out += "<td width='40%'><p style='margin-top:10px'><input id='input_adapter' type='text' name='adapter_url' value='' class='input-xlarge' placeholder='Enter URL' style='margin:0'/>";
120
+ out += "<input id='app_url' type='button' value='Save' class='btn btn-primary' style='margin-left:10px'/><div class='setadapter-status' style='display:inline;margin-left:10px;visibility:hidden'><span class=''></span></div></p></td>";
121
+ out += "<td width='40%'><p style='margin-top:10px'>If you are using <a href='http://docs.rhomobile.com/rhoconnect/plugin-intro' target='_blank'>RhoConnect Plugins</a>, you will need to ";
122
+ out += "define your backend app URL either here or in the plugin configuration. For example, if you are using the rhoconnect-rb plugin in your rails app running locally, use the URL http://localhost:3000. <em><b>This needs to be set in order to use RhoConnect Plugins.</b></em></p></td>"
123
+ out += "</table>"
124
+
52
125
  out += "<div class='span12' style='margin-top:20px'><h2>Getting Started with RhoConnect</h2>";
53
126
  out += "<ol style='font-size:18px;margin-top:20px'><li>The Home Screen</li>";
54
127
  out += "<ul style='margin:20px'>"
@@ -61,15 +134,15 @@ App.Views.Home = Backbone.View.extend({
61
134
  out += "<p style='margin:10px'>Enter a key to view the stored value in the database. You can also set and delete keys here.</p>"
62
135
  out += "<li>Users</li>"
63
136
  out += "<p style='margin:10px'>View a list of registered users here. You can also create,delete, and ping users. Viewing a particular user will allow you to view source adapters partitioned by user as well as that user's registered devices."
64
- out += "<li>Settings</li><ul style='margin:20px'><li>Change Admin Password</li><p style='margin-top:10px'>By default the admin password is blank. Here you can change the admin password.</p>"
65
- out += "<li>API Token</li><p>View your RhoConnect API Token. This token needs to be included in all API calls made to RhoConnect</p>"
66
- out += "<li>Plugin Settings</li><p style='margin-top:10px'>If you are using Dynamic Adapters (opposed to source adapters) with <a href='http://docs.rhomobile.com/rhoconnect/plugin-intro' target='_blank'>RhoConnect Plugins</a>, you will need to "
67
- out += "define your backend app URL here. For example, if I am using the plugin rhoconnect-rb with my rails app, I would put the URL http://myrailsapp.com here. <em><b>This value needs to be set in order to use RhoConnect Plugins.</b></em></p></ul>"
137
+ out += "</ul>"
68
138
  out += "<li>Statistics</li>"
69
139
  out += "<p style='margin-top:10px'>If you do not see a link to Statistics, it is not enabled in your config.ru file. By default Rhoconnect apps will have this line <code>Rhoconnect::Server.enable :stats</code> commented out. "
70
140
  out += "Older versions of RhoConnect will not have this line in the config.ru file at all. Uncomment or add the line above to enable Statistics. The Statistics tab will have different graphs to measure metrics/performance for RhoConnect.</p>"
71
- out += "</ol></div>"
72
-
141
+ out += "</ol>"
142
+ out += "<div class='pull-right'>"
143
+ out += "<div class='reset-status' style='display:inline;'><span class='' style='margin-right:5px'></span></div>"
144
+ out += "<a id='reset' class='btn btn-danger'>Reset</a>"
145
+ out += "</div>"
73
146
  $(this.el).html(out);
74
147
  $('#main_content').html(this.el);
75
148
  return this
@@ -14,7 +14,7 @@ App.Views.Index = Backbone.View.extend({
14
14
  var password = $("#password").val();
15
15
  $.ajax({
16
16
  type: 'POST',
17
- url: '/api/admin/login',
17
+ url: '/rc/v1/system/login',
18
18
  data: {login:login,password:password},
19
19
  success: function(resp){
20
20
  var session = new Session();
@@ -20,11 +20,14 @@ App.Views.NewPing = Backbone.View.extend({
20
20
  var sound = $('#pingsound').val();
21
21
  var badge = $('#pingbadge').val();
22
22
  var sources = $('#sources').val().split(',');
23
-
23
+ var token = this.model.get('api_token');
24
24
  $.ajax({
25
25
  type: 'POST',
26
- url: '/api/client/ping',
27
- data: {api_token : this.model.get('api_token'), user_id : users, message : message, vibrate : vibrate, badge : badge, sources : sources},
26
+ url: '/rc/v1/users/ping',
27
+ data: {user_id : users, message : message, vibrate : vibrate, badge : badge, sources : sources},
28
+ beforeSend: function (HttpRequest) {
29
+ HttpRequest.setRequestHeader("X-RhoConnect-API-TOKEN", token);
30
+ },
28
31
  success: function(){
29
32
  router.navigate("users", true);
30
33
  },
@@ -13,11 +13,15 @@ App.Views.ServerDoc = Backbone.View.extend({
13
13
  clear: function(e){
14
14
  e.preventDefault();
15
15
  dbkey = this.model.get('dbkey');
16
+ token = this.model.get('api_token')
16
17
  var self = this;
17
18
  $.ajax({
18
19
  type: 'POST',
19
- url: '/api/source/set_db_doc',
20
- data: {api_token : this.model.get('api_token'), doc : dbkey, data : '', data_type : 'string'},
20
+ url: '/rc/v1/store/' + dbkey,
21
+ data: {data : ''},
22
+ beforeSend: function (HttpRequest) {
23
+ HttpRequest.setRequestHeader("X-RhoConnect-API-TOKEN", token);
24
+ },
21
25
  success: function(){
22
26
  data = "<tr><th colspan=3><h3 style='display:inline'>Data</h3><div class='pull-right'>" +
23
27
  "<a class='btn btn-danger'>clear document</a></div></th></tr>" +
@@ -44,10 +48,14 @@ App.Views.ServerDoc = Backbone.View.extend({
44
48
  $(".upload-status").css("visibility","visible");
45
49
  var doc = $('#input_key').val();
46
50
  var data = $("#data").val();
51
+ token = this.model.get('api_token');
47
52
  $.ajax({
48
53
  type: 'POST',
49
- url: '/api/source/set_db_doc',
50
- data: {api_token : this.model.get('api_token'), doc : doc, data : data, data_type : 'string'},
54
+ url: '/rc/v1/store/' + doc,
55
+ data: {data : data},
56
+ beforeSend: function (HttpRequest) {
57
+ HttpRequest.setRequestHeader("X-RhoConnect-API-TOKEN", token);
58
+ },
51
59
  success: function(){
52
60
  $(".upload-status")[0].firstChild.className = "label label-success";
53
61
  $(".upload-status")[0].firstChild.innerHTML = "success";
@@ -21,10 +21,13 @@ App.Views.ShowDevice = Backbone.View.extend({
21
21
  if(confirm("Are you sure you want to delete this device?")){
22
22
  var user_id = this.model.get('user_id');
23
23
  var client_id = this.model.get('device_id');
24
+ var token = this.model.get('api_token')
24
25
  $.ajax({
25
- type: 'POST',
26
- url: ' /api/client/delete_client',
27
- data: {api_token : this.model.get('api_token'), user_id : user_id, client_id : client_id},
26
+ type: 'DELETE',
27
+ url: ' /rc/v1/users/' + user_id + '/clients/' + client_id,
28
+ beforeSend: function (HttpRequest) {
29
+ HttpRequest.setRequestHeader("X-RhoConnect-API-TOKEN", token);
30
+ },
28
31
  success: function(resp){
29
32
  router.navigate("user/"+user_id,true)
30
33
  },
@@ -38,7 +38,6 @@ Gem::Specification.new do |s|
38
38
  ]
39
39
 
40
40
  s.add_dependency('bundler', '~> 1.0')
41
- # s.add_dependency("rack", '~> 1.4.0')
42
41
  s.add_dependency("sinatra", '~> 1.3')
43
42
  s.add_dependency('rake', '~> 0.9.2')
44
43
  s.add_dependency('json', '~> 1.6.0')
@@ -48,5 +47,5 @@ Gem::Specification.new do |s|
48
47
  s.add_dependency('resque', '~> 1.20.0')
49
48
  s.add_dependency('rest-client', '~> 1.6.1')
50
49
  s.add_dependency('templater', '~> 1.0.0')
51
- s.add_dependency('thor', '~> 0.14.6')
50
+ s.add_dependency('thor', '~> 0.15.0')
52
51
  end
@@ -6,8 +6,8 @@ describe "RhoconnectApiFastDelete" do
6
6
  data = {'1' => @product1, '2' => @product2, '3' => @product3}
7
7
  @s = Source.load(@s_fields[:name],@s_params)
8
8
  set_state(@s.docname(:md) => data,@s.docname(:md_size) => '3')
9
- post "/api/source/fast_delete", :api_token => @api_token,
10
- :user_id => @u.id, :source_id => @s_fields[:name], :data => {'3' => @product3}
9
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_delete",
10
+ {:user_id => @u.id, :data => {'3' => @product3}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
11
11
  last_response.should be_ok
12
12
  data.delete('3')
13
13
  verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'2')
@@ -18,8 +18,8 @@ describe "RhoconnectApiFastDelete" do
18
18
  delete_data = {'3' => {'price' => '1.99'}}
19
19
  @s = Source.load(@s_fields[:name],@s_params)
20
20
  set_state(@s.docname(:md) => data,@s.docname(:md_size) => '3')
21
- post "/api/source/fast_delete", :api_token => @api_token,
22
- :user_id => @u.id, :source_id => @s_fields[:name], :data => delete_data
21
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_delete",
22
+ {:user_id => @u.id, :data => delete_data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
23
23
  last_response.should be_ok
24
24
  verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'2')
25
25
  end
@@ -6,8 +6,8 @@ describe "RhoconnectApiFastInsert" do
6
6
  data = {'1' => @product1, '2' => @product2}
7
7
  @s = Source.load(@s_fields[:name],@s_params)
8
8
  set_state(@s.docname(:md) => data,@s.docname(:md_size) => '2')
9
- post "/api/source/fast_insert", :api_token => @api_token,
10
- :user_id => @u.id, :source_id => @s_fields[:name], :data => {'3' => @product3}
9
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_insert",
10
+ {:user_id => @u.id, :data => {'3' => @product3}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
11
11
  last_response.should be_ok
12
12
  data.merge!({'3' => @product3})
13
13
  verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'3')
@@ -18,8 +18,8 @@ describe "RhoconnectApiFastInsert" do
18
18
  incorrect_insert = {'3' => {'price' => '1.99', 'new_field' => 'value'}}
19
19
  @s = Source.load(@s_fields[:name],@s_params)
20
20
  set_state(@s.docname(:md) => data,@s.docname(:md_size) => '3')
21
- post "/api/source/fast_insert", :api_token => @api_token,
22
- :user_id => @u.id, :source_id => @s_fields[:name], :data => incorrect_insert
21
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_insert",
22
+ {:user_id => @u.id, :data => incorrect_insert}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
23
23
  last_response.should be_ok
24
24
  data['3'].merge!(incorrect_insert['3'])
25
25
  verify_result(@s.docname(:md_size)=>'4')
@@ -10,13 +10,29 @@ describe "RhoconnectApiFastUpdate" do
10
10
  orig_obj_attrs = {'3' => {'price' => @product3['price']}}
11
11
  new_obj_attrs = {'3' => {'price' => '0.99', 'new_attr' => 'new_value'}}
12
12
 
13
- post "/api/source/fast_update", :api_token => @api_token,
14
- :user_id => @u.id, :source_id => @s_fields[:name], :delete_data => orig_obj_attrs, :data => new_obj_attrs
13
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_update",
14
+ {:user_id => @u.id, :delete_data => orig_obj_attrs, :data => new_obj_attrs}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
15
15
  last_response.should be_ok
16
16
  data['3'].merge!(new_obj_attrs['3'])
17
17
  verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'3')
18
18
  end
19
19
 
20
+ it "should update an attribute and add new one for an object in rhoconnect's :md using old route with deprecation warning" do
21
+ data = {'1' => @product1, '2' => @product2, '3' => @product3}
22
+ @s = Source.load(@s_fields[:name],@s_params)
23
+ set_state(@s.docname(:md) => data,@s.docname(:md_size) => '3')
24
+
25
+ orig_obj_attrs = {'3' => {'price' => @product3['price']}}
26
+ new_obj_attrs = {'3' => {'price' => '0.99', 'new_attr' => 'new_value'}}
27
+
28
+ post "/api/source/fast_update",
29
+ {:user_id => @u.id, :source_id => @s_fields[:name], :delete_data => orig_obj_attrs, :data => new_obj_attrs}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
30
+ last_response.should be_ok
31
+ last_response.headers["Warning"].index('deprecated').should_not == nil
32
+ data['3'].merge!(new_obj_attrs['3'])
33
+ verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'3')
34
+ end
35
+
20
36
  it "should update one attr, add one attr, and remove one attr for an object in rhoconnect's :md" do
21
37
  data = {'1' => @product1, '2' => @product2, '3' => @product3}
22
38
  @s = Source.load(@s_fields[:name],@s_params)
@@ -25,8 +41,8 @@ describe "RhoconnectApiFastUpdate" do
25
41
  orig_obj_attrs = {'3' => {'name' => @product3['name'], 'price' => @product3['price']}}
26
42
  new_obj_attrs = {'3' => {'price' => '0.99', 'new_attr' => 'new_value'}}
27
43
 
28
- post "/api/source/fast_update", :api_token => @api_token,
29
- :user_id => @u.id, :source_id => @s_fields[:name], :delete_data => orig_obj_attrs, :data => new_obj_attrs
44
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_update",
45
+ {:user_id => @u.id, :delete_data => orig_obj_attrs, :data => new_obj_attrs}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
30
46
  last_response.should be_ok
31
47
  data['3'].delete('name')
32
48
  data['3'].merge!(new_obj_attrs['3'])
@@ -41,8 +57,8 @@ describe "RhoconnectApiFastUpdate" do
41
57
  orig_obj_attrs = {'3' => @product3}
42
58
  new_obj_attrs = {}
43
59
 
44
- post "/api/source/fast_update", :api_token => @api_token,
45
- :user_id => @u.id, :source_id => @s_fields[:name], :delete_data => orig_obj_attrs, :data => new_obj_attrs
60
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_update",
61
+ {:user_id => @u.id, :delete_data => orig_obj_attrs, :data => new_obj_attrs}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
46
62
  last_response.should be_ok
47
63
  data.delete('3')
48
64
  verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'3')
@@ -8,8 +8,8 @@ describe "RhoconnectApiPushDeletes" do
8
8
  @s = Source.load(@s_fields[:name],@s_params)
9
9
  set_state(@s.docname(:md) => data,@s.docname(:md_size) => '3')
10
10
  data.delete('2')
11
- post "/api/source/push_deletes", :api_token => @api_token,
12
- :user_id => @u.id, :source_id => @s_fields[:name], :objects => ['2']
11
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/push_deletes",
12
+ {:user_id => @u.id, :objects => ['2']}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
13
13
  last_response.should be_ok
14
14
  verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'2')
15
15
  end
@@ -0,0 +1,45 @@
1
+ require File.join(File.dirname(__FILE__),'..','api_helper')
2
+
3
+ describe "RhoconnectApiPushObjects" do
4
+ it_should_behave_like "ApiHelper" do
5
+ it "should push new objects to rhoconnect's :md" do
6
+ data = {'1' => @product1, '2' => @product2, '3' => @product3}
7
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/push_objects",
8
+ {:user_id => @u.id, :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
+ last_response.should be_ok
10
+ verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'3')
11
+ end
12
+
13
+ it "should push new objects to rhoconnect's :md with old api/source route and deprecation warning" do
14
+ data = {'1' => @product1, '2' => @product2, '3' => @product3}
15
+ post "/api/source/push_objects",
16
+ {:user_id => @u.id, :source_id => @s_fields[:name], :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
17
+ last_response.should be_ok
18
+ last_response.headers["Warning"].index('deprecated').should_not == nil
19
+ verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'3')
20
+ end
21
+
22
+ it "should push new objects to rhoconnect's :md with oldest api route and deprecation warning" do
23
+ data = {'1' => @product1, '2' => @product2, '3' => @product3}
24
+ post "/api/push_objects",
25
+ {:user_id => @u.id, :source_id => @s_fields[:name], :objects => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
26
+ last_response.should be_ok
27
+ last_response.headers["Warning"].index('deprecated').should_not == nil
28
+ verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'3')
29
+ end
30
+
31
+ it "should push updates to existing objects to rhoconnect's :md" do
32
+ data = {'1' => @product1, '2' => @product2, '3' => @product3}
33
+ update = {'price' => '0.99', 'new_field' => 'value'}
34
+ @s = Source.load(@s_fields[:name],@s_params)
35
+ set_state(@s.docname(:md) => data,@s.docname(:md_size) => '3')
36
+ update.each do |key,value|
37
+ data['2'][key] = value
38
+ end
39
+ post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/push_objects",
40
+ {:user_id => @u.id, :objects => {'2'=>update}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
41
+ last_response.should be_ok
42
+ verify_result(@s.docname(:md) => data,@s.docname(:md_size)=>'3')
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__),'..','api_helper')
2
+
3
+ describe "RhoconnectApiClientGetDbDoc" do
4
+ it_should_behave_like "ApiHelper" do
5
+ it "should get clients's db document by doc key and data" do
6
+ data = {'1' => {'foo' => 'bar'}}
7
+ dockey = 'myclientdoc'
8
+ post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
9
+ last_response.should be_ok
10
+
11
+ get "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
12
+ last_response.should be_ok
13
+ JSON.parse(last_response.body).should == data
14
+ end
15
+
16
+ it "should append data to the client's db document by doc name and data" do
17
+ data = {'1' => {'foo' => 'bar'}}
18
+ data2 = {'2' => {'foo1' => 'bar1'}}
19
+ data3 = data.merge(data2)
20
+ dockey = 'abc:abc'
21
+ cdocname = @c.docname(dockey)
22
+ post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
23
+ last_response.should be_ok
24
+ verify_result(cdocname => data)
25
+
26
+ post "/rc/#{Rhoconnect::API_VERSION}/clients/#{@c.id}/sources/#{@c.source_name}/docs/#{dockey}", {:data => data2, :append => true}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
27
+ last_response.should be_ok
28
+ verify_result(cdocname => data3)
29
+ end
30
+ end
31
+ end