Commit dc9a3468 authored by Noorindria Mayrien  Nariswari 's avatar Noorindria Mayrien Nariswari
Browse files

UAS FrontEnd V3422051 Noorindria Mayrien N

parents
Showing with 429 additions and 0 deletions
+429 -0
*
!.gitignore
<?php
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;
trait CreatesApplication
{
/**
* Creates the application.
*/
public function createApplication(): Application
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
}
<?php
namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');
$response->assertStatus(200);
}
}
<?php
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
}
<?php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_that_true_is_true(): void
{
$this->assertTrue(true);
}
}
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
],
});
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# frontend
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}
This diff is collapsed.
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^1.6.1",
"bootstrap": "^5.3.2",
"core-js": "^3.8.3",
"jquery": "^3.7.1",
"popper.js": "^1.16.1",
"vue": "^3.2.13",
"vue-router": "^4.0.13"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {
"vue/multi-word-component-names": "off"
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
frontend/public/favicon.ico

4.19 KB

<!DOCTYPE html>
<html lang="">
<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">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<router-view></router-view>
</template>
<script>
export default {
}
</script>
\ No newline at end of file
frontend/src/assets/logo.png

6.69 KB

<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
import { createApp } from 'vue'
import App from './App.vue'
//import router
import router from './router'
//import Bootstrap, Popper, jQuery
import 'bootstrap/dist/css/bootstrap.css'
import 'jquery/dist/jquery.min'
import 'popper.js/dist/popper.min'
import 'bootstrap/dist/js/bootstrap.min'
const app = createApp(App)
//use vue router
app.use(router)
app.mount('#app')
\ No newline at end of file
//import vue router
import { createRouter, createWebHistory } from "vue-router";
//define a routes
const routes = [
{
path: "/",
name: "auth.login",
component: () => import(/* webpackChunkName: "auth.login" */ "@/views/auth/Login.vue"),
},
{
path: "/register",
name: "auth.register",
component: () => import(/* webpackChunkName: "auth.register" */ "@/views/auth/Register.vue"),
},
{
path: "/user",
name: "siswa.user",
component: () =>
import(/* webpackChunkName: "siswa.user" */ "@/views/siswa/user.vue"),
},
{
path: "/siswa",
name: "siswa.Index",
component: () =>
import(/* webpackChunkName: "siswa.siswa" */ "@/views/siswa/Index.vue"),
},
{
path: "/create",
name: "siswa.create",
component: () =>
import(/* webpackChunkName: "siswa.create" */ "@/views/siswa/Create.vue"),
},
{
path: "/edit/:id",
name: "siswa.edit",
component: () =>
import(/* webpackChunkName: "siswa.edit" */ "@/views/siswa/Edit.vue"),
},
];
//create router
const router = createRouter({
history: createWebHistory(),
routes, // config routes
});
export default router;
<template>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card border-0 rounded shadow">
<div class="card-body">
<h2 class="text-center">Login</h2>
<form @submit.prevent="LoginData">
<div class="form-group">
<label>Email</label>
<input type="email" v-model="siswa.email" class="form-control" placeholder="Email" />
</div>
<div class="form-group">
<label>Password</label>
<input type="password" v-model="siswa.password" class="form-control" placeholder="Password" />
</div>
<button type="submit" class="btn btn-primary btn-block mt-3">
Login
</button>
</form>
<p class="mt-3 text-center">
Belum punya akun?
<router-link to="/register">Register Disini</router-link>
</p>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import axios from "axios";
export default {
name: "Login",
data() {
return {
siswa: {
email: "",
password: "",
},
};
},
methods: {
LoginData() {
axios.post("http://127.0.0.1:8000/api/login", this.siswa)
.then(({ data }) => {
try {
// Login berhasil
if (data.status) {
// Berhasil login, tentukan alur berdasarkan role
if (data.role === "admin") {
console.log(data)
// Pengguna dengan peran admin, arahkan ke halaman siswa
this.$router.push({ name: "siswa.Index" });
} else if (data.role === "user") {
// Pengguna dengan peran user, arahkan ke halaman user
this.$router.push({ name: "siswa.user" });
} else {
// Jika peran tidak sesuai, mungkin ada kesalahan
alert("Invalid role. Please contact administrator.");
}
} else {
// Jika status login adalah false, tampilkan pesan kegagalan
alert("Login failed. Please check your credentials.");
}
} catch (err) {
alert("Error, please try again");
}
})
.catch((error) => {
console.error("Error during login:", error);
alert("Error during login. Please try again.");
});
},
},
};
</script>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment