Compare commits

...

2 Commits

Author SHA1 Message Date
d8517bbe4e Cleanup
- Removed unnecessary comment.
- Disabled placeholder nav elements.
2023-05-13 00:05:52 +02:00
3b1b4f3092 Updated styles and Added storageManager.
- Dark/White-mode support
- Collapsible navs
- Renamed items template.
- StorageBuilding's are now StorageUnit's
- Formatting, general cleanup, some bug fixing.
2023-05-12 23:57:21 +02:00
14 changed files with 234 additions and 68 deletions

View File

@ -1,4 +1,15 @@
# Assetflow
## Theme?
https://bootswatch.com/darkly/
Assetflow is an inventory management solution targeted at the event industry.
## Formats and conventions (WiP)
SKU
Stock Keeping Unit
LocID
LocID_Regal16_Fach7
StorageLocation_LocID_Regal16_Fach7

View File

@ -9,7 +9,8 @@
"/bootstrap/dist/css/bootstrap.min.css.map",
"/@popperjs/core/dist/umd/popper.min.js",
"/@popperjs/core/dist/umd/popper.min.js.map",
"/bootstrap/dist/js/bootstrap.bundle.min.js.map"
"/bootstrap/dist/js/bootstrap.bundle.min.js.map",
"/bootstrap-icons/font/fonts/bootstrap-icons.woff"
],
"debugMode": false
}

View File

@ -51,13 +51,13 @@ model Item {
model StorageLocation {
id Int @id @default(autoincrement())
name String
storageBuilding StorageBuilding? @relation(fields: [storageBuildingId], references: [id])
storageBuildingId Int?
name String @unique
storageUnit StorageUnit? @relation(fields: [storageUnitId], references: [id])
storageUnitId Int?
Item Item[]
}
model StorageBuilding {
model StorageUnit {
id Int @id @default(autoincrement())
name String
street String

View File

@ -5,20 +5,18 @@
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">SKU</th>
<th scope="col">Name</th>
<th scope="col">Status</th>
<th scope="col">SKU</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<% it.items.forEach(function(user){ %>
<tr>
<th scope="row"><%= user.id %></th>
<td><%= user.SKU %></td>
<td><%= user.name %></td>
<td><span class="badge text-bg-success"><%= user.status %></span></td>
<td><%= user.SKU %></td>
<td><a href="#" class="btn btn-primary">Edit</a></td>
</tr>
<% }) %>

View File

@ -0,0 +1,75 @@
<%~ E.includeFile("../partials/head.eta.html", {"title": "Settings - Storage Manager"}) %> <%~ E.includeFile("../partials/controls.eta.html", {"active": "SETT_STORE"}) %>
<h1>Storages</h1>
<ul class="nav nav-underline" id="storageTabList" role="tablist">
<li class="nav-item" role="presentation">
<button
class="nav-link active"
id="storage-loc-tab"
data-bs-toggle="tab"
data-bs-target="#storage-loc-tab-pane"
type="button"
role="tab"
aria-controls="storage-loc-tab-pane"
aria-selected="true">
<i class="bi bi-bookshelf"></i> Storage Location
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="storage-unit-tab"
data-bs-toggle="tab"
data-bs-target="#storage-unit-tab-pane"
type="button"
role="tab"
aria-controls="storage-unit-tab-pane"
aria-selected="false">
<i class="bi bi-buildings"></i> Storage Unit
</button>
</li>
</ul>
<div class="tab-content" id="storageTabListContent">
<div class="tab-pane fade show active" id="storage-loc-tab-pane" role="tabpanel" aria-labelledby="storage-loc-tab-pane" tabindex="0">
<br>
<div class="row">
<div class="col-12">
<a href="/settings/category/new" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#createNewStorageLocationModal"><i class="bi bi-plus-lg"></i> Create new Location</a>
</div>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">LocId</th>
<th scope="col">Name</th>
<th scope="col">Storage Unit</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="tab-pane fade" id="storage-unit-tab-pane" role="tabpanel" aria-labelledby="storage-unit-tab-pane" tabindex="0">
<br>
<div class="row">
<div class="col-12">
<a href="/settings/category/new" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#createNewStorageUnitModal"><i class="bi bi-building-add"></i> Create new unit</a>
</div>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Address</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
</div>
</div>
<script src="/js/editStorages.js"></script>
<%~ E.includeFile("../partials/controlsFoot.eta.html") %> <%~ E.includeFile("../partials/foot.eta.html") %>

View File

@ -12,10 +12,7 @@
</button>
<input class="form-control form-control-dark w-100 bg-secondary" type="text" placeholder="Search" aria-label="Search" id="SearchBox" />
<div class="autocomplete-items bg-secondary w-75 border-primary me-5 p-2" id="autocomplete-items" style="left: 16.7%">
</div>
<div class="autocomplete-items bg-secondary w-75 border-primary me-5 p-2" id="autocomplete-items" style="left: 16.7%"></div>
<div class="navbar-nav">
<div class="nav-item text-nowrap">
@ -24,7 +21,6 @@
</div>
</header>
<div class="toast-container position-fixed bottom-0 end-0 p-3">
<div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
@ -32,53 +28,53 @@
<small>Just now</small>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body" id="toastText">
The button you just pressed is very useless.
</div>
<div class="toast-body" id="toastText">The button you just pressed is very useless.</div>
</div>
</div>
<script>
let texti = 0;
alltexts = ["Nope, still useless", "Stop pressing me!", "There are NO USERS!", "Please stop.", "PLEASE!"];
const toastLiveExample = document.getElementById('liveToast')
const logoutButton = document.getElementById('logoutButton')
alltexts = ['Nope, still useless', 'Stop pressing me!', 'There are NO USERS!', 'Please stop.', 'PLEASE!'];
const toastLiveExample = document.getElementById('liveToast');
const logoutButton = document.getElementById('logoutButton');
logoutButton.addEventListener('click', () => {
toastFunction();
texti++;
if (texti >= alltexts.length) texti = 0;
})
});
function toastFunction() {
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample)
toastBootstrap.show()
setTimeout(function(){ toastBootstrap.hide(); document.getElementById("toastText").innerHTML = alltexts[texti] }, 3000);
const toastBootstrap = bootstrap.Toast.getOrCreateInstance(toastLiveExample);
toastBootstrap.show();
setTimeout(function () {
toastBootstrap.hide();
document.getElementById('toastText').innerHTML = alltexts[texti];
}, 3000);
}
</script>
<div class="container-fluid">
<div class="row">
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block sidebar collapse">
<div class="position-sticky pt-3">
<ul class="nav flex-column">
<li class="nav-item">
<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="/items"> <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> Items </a>
</li>
<!-- <li class="nav-item">
<a class="nav-link <%= it.active == 'placeholder' ? 'active' : ''%>" href="#"> Products </a>
</li>
<li class="nav-item">
<a class="nav-link <%= it.active == 'placeholder' ? 'active' : ''%>"" href="#"> Products </a>
<a class="nav-link <%= it.active == 'placeholder' ? 'active' : ''%>" href="#"> Customers </a>
</li>
<li class="nav-item">
<a class="nav-link <%= it.active == 'placeholder' ? 'active' : ''%>"" href="#"> Customers </a>
<a class="nav-link <%= it.active == 'placeholder' ? 'active' : ''%>" href="#"> Reports </a>
</li>
<li class="nav-item">
<a class="nav-link <%= it.active == 'placeholder' ? 'active' : ''%>"" href="#"> Reports </a>
</li>
<li class="nav-item">
<a class="nav-link <%= it.active == 'placeholder' ? 'active' : ''%>"" href="#"> Integrations </a>
</li>
<a class="nav-link <%= it.active == 'placeholder' ? 'active' : ''%>" href="#"> Integrations </a>
</li> -->
</ul>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
@ -96,7 +92,28 @@
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>Settings</span>
</h6>
<ul class="nav flex-column mb-2">
<a class="nav-link <%= it.active == 'SETT_STORE' ? 'active' : ''%>" href="/manage/storages"
><i class="bi bi-box-seam"></i> Manage storages
<span
class="<%= it.active == 'SETT_STORE' ? 'active' : ''%>"
type="button"
onclick="return false"
data-bs-toggle="collapse"
data-bs-target="#collapseSettingsStorages"
aria-expanded="<%= it.active == 'SETT_STORE' ? 'true' : 'false'%>"
aria-controls="collapseSettingsStorages">
<i class="bi bi-caret-down-fill"></i>
<!-- TODO: This little triangle does not care if it is collapsed or not. But it should so -->
</span>
</a>
<div class="collapse <%= it.active == 'SETT_STORE' ? 'show' : ''%>" id="collapseSettingsStorages">
<a class="nav-link ms-4" href="/manage/storages#storage-loc-tab"><i class="bi bi-bookshelf"></i> Manage locations </a>
<a class="nav-link ms-4" href="/manage/storages#storage-unit-tab"><i class="bi bi-buildings"></i> Manage units </a>
</div>
<li class="nav-item">
<a class="nav-link <%= it.active == 'SETT_CAT' ? 'active' : ''%>" href="/manage/categories"><i class="bi bi-tag"></i> Manage categories </a>
</li>
@ -104,4 +121,5 @@
</div>
</nav>
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4" style="min-height: 100%;">
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4" style="min-height: 100%">
<!-- The main tag needs to be left open! -->

View File

@ -1,5 +1,3 @@
<script src="/static/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="/static/@popperjs/core/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script>
</body>
</html>

View File

@ -12,9 +12,34 @@
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<script src="/static/jquery/dist/jquery.min.js"></script>
<link href="/static/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
<link href="/css/dashboard.css" rel="stylesheet">
<link href="/static/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="/static/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet" />
<link href="/css/dashboard.css" rel="stylesheet" />
<script src="/static/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="/static/@popperjs/core/dist/umd/popper.min.js"></script>
<script>
// Listen for changes in the prefers-color-scheme media query and update the "data-bs-theme" attribute on the <html> element.
(function () {
const currentTheme = localStorage.getItem('bs.theme') ?? 'auto';
const isDark = currentTheme === 'dark';
const isLight = currentTheme === 'light';
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const prefersLight = window.matchMedia('(prefers-color-scheme: light)').matches;
if (currentTheme === 'auto') {
if (prefersDark) {
document.documentElement.setAttribute('data-bs-theme', 'dark');
} else if (prefersLight) {
document.documentElement.setAttribute('data-bs-theme', 'light');
}
} else if (isDark) {
document.documentElement.setAttribute('data-bs-theme', 'dark');
} else if (isLight) {
document.documentElement.setAttribute('data-bs-theme', 'light');
}
})();
</script>
</head>
<body>

View File

@ -4,6 +4,7 @@ import { prisma, __path } from '../../index.js';
export default (req: Request, res: Response) => {
// TODO: Fix it? Express behaves like fucking shit with routers and /. Do not ask about it or touch it. EVER! (But if you can fix it a PR is welcome!)
if (req.originalUrl !== '/') {
// TODO: Respond based on content-type (with req.is('application/json'))
res.status(404).render(__path + '/src/frontend/errors/404.eta.html', { url: req.originalUrl });
} else {
prisma.item

View File

@ -6,7 +6,7 @@ export default (req: Request, res: Response) => {
.findMany({})
.then((items) => {
// Count amount of total items
res.render(__path + '/src/frontend/allItems.eta.html', { items: items });
res.render(__path + '/src/frontend/items.eta.html', { items: items });
})
.catch((err) => {
console.error(err);

View File

@ -4,12 +4,14 @@ import express from 'express';
import testRoute from './test.js';
import csvImportRoute from './import/csvImport.js';
import categoryManager from './categoryManager.js';
import storageManager from './storageManager.js';
// Router base is '/manage'
const Router = express.Router({ strict: false });
Router.use('/test', testRoute);
Router.use('/categories', categoryManager)
Router.use('/storages', storageManager)
Router.use('/import/csv', csvImportRoute);
export default Router;

View File

@ -0,0 +1,15 @@
import express, { Request, Response } from 'express';
import { prisma, __path } from '../../../index.js';
export default (req: Request, res: Response) => {
// prisma.item
// .findMany({})
// .then((items) => {
// Count amount of total items
res.render(__path + '/src/frontend/manage/storageManager.eta.html'); //, { items: items });
// })
// .catch((err) => {
// console.error(err);
// res.status(500).render(__path + '/src/frontend/errors/dbError.eta.html', { error: err });
// });
};

View File

@ -9,11 +9,8 @@ body {
.sidebar {
position: fixed;
top: 0;
/* rtl:raw:
right: 0;
*/
bottom: 0;
/* rtl:remove */
left: 0;
z-index: 100; /* Behind the navbar */
padding: 48px 0 0; /* Height of navbar */
@ -37,12 +34,13 @@ body {
.sidebar .nav-link {
font-weight: 500;
color: #333;
/* color: #333; */
color: var(--bs-body-color);
}
.sidebar .nav-link .feather {
margin-right: 4px;
color: #727272;
color: var(--bs-body-color);
}
.sidebar .nav-link.active {
@ -59,6 +57,10 @@ body {
text-transform: uppercase;
}
#sidebarMenu {
background-color: var(--bs-secondary-bg);
}
/*
* Navbar
*/
@ -67,7 +69,6 @@ body {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
font-size: 1rem;
background-color: rgba(0, 0, 0, 0.25);
box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.25);
}
@ -83,8 +84,6 @@ body {
}
.form-control-dark {
color: #fff;
background-color: rgba(255, 255, 255, 0.1);
border-color: rgba(255, 255, 255, 0.1);
}

23
static/js/editStorages.js Normal file
View File

@ -0,0 +1,23 @@
// Javascript to enable link to tab
// This magic js codes enables anchor links to work with bootstrap tabs
// Taken from https://stackoverflow.com/a/9393768/11317151 (and edited, like a lot)
// Also update on location change
window.addEventListener("hashchange", function() {
var hash = location.hash.replace(/^#/, ''); // ^ means starting, meaning only match the first hash
if (hash) {
bootstrap.Tab.getOrCreateInstance(document.querySelector('#' + hash)).show()
}
}, false);
var hash = location.hash.replace(/^#/, ''); // ^ means starting, meaning only match the first hash
if (hash) {
bootstrap.Tab.getOrCreateInstance(document.querySelector('#' + hash)).show()
}
// Change hash for page-reload
$('.nav-link').on('click', function (e) {
window.location.hash = e.target.id;
})