- category wip
This commit is contained in:
parent
95ec75b8d7
commit
4ce9dae7ab
32
src/frontend/categoryManager.eta.html
Normal file
32
src/frontend/categoryManager.eta.html
Normal file
@ -0,0 +1,32 @@
|
||||
<%~ E.includeFile("partials/head.eta.html", {"title": "Settings - Category"}) %> <%~ E.includeFile("partials/controls.eta.html", {"active": "SETT_CAT"}) %>
|
||||
|
||||
<h1>All categories</h1>
|
||||
<div class="container">
|
||||
<!-- Create new category button -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<a href="/settings/category/new" class="btn btn-primary">Create new category</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Table with all categories -->
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% it.items.forEach(function(user){ %>
|
||||
<tr>
|
||||
<th scope="row"><%= user.id %></th>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.description %></td> </tr>
|
||||
<% }) %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<%~ E.includeFile("partials/controlsFoot.eta.html") %> <%~ E.includeFile("partials/foot.eta.html") %>
|
@ -93,6 +93,15 @@
|
||||
<a class="nav-link <%= it.active == 'json_import' ? 'active' : ''%>" href="/import/json"> <i class="bi bi-filetype-json"></i>JSON Import </a>
|
||||
</li>
|
||||
</ul>
|
||||
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
|
||||
<span>Settings</span>
|
||||
<a class="link-secondary" href="#" aria-label="Add a new report"> </a>
|
||||
</h6>
|
||||
<ul class="nav flex-column mb-2">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <%= it.active == 'SETT_CAT' ? 'active' : ''%>" href="/allCategories"><i class="bi bi-tag"></i> Manage categories </a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
15
src/routes/frontend/categoryManager.ts
Normal file
15
src/routes/frontend/categoryManager.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import { prisma, __path } from '../../index.js';
|
||||
|
||||
export default (req: Request, res: Response) => {
|
||||
prisma.category
|
||||
.findMany({})
|
||||
.then((items) => {
|
||||
// Count amount of total items
|
||||
res.render(__path + '/src/frontend/categoryManager.eta.html', { items: items });
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
res.status(500).render(__path + '/src/frontend/errors/dbError.eta.html', { error: err });
|
||||
});
|
||||
};
|
@ -6,6 +6,7 @@ import testRoute from './test.js';
|
||||
import dashboardRoute from './dashboard.js';
|
||||
import csvImportRoute from './import/csvImport.js';
|
||||
import listAllItems from './listAllItems.js';
|
||||
import categoryManager from './categoryManager.js';
|
||||
|
||||
// Router base is '/'
|
||||
const Router = express.Router({ strict: false });
|
||||
@ -13,6 +14,7 @@ const Router = express.Router({ strict: false });
|
||||
|
||||
Router.use('/test', testRoute);
|
||||
Router.use('/allItems', listAllItems)
|
||||
Router.use('/allCategories', categoryManager)
|
||||
Router.use('/import/csv', csvImportRoute);
|
||||
Router.use('/:id(\\w{8})', skuRoute);
|
||||
Router.use('/', dashboardRoute);
|
||||
|
Loading…
Reference in New Issue
Block a user