Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a3-NobleKalish-Noble-Kalish #6

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 15 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,25 @@
Assignment 3 - Persistence: Two-tier Web Application with Flat File Database, Express server, and CSS template
===
## Pallet Organizer

Due: September 16th, by 11:59 AM.

This assignnment continues where we left off, extending it to use the most popular Node.js server framework (express), a flat file database suitable for small applications (lowdb), and a CSS application framework / template of your choice (Boostrap, Material Design, Semantic UI, Pure etc.)


Baseline Requirements
---

Your application is required to implement the following functionalities:

- a `Server`, created using Express (no alternatives will be accepted for this assignment)
- a `Results` functionality which shows the entire dataset residing in the server's memory
- a `Form/Entry` functionality which allows users to add, modify, and delete data items (must be all three!) associated with their user name / account.
- Use of at least five [Express middleware packages](https://expressjs.com/en/resources/middleware.html). Explore!
- Basic authentication using the [Passport middleware](http://www.passportjs.org) for Express (this counts as one of your five middleware packages). We encourage using the Local strategy, but OAuth (Open Authentication) can also be used for additional technical achievement. The course staff cannot help you with the various flavors of OAuth strategies. YOU MUST PROVIDE US WITH ACCOUNT CREDENTIALS TO LOGIN TO YOUR APPLICATION IF YOU USE OAUTH. The course staff cannot be expected to have credentials for any particular OAuth service.
- Persistent data storage in between server sessions. [lowdb](https://github.com/typicode/lowdb) is a suitable database package for this assignment and will be discussed in class.
- Use of a [CSS framework or template](https://github.com/troxler/awesome-css-frameworks). This should do the bulk of your styling/CSS for you and be appropriate to your application. For example, don't use [NES.css](https://nostalgic-css.github.io/NES.css/) (which is awesome!) unless you're creating a game or some type of retro 80s site.

Your application is required to demonstrate the use of the following concepts:

HTML:
- HTML input tags and form fields of various flavors (`<textarea>`, `<input>`, checkboxes, radio buttons etc.)
- HTML that can display all data *for a particular authenticated user*. Note that this is different from the last assignnment, which required the display of all data in memory on the server.

Note that it might make sense to have two simple pages for this assignment, one that handles login / authentication, and one that contains the rest of your application. For this assignment, it is acceptable to simply create new user accounts upon login if none exist, however, you must alert your users to this fact. If you're not using OAuth

CSS:
- CSS styling should primarily be provided by your chosen template/framework. Oftentimes a great deal of care has been put into designing CSS templates; don't override their stylesheets unless you are extremely confident in your graphic design capabilities. The idea is to use CSS templates that give you a professional looking design aesthetic without requiring you to be a graphic designer yourself.

JavaScript:
- At minimum, a small amount of front-end JavaScript to get / fetch data from the server. See the [previous assignment](https://github.com/cs4241-19a/a2-shortstack) for reference.

Node.js:
- A server using Express, at least five pieces of Express middleware, and a persistent database (a flat file using lowdb is great).

Deliverables
---

Do the following to complete this assignment:

1. Implement your project with the above requirements. A good potential starting point is to use the "hello-express" project template inside of Glitch; this appears as an option when you hit the "New Project" button. Use the work you did in the last assignment as a reference to implement functionality, as well as the notes from class on 9/9 and 9/12.
2. If you developed your project locally, deploy your project to Glitch, and fill in the appropriate fields in your package.json file.
3. Test your project to make sure that when someone goes to your main page on Glitch, it displays correctly.
4. Ensure that your project has the proper naming scheme `a3-yourname` so we can find it.
5. Fork this repository and modify the README to the specifications below. You do not need to include any of your project files in this repo (we will see those on Glitch), you only need to update and commit thhe README file.
6. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a2-gitname-firstname-lastname`.

Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions)
---

## Your Web Application Title

your glitch link e.g. http://a3-charlieroberts.glitch.me
your glitch link e.g. https://a3-noblekalish.glitch.me

Include a very brief summary of your project here. Images are encouraged, along with concise, high-level text. Be sure to include:

- the goal of the application
- challenges you faced in realizing the application
- what authentication strategy / database you chose to use and why (choosing one because it seemed the easiest to implement is perfectly acceptable)
- the goal of the application is to create a way to organize makeup pallets for each user.
- challenges you faced in realizing the application was dealing with arrays as they would not update the way I needed. I also had issues with making the data base correctly \
work with the data structure I used.
- what authentication strategy / database you chose to use and why (choosing one because it seemed the easiest to implement is perfectly acceptable) I choose to use pouchdb because I had experience with it from the \
previous project. I also used a local strategy that was shown in class for authentication as it was easy.
- what CSS framework you used and why.
- include any modifications to the CSS framework you made via custom CSS you authored.
- I choose to use Tailwind for my framework. I used it because it had a cool look and I never used it before.
- the five Express middleware packages you used and a short (one sentence) summary of what each one does.
1. I used passport as a middleware to authenticate users.
2. I used body-parser as a way to parse json from the html to the server.
3. I used express-session to create session cookies for the users
4. I used connect-flash to use the req.flash functions when people incorrectly log in
5. I used express-favicon to put favicons on the website.

## Technical Achievements
- **Tech Achievement 1**: I used OAuth authentication via the GitHub strategy
- **Tech Achievement 2**: I used over ten Express middleware packages, enabling me to create a server that...
- **Tech Achievement 1**: I used a plugin for pouchdb to allow the function upsert that allowed me to check if a doc existed and update it otherwise crete a new one.
- **Tech Achievement 2**: I used pouchdb as the database and created a document for every individual user and uses sessions to check for that users document to keep everyone information separate

### Design/Evaluation Achievements
- **Design Achievement 1**: I tested my application using screen reading software, and found that...
- **Design Achievement 2**: I followed best practices for accessibility, including providing alt attributes for images and using semantic HTML. There are no `<div>` or `<span>` elements in my document.
- **Design Achievement 3**: We tested the application with n=X users, finding that...
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "persistance",
"version": "1.0.0",
"description": "Project 3 for webware",
"author": "Noble Kalish",
"scripts": {
"start": "node server.js",
"bundle": "browserify public/js/scripts.js -o public/js/bundle.js",
"build": "npm run bundle; npm start;"
},
"dependencies": {
"body-parser": "^1.19.0",
"bulma": "^0.7.5",
"connect-flash": "^0.1.1",
"express": "^4.17.1",
"express-favicon": "^2.0.1",
"express-session": "^1.16.2",
"mime": "^2.4.4",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"path": "^0.12.7",
"pouchdb": "^7.1.1",
"pouchdb-upsert": "^2.2.0",
"serve-favicon": "^2.5.0",
"tailwindcss": "^1.1.2"
},
"engines": {
"node": "8.x"
}
}
5 changes: 5 additions & 0 deletions public/css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@tailwind base;

@tailwind components;

@tailwind utilities;
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions public/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<link rel="shortcut icon" href="../favicon.ico" />
</head>
<body>
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2">
Pick Existing Pallet or Make a New One
</label>
<div class="relative">
<select id="palletList" class="block appearance-none w-full bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500">
<option value="newPallet">-- New Pallet --</option>
</select>
</div>
</div>
<div>
<form id="submitPallet" class="w-full max-w-lg">
<div class="flex flex-wrap -mx-3 mb-6">
<div class="w-full md:w-1/2 px-3 mb-6 md:mb-0">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2">Pallet Name</label>
<input type="text" name="palletName" id="palletName" required class="appearance-none block w-full bg-gray-200 text-gray-700 border border-red-500 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white"/>
</div>
<div class="w-full md:w-1/2 px-3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2">Designer</label>
<input type="text" name="designer" id="designer" required class="appearance-none block w-full bg-gray-200 text-gray-700 border border-red-500 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white"/>
</div>
<div class="w-full md:w-1/2 px-3">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2">Number of colors</label>
<input type="number" name="colorNumber" id="colorNumber" min="1" max="30" required class="appearance-none block w-full bg-gray-200 text-gray-700 border border-red-500 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white"/>
</div>
<div class="w-full md:w-1/2 px-3">
<div class="md:w-1/3"></div>
<label class="md:w-2/3 block text-gray-500 font-bold"/>
<span class="text-sm">Is this pallet in production</span>
<input type="checkbox" name="use" id="inUse" value="inUse" class="mr-2 leading-tight" required />
</div>
<div class="w-full md:w-1/2 px-3">
<div class="md:w-1/3"></div>
<label class="md:w-2/3 block text-gray-500 font-bold"/>
<span class="text-sm">Do you own this pallet</span>
<input type="radio" name="own" value="yes" id="ownYes" class="mr-2 leading-tight"/> yes
<input type="radio" name="own" value="no" id="ownNo" class="mr-2 leading-tight"/> no <br>
</div>
<div class="w-full md:w-1/2 px-3">
<input type="submit" name="submit" id="submit" class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded"/>
<input type="button" name="delete" id="delete" value="Delete" class="bg-transparent hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded" disabled/>
</div>
</div>
</form>
</div>
</body>
<script src="../js/index.js"></script>
</html>
43 changes: 43 additions & 0 deletions public/html/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<link rel="shortcut icon" href="../favicon.ico" />
</head>
<body>
<div class="w-full max-w-xs">
<form action="/login" method="post" class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
<div class="mb-4">
<label>Username:</label>
<input type="text" name="username" class="bg-gray focus:outline-none focus:shadow-outline border border-gray-300 rounded-lg py-2 px-4 block w-full appearance-none leading-normal"
placeholder="username"/>
</div>
<div>
<label>Password:</label>
<input type="password" name="password" class="bg-gray focus:outline-none focus:shadow-outline border border-gray-300 rounded-lg py-2 px-4 block w-full appearance-none leading-normal"
placeholder="password"/>
</div>
<div>
<input type="submit" value="Log In" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"/>
</div>
</form>
<form action="/createUser" method="post" class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
<div>
<label>Choose a Username</label>
<input type="text" name="newUsername" class="bg-gray focus:outline-none focus:shadow-outline border border-gray-300 rounded-lg py-2 px-4 block w-full appearance-none leading-normal"
placeholder="username"/>
</div>
<div>
<label>Choose a Password</label>
<input type="text" name="newPassword" class="bg-gray focus:outline-none focus:shadow-outline border border-gray-300 rounded-lg py-2 px-4 block w-full appearance-none leading-normal"
placeholder="password"/>
</div>
<div>
<input type="submit" value="Create User" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"/>
</div>
</form>
</div>
</body>
</html>
Loading