Skip to content
Snippets Groups Projects
Commit e7fe2e74 authored by Robin Steiner's avatar Robin Steiner
Browse files

KP

parents
No related branches found
No related tags found
No related merge requests found
node_modules
# Keep environment variables out of version control
.env
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/tierlexikon-api-main.iml" filepath="$PROJECT_DIR$/.idea/tierlexikon-api-main.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
FROM node:16-alpine
WORKDIR /app
COPY package.json .
COPY package-lock.json .
RUN npm ci
COPY . .
RUN npx prisma generate
CMD node index.js
EXPOSE 28785
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tierlexikon</title>
<link rel="stylesheet" href="src/style.css">
</head>
<body style="background-color: #0a2d0f">
<div class="headline">
<h1>Das grosse Tierlexikon</h1>
<p>Semsterprojekt VS 2022</p>
</div>
<form id="create" class="create">
<div class="createleft">
<div class="name">NAME</div>
<div class="id">
<textarea readonly type="text" rows="1" cols="50" id="id" input="text"></textarea>
</div>
<div class="name">
<textarea required type="text" rows="1" cols="50" id="name" input="text"></textarea>
</div>
<div class="size">GRÖßE</div>
<div class="size">
<textarea required type="text" rows="1" cols="50" id="size" input="text"></textarea>
</div>
<div class="weight_min">GEWICHT MIN</div>
<div class="weight">
<textarea required type="text" rows="1" cols="50" id="weight_min" input="text"></textarea>
</div>
<div class="weight_max">GEWICHT MAX</div>
<div class="weight">
<textarea required type="text" rows="1" cols="50" id="weight_max" input="text"></textarea>
</div>
<div class="class">KLASSE</div>
<div class="class">
<textarea required type="text" rows="1" cols="50" id="class" input="text"></textarea>
</div>
<div class="age">ALTER</div>
<div class="age">
<textarea required type="text" rows="1" cols="50" id="age" input="text"></textarea>
</div>
<div class="origin">HERKUNFT</div>
<div class="origin">
<textarea required type="text" rows="1" cols="50" id="origin" input="text"></textarea>
</div>
</div>
<div class="createright">
<div class="description">BESCHREIBUNG</div>
<div class="description">
<textarea required type="text" rows="10" cols="50" id="desc2" input="text"></textarea>
</div>
<div class="erstellenknopf">
<button value="create" type="submit" id="erstellen">Tier Hinzufügen</button>
</div>
<div class="editknopf">
<button value="edit" type="submit" id="edit">Tier Editieren</button>
</div>
</div>
</form>
<div class="read">
<div class="products">Lexikon Einträge</div>
<div id="container"> <table id="table">
<caption>Tierarten</caption>
<tr>
<th scope="col">Tiere</th>
<th scope="col">Name</th>
<th scope="col">Größe</th>
<th scope="col">Gewicht</th>
<th scope="col">Klasse</th>
<th scope="col">Alter</th>
<th scope="col">Herkunft</th>
</tr>
<tr>
<th scope="row">Pinguin</th>
<td>Adéliepinguin</td>
<td>70 cm</td>
<td>4-5 kg</td>
<td>Vögel</td>
<td>5 Jahre</td>
<td>Antarktis</td>
</tr>
<tr>
<th scope="row">Wal</th>
<td>Belugawal</td>
<td>3-6 m</td>
<td>1500 kg</td>
<td>Säugetiere</td>
<td>50 Jahre</td>
<td>Alaska, Kanada</td>
</tr>
<tr>
<th scope="row">Hund</th>
<td>Dalmatiner</td>
<td>60 cm</td>
<td>30 kg</td>
<td>Säugetiere</td>
<td>10-13 Jahre</td>
<td>Kroatien</td>
</tr>
</table>
</div>
</div>
<div class="delete">
</div>
<div class="patch">
</div>
<script src="src/index.js"></script>
</body>
</html>
index.js 0 → 100644
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const { PrismaClient } = require('@prisma/client');
const app = express();
const prisma = new PrismaClient();
app.use(cors());
app.use(bodyParser.json());
app.get('/api/v1/animals', async (req, res) => {
const animals = await prisma.animal.findMany();
res.json({ animals });
});
app.post('/api/v1/animals', async (req, res) => {
const data = req.body;
const newAnimal = await prisma.animal.create({
data: {
name: data.name,
class: data.class,
origin: data.origin,
weight_min: data.weight_min,
weight_max: data.weight_max,
feed: data.feed,
size: data.size
}
});
res.json({ newAnimal });
});
const main = async () => {
app.listen(28785, () => {
console.log('Server started successfully on port 28785');
});
};
(() => {
main();
})();
\ No newline at end of file
This diff is collapsed.
{
"name": "tierlexikon-backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@prisma/client": "^4.0.0",
"body-parser": "^1.20.0",
"cors": "^2.8.5",
"express": "^4.18.1"
},
"devDependencies": {
"prisma": "^4.0.0"
}
}
File added
-- CreateTable
CREATE TABLE "Animal" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"name" TEXT NOT NULL,
"class" TEXT NOT NULL,
"origin" TEXT NOT NULL,
"weight_min" INTEGER NOT NULL,
"weight_max" INTEGER NOT NULL,
"feed" TEXT NOT NULL,
"size" REAL NOT NULL
);
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "sqlite"
\ No newline at end of file
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl"]
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model Animal {
id Int @id @default(autoincrement())
name String
class String
origin String
weight_min Int
weight_max Int
feed String
size Float
}
\ No newline at end of file
const API_BASE = 'http://localhost:28785/api/v1/animals';
function fill(animals){
document.getElementById("ID").value=element.name;
document.getElementById("name").value=element.class;
document.getElementById("origin").value=element.origin;
document.getElementById("weight_min").value=element.weight_min;
document.getElementById("weight_max").value=element.weight_max;
document.getElementById("feed").value=element.feed;
document.getElementById("size").value=element.size;
}
function getID(){
return document.getElementById("id").value;
}
function getData(){
let data = JSON.stringify({
name: document.getElementById("name").value,
origin: document.getElementById("origin").value,
weight_min: document.getElementById("weight_min").value,
weight_max: document.getElementById("weight_max").value,
feed: document.getElementById("feed").value,
size: document.getElementById("size").value
})
return data;
}
async function getAllItems() {
fetch(API_BASE)
.then((response) => {
return response.json();
})
.then((text) => {
console.log(text);
})
window.onload = () => {
getAllItems();
}}
/* Webshop-Administration Styles */
.headline{
background: #50bc48;
text-align: center;
font-size: 50px;
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
font-weight: bolder;
width: 100%;
}
h1{
margin-bottom: 1px;
}
p{
font-size: 15px;
height: 40px;
}
.name{
color:white;
}
.weight{
color:white;
}
.size{
color:white;
}
.class{
color:white;
}
.age{
color:white;
}
.origin{
color:white;
}
.description{
color:white;
}
.products{
color:white;
}
#table{
color:white;
}
.id{
display: none;
}
.products{
border: solid 2px black;
}
#container{
border: solid 2px rgb(0, 0, 0);
}
td,tr{
border: solid 2px rgb(0, 0, 0);
}
td{
text-transform: uppercase;
}
button{
width: 100px;
height: 100px;
font-size: 20px;
color: #ffffff;
background: linear-gradient(to top right, #000000, #000000);
border: none;
border-radius: 0px;
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
font-weight: bold;
transition: all 0.25s ease;
}
button:hover {
color: #000000;
background: linear-gradient(to top right, #fde374, #fde374);
}
.create{
text-align: center;
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
float: top;
height: 375px;
width: 100%;
background: #246532;
margin-top: 1%;
font-weight: bold;
}
.createleft {
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
float: left;
height: max-content;
align-content: center;
margin-left: 10%;
margin-top: 1%;
}
.createright {
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
float: left;
width: max-content;
margin-left: 1%;
margin-right: 10%;
margin-top: 1%;
}
.read {
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
float: left;
height: 100%;
width: 100%;
background: #246532;
margin-top: 1%;
text-align: center;
font-weight: bold;
}
.erstellenknopf {
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
height: max-content;
width: 100%;
float: left;
text-align: center;
margin-top: 1%;
}
#erstellen {
width: 200px;
height: 50px;
font-size: 20px;
color: #ffffff;
background: linear-gradient(to top right, #000000, #000000);
border: none;
border-radius: 0px;
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
font-weight: bold;
transition: all 0.25s ease;
}
#erstellen:hover {
color: #000000;
background: linear-gradient(to top right, #fde374, #fde374);
}
.editknopf {
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
height: max-content;
width: 100%;
float: left;
text-align: center;
margin-top: 1%;
}
#edit {
width: 200px;
height: 50px;
font-size: 20px;
color: #ffffff;
background: linear-gradient(to top right, #000000, #000000);
border: none;
border-radius: 0px;
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
font-weight: bold;
transition: all 0.25s ease;
}
#edit:hover {
color: #000000;
background: linear-gradient(to top right, #fde374, #fde374);
}
table#table{
width:70%;
margin-left:15%;
margin-right:15%;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment