diff --git a/config/routes/routes.js b/config/routes/routes.js index c7ac04e..a28f568 100644 --- a/config/routes/routes.js +++ b/config/routes/routes.js @@ -191,6 +191,36 @@ function controlPanelCategoriesRoute(req, res) { }); } +function controlPanelContentRoute(req, res) { + res.render('admin/content', { + name: req.user.name, + email: req.user.email, + title: 'Digital-Store | Контент', + host: req.headers.host, + pageName: ['Контент', 'content'], + }); +} + +function controlPanelAdministratorsRoute(req, res) { + res.render('admin/administrators', { + name: req.user.name, + email: req.user.email, + title: 'Digital-Store | Администраторы', + host: req.headers.host, + pageName: ['Администраторы', 'administrators'], + }); +} + +function controlPanelDatabaseRoute(req, res) { + res.render('admin/database', { + name: req.user.name, + email: req.user.email, + title: 'Digital-Store | Настройка Базы Данных', + host: req.headers.host, + pageName: ['База данных', 'database'], + }); +} + module.exports = function (server, db) { server.get('/', (req, res) => indexRoute(req, res, db)); server.get('/api', (req, res) => getItemsRoute(req, res, db)); @@ -202,4 +232,7 @@ module.exports = function (server, db) { server.get('/control-panel', checkAuthenticated, (req, res) => controlPanelRoute(req, res)); server.get('/control-panel/items', checkAuthenticated, (req, res) => controlPanelItemsRoute(req, res)); server.get('/control-panel/categories', checkAuthenticated, (req, res) => controlPanelCategoriesRoute(req, res)); + server.get('/control-panel/content', checkAuthenticated, (req, res) => controlPanelContentRoute(req, res)); + server.get('/control-panel/administrators', checkAuthenticated, (req, res) => controlPanelAdministratorsRoute(req, res)); + server.get('/control-panel/database', checkAuthenticated, (req, res) => controlPanelDatabaseRoute(req, res)); } diff --git a/dist/public/css/style.css b/dist/public/css/style.css index 878583d..d8fafe4 100644 --- a/dist/public/css/style.css +++ b/dist/public/css/style.css @@ -744,8 +744,8 @@ div.table-items > table > tbody > tr > td:nth-child(7) > button.btn.orange { margin-left: 5px; } .sidenav .collapsible-body>ul:not(.collapsible)>li.active, .sidenav.sidenav-fixed .collapsible-body>ul:not(.collapsible)>li.active { - background-color: #e6e6e6; + background-color: #4E978C; } -.sidenav .collapsible-body>ul:not(.collapsible)>li.active a, .sidenav.sidenav-fixed .collapsible-body>ul:not(.collapsible)>li.active a { - color: rgba(0,0,0,0.87); +.sidenav .collapsible-body>ul:not(.collapsible)>li.active a, .sidenav.sidenav-fixed .collapsible-body>ul:not(.collapsible)>li.active a, .sidenav.sidenav-fixed .collapsible-body>ul:not(.collapsible)>li.active i { + color: #f6f6f6; } \ No newline at end of file diff --git a/dist/public/js/admin/materialize.config.js b/dist/public/js/admin/materialize.config.js index 7083d1a..3236137 100644 --- a/dist/public/js/admin/materialize.config.js +++ b/dist/public/js/admin/materialize.config.js @@ -1,16 +1,43 @@ document.addEventListener('DOMContentLoaded', function () { + // Closest полифилл для ie11 + (function() { + if (!Element.prototype.closest) { + Element.prototype.closest = function(css) { + var node = this; + + while (node) { + if (node.matches(css)) return node; + else node = node.parentElement; + } + return null; + }; + } + })(); + // Matches полифилл для ie11 + (function() { + if (!Element.prototype.matches) { + Element.prototype.matches = Element.prototype.matchesSelector || + Element.prototype.webkitMatchesSelector || + Element.prototype.mozMatchesSelector || + Element.prototype.msMatchesSelector; + } + })() + M.Sidenav.init(document.querySelectorAll('.sidenav')); M.Collapsible.init(document.querySelectorAll('.collapsible')); M.Modal.init(document.querySelectorAll('.modal')); //- active временно!!!!! - const currentPage = document.querySelector('#editCollapse .collapsible-body ul').dataset.current; - const pages = document.querySelectorAll('#editCollapse .collapsible-body ul li'); - pages.forEach(page => { - if (currentPage === page.dataset.page) { - page.classList.add('active'); - const list = M.Collapsible.getInstance(document.querySelector('#editCollapse')); - list.open(); + const currentPage = document.querySelector('#currentPage').dataset.current; + const pages = Array.from(document.querySelectorAll('.collapsible li')); + pages.forEach(function (page) { + if (page.dataset.page) { + if (currentPage === page.dataset.page) { + document.querySelector('#dashboard').classList.remove('active'); + page.classList.add('active'); + const collapse = M.Collapsible.getInstance(page.closest('.collapsible')); + collapse.open(); + } } - }) + }); }); diff --git a/dist/views/admin/administrators.pug b/dist/views/admin/administrators.pug new file mode 100644 index 0000000..509b9d0 --- /dev/null +++ b/dist/views/admin/administrators.pug @@ -0,0 +1,11 @@ +include ../assets/head.pug +body.has-fixed-sidenav + include ./assets/templates/header.pug + main.admin-main + .container + .row + .col.s12 + h2 Редактирование администраторов + + include ./assets/templates/footer.pug + include ./assets/scripts.pug \ No newline at end of file diff --git a/dist/views/admin/assets/templates/header.pug b/dist/views/admin/assets/templates/header.pug index 40f41c4..919e40f 100644 --- a/dist/views/admin/assets/templates/header.pug +++ b/dist/views/admin/assets/templates/header.pug @@ -25,36 +25,36 @@ header.admin-header i.material-icons exit_to_app li .divider - li + li#currentPage(data-current=pageName[1]) a(href="#" class="subheader") Управление сайтом li.no-padding - li - a(href="/control-panel" class="collapsible-header waves-effect") + li#dashboard.active + a(href="/control-panel" class="collapsible-header waves-effect active") i.material-icons dashboard | Статистика - ul#editCollapse.collapsible - li - a(href="#" class="collapsible-header waves-effect") - i.material-icons edit - | Редактирование - .collapsible-body - ul(data-current=pageName[1]) - li(data-page="items") - a(href='http://'+host+'/control-panel/items') - i.material-icons list - | Товары - li(data-page="categories") - a(href='http://'+host+'/control-panel/categories') - i.material-icons category - | Категории - li(data-page="content") - a(href="#content") - i.material-icons visibility - | Контент на сайте - li(data-page="administrators") - a(href="#administrators") - i.material-icons supervisor_account - | Администраторы + ul.collapsible + li + a(href="#" class="collapsible-header waves-effect") + i.material-icons edit + | Редактирование + .collapsible-body + ul + li(data-page="items") + a(href='http://'+host+'/control-panel/items') + i.material-icons list + | Товары + li(data-page="categories") + a(href='http://'+host+'/control-panel/categories') + i.material-icons category + | Категории + li(data-page="content") + a(href='http://'+host+'/control-panel/content') + i.material-icons visibility + | Контент на сайте + li(data-page="administrators") + a(href='http://'+host+'/control-panel/administrators') + i.material-icons supervisor_account + | Администраторы ul.collapsible li a(href="#" class="collapsible-header waves-effect") @@ -62,8 +62,8 @@ header.admin-header | Настройки .collapsible-body ul - li - a(href="#items") + li(data-page="database") + a(href='http://'+host+'/control-panel/database') i.material-icons storage | База данных //- Модальные окна diff --git a/dist/views/admin/content.pug b/dist/views/admin/content.pug new file mode 100644 index 0000000..d068404 --- /dev/null +++ b/dist/views/admin/content.pug @@ -0,0 +1,11 @@ +include ../assets/head.pug +body.has-fixed-sidenav + include ./assets/templates/header.pug + main.admin-main + .container + .row + .col.s12 + h2 Редактирование контента + + include ./assets/templates/footer.pug + include ./assets/scripts.pug \ No newline at end of file diff --git a/dist/views/admin/database.pug b/dist/views/admin/database.pug new file mode 100644 index 0000000..5357722 --- /dev/null +++ b/dist/views/admin/database.pug @@ -0,0 +1,11 @@ +include ../assets/head.pug +body.has-fixed-sidenav + include ./assets/templates/header.pug + main.admin-main + .container + .row + .col.s12 + h2 Настройка БД + + include ./assets/templates/footer.pug + include ./assets/scripts.pug \ No newline at end of file