If anyone would like to refactor the messy code and teach me industry best practices or save me from callback hell, please let me know at changchuming@gmail.com. Thank you.
You can set up your own client to perform other functions besides monitoring laundry. Here is a list of post requests you can do to the server. Examples are written using jquery's post, but you can use any method to send the post request.
To add a cluster of machines
$.post(server + '/addcluster', {name: clusterName}, function(data, status, xhr) {
// Returns true or false
});
To get all clusters with their respective machines
$.post(server + '/getallclusters', function(data, status, xhr) {
// Returns all clusters as json object or false
});
To add a machine
$.post(server + '/addmachine', {clustername: clusterName, type: machineType, timeout: machineTimeout}, function(data, status, xhr) {
// Returns true or false
});
To get machine usage
$.post(server + '/getmachineusage', {clustername: clusterName, index: machineIndex}, function(data, status, xhr) {
// Returns username or false
});
To set machine usage (userID is optional)
$.post(server + '/setmachineusage', {clustername: clusterName, index: machineIndex, userid: userID}, function(data, status, xhr) {
// Returns true or false
});
To clear machine usage (userID is optional)
$.post(server + '/clearmachineusage', {clustername: clusterName, index: machineIndex, userid: userID}, function(data, status, xhr) {
// Returns true or false
});
To add a user
$.post(server + '/adduser', {id: userID, name: userName, number: userPhoneNumber}, function(data, status, xhr) {
// Returns true or false
});
To check whether user is in database
$.post(server + '/checkuser', {id: userID}, function(data, status, xhr) {
// Returns username if user exists, else returns false
});
- Make sure you have nodejs, npm, and mongodb installed.
- Install gulp with
npm install gulp -g
. - Install bower with
npm install bower -g
. - Do
npm install
to install node dependencies. - Do
bower install
to install bower dependencies. - Do
gulp
to build and track changes. - Make sure mongodb is running.
- Start server or client.