Assignment title: Information
Introduction
You where assigned the task of creating a data logger to capture experimental data in a
mobile application that stores data in a local database. The app has fields to record data for
each of five treatments. If a treatment is selected, a page is shown to add data values for that
treatment.
A treatment entry consists of a date and log data. When the Save Log Entry button is pressed
these values are saved locally in the devices localStorage. When the Show Logs button is
pressed a page is shown that list all the date/time and data entries made for that treatment. On
this screen a Send button is used for submitting the data to a web service provider that stores
the data in a MongoLab cloud database setup for that purpose. The data is also "logged" on
the local PC.
The treatment values are removed from the phone's localStorage after they are successfully
uploaded to the MongoLab database. Also on this screen a Get button is used for getting the
data from the mongdb you created for this purpose at MongoLab. More details of these pages
will be given in the Client and Server Side sections below.
We referred to our app as TreatmentLogs. The specification of this app was given in
assignment 1. This specification is further refined below. This app is to be tested using the
Safari, FireFox or Chrome browser and tested on an Android or iPhone mobile device.
Client Side HTML / CSS / JavaScript Mobile Application
You are to implement the client for this app using HTML5, CSS and JQuery Mobile. The
website should be based on a multi-page template structure. The client side application home
page was shown in assignment 1. The HP 1, HP 2, FO, MZ and Control buttons should link
to pages in a JQuery-mobile multi-page structure.
Images for the page/views required to implement the assignment where given in assignment 1
and are refined in the following figures. Please note that the illustrations are for reference
only, and your actual pages will be based on the CSS style-guide in use on your actual mobile
device.
Home page view
The home page view is the same as in assignment 1.
Treatment view
The pages for entering the treatment data are all the same as in assignment 1 and so are not
discussed further.
Treatment logs view
When the Show logs button in the treatment's page header is pressed the current date/time
should be added to the data structure used to store the four treatment values being recorded,
as in assignment 1. The log entries should then be saved in the device's localStorage. Then a
treatment logs page is shown with all the locally saved logs listed, as shown in Fig. 1. Note
the view now has a Get button on the left of the header bar, and a region for displaying cloud
log entries has now been added to the display.
Fig. 1: Treatments logs page.
Send button
When the Send button is tapped all the treatment logs for the treatment are sent to the local
server and saved to the cloud mongolab mongdb database set up for this purpose. You should
provide a success or failure alert. In the success alert, show the data that has been sent. When
a response is received another alert should indicate success or failure. When a treatment's
logs have been sent the treatment's local logs should be cleared from localStorage so that the
treatment's page will not show any local logs.
If the Yes button is pressed the Send logs dialog shown in Fig. 2 is presented and we return
the treatments view shown in Fig. 1. If the No button is pressed we just return to the
treatment view page shown in Fig. 1.
Get button
Fig. 8: Logs sent confirmation.
The Get button is used to search the mongolab mongdb database for all database entries that
match the treatment number (FO in the figure). If successful these entries are to be shown
below the Cloud log entries: label as shown in the figure 1. Again appropriate alerts need to
be made when the request is sent and when a response is received.
Server Side: node+packages and JavaScript
Our user data scheme has the following fields:
-ID- user ID (always 9999)
- treatment - one of {HP1, HP2, FO, MZ, CONTROL}
- date -date and time stamp of log
- conductivity - measured conductivity of soil
- moisture - measured moisture of soil
- pH - measured pH of water
- dissolvedOxygen - measured dissolved oxygen in water in ppm
This data is to be stored in the mongolab mongdb database in a treatment_logs collection.
Entries are also to be echoed (written) to a file in the ./logs directory of the local server in a
file called logs.dat.
The server will have the following URL that provides requested services. The URL is based
on http://your.IP.address/treatment/user/. A security feature has been added to trial a
username based on an ID. For the purposes of this assignment the value of ID is set to '9999'.
Only if this key is present should Get or Send requests be accepted by the server. Hence the
base URL will be http://your.IP.address/treatment/user/9999.
Your web service API will support these actions:
search/:query- searches for users in the mongoLabs database and returns all logs with that
:query value, where :query will be the treatment {HP1, HP2, FO, MZ or CONTROL} to
search for.
:treatment/log - appends a treatment entry to the local server file ./logs/logs.dat and to the
mongoLabs treatment_log mongdb databases logs collection.
The above diagram shows the message streams in the application. Ideally the mobile device
POST's requests to the WWW and receives responses from the