Moved to new route structure.
This commit is contained in:
parent
c6fb84759f
commit
96853debe2
@ -3,7 +3,7 @@
|
||||
<i class="bi bi-database-fill-slash" style="font-size: 5rem"></i>
|
||||
<p class="mt-2 mb-0">There seems to be an error with the database</p>
|
||||
<p>
|
||||
<a class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample"> Get the error </a>
|
||||
<a class="btn btn-secondary" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample"> Get the error </a>
|
||||
</p>
|
||||
<div class="collapse" id="collapseExample">
|
||||
<div class="card card-body">
|
||||
|
@ -1,4 +1,4 @@
|
||||
<%~ E.includeFile("partials/head.eta.html", {"title": "Settings - Category"}) %> <%~ E.includeFile("partials/controls.eta.html", {"active": "SETT_CAT"}) %>
|
||||
<%~ 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">
|
||||
@ -97,4 +97,4 @@
|
||||
</div>
|
||||
<script src="/js/editCategory.js"></script>
|
||||
|
||||
<%~ E.includeFile("partials/controlsFoot.eta.html") %> <%~ E.includeFile("partials/foot.eta.html") %>
|
||||
<%~ E.includeFile("../partials/controlsFoot.eta.html") %> <%~ E.includeFile("../partials/foot.eta.html") %>
|
@ -1,5 +1,5 @@
|
||||
<%~ E.includeFile("../partials/head.eta.html", {"title": "Importer - CSV" }) %>
|
||||
<%~ E.includeFile("../partials/controls.eta.html", {"active": "CSV_import" }) %>
|
||||
<%~ E.includeFile("../../partials/head.eta.html", {"title": "Importer - CSV" }) %>
|
||||
<%~ E.includeFile("../../partials/controls.eta.html", {"active": "CSV_import" }) %>
|
||||
|
||||
<h1>Import A CSV File</h1>
|
||||
Upload a CSV file to import into the database. The CSV file must have the following columns:
|
||||
@ -24,5 +24,5 @@
|
||||
</form>
|
||||
|
||||
|
||||
<%~ E.includeFile("../partials/controlsFoot.eta.html") %>
|
||||
<%~ E.includeFile("../partials/foot.eta.html") %>
|
||||
<%~ E.includeFile("../../partials/controlsFoot.eta.html") %>
|
||||
<%~ E.includeFile("../../partials/foot.eta.html") %>
|
@ -65,7 +65,7 @@
|
||||
<a class="nav-link <%= it.active == 'Dashboard' ? 'active' : ''%>" aria-current="page" href="/"> <i class="bi bi-house"></i> Dashboard </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <%= it.active == 'AllItems' ? 'active' : ''%>"" href="/allItems"> <i class="bi bi-list-ul"></i> All Items </a>
|
||||
<a class="nav-link <%= it.active == 'AllItems' ? 'active' : ''%>"" href="/items"> <i class="bi bi-list-ul"></i> All Items </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <%= it.active == 'placeholder' ? 'active' : ''%>"" href="#"> Products </a>
|
||||
@ -87,19 +87,18 @@
|
||||
</h6>
|
||||
<ul class="nav flex-column mb-2">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <%= it.active == 'CSV_import' ? 'active' : ''%>" href="/import/csv"><i class="bi bi-filetype-csv"></i> CSV Import </a>
|
||||
<a class="nav-link <%= it.active == 'CSV_import' ? 'active' : ''%>" href="/manage/import/csv"><i class="bi bi-filetype-csv"></i> CSV Import </a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <%= it.active == 'json_import' ? 'active' : ''%>" href="/import/json"> <i class="bi bi-filetype-json"></i>JSON Import </a>
|
||||
<a class="nav-link <%= it.active == 'json_import' ? 'active' : ''%>" href="/manage/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>
|
||||
<a class="nav-link <%= it.active == 'SETT_CAT' ? 'active' : ''%>" href="/manage/categories"><i class="bi bi-tag"></i> Manage categories </a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -1,11 +1,11 @@
|
||||
import express from 'express';
|
||||
|
||||
// Route imports
|
||||
import testRoute from './test.js';
|
||||
import v1_routes from './v1/index.js';
|
||||
|
||||
// Router base is '/api'
|
||||
const Router = express.Router();
|
||||
const Router = express.Router({ strict: false });
|
||||
|
||||
Router.use('/test', testRoute);
|
||||
Router.use('/v1', v1_routes);
|
||||
|
||||
export default Router;
|
||||
|
11
src/routes/api/v1/index.ts
Normal file
11
src/routes/api/v1/index.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import express from 'express';
|
||||
|
||||
// Route imports
|
||||
import testRoute from './test.js';
|
||||
|
||||
// Router base is '/api/v1'
|
||||
const Router = express.Router({ strict: false });
|
||||
|
||||
Router.use('/test', testRoute);
|
||||
|
||||
export default Router;
|
@ -1,5 +1,5 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
|
||||
export default (req: Request, res: Response) => {
|
||||
res.status(200).send('API Test Successful!');
|
||||
res.status(200).send('API v1 Test Successful!');
|
||||
};
|
@ -4,19 +4,16 @@ import express from 'express';
|
||||
import skuRoute from './:id.js';
|
||||
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';
|
||||
import itemsRoute from './items.js';
|
||||
import manage_routes from "./manage/index.js";
|
||||
|
||||
// Router base is '/'
|
||||
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('/items', itemsRoute)
|
||||
Router.use('/:id(\\w{8})', skuRoute);
|
||||
Router.use('/manage', manage_routes);
|
||||
Router.use('/', dashboardRoute);
|
||||
|
||||
export default Router;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import { prisma, __path, log } from '../../index.js';
|
||||
import { prisma, __path, log } from '../../../index.js';
|
||||
|
||||
export default (req: Request, res: Response) => {
|
||||
// If method is get, render the page
|
||||
@ -9,7 +9,7 @@ export default (req: Request, res: Response) => {
|
||||
.findMany({})
|
||||
.then((items) => {
|
||||
// Count amount of total items
|
||||
res.render(__path + '/src/frontend/categoryManager.eta.html', { items: items });
|
||||
res.render(__path + '/src/frontend/manage/categoryManager.eta.html', { items: items });
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
@ -1,5 +1,5 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import { prisma, __path, log } from '../../../index.js';
|
||||
import { prisma, __path, log } from '../../../../index.js';
|
||||
import { UploadedFile } from 'express-fileupload';
|
||||
import { parse, transform } from 'csv';
|
||||
import { Status, Category, PrismaPromise } from '@prisma/client';
|
||||
@ -96,7 +96,7 @@ export default (req: Request, res: Response) => {
|
||||
|
||||
} else {
|
||||
// Render page
|
||||
res.render(__path + '/src/frontend/imports/csvImport.eta.html');
|
||||
res.render(__path + '/src/frontend/manage/imports/csvImport.eta.html');
|
||||
}
|
||||
|
||||
};
|
15
src/routes/frontend/manage/index.ts
Normal file
15
src/routes/frontend/manage/index.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import express from 'express';
|
||||
|
||||
// Route imports
|
||||
import testRoute from './test.js';
|
||||
import csvImportRoute from './import/csvImport.js';
|
||||
import categoryManager from './categoryManager.js';
|
||||
|
||||
// Router base is '/manage'
|
||||
const Router = express.Router({ strict: false });
|
||||
|
||||
Router.use('/test', testRoute);
|
||||
Router.use('/categories', categoryManager)
|
||||
Router.use('/import/csv', csvImportRoute);
|
||||
|
||||
export default Router;
|
4
src/routes/frontend/manage/test.ts
Normal file
4
src/routes/frontend/manage/test.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
export default (req: Request, res: Response) => {
|
||||
res.status(200).send('Manage Test Successful!');
|
||||
};
|
@ -10,7 +10,7 @@ const Router = express.Router({ strict: false });
|
||||
|
||||
Router.use('/static', static_routes);
|
||||
Router.use('/api', api_routes);
|
||||
Router.use('/dev', dev_routes); // This is just for development. ToDo: Add check if we are in devmode.
|
||||
Router.use('/dev', dev_routes); // This is just for development. TODO: Add check if we are in devmode.
|
||||
Router.use('/', frontend_routes);
|
||||
|
||||
export default Router;
|
Loading…
Reference in New Issue
Block a user