mirror of
https://github.com/sergeyyarkov/digital-store.git
synced 2026-10-11 10:19:15 +03:00
v1.1.1
This commit is contained in:
parent
7282c740f4
commit
84338c9566
17
dist/public/css/style.css
vendored
17
dist/public/css/style.css
vendored
@ -89,7 +89,7 @@ hr {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 999;
|
z-index: 99999999;
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
@ -162,6 +162,14 @@ hr {
|
|||||||
min-height: 300px;
|
min-height: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div#rosterButtons {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
button#addItem {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Cart */
|
/* Cart */
|
||||||
.cart-btn {
|
.cart-btn {
|
||||||
@ -503,6 +511,12 @@ footer.main-footer .container {
|
|||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.items-list__name {
|
||||||
|
max-width: 525px;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.items-list__name,
|
.items-list__name,
|
||||||
.items-list__info {
|
.items-list__info {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -781,6 +795,7 @@ footer.main-footer {
|
|||||||
}
|
}
|
||||||
#items .card-content {
|
#items .card-content {
|
||||||
min-height: 519px;
|
min-height: 519px;
|
||||||
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
footer.admin-footer{
|
footer.admin-footer{
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
|
|||||||
4
dist/public/js/admin.js
vendored
4
dist/public/js/admin.js
vendored
File diff suppressed because one or more lines are too long
2
dist/public/js/main.js
vendored
2
dist/public/js/main.js
vendored
File diff suppressed because one or more lines are too long
10
dist/views/admin/categories.pug
vendored
10
dist/views/admin/categories.pug
vendored
@ -2,6 +2,16 @@ include ./assets/head.pug
|
|||||||
body.has-fixed-sidenav
|
body.has-fixed-sidenav
|
||||||
include ./assets/templates/header.pug
|
include ./assets/templates/header.pug
|
||||||
main.admin-main
|
main.admin-main
|
||||||
|
#loader.loader-fullscreen.hide
|
||||||
|
.loader-fullscreen__wrap
|
||||||
|
.preloader-wrapper.big.active
|
||||||
|
.spinner-layer.spinner-green-only
|
||||||
|
.circle-clipper.left
|
||||||
|
.circle
|
||||||
|
.gap-patch
|
||||||
|
.circle
|
||||||
|
.circle-clipper.right
|
||||||
|
.circle
|
||||||
.container
|
.container
|
||||||
.row
|
.row
|
||||||
.col.s12
|
.col.s12
|
||||||
|
|||||||
12
dist/views/admin/control-panel.pug
vendored
12
dist/views/admin/control-panel.pug
vendored
@ -2,6 +2,16 @@ include ./assets/head.pug
|
|||||||
body.has-fixed-sidenav
|
body.has-fixed-sidenav
|
||||||
include ./assets/templates/header.pug
|
include ./assets/templates/header.pug
|
||||||
main.admin-main
|
main.admin-main
|
||||||
|
#loader.loader-fullscreen.hide
|
||||||
|
.loader-fullscreen__wrap
|
||||||
|
.preloader-wrapper.big.active
|
||||||
|
.spinner-layer.spinner-green-only
|
||||||
|
.circle-clipper.left
|
||||||
|
.circle
|
||||||
|
.gap-patch
|
||||||
|
.circle
|
||||||
|
.circle-clipper.right
|
||||||
|
.circle
|
||||||
.container
|
.container
|
||||||
.row
|
.row
|
||||||
.col.s12
|
.col.s12
|
||||||
@ -46,8 +56,6 @@ body.has-fixed-sidenav
|
|||||||
th Информация о покупке
|
th Информация о покупке
|
||||||
.divider
|
.divider
|
||||||
tbody
|
tbody
|
||||||
#loader.progress
|
|
||||||
.indeterminate
|
|
||||||
ul#pagination.pagination.center(data-page="1")
|
ul#pagination.pagination.center(data-page="1")
|
||||||
include ./assets/templates/modals/bill_data.pug
|
include ./assets/templates/modals/bill_data.pug
|
||||||
include ./assets/templates/footer.pug
|
include ./assets/templates/footer.pug
|
||||||
|
|||||||
12
dist/views/admin/items.pug
vendored
12
dist/views/admin/items.pug
vendored
@ -2,6 +2,16 @@ include ./assets/head.pug
|
|||||||
body.has-fixed-sidenav
|
body.has-fixed-sidenav
|
||||||
include ./assets/templates/header.pug
|
include ./assets/templates/header.pug
|
||||||
main.admin-main
|
main.admin-main
|
||||||
|
#loader.loader-fullscreen.hide
|
||||||
|
.loader-fullscreen__wrap
|
||||||
|
.preloader-wrapper.big.active
|
||||||
|
.spinner-layer.spinner-green-only
|
||||||
|
.circle-clipper.left
|
||||||
|
.circle
|
||||||
|
.gap-patch
|
||||||
|
.circle
|
||||||
|
.circle-clipper.right
|
||||||
|
.circle
|
||||||
.container
|
.container
|
||||||
.row
|
.row
|
||||||
.col.s12
|
.col.s12
|
||||||
@ -32,8 +42,6 @@ body.has-fixed-sidenav
|
|||||||
|
|
||||||
.divider
|
.divider
|
||||||
tbody
|
tbody
|
||||||
#loader.progress
|
|
||||||
.indeterminate
|
|
||||||
ul#pagination.pagination.center(data-page="1")
|
ul#pagination.pagination.center(data-page="1")
|
||||||
.divider
|
.divider
|
||||||
.items-add
|
.items-add
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "digital-store",
|
"name": "digital-store",
|
||||||
"version": "1.0.0",
|
"version": "1.1.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "server/server.js",
|
"main": "server/server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -57,6 +57,15 @@ module.exports = function(server, db) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.get('/api/items/id/:id', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const item = await db.collection('items').findOne({_id: ObjectID(req.params.id)})
|
||||||
|
res.json(item)
|
||||||
|
} catch {
|
||||||
|
res.status(500).render('main/404');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
server.get('/api/items/page/:page', async (req, res) => {
|
server.get('/api/items/page/:page', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const page = parseInt(req.params.page),
|
const page = parseInt(req.params.page),
|
||||||
@ -77,6 +86,15 @@ module.exports = function(server, db) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.get('/api/items/data/:id', checkAuthenticated, async (req, res) => {
|
||||||
|
try {
|
||||||
|
const data = await db.collection('info').findOne({_id: ObjectID(req.params.id)});
|
||||||
|
res.json(data)
|
||||||
|
} catch {
|
||||||
|
res.status(500).render('main/404');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
server.get('/api/buyers', checkAuthenticated, async (req, res) => {
|
server.get('/api/buyers', checkAuthenticated, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const buyers = await db.collection('buyers').find({}).toArray();
|
const buyers = await db.collection('buyers').find({}).toArray();
|
||||||
@ -92,7 +110,7 @@ module.exports = function(server, db) {
|
|||||||
|
|
||||||
server.get('/api/buyers/:bill_id', checkAuthenticated, async (req, res) => {
|
server.get('/api/buyers/:bill_id', checkAuthenticated, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const buyers = await db.collection('buyers').find({bill_id: req.params.bill_id}).toArray();
|
const buyers = await db.collection('buyers').findOne({bill_id: req.params.bill_id});
|
||||||
res.json(buyers);
|
res.json(buyers);
|
||||||
} catch {
|
} catch {
|
||||||
res.status(500).render('main/404');
|
res.status(500).render('main/404');
|
||||||
@ -161,6 +179,15 @@ module.exports = function(server, db) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.get('/api/category/id/:id', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const category = await db.collection('categories').findOne({_id: ObjectID(req.params.id)});
|
||||||
|
res.json(category)
|
||||||
|
} catch {
|
||||||
|
res.status(500).render('main/404');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
server.get('/api/icons', checkAuthenticated, (req, res) => {
|
server.get('/api/icons', checkAuthenticated, (req, res) => {
|
||||||
try {
|
try {
|
||||||
const icons = fs.readdirSync('dist/public/img/service-icons');
|
const icons = fs.readdirSync('dist/public/img/service-icons');
|
||||||
|
|||||||
@ -177,8 +177,7 @@ module.exports = function (server, db) {
|
|||||||
});
|
});
|
||||||
server.post('/control-panel/categories/delete', checkAuthenticated, (req, res) => {
|
server.post('/control-panel/categories/delete', checkAuthenticated, (req, res) => {
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(req.body.category);
|
db.collection('categories').deleteOne({"_id": ObjectID(req.body.category)});
|
||||||
db.collection('categories').deleteOne({"_id": ObjectID(data.id)});
|
|
||||||
res.redirect('/control-panel/categories');
|
res.redirect('/control-panel/categories');
|
||||||
} catch {
|
} catch {
|
||||||
res.status(500).render('main/404');
|
res.status(500).render('main/404');
|
||||||
@ -221,15 +220,16 @@ module.exports = function (server, db) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// товары
|
// товары
|
||||||
server.post('/control-panel/items/create', checkAuthenticated, (req, res) => {
|
server.post('/control-panel/items/create', checkAuthenticated, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
const category = await db.collection('categories').findOne({_id: ObjectID(req.body.category)})
|
||||||
// документ с информацией товара для отдачи клиенту
|
// документ с информацией товара для отдачи клиенту
|
||||||
const item = {
|
const item = {
|
||||||
_id: new ObjectID(),
|
_id: new ObjectID(),
|
||||||
title: req.body.title,
|
title: req.body.title,
|
||||||
count: req.body.data.split(',').length,
|
count: req.body.data.split(',').length,
|
||||||
price: parseFloat(req.body.price),
|
price: parseFloat(req.body.price),
|
||||||
category: JSON.parse(req.body.category).title,
|
category: category.title,
|
||||||
description: req.body.description,
|
description: req.body.description,
|
||||||
date: new Date()
|
date: new Date()
|
||||||
}
|
}
|
||||||
@ -257,17 +257,18 @@ module.exports = function (server, db) {
|
|||||||
res.render('main/404');
|
res.render('main/404');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
server.post('/control-panel/items/update', checkAuthenticated, (req, res) => {
|
server.post('/control-panel/items/update', checkAuthenticated, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
const category = await db.collection('categories').findOne({_id: ObjectID(req.body.category)})
|
||||||
const data = {
|
const data = {
|
||||||
id: req.body.id,
|
id: req.body.id,
|
||||||
title: req.body.title,
|
title: req.body.title,
|
||||||
price: parseFloat(req.body.price),
|
price: parseFloat(req.body.price),
|
||||||
description: req.body.description,
|
description: req.body.description,
|
||||||
category: JSON.parse(req.body.category),
|
category,
|
||||||
info: req.body.data.split(',')
|
info: req.body.data.split(',')
|
||||||
}
|
}
|
||||||
db.collection('items').updateOne({"_id": ObjectID(data.id)}, {$set: {title: data.title, price: data.price, description: data.description, category: data.category.title}});
|
db.collection('items').updateOne({"_id": ObjectID(data.id)}, {$set: {title: data.title, price: data.price, description: data.description, category: category.title}});
|
||||||
db.collection('info').updateOne({"_id": ObjectID(data.id)}, {$set: {title: data.title, data: data.info}});
|
db.collection('info').updateOne({"_id": ObjectID(data.id)}, {$set: {title: data.title, data: data.info}});
|
||||||
res.redirect('/control-panel/items');
|
res.redirect('/control-panel/items');
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@ -23,13 +23,13 @@ MongoClient.connect(db_config.url, {useNewUrlParser: true, useUnifiedTopology: t
|
|||||||
const storage = multer.diskStorage({
|
const storage = multer.diskStorage({
|
||||||
destination: 'dist/public/img/service-icons',
|
destination: 'dist/public/img/service-icons',
|
||||||
filename: function(req, file, cb) {
|
filename: function(req, file, cb) {
|
||||||
cb(null, file.fieldname + '-' + Date.now() + path.extname(file.originalname));
|
cb(null, `${file.fieldname}-${Date.now()}${path.extname(file.originalname)}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
server.use(cors());
|
server.use(cors());
|
||||||
server.use(express.static(path.join(__dirname, '../dist/public')));
|
server.use(express.static(`${__dirname}/../dist/public`));
|
||||||
server.use(multer({storage: storage}).single('img'));
|
server.use(multer({storage: storage}).single('img'));
|
||||||
server.use(express.urlencoded({ extended: false }));
|
server.use(express.urlencoded({ extended: false }));
|
||||||
server.use(express.json());
|
server.use(express.json());
|
||||||
@ -39,7 +39,7 @@ MongoClient.connect(db_config.url, {useNewUrlParser: true, useUnifiedTopology: t
|
|||||||
server.use(passport.session());
|
server.use(passport.session());
|
||||||
server.use(methodOverride('_method'));
|
server.use(methodOverride('_method'));
|
||||||
server.set('view engine', 'pug');
|
server.set('view engine', 'pug');
|
||||||
server.set('views', path.join(__dirname, '../dist/views'));
|
server.set('views', `${__dirname}/../dist/views`);
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
require('./routes/main')(server, db); // маршруты сайта
|
require('./routes/main')(server, db); // маршруты сайта
|
||||||
@ -60,9 +60,4 @@ MongoClient.connect(db_config.url, {useNewUrlParser: true, useUnifiedTopology: t
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(server.listen(process.env.PORT || 3000, console.log('App is running...')));
|
||||||
const port = process.env.PORT || 3000;
|
|
||||||
server.listen(port, () => {
|
|
||||||
console.log('App is running...');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user