App.Views.Home = Backbone.View.extend({ events: { "click a#reset" : "reset", "click #app_url" : "set_adapter", "submit form" : "edit", "click #api_btn" : "toggle_api_token" }, initialize: function() { var domain = $('input#domain').val(); this.model.get_license_info(); this.model.set('partition_type','app') this.model.fetch({ error: function(model,resp) { if(resp.status == 422){ new App.Views.Index() } } }); this.render(domain); this.options.model2.get_adapter(); }, reset: function(){ var session = new Session(); if(confirm("Are you sure you want to reset?")){ session.reset() } }, edit: function(e){ e.preventDefault(); var session = new Session() var password = $("#password2").val(); $(".edituser-status")[0].firstChild.className = "label label-warning"; $(".edituser-status")[0].firstChild.innerHTML = "loading..."; $(".edituser-status").css("visibility","visible"); $.ajax({ type: 'PUT', url: '/rc/v1/users/' + 'rhoadmin', data: {attributes : {login : 'rhoadmin', password : password}}, beforeSend: function (HttpRequest) { HttpRequest.setRequestHeader("X-RhoConnect-API-TOKEN", session.getApiKey()); }, success: function(){ //router.navigate("users", true); $(".edituser-status")[0].firstChild.className = "label label-success"; $(".edituser-status")[0].firstChild.innerHTML = "success"; }, error: function(resp){ if(resp.status == 422){ new App.Views.Index() } $(".edituser-status")[0].firstChild.className = "label label-important"; $(".edituser-status")[0].firstChild.innerHTML = "error"; $('#home-alert')[0].innerHTML = resp.responseText; $('#home-alert').css('display','block'); } }) return false; }, set_adapter: function(e){ e.preventDefault(); var adapter_url = $('#input_adapter').val(); //this.render(); $(".setadapter-status")[0].firstChild.className = "label label-warning"; $(".setadapter-status")[0].firstChild.innerHTML = "loading..."; $(".setadapter-status").css("visibility","visible"); this.delegateEvents(); this.options.model2.set_adapter(adapter_url); return false; }, toggle_api_token: function(e){ e.preventDefault(); if ($("#api_btn").attr("value") == "Show"){ $("#api_token").css('display','inline'); $("#api_btn").attr("value","Hide"); } else { $("#api_token").css('display','none'); $("#api_btn").attr("value","Show"); } }, render: function(domain) { session = new Session(); $('#secondary-nav').css('display','block'); out = "" out += "
" out += "
" out += "
"; out += "
" out += "" out += "

App partition sources

"; out += "
" out += ""; out += ""; out += ""; out += "" out += "" out += "" out += "" out += "" out += "" out += "" out += "" out += "" out += "" out += "" out += ""; out += ""; out += ""; out += "" out += "

Sync Server

http://"+domain+"

Paste this url into your client app configuration to sync with this RhoConnect instance.

Change Admin Password

" out += "

By default the admin password is blank.

API Token

"; out += "

Include this token in all API calls made to RhoConnect.

Backend App URL

"; out += "

If you are using RhoConnect Plugins, you will need to "; 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. This needs to be set in order to use RhoConnect Plugins.

" out += "

Getting Started with RhoConnect

"; out += "
  1. The Home Screen
  2. "; out += "" out += "
  3. Server Doc
  4. "; out += "

    Enter a key to view the stored value in the database. You can also set and delete keys here.

    " out += "
  5. Users
  6. " out += "

    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." out += "" out += "

  7. Statistics
  8. " out += "

    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 Rhoconnect::Server.enable :stats commented out. " 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.

    " out += "
" out += "
" out += "
" out += "Reset" out += "
" $(this.el).html(out); $('#main_content').html(this.el); return this } });