Fakultas Ilmu Komputer UI

Commit a18fb51b authored by Muhamad Fariz Farhan's avatar Muhamad Fariz Farhan
Browse files

ngerjain route login, ui login, create delete admin

parent 28594ab2
......@@ -2,9 +2,12 @@
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use App\Services\UserService;
use App\Services\AdminerDatabaseService;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class AdminController extends Controller
{
......
......@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use App\Services\UserService;
use Illuminate\Support\Facades\Hash;
class UserController extends Controller
{
......@@ -56,7 +57,14 @@ class UserController extends Controller
*/
public function store(Request $request)
{
//
$user = new User;
$user->name = $request->name;
$user->email = $request->email;
$user->email_verified_at = now();
$user->password = Hash::make($request->password);
$user->is_admin = 1;
$user->save();
}
/**
......@@ -101,6 +109,6 @@ class UserController extends Controller
*/
public function destroy(User $user)
{
//
$user->delete();
}
}
......@@ -15,7 +15,7 @@ class Authenticate extends Middleware
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
return route('admin.login');
}
}
}
......@@ -18,6 +18,6 @@ class RedirectIfNotAdmin {
return $next($request);
}
return redirect('/login');
return redirect('/admin/login');
}
}
\ No newline at end of file
......@@ -4150,7 +4150,7 @@ Invoice
Account Pages
===================*/
.accountbg {
background: url("../images/bg.jpg");
background-color: #263238;
position: absolute;
background-size: cover;
height: 100%;
......
......@@ -2048,7 +2048,7 @@ __webpack_require__.r(__webpack_exports__);
if (result.value) {
_this3.$swal.fire({
title: 'Success!',
text: 'Article deleted successfully',
text: 'Data deleted successfully',
icon: 'success',
timer: 10000
});
......@@ -2117,10 +2117,44 @@ __webpack_require__.r(__webpack_exports__);
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ __webpack_exports__["default"] = ({
data: function data() {
return {
admins: [],
admin: {
name: '',
email: '',
password: ''
},
user_uri: (window.location.href.includes("cs.ui.ac.id") ? "https://opensauce.cs.ui.ac.id/_admin" : "") + "/admin/resource/users",
admins_uri: (window.location.href.includes("cs.ui.ac.id") ? "https://opensauce.cs.ui.ac.id/_admin" : "") + "/admin/resource/users/admins"
};
},
......@@ -2134,8 +2168,49 @@ __webpack_require__.r(__webpack_exports__);
});
});
},
submitForm: function submitForm(e) {
var _this2 = this;
e.preventDefault();
axios.post(this.user_uri, {
name: this.admin.name,
email: this.admin.email,
password: this.admin.password
}).then(function (response) {
_this2.loadData();
});
},
putAsyncData: function putAsyncData(data) {
this.admins = data;
},
deleteData: function deleteData(id, index) {
var _this3 = this;
this.$swal.fire({
title: 'Are you sure?',
text: 'Data will be deleted permanently',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel'
}).then(function (result) {
if (result.value) {
_this3.$swal.fire({
title: 'Success!',
text: 'Data deleted successfully',
icon: 'success',
timer: 10000
});
axios["delete"](_this3.user_uri + '/' + id).then(function (res) {
_this3.loadData();
_this3.$delete(_this3.admins, index);
});
}
});
}
},
mounted: function mounted() {
......@@ -2229,6 +2304,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
$.when(_this.putAsyncData(response.data)).then(function () {
$("#datatable").DataTable();
});
console.log(_this.mahasiswas);
});
},
putAsyncData: function putAsyncData(data) {
......@@ -26976,6 +27052,91 @@ var render = function() {
_c("div", { staticClass: "col-12" }, [
_c("div", { staticClass: "card m-b-20" }, [
_c("div", { staticClass: "card-body" }, [
_c("form", { on: { submit: _vm.submitForm } }, [
_c("h2", [_vm._v("Buat Admin Baru")]),
_vm._v(" "),
_c("strong", [_vm._v("Nama:")]),
_vm._v(" "),
_c("input", {
directives: [
{
name: "model",
rawName: "v-model",
value: _vm.admin.name,
expression: "admin.name"
}
],
staticClass: "form-control",
staticStyle: { "margin-bottom": "20px" },
attrs: { type: "text" },
domProps: { value: _vm.admin.name },
on: {
input: function($event) {
if ($event.target.composing) {
return
}
_vm.$set(_vm.admin, "name", $event.target.value)
}
}
}),
_vm._v(" "),
_c("strong", [_vm._v("Email:")]),
_vm._v(" "),
_c("input", {
directives: [
{
name: "model",
rawName: "v-model",
value: _vm.admin.email,
expression: "admin.email"
}
],
staticClass: "form-control",
staticStyle: { "margin-bottom": "20px" },
attrs: { type: "email" },
domProps: { value: _vm.admin.email },
on: {
input: function($event) {
if ($event.target.composing) {
return
}
_vm.$set(_vm.admin, "email", $event.target.value)
}
}
}),
_vm._v(" "),
_c("strong", [_vm._v("Password")]),
_vm._v(" "),
_c("input", {
directives: [
{
name: "model",
rawName: "v-model",
value: _vm.admin.password,
expression: "admin.password"
}
],
staticClass: "form-control",
staticStyle: { "margin-bottom": "20px" },
attrs: { type: "password" },
domProps: { value: _vm.admin.password },
on: {
input: function($event) {
if ($event.target.composing) {
return
}
_vm.$set(_vm.admin, "password", $event.target.value)
}
}
}),
_vm._v(" "),
_c("button", { staticClass: "btn btn-success" }, [
_vm._v("Create")
])
]),
_vm._v(" "),
_c("hr"),
_vm._v(" "),
_c(
"table",
{
......@@ -26993,7 +27154,20 @@ var render = function() {
_vm._v(" "),
_c("td", [_vm._v(_vm._s(admin.email))]),
_vm._v(" "),
_c("td")
_c("td", [
_c(
"button",
{
staticClass: "btn btn-danger btn-sm",
on: {
click: function($event) {
return _vm.deleteData(admin.id, index)
}
}
},
[_vm._v("Delete")]
)
])
])
}),
0
......@@ -39908,8 +40082,8 @@ __webpack_require__.r(__webpack_exports__);
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
 
__webpack_require__(/*! D:\Kuliah\OSSD\open-sauce\admin\resources\js\app.js */"./resources/js/app.js");
module.exports = __webpack_require__(/*! D:\Kuliah\OSSD\open-sauce\admin\resources\sass\app.scss */"./resources/sass/app.scss");
__webpack_require__(/*! F:\Muhamad Fariz Farhan\Pelajaran\Term 7\OSSD\open-sauce\admin\resources\js\app.js */"./resources/js/app.js");
module.exports = __webpack_require__(/*! F:\Muhamad Fariz Farhan\Pelajaran\Term 7\OSSD\open-sauce\admin\resources\sass\app.scss */"./resources/sass/app.scss");
 
 
/***/ })
......@@ -103,7 +103,7 @@ export default {
if(result.value) {
this.$swal.fire({
title: 'Success!',
text: 'Article deleted successfully',
text: 'Data deleted successfully',
icon: 'success',
timer: 10000
});
......
......@@ -4,6 +4,32 @@
<div class="col-12">
<div class="card m-b-20">
<div class="card-body">
<form @submit="submitForm">
<h2>Buat Admin Baru</h2>
<strong>Nama:</strong>
<input
type="text"
class="form-control"
v-model="admin.name"
style="margin-bottom: 20px"
/>
<strong>Email:</strong>
<input
type="email"
class="form-control"
v-model="admin.email"
style="margin-bottom: 20px"
/>
<strong>Password</strong>
<input
type="password"
class="form-control"
v-model="admin.password"
style="margin-bottom: 20px"
/>
<button class="btn btn-success">Create</button>
</form>
<hr />
<table
id="datatable"
class="table table-bordered dt-responsive nowrap"
......@@ -24,7 +50,9 @@
>
<td>{{ admin.name }}</td>
<td>{{ admin.email }}</td>
<td></td>
<td>
<button class="btn btn-danger btn-sm" @click="deleteData(admin.id, index)">Delete</button>
</td>
</tr>
</tbody>
</table>
......@@ -40,6 +68,14 @@ export default {
data() {
return {
admins: [],
admin: {
name:'',
email:'',
password:'',
},
user_uri: (window.location.href.includes("cs.ui.ac.id")
? "https://opensauce.cs.ui.ac.id/_admin"
: "") + "/admin/resource/users",
admins_uri:
(window.location.href.includes("cs.ui.ac.id")
? "https://opensauce.cs.ui.ac.id/_admin"
......@@ -54,8 +90,45 @@ export default {
});
});
},
submitForm(e){
e.preventDefault();
axios.post(this.user_uri, {
name: this.admin.name,
email: this.admin.email,
password: this.admin.password
})
.then(response=>{
this.loadData();
});
},
putAsyncData(data) {
this.admins = data;
},
deleteData(id, index) {
this.$swal.fire({
title: 'Are you sure?',
text: 'Data will be deleted permanently',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel'
}).then((result) => {
if(result.value) {
this.$swal.fire({
title: 'Success!',
text: 'Data deleted successfully',
icon: 'success',
timer: 10000
});
axios.delete(this.user_uri + '/' + id)
.then(res=>{
this.loadData();
this.$delete(this.admins, index)
});
}
})
}
},
mounted() {
......
......@@ -69,6 +69,7 @@ export default {
$.when(this.putAsyncData(response.data)).then(function() {
$("#datatable").DataTable();
});
console.log(this.mahasiswas);
});
},
putAsyncData(data) {
......
......@@ -4,7 +4,7 @@
<div class="container-fluid">
<div class="row">
<div class="col-12">
Love you
Work In Progress
</div>
</div>
</div>
......
<footer class="footer">
Open Sauce <span class="text-muted d-none d-sm-inline-block float-right">Created with <i class="mdi mdi-heart text-danger"></i> by Anak Fasilkom Yang Bentar Lagi Lulus</span>
Open Sauce
</footer>
\ No newline at end of file
......@@ -77,7 +77,7 @@
<a class="dropdown-item" href="#"><span class="badge badge-success pull-right m-t-5">5</span><i class="dripicons-gear text-muted"></i> Settings</a>
<a class="dropdown-item" href="#"><i class="dripicons-lock text-muted"></i> Lock screen</a>
<div class="dropdown-divider"></div>-->
<form action="/logout" method="POST">{{ csrf_field() }}
<form action="/admin/logout" method="POST">{{ csrf_field() }}
<button class="dropdown-item" type="submit"><i class="dripicons-exit text-muted"></i> Logout</button>
</form>
</div>
......
......@@ -2,7 +2,7 @@
@section('content')
<div id="app">
<admins-component></admins-component>
<users-component></users-component>
</div>
@endsection
......
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Login') }}</div>
<!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, user-scalable=0, minimal-ui">
<title>Open Sauce - Admin Backend</title>
<meta content="Admin Backend" name="description" />
<meta content="Open Sauce" name="author" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App Icons -->
<link rel="shortcut icon" href="{{ asset('assets/admin/images/logo.jpg')}}">
@yield('stylesheet')
<!-- Basic Css files -->
<link href="{{ asset('/assets/admin/css/bootstrap.min.css') }}" rel="stylesheet" type="text/css">
<link href="{{ asset('/assets/admin/css/icons.css') }}" rel="stylesheet" type="text/css">
<link href="{{ asset('/assets/admin/css/style.css') }}" rel="stylesheet" type="text/css">
<link href="{{ asset('css/app.css') }}" rel="stylesheet" type="text/css">
<style>
img {
width: 100%
}
</style>
</head>
<body class="fixed-left">
<!-- Loader -->
<div id="preloader"><div id="status"><div class="spinner"></div></div></div>
<!-- Begin page -->
<div class="accountbg"></div>
<div class="wrapper-page">
<div class="card">
<div class="card-body">
<form method="POST" action="{{ route('login') }}">
@csrf
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<h3 class="text-center m-0">
<img class="w-30" src="{{ asset('assets/admin/images/logo.jpg')}}" alt="logo" style="width:30%; border-radius: 100%; box-shadow: 3px 3px 4px;">
</h3>
<div class="col-md-6">
<div class="p-3">
<h4 class="font-18 m-b-5 text-center">Welcome Back !</h4>
<p class="text-muted text-center">Sign in to continue to Admin.</p>
<form class="form-horizontal m-t-30" method="POST" action="/admin/login">
@csrf
<div class="form-group">
<label for="email">Email</label>
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
@error('email')
......@@ -23,12 +64,9 @@
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<div class="form-group">
<label for="password">Password</label>
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
@error('password')
......@@ -37,37 +75,45 @@
</span>
@enderror
</div>
</div>
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<div class="form-group row m-t-20">
<div class="col-sm-6">
<div class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>
<label class="form-check-label" for="remember">
{{ __('Remember Me') }}
</label>
<label class="custom-control-label" for="remember">
{{ __('Remember Me') }}
</label>
</div>
</div>
<div class="col-sm-6 text-right">
<button class="btn btn-primary w-md waves-effect waves-light" type="submit">Log In</button>
</div>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Login') }}
</button>
@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
</div>
</div>
</form>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
<!-- jQuery -->
<script src="{{ asset('/assets/admin/js/jquery.min.js') }}"></script>
<script src="{{ asset('/assets/admin/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ asset('/assets/admin/js/modernizr.min.js') }}"></script>
<script src="{{ asset('/assets/admin/js/jquery.slimscroll.js') }}"></script>
<script src="{{ asset('/assets/admin/js/waves.js') }}"></script>
<script src="{{ asset('/assets/admin/js/jquery.nicescroll.js') }}"></script>
<script src="{{ asset('/assets/admin/js/jquery.scrollTo.min.js') }}"></script>
@yield('script