Week ending 16th July – Android/REST interface

Sunday 9th July 2017

I was so busy working on the Android app to get data from the web server, I completely forgot to check out my own project plan where it clearly states that I should be working on the Tablet REST interface. I was looking at all the data I was getting from the GET request and pondering how I would parse it out when I remembered. If I write an Android interface then I will not have to do much of the parsing. So this is today’s plan – write the simple interface to obtain the client data from the login information.

OK, I have set up a nice little URL that just delivers JSON data (apart from the usual HTML headers etc. unfortunately).

localhost:8080/WSAndroidUser?demo returns the following:

{“railroadName”: “Sunset & North Eastern RR”,”railroadLogoURL”: “http://www.tm470routingproject.co.uk/images/snelogo.png”,”username”: “demo”,”password”: “5F4DCC3B5AA765D61D8327DEB882CF99″,”currentTTPositionString”: “6”,”maxTTPositionString”: “0”}

whilst localhost:8080/WSAndroidUser?demo:routes delivers a JSON listing all of the routes  set up for user “demo”.  “routes” can be replaced by any of the other data types. Exactly what I was trying for.

Monday 10th July 2017

Back to working on the JavaScript. However, it would be nice of the Seaside server only sent the JSON rather than a pseudo-HTML page with all the headers, etc. I have posted a question to the Seaside support group to see if anyone knows how to do this. Somewhere inside Seaside there is some code that makes the basic page. I need to subclass that and clear out all the extraneous text. Whilst waiting to see if anyone has any idea, I shall continue without the knowledge and parse out the JSON directly.

As I only know the javascript that they taught in TM352, I have to keep looking things up but I finally got a JSON parse out of the data coming back. problems were getting rid of the &quot and the ; that HTML seems to insert into these things. I now have a fully defined object that is a JSON – so that means that all of the individual items in the above example are now held in the following fashion:

Tomorrow, I will try and get this data to show on the next page.

Tuesday 11th July 2017

Success. I have managed to get the login process finished. The aim was to make the branding of the app to change from 470Router to your own railroad after login.

Here is the before:          and here is the after:

Next step, on Thursday, is to put up the main menu – buttons to display all of the data and a button to call up the next train.

This plan of setting daily goals is working really well.  Also, as there is no version control, I am also testing at every code change. This involves using Ctrl-C to stop the running app; execute the terminal build command; tell Chrome to accept a localhost request (I have to have a special app built into Chrome for that); start the debugger; etc. and then the app will run. It’s a bit of a pain and more complex than I am used to but it does mean that I always have an app that works (or is one code change away). Regularly, I am saving back to Dropbox so everything is quite safe.

I have given up with my request to the Seaside group for help. This group seems to be a bunch of academics that delight in complicating everything up. If I had two weeks to spare, I could follow up on their various suggestions. As it is, it works so I will stay as I am. I agree that, if there was a variety of data sources, my parsing may not be sufficient, or even work. However, the data formats are completely under my control so the parsing that I am doing is guaranteed to be successful.

Thursday 13th July 2017

I have spent today creating and including image buttons for the various items of data that can be displayed. I have taken images of my own railroad and (with the help of Photoshop and Illustrator) created images of “nearly” the correct proportions. I have included these images in a <div> and in a <form> so that they can be removed or displayed as required and I have tied them into a JavaScript function that I have written that will display the various items of data dependent upon the name parameter sent to it from the various buttons. This all works fine, thanks to reference to the JavaScript code i wrote for my TM352 EMA.

Next step is to get the buttons to align in rows of three (I will probably use a table for this). To do that, I will also have to do a bit of resizing to get them all the same shape. This will happen on Saturday – British Grand Prix providing!

Saturday 15th July 2017

Well, the week ended in a bit of a crisis. I stupidly installed a beta of the new iMac OS – High Sierra – only to find that it was “dog” slow and doing some strange things. As I have Time Machine installed and have back ups going back months, this was to be easily solved by recovering back to a good “Sierra” day. I tried this three times but, each time, the install froze 3/4 of the way through. I decided to use the recovery option to install new system only to find that the new system it would install was the beta of High Sierra. Done like a kipper! Eventually, on Monday morning, I found I had a good install of that and started recovering files from theTime Machine backup – yes I could pull folders and files out but not a whole day. I made a big decision at that point. I was getting fed up with being closeted in the hobby room all of the time whilst my wife was busy doing jigsaws in the living room. I was also fed up with having my personal iMac configured for coding. See next week’s posts for more.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s