From 5765cfcfa56c71c4582e5c0a6fae087204185010 Mon Sep 17 00:00:00 2001 From: Meghraj Deshmukh Date: Sat, 25 Apr 2020 23:51:40 +0530 Subject: [PATCH] addded admin also --- app.js | 12 ++++++- controller/index.js | 9 +++++ package-lock.json | 70 +++++++++++++++++++++++++++++++++++++++ package.json | 1 + router/register.js | 39 +++++++++++++++++++++- view/admin.ejs | 79 ++++++++++++++++++++++++++++++++++++++++++++ view/adminlogin.html | 67 +++++++++++++++++++++++++++++++++++++ view/index.html | 5 ++- 8 files changed, 279 insertions(+), 3 deletions(-) create mode 100644 view/admin.ejs create mode 100644 view/adminlogin.html diff --git a/app.js b/app.js index d388022..b2cfbea 100644 --- a/app.js +++ b/app.js @@ -8,10 +8,20 @@ let cookieParser = require('cookie-parser'); const app=Express(); //app.use(bodyParser.json()); -app.use(bodyParser.urlencoded({extended: true})); +app.use(bodyParser.urlencoded({extended: false})); + +app.use(bodyParser.json()); app.use(cookieParser()); app.use(Express.static(path.join(__dirname, 'asset'))); + +//setup view enginer +app.set('view engine','ejs'); +app.set('views','./view'); + + + + app.use('/', router); app.listen(2000, function(err){ diff --git a/controller/index.js b/controller/index.js index ad3e236..b8aa958 100644 --- a/controller/index.js +++ b/controller/index.js @@ -35,12 +35,21 @@ module.exports.register=function(req, res) +} + +module.exports.adminHome=function(req,res) +{ + console.log(req.body); + + + } module.exports.login=function(req,res) { + user.find(email=req.body.email, function(err, user){ diff --git a/package-lock.json b/package-lock.json index dbb610f..fee5e34 100644 --- a/package-lock.json +++ b/package-lock.json @@ -84,6 +84,11 @@ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, + "async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -390,6 +395,14 @@ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, + "ejs": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.2.tgz", + "integrity": "sha512-zFuywxrAWtX5Mk2KAuoJNkXXbfezpNA0v7i+YC971QORguPekpjpAgeOv99YWSdKXwj7JxI2QAWDeDkE8fWtXw==", + "requires": { + "jake": "^10.6.1" + } + }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", @@ -418,6 +431,11 @@ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, "etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -460,6 +478,14 @@ "vary": "~1.1.2" } }, + "filelist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.1.tgz", + "integrity": "sha512-8zSK6Nu0DQIC08mUC46sWGXi+q3GGpKydAG36k+JDba6VRpkevvOWUW5a/PhShij4+vHT9M+ghgG7eM+a9JDUQ==", + "requires": { + "minimatch": "^3.0.4" + } + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -688,6 +714,50 @@ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, + "jake": { + "version": "10.6.1", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.6.1.tgz", + "integrity": "sha512-pHUK3+V0BjOb1XSi95rbBksrMdIqLVC9bJqDnshVyleYsET3H0XAq+3VB2E3notcYvv4wRdRHn13p7vobG+wfQ==", + "requires": { + "async": "0.9.x", + "chalk": "^2.4.2", + "filelist": "^1.0.1", + "minimatch": "^3.0.4" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + } + } + }, "json-buffer": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", diff --git a/package.json b/package.json index b1d7ba9..b952ee6 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "homepage": "https://github.com/Meghraj1998/gocorona#readme", "dependencies": { "cookie-parser": "^1.4.5", + "ejs": "^3.1.2", "express": "^4.17.1", "mongoose": "^5.9.9", "nodemon": "^2.0.3" diff --git a/router/register.js b/router/register.js index 2fbc49a..b715fef 100644 --- a/router/register.js +++ b/router/register.js @@ -2,7 +2,7 @@ const Express=require('express'); var controller=require('../controller/index'); var router=Express.Router(); var path=require('path'); - +var Stuff=require('../model/stuff'); router.get('/', function(req,res){ @@ -42,6 +42,43 @@ router.use('/paysucess', function(req, res){ }) +router.use('/adminHome',function(req,res){ + + console.log(req.body.email); + + if(req.body.email!=undefined) + if(req.body.email!='admin@gmail.com') + { + return res.send("cannot find user"); + } + + + Stuff.find({}, function(err, userObj){ + + res.render('admin.ejs', { + + obj:userObj + + }); + + }) + + + + +}); + + + +router.get('/Adminlogin', function(req,res){ + + console.log("we are into AdminLogin"); + + res.sendFile('/Users/meghrajdeshmukh/Desktop/WebDevelopment/SanketPro/DonateToCovid/view/adminlogin.html'); + +}); + + router.use('/donatestuff', function(req,res){ diff --git a/view/admin.ejs b/view/admin.ejs new file mode 100644 index 0000000..5d0223c --- /dev/null +++ b/view/admin.ejs @@ -0,0 +1,79 @@ + + + + DonateForCovid + + + + + + + + + + + + + + + +
+ + + + + +

List Of User Donated Item

+ <% for( i of obj) { %> + + +

Phone--<%=i.phone %>

+

List Of Item--<%=i.stuff %>

+

Date--<%=i.date %>

+
+ + <% } %> + +
+
+ + + + + + + + + diff --git a/view/adminlogin.html b/view/adminlogin.html new file mode 100644 index 0000000..7eac431 --- /dev/null +++ b/view/adminlogin.html @@ -0,0 +1,67 @@ + + + + + DonateForCovid + + + + + + + + + + + + + + + + + +
+

Admin

+ + + + +

+ Don't have an account? + Sign Up +

+

+ + + + + + + + \ No newline at end of file diff --git a/view/index.html b/view/index.html index 74491ac..21a0209 100644 --- a/view/index.html +++ b/view/index.html @@ -36,7 +36,10 @@ +