- migrated old page to new partials

- fixed setDemoData endpoint
This commit is contained in:
Sören Oesterwind 2023-05-01 18:36:24 +02:00
parent 5a21e56e80
commit 58a36d36ec
5 changed files with 26 additions and 72 deletions

View File

@ -34,8 +34,8 @@ model Item {
manufacturer String manufacturer String
category Category category Category
status Status status Status
StorageLocation StorageLocation @relation(fields: [storageLocationId], references: [id]) StorageLocation StorageLocation? @relation(fields: [storageLocationId], references: [id])
storageLocationId Int storageLocationId Int?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
} }
@ -43,8 +43,8 @@ model Item {
model StorageLocation { model StorageLocation {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
name String name String
storageBuilding StorageBuilding @relation(fields: [storageBuildingId], references: [id]) storageBuilding StorageBuilding? @relation(fields: [storageBuildingId], references: [id])
storageBuildingId Int storageBuildingId Int?
Item Item[] Item Item[]
} }

View File

@ -1,4 +1,4 @@
<%~ E.includeFile("head.eta.html") %> <%~ E.includeFile("head.eta.html", {"title": "Bootstrap Demo Page"}) %>
<div class="alert alert-primary" role="alert"> <div class="alert alert-primary" role="alert">
A simple primary alert—check it out! A simple primary alert—check it out!

View File

@ -5,7 +5,7 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title>AssetFlow - Info about item</title> <title>AssetFlow - <%= it.title %></title>
<meta name="description" content="A simple HTML5 Template for new projects." /> <meta name="description" content="A simple HTML5 Template for new projects." />
<meta name="author" content="[Project-Name-Here]" /> <meta name="author" content="[Project-Name-Here]" />

View File

@ -1,24 +1,5 @@
<!DOCTYPE html> <%~ E.includeFile("head.eta.html", {"title": "Item Info"}) %>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>AssetFlow - Info about item</title>
<meta name="description" content="A simple HTML5 Template for new projects." />
<meta name="author" content="[Project-Name-Here]" />
<link rel="icon" href="/favicon.ico" />
<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">
<script src="/static/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class="ui raised very padded text container segment"> <div class="ui raised very padded text container segment">
<h2 class="ui header"><%= it.name %></h2> <h2 class="ui header"><%= it.name %></h2>
<p><strong>Category:</strong> <%= it.category%></p> <p><strong>Category:</strong> <%= it.category%></p>
@ -27,5 +8,5 @@
<p><strong>Comment:</strong> <%= it.comment %></p> <p><strong>Comment:</strong> <%= it.comment %></p>
</div> </div>
</body>
</html> <%~ E.includeFile("foot.eta.html") %>

View File

@ -1,52 +1,25 @@
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import { prisma } from '../../index.js'; import { prisma } from '../../index.js';
import { Status, Category } from '@prisma/client';
export default (req: Request, res: Response) => { export default (req: Request, res: Response) => {
/*
// fill database with demo data // fill database with demo data
prisma.StorageBuilding.create({
data: { prisma.item
name: 'Test Storage Building', .create({
street: 'Test Street',
houseNumber: '1',
zipCode: '12345',
city: 'Test City',
country: 'Test Country'
}
}).then(() => {
prisma.StorageLocation.create({
data: { data: {
name: 'Test Storage Location', SKU: 'ee189749',
StorageBuilding: { Amount: 1,
connect: { name: 'Test Item',
id: 1 manufacturer: 'Test Manufacturer',
} category: Category.Other,
} status: Status.normal
} }
}).then(() => { })
prisma.item .then(() => {
.create({ res.send('Demo data added');
data: { })
SKU: 'ee189749', .catch((err) => {
Amount: 1, res.send('Error adding demo data: ' + err);
name: 'Test Item',
manufacturer: 'Test Manufacturer',
category: Category.Other,
status: Status.normal,
storageLocation: {
connect: {
id: 1
}
}
}
})
.then(() => {
res.send('Demo data added');
})
.catch((err) => {
res.send('Error adding demo data: ' + err);
});
}); });
});
*/
res.status(200).send('Demo data added (not)');
}; };