Created svetle app
This commit is contained in:
		
							
								
								
									
										89
									
								
								frontend-plain/pages/beer_add/beer_add.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								frontend-plain/pages/beer_add/beer_add.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,89 @@
 | 
			
		||||
<?php
 | 
			
		||||
	$API_URL = "http://localhost:6060"
 | 
			
		||||
?>
 | 
			
		||||
<link href="/css/add.css" rel="stylesheet">
 | 
			
		||||
<h1>Přidání piva</h1>
 | 
			
		||||
 | 
			
		||||
<section class="flex f-center">
 | 
			
		||||
<form class="form_add card">
 | 
			
		||||
	<div class=form_group>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="name">Název, značka:</label>
 | 
			
		||||
			<input type="text" name="name" id="name" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="degree">Stupeň:</label>
 | 
			
		||||
			<input type="text" name="degree" id="degree" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="percentage">Procento:</label>
 | 
			
		||||
			<input type="text" name="percentage" id="percentage" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
	<div class=form_group>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="packaging">Obal:</label>
 | 
			
		||||
			<select id="packaging" name="packaging" enable>
 | 
			
		||||
				<option value="1">Plech</option>
 | 
			
		||||
				<option value="2">Sklo</option>
 | 
			
		||||
				<option value="3">Sud</option>
 | 
			
		||||
				<option value="4">Tank</option>
 | 
			
		||||
				<option value="5">Jiné</option>
 | 
			
		||||
			</select>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="note">Poznámka:</label>
 | 
			
		||||
			<input type="text" name="note" id="note" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
	<div class="form_group">
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="photo">Foto:</label>
 | 
			
		||||
			<input type="file" name="photo" id="photo" enable>
 | 
			
		||||
			<label for="upload">Upload File</label>
 | 
			
		||||
n
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
	<div class="form_group">
 | 
			
		||||
		<button class="btn-send">Přidat záznam</button>
 | 
			
		||||
	</div>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
	const btn = document.querySelector('.btn-send')
 | 
			
		||||
	btn.addEventListener('click', (e) => {
 | 
			
		||||
		e.preventDefault()
 | 
			
		||||
		console.log('click')
 | 
			
		||||
		send()
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	async function send() {
 | 
			
		||||
		console.log('click')
 | 
			
		||||
		let form = new FormData(document.querySelector("form"));
 | 
			
		||||
 | 
			
		||||
		let body = JSON.stringify(Object.fromEntries(form))
 | 
			
		||||
			fetch('<?php echo $API_URL;?>/api/v1/beer/add', {
 | 
			
		||||
			credentials: 'include',
 | 
			
		||||
			headers: {
 | 
			
		||||
				'Content-Type': 'application/json',
 | 
			
		||||
			},
 | 
			
		||||
			method: 'POST',
 | 
			
		||||
			body: body,
 | 
			
		||||
		})
 | 
			
		||||
			.then(res => {
 | 
			
		||||
				console.log(res)
 | 
			
		||||
				console.log(res.json())
 | 
			
		||||
				
 | 
			
		||||
			})
 | 
			
		||||
			.then(data => {
 | 
			
		||||
				console.log(data)
 | 
			
		||||
			})
 | 
			
		||||
			.catch(err => {
 | 
			
		||||
				console.log(err)
 | 
			
		||||
			})
 | 
			
		||||
	}
 | 
			
		||||
</script>
 | 
			
		||||
</section>
 | 
			
		||||
							
								
								
									
										20
									
								
								frontend-plain/pages/beer_get/beer_get.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								frontend-plain/pages/beer_get/beer_get.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
<section class="card-wrapper f-center" style="">
 | 
			
		||||
<?php
 | 
			
		||||
if(Router::getID() == null) {
 | 
			
		||||
for ($i=0; $i < 8; $i++) { 
 | 
			
		||||
?>
 | 
			
		||||
	<div class="card card-beer f-col">
 | 
			
		||||
		<img width="200px" id="<?= $i ?>" src="https://live.staticflickr.com/65535/49818361653_351771faae_h.jpg" alt="beer image">
 | 
			
		||||
		<h2>Beer Name</h2>
 | 
			
		||||
		<p>12 Degree</p>
 | 
			
		||||
	</div>
 | 
			
		||||
<?php
 | 
			
		||||
}} else { ?>
 | 
			
		||||
	<div class="card card-beer f-col">
 | 
			
		||||
		<img width="200px" id="<?= $i ?>" src="https://live.staticflickr.com/65535/49818361653_351771faae_h.jpg" alt="beer image">
 | 
			
		||||
		<h2>Beer Name</h2>
 | 
			
		||||
		<p>12 Degree</p>
 | 
			
		||||
	</div>
 | 
			
		||||
<?php
 | 
			
		||||
}?>
 | 
			
		||||
</section>
 | 
			
		||||
							
								
								
									
										0
									
								
								frontend-plain/pages/errors/404.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								frontend-plain/pages/errors/404.php
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										3
									
								
								frontend-plain/pages/home/home.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								frontend-plain/pages/home/home.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
<h1>Welcome to DeguApp!</h1>
 | 
			
		||||
<br>
 | 
			
		||||
<p style="text-align: center">Please Log in</p>
 | 
			
		||||
							
								
								
									
										50
									
								
								frontend-plain/pages/login/login.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								frontend-plain/pages/login/login.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,50 @@
 | 
			
		||||
<?php
 | 
			
		||||
	$API_URL = "http://localhost:6060"
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
<link rel="stylesheet" href="/css/add.css">
 | 
			
		||||
 | 
			
		||||
<form class="form_add">
 | 
			
		||||
	<label for="email">E-mail:</label>
 | 
			
		||||
	<input type="email" name="email" id="email">
 | 
			
		||||
 | 
			
		||||
	<label for="password">Heslo:</label>
 | 
			
		||||
	<input type="password" name="password" id="password">
 | 
			
		||||
 | 
			
		||||
	<button id="submit" class="btn-send">Přihlásit se</button>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
	const btn = document.querySelector('.btn-send')
 | 
			
		||||
	btn.addEventListener('click', (e) => {
 | 
			
		||||
		e.preventDefault()
 | 
			
		||||
		send()
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	function send() {
 | 
			
		||||
		let form = new FormData(document.querySelector("form"));
 | 
			
		||||
 | 
			
		||||
		let body = JSON.stringify(Object.fromEntries(form))
 | 
			
		||||
 | 
			
		||||
		//fetch('<?php echo $API_URL;?>/api/v1/user/add', {
 | 
			
		||||
		//	credentials: 'include',
 | 
			
		||||
		//	headers: {
 | 
			
		||||
		//		'Content-Type': 'application/json',
 | 
			
		||||
		//	},
 | 
			
		||||
		//	method: 'POST',
 | 
			
		||||
		//	body: body,
 | 
			
		||||
		//})
 | 
			
		||||
			.then(res => {
 | 
			
		||||
				console.log(res)
 | 
			
		||||
				console.log(res.json())
 | 
			
		||||
				
 | 
			
		||||
			})
 | 
			
		||||
			.then(data => {
 | 
			
		||||
				console.log(data)
 | 
			
		||||
			})
 | 
			
		||||
			.catch(err => {
 | 
			
		||||
				console.log(err)
 | 
			
		||||
			})
 | 
			
		||||
	}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										197
									
								
								frontend-plain/pages/review_add/review_add.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										197
									
								
								frontend-plain/pages/review_add/review_add.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,197 @@
 | 
			
		||||
<?php
 | 
			
		||||
	$API_URL = "http://localhost:6060"
 | 
			
		||||
?>
 | 
			
		||||
<link href="/css/add.css" rel="stylesheet">
 | 
			
		||||
<h1>Přidání záznamu</h1>
 | 
			
		||||
 | 
			
		||||
<form class="form_add">
 | 
			
		||||
	<div class=form_group>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="user">Uživatel:</label>
 | 
			
		||||
			<select id="user" name="user" enable>
 | 
			
		||||
				<option value="649f42f62b93542c8a465526">Dž</option>
 | 
			
		||||
				<option value="649f43182b93542c8a465528">Dý Ej En</option>
 | 
			
		||||
				<option value="649f42c32b93542c8a465524">frfr</option>
 | 
			
		||||
				<option value="649f43332b93542c8a46552a">Pch</option>
 | 
			
		||||
				<option value="649f46072b93542c8a46552f">Sš</option>
 | 
			
		||||
			</select>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
	<div class=form_group>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="beer">Beer:</label>
 | 
			
		||||
			<select name="beer_id" id="beer_id">
 | 
			
		||||
			</select>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
	<div class=form_group>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="logo">Logo:</label>
 | 
			
		||||
			<input type="number" name="logo" id="logo" min="1" max="10" step="1" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="aroma">Vůně:</label>
 | 
			
		||||
			<input type="number" name="aroma" id="aroma" min="1" max="10" step="1" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="foam">Pěna:</label>
 | 
			
		||||
			<input type="number" name="foam" id="foam" min="1" max="10" step="1" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="color">Barva:</label>
 | 
			
		||||
			<input type="number" name="color" id="color" min="1" max="10" step="1" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
	<div class=form_group>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="bitterness">Hořkost:</label>
 | 
			
		||||
			<input type="number" name="bitterness" id="bitterness" min="1" max="10" step="1" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="sweetness">Sladkost:</label>
 | 
			
		||||
			<input type="number" name="sweetness" id="sweetness" min="1" max="10" step="1" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="note">Poznámka:</label>
 | 
			
		||||
			<input type="text" name="note" id="note" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
	<div class=form_group>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="again">Dal bych si znovu?</label>
 | 
			
		||||
			<select name="again" enable>
 | 
			
		||||
				<option value="yes">Ano</option>
 | 
			
		||||
				<option value="no">Ne</option>
 | 
			
		||||
			</select>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="overall_rating">Celkový dojem:</label>
 | 
			
		||||
			<input type="number" name="overall_rating" id="overall_rating" min="1" max="10" step="1" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="final_rating">Hodnocení:</label>
 | 
			
		||||
			<input type="number" name="final_rating" id="final_rating" min="1" max="10" step="0.5" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
	<div class=form_group>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="date">Datum:</label>
 | 
			
		||||
			<input type="date" name="date" id="date" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="attendedts">S kým:</label>
 | 
			
		||||
			<select id="attendedts" name="attendedts" multiple size="3" enable>
 | 
			
		||||
				<option value="649f42f62b93542c8a465526">Dž</option>
 | 
			
		||||
				<option value="649f43182b93542c8a465528">Dý Ej En</option>
 | 
			
		||||
				<option value="649f42c32b93542c8a465524">frfr</option>
 | 
			
		||||
				<option value="649f43332b93542c8a46552a">Pch</option>
 | 
			
		||||
				<option value="649f46072b93542c8a46552f">Sš</option>
 | 
			
		||||
			</select>
 | 
			
		||||
		</div>
 | 
			
		||||
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="sign">Podpis:</label>
 | 
			
		||||
			<input type="text" name="sign" id="sign" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
	<div class="form_group">
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="photo">Foto:</label>
 | 
			
		||||
			<input type="file" name="image" id="image" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div class=form_group_label>
 | 
			
		||||
			<label for="bebeer">BeBeer:</label>
 | 
			
		||||
			<input type="file" name="bebeer" id="bebeer" enable>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	<div class="form_group">
 | 
			
		||||
		<button class="btn-send">Přidat záznam</button>
 | 
			
		||||
	</div>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<script defer>
 | 
			
		||||
	async function getBeers() {
 | 
			
		||||
		try {
 | 
			
		||||
			const res = await fetch('<?php echo $API_URL;?>/api/v1/beer/get')
 | 
			
		||||
			const data = await res.json()
 | 
			
		||||
			console.log(data)
 | 
			
		||||
			return data
 | 
			
		||||
		} catch(err) {
 | 
			
		||||
			console.log(err, "penis")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	const btn = document.querySelector('.btn-send')
 | 
			
		||||
	btn.addEventListener('click', (e) => {
 | 
			
		||||
		e.preventDefault()
 | 
			
		||||
		send()
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	async function send() {
 | 
			
		||||
		let form = new FormData(document.querySelector("form"));
 | 
			
		||||
 | 
			
		||||
		let body = JSON.stringify(Object.fromEntries(form))
 | 
			
		||||
			fetch('<?php echo $API_URL;?>/api/v1/review/add', {
 | 
			
		||||
			credentials: 'include',
 | 
			
		||||
			headers: {
 | 
			
		||||
				'Content-Type': 'application/json',
 | 
			
		||||
			},
 | 
			
		||||
			method: 'POST',
 | 
			
		||||
			body: body,
 | 
			
		||||
		})
 | 
			
		||||
			.then(res => {
 | 
			
		||||
				console.log(res)
 | 
			
		||||
				console.log(res.json())
 | 
			
		||||
				
 | 
			
		||||
			})
 | 
			
		||||
			.then(data => {
 | 
			
		||||
				console.log(data)
 | 
			
		||||
			})
 | 
			
		||||
			.catch(err => {
 | 
			
		||||
				console.log(err)
 | 
			
		||||
			})
 | 
			
		||||
	}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<script async defer>
 | 
			
		||||
	const packagingToLang = (id_pckg) => {
 | 
			
		||||
		const pckgs = {
 | 
			
		||||
			1: "Plech",
 | 
			
		||||
			2: "Sklo",
 | 
			
		||||
			3: "Plast"
 | 
			
		||||
		}
 | 
			
		||||
		return pckgs[id_pckg]
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	(async() => {
 | 
			
		||||
		// get beers and fill form data
 | 
			
		||||
		const beerData = await getBeers()
 | 
			
		||||
		const beer = document.querySelector('#beer_id')
 | 
			
		||||
 | 
			
		||||
		const beerOptions = beerData?.map((beer) => {
 | 
			
		||||
			return `
 | 
			
		||||
				<option value="${beer._id}">${beer.name} ${beer.degree} ${packagingToLang(beer.packaging)}</option>
 | 
			
		||||
			`
 | 
			
		||||
		})
 | 
			
		||||
		console.log(beerData)
 | 
			
		||||
 | 
			
		||||
		beer.innerHTML = beerOptions
 | 
			
		||||
	})()
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										0
									
								
								frontend-plain/pages/show/show.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								frontend-plain/pages/show/show.php
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										55
									
								
								frontend-plain/pages/signup/signup.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								frontend-plain/pages/signup/signup.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
<?php
 | 
			
		||||
	$API_URL = "http://localhost:6060"
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
<link rel="stylesheet" href="/css/add.css">
 | 
			
		||||
 | 
			
		||||
<form class="form_add">
 | 
			
		||||
	<label for="username">Uživatelské jméno:</label>
 | 
			
		||||
	<input type="text" name="username" id="username">
 | 
			
		||||
 | 
			
		||||
	<label for="email">E-mail:</label>
 | 
			
		||||
	<input type="email" name="email" id="email">
 | 
			
		||||
 | 
			
		||||
	<label for="password">Heslo:</label>
 | 
			
		||||
	<input type="password" name="password" id="password">
 | 
			
		||||
 | 
			
		||||
	<button id="submit" class="btn-send">Registrovat se</button>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
	(() => {
 | 
			
		||||
		const btn = document.querySelector('.btn-send')
 | 
			
		||||
		btn.addEventListener('click', (e) => {
 | 
			
		||||
			e.preventDefault()
 | 
			
		||||
			send()
 | 
			
		||||
		})
 | 
			
		||||
	})()
 | 
			
		||||
 | 
			
		||||
	function send() {
 | 
			
		||||
		let form = new FormData(document.querySelector("form"));
 | 
			
		||||
 | 
			
		||||
		let body = JSON.stringify(Object.fromEntries(form))
 | 
			
		||||
 | 
			
		||||
		fetch('<?php echo $API_URL;?>/api/v1/user/add', {
 | 
			
		||||
			credentials: 'include',
 | 
			
		||||
			headers: {
 | 
			
		||||
				'Content-Type': 'application/json',
 | 
			
		||||
			},
 | 
			
		||||
			method: 'POST',
 | 
			
		||||
			body: body,
 | 
			
		||||
		})
 | 
			
		||||
			.then(res => {
 | 
			
		||||
				console.log(res)
 | 
			
		||||
				console.log(res.json())
 | 
			
		||||
				
 | 
			
		||||
			})
 | 
			
		||||
			.then(data => {
 | 
			
		||||
				console.log(data)
 | 
			
		||||
			})
 | 
			
		||||
			.catch(err => {
 | 
			
		||||
				console.log(err)
 | 
			
		||||
			})
 | 
			
		||||
	}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user