Author Topic: Ruby on Rails modelling of database with web GUI and REST API  (Read 5661 times)

chrisbirkinshaw

  • Guru
  • ****
  • Posts: 431
    • View Profile
I started work on a RoR app which models the pluto DB and offers a simple web interface and also a RESTful XML interface as a free bonus. I will make a few changes next weekend to provide an iPhone interface to it using IUI. I've literally only done about 2 hours work or less but there is a beginning of something. The webpages are very basic.

The code is on github: http://github.com/chrisbirkinshaw/lmce_webservice

I just found out that there is an XML plugin being developed for LMCE anyway, so this work is probably redundant, but it was a fun exercise for me anyway, and gives me a platform on my test system in which I can mess around a bit. Someone out there might find this useful perhaps.

Chris




niz23

  • Guru
  • ****
  • Posts: 361
    • View Profile
Re: Ruby on Rails modelling of database with web GUI and REST API
« Reply #1 on: March 03, 2010, 08:44:32 am »
Hi

DonĀ“t know if you have seen http://www.jqtouch.com/ instead of iUI which seem to be stalled.

I have just started to look at ruby and find it interesting especially since our GSD device use ruby.
My goal is a html socket like server within a gsd device based on true websocket or Orbited (Ajax long-polling).

I have a couple of possible solutions for a web based Orbiter with bi-directional communication. Which mean lmce can send command and events to it.
-Websocket/Orbited within a GSD device and a javascript client.
-GSD device with a Stomp client that connect to a message queue server and a javascript Stomp client.


/niz23

caiman

  • Veteran
  • ***
  • Posts: 119
    • View Profile
Re: Ruby on Rails modelling of database with web GUI and REST API
« Reply #2 on: March 03, 2010, 11:00:00 pm »
Hi Chris,

thanks!  I have started to play with it as a potential webservice replacement for the LmceRemote iphone app.

Trying to get the list of lights for example, I understand one would need to first download http://192.168.80.1:3000/devices.xml and then filter in the application devices with a type of light-switch for example. A quick test shows me this query returns a page of 114 kB for my installation. This would be quite slow on a 3G network.

In comparison, the (ugly hack) at http://wiki.linuxmce.com/index.php/WebServiceSource returns 277 bytes for the list of lights.

I was wondering if there are ways to restrict the amount of data that is returned, or if it gives the whole table no matter what?

cheers,
Sam

chrisbirkinshaw

  • Guru
  • ****
  • Posts: 431
    • View Profile
Re: Ruby on Rails modelling of database with web GUI and REST API
« Reply #3 on: March 04, 2010, 04:29:09 am »
Yeah I was just writing a couple of denormalised views to do some things like like show all devices when you specify a template group. I also need to add some filter options so that you can get back really basic data if you like (like just ids). It's all pretty simple, just work. I'm in Paris shooting pics for fashion week but am back in the real world next week. If I get chance tomorrow I'll write in a couple of functions to replicate what you have already in your webservice script for the iphone interface you made.

caiman

  • Veteran
  • ***
  • Posts: 119
    • View Profile
Re: Ruby on Rails modelling of database with web GUI and REST API
« Reply #4 on: March 04, 2010, 04:05:37 pm »
Fantastic Chris. If that's the case I'll see how I can re-write the web query classes to migrate from the current JSON format to XML format.

Another open question I have is with authentication, I'm not familiar with rails but I'm sure there's an easy way to enable http authentication on the server. That would be great so one can use a split-DNS setup and have the control app work seamlessly from inside the network over wifi and outside over 3G. I so love to monitor and control the devices remotely ;)