183 lines
5.0 KiB
HTML
183 lines
5.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<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>Halaman Login</title>
|
|
<link rel="stylesheet" href="template_assets/vendor/toastr/toastr.min.css">
|
|
<style>
|
|
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
font-family: 'Poppins', sans-serif
|
|
}
|
|
|
|
body {
|
|
background: #ecf0f3
|
|
}
|
|
|
|
|
|
.wrapper {
|
|
max-width: 350px;
|
|
min-height: 350px;
|
|
margin: 200px auto;
|
|
padding: 40px 30px 30px 30px;
|
|
background-color: #ecf0f3;
|
|
border-radius: 15px;
|
|
box-shadow: 13px 13px 20px #cbced1, -13px -13px 20px #fff
|
|
}
|
|
|
|
.logo {
|
|
width: 80px;
|
|
margin: auto
|
|
}
|
|
|
|
.logo img {
|
|
width: 100%;
|
|
height: 80px;
|
|
object-fit: cover;
|
|
border-radius: 50%;
|
|
box-shadow: 0px 0px 3px #5f5f5f, 0px 0px 0px 5px #ecf0f3, 8px 8px 15px #a7aaa7, -8px -8px 15px #fff
|
|
}
|
|
|
|
.wrapper .name {
|
|
font-weight: 600;
|
|
font-size: 1.4rem;
|
|
letter-spacing: 1.3px;
|
|
padding-left: 10px;
|
|
color: #555
|
|
}
|
|
|
|
.wrapper .form-field input {
|
|
width: 100%;
|
|
display: block;
|
|
border: none;
|
|
outline: none;
|
|
background: none;
|
|
font-size: 1.2rem;
|
|
color: #666;
|
|
padding: 10px 15px 10px 10px
|
|
}
|
|
|
|
.wrapper .form-field {
|
|
padding-left: 10px;
|
|
margin-bottom: 20px;
|
|
border-radius: 20px;
|
|
box-shadow: inset 8px 8px 8px #cbced1, inset -8px -8px 8px #fff
|
|
}
|
|
|
|
.wrapper .form-field .fas {
|
|
color: #555
|
|
}
|
|
|
|
.wrapper .btn {
|
|
box-shadow: none;
|
|
width: 100%;
|
|
height: 40px;
|
|
background-color: #03A9F4;
|
|
color: #fff;
|
|
border-radius: 25px;
|
|
box-shadow: 3px 3px 3px #b1b1b1, -3px -3px 3px #fff;
|
|
letter-spacing: 1.3px
|
|
}
|
|
|
|
.wrapper .btn:hover {
|
|
background-color: #039BE5
|
|
}
|
|
|
|
.wrapper a {
|
|
text-decoration: none;
|
|
font-size: 0.8rem;
|
|
color: #03A9F4
|
|
}
|
|
|
|
.wrapper a:hover {
|
|
color: #039BE5
|
|
}
|
|
|
|
@media(max-width: 380px) {
|
|
.wrapper {
|
|
margin: 30px 20px;
|
|
padding: 40px 15px 15px 15px
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="wrapper">
|
|
<!-- <div class="logo"> <img
|
|
src="https://www.freepnglogos.com/uploads/twitter-logo-png/twitter-bird-symbols-png-logo-0.png" alt=""> </div> -->
|
|
<div class="text-center mt-4 name">
|
|
<center>Login</center>
|
|
</div>
|
|
<div class="p-3 mt-3">
|
|
<br>
|
|
<div class="form-field d-flex align-items-center"> <span class="far fa-user"></span> <input type="text"
|
|
name="username" id="username" placeholder="Username"> </div>
|
|
<div class="form-field d-flex align-items-center"> <span class="fas fa-key"></span> <input type="password"
|
|
name="password" id="password" placeholder="Password"> </div> <button class="btn mt-3"
|
|
onclick="login()">Login</button>
|
|
</div>
|
|
<!-- <div class="text-center fs-6"> <a href="#">Forget password?</a> or <a href="#">Sign up</a> </div> -->
|
|
</div>
|
|
<script src="assets/bundles/libscripts.bundle.js"></script>
|
|
<script src="template_assets/vendor/toastr/toastr.js"></script>
|
|
<script>
|
|
async function login() {
|
|
// create let variable username and password
|
|
let username = document.getElementById('username').value
|
|
let password = document.getElementById('password').value
|
|
|
|
//if username and password is empty
|
|
if (username == '' || password == '') {
|
|
// alert('Username and Password is required')
|
|
toastr.error('Username and Password is required')
|
|
//focus on username
|
|
document.getElementById('username').focus()
|
|
} else {
|
|
//create try catch
|
|
try {
|
|
|
|
//create fetch
|
|
let response = await fetch(`http://localhost/ilham/server/api/login_user?username=${username}&password=${password}`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Basic ' + btoa('Kicap_karan:bb10c6d9f01ec0cb16726b59e36c2f73')
|
|
}
|
|
})
|
|
//create json
|
|
let json = await response.json()
|
|
//if response status is 200 then console.log("ok") else if response status is 400 then console.log("username or password is wrong")
|
|
if (response.status == 200) {
|
|
localStorage.setItem('no_user', json.data.no_user)
|
|
localStorage.setItem('username', json.data.username)
|
|
localStorage.setItem('password', json.data.password)
|
|
// console.log
|
|
window.location.replace('admin_index.html')
|
|
|
|
} else if (response.status == 400) {
|
|
|
|
toastr.error('Username or Password is wrong')
|
|
//focus on username
|
|
document.getElementById('username').focus()
|
|
}
|
|
|
|
} catch (error) {
|
|
//if error
|
|
console.log(error)
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html> |