Giter VIP home page Giter VIP logo

react-movies's Introduction

Registration to queue

Customers registration to queue and waiting room display

Description

Application consists of three pages: administrator, specialist and waiting room board.
The admin page is for queuing a new client. The administrator enters the name of the new customer and chooses from the list which specialist he/she wants to access. The customers table is displayed. Table consist of columns with: customer name, registration to queue time, wanted specialist and status (not served or end of service time).
To access the specialist page and manage the users assigned to the specialist, you need to select a specialist and enter passw ord. After that users who belongs to specialist is displayed. Specialist can see all his customes with registration to queue time and status. After specialist ends consultation, he/she clicks the button on current customer row and changes customer status from not served to end of service date and time.
On waiting room board page is displayed customers list sorted by specialist and place in queue.

Demo

https://willow9.github.io/Registration-app/

Database

This application uses Mongo DB Atlas. Document in mongo db consist of following fields:

    _id:ObjectId("5db84459cf89dc3b60160891")
    id:"132"
    name:"Mr. Burns"
    timestamp:"1572357209128"
    servicedDate:"not served"
    specialist:"Transformation Specialist"
  1. AJAX is used to retrieve a document from a database. mongoDB.js:
   function get() {
     return $.ajax({
       url:
          'https://webhooks.mongodb-stitch.com/api/client/v2.0/app/mongocrud-bgxqf/service/http/incoming_webhook/webhook0',
       dataType: 'json',
       type: 'get'
    });
   }

MongoDB service code for retrieving all documents (customers) from database and returning to frontend is:

  exports = function(payload) {
 const mongodb = context.services.get("mongodb-atlas");
 const mycollection = mongodb.db("mongoDB").collection("todo");
 return mycollection.find({}).toArray();
};
  1. To add new customer in database another webhook is used and declared in AJAX request url field. mongoDB.js:
  function post(dataToSend) {
 return $.ajax({
   url:
     'https://webhooks.mongodb-stitch.com/api/client/v2.0/app/mongocrud-bgxqf/service/post/incoming_webhook/webhook1',
   dataType: 'json',
   type: 'POST',
   contentType: 'application/json',
   data: dataToSend
 });
}

MongoDB function for post request:

 exports = function(payload, response) {
 const mongodb = context.services.get("mongodb-atlas");
 const requestLogs = mongodb.db("mongoDB").collection("todo");
 requestLogs.insertOne({
   id: EJSON.parse(payload.body.text()).id,
   name: EJSON.parse(payload.body.text()).name,
   timestamp: EJSON.parse(payload.body.text()).timestamp,
   servicedDate: EJSON.parse(payload.body.text()).servicedDate,
   specialist: EJSON.parse(payload.body.text()).specialist,})
   .then((result) => {
   response.setStatusCode(201);
   console.log('result.insertedId');
  response.setBody(EJSON.stringify('insertedId ' + result.insertedId));
 });
};
  1. To generate unique and short identification number for new customers we need largest id number increased by one. In order to do so we get array of all ids from database, filter largest one and increase by one. MongoDB service to retrieve ids array:
  exports = function() {
  const mongodb = context.services.get("mongodb-atlas");
  const mycollection = mongodb.db("mongoDB").collection("todo");

 return mycollection.find({}).toArray().then((item) => {
    let ids = [];
    item.map((i) => {
    ids.push(i.id);
    });
    return ids;
  });
  
 };
  1. When customer gets service, the status "not served" is changed to the current timestamp. In order to edit database document, MongoDB service is used:
  exports = function(payload, response) {
  const mongodb = context.services.get("mongodb-atlas");
  const requestLogs = mongodb.db("mongoDB").collection("todo");
 
  requestLogs.updateOne(
    {id: EJSON.parse(payload.body.text()).id },
    { $set: { servicedDate: EJSON.parse(payload.body.text()).servicedDate }} 
          ).then ((result) =>{
            response.setBody(EJSON.stringify('insertedId ' + result.insertedId));
          });

};

react-movies's People

Contributors

willow9 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.