latest commit

This commit is contained in:
armiejean 2025-05-11 22:58:53 +08:00
parent 6c47477da1
commit 3cbf077990
4 changed files with 88 additions and 49 deletions

4
composer.lock generated
View File

@ -8205,12 +8205,12 @@
], ],
"aliases": [], "aliases": [],
"minimum-stability": "stable", "minimum-stability": "stable",
"stability-flags": [], "stability-flags": {},
"prefer-stable": true, "prefer-stable": true,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": "^8.2" "php": "^8.2"
}, },
"platform-dev": [], "platform-dev": {},
"plugin-api-version": "2.6.0" "plugin-api-version": "2.6.0"
} }

View File

@ -24,9 +24,15 @@
{{ session('success') }} {{ session('success') }}
</div> </div>
@endif @endif
@if (session('error'))
@if (session('error_username')) <div class="alert alert-danger">
<span style="color: red;">{{ session('error_username') }}</span> {{ session('error') }}
</div>
@endif
@if (session('prompt_password'))
<div class="alert alert-warning">
You must change your password. <a href="{{ route('change.password.form') }}">Change Password</a>
</div>
@endif @endif
<form method="POST" action="{{ route('login') }}"> <form method="POST" action="{{ route('login') }}">
@ -34,13 +40,17 @@
<div class="mb-3"> <div class="mb-3">
<label for="username" class="form-label fw-semibold" style="font-size: 13px; color: #003366;">Enter Username</label> <label for="username" class="form-label fw-semibold" style="font-size: 13px; color: #003366;">Enter Username</label>
<input type="text" class="form-control" id="username" name="username" placeholder="superadmin" value="{{ old('username') }}" required> <input type="text" class="form-control" id="username" name="username" placeholder="superadmin" value="{{ old('username') }}" required>
@error('username')
<div style="color: red; font-size: 0.875em;">{{ $message }}</div>
@enderror
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="password" class="form-label fw-semibold" style="font-size: 13px; color: #003366;">Enter Password</label> <label for="password" class="form-label fw-semibold" style="font-size: 13px; color: #003366;">Enter Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="••••••••" required> <input type="password" class="form-control" id="password" name="password" placeholder="••••••••" required>
@error('password')
<div style="color: red; font-size: 0.875em;">{{ $message }}</div>
@enderror
</div> </div>
<div class="row mt-4"> <div class="row mt-4">
<div class="col-6"> <div class="col-6">
<a href="#" class="text-decoration-none text-primary" data-bs-toggle="modal" data-bs-target="#forgotPasswordModal">Forgot Username</a> <a href="#" class="text-decoration-none text-primary" data-bs-toggle="modal" data-bs-target="#forgotPasswordModal">Forgot Username</a>
@ -72,6 +82,6 @@
</div> </div>
</div> </div>
<!-- Include Bootstrap 5 JS for modal functionality --> <!-- Include Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
@endsection @endsection

View File

@ -3,35 +3,74 @@
@section('page_title', 'User Management') @section('page_title', 'User Management')
@section('content') @section('content')
@php <div id="user-table">
$users = [ @include('components.table-component', [
['id' => 1, 'username' => 'superadmin', 'firstName' => 'Maryse', 'lastName' => 'Howe', 'role' => 'Admin', 'email' => 'maryse.howe@qqq.com', 'status' => 'Inctive'], 'pageTitle' => 'User Management',
['id' => 2, 'username' => 'superadmin1', 'firstName' => 'Joseph', 'lastName' => 'Sazon', 'role' => 'Admin', 'email' => 'mis.specialist@unioil.com', 'status' => 'Active'], 'data' => [],
['id' => 3, 'username' => 'graxia', 'firstName' => 'Graxia', 'lastName' => 'Montino', 'role' => 'Admin', 'email' => 'business.analyst@unioil.com', 'status' => 'Inctive'], 'columns' => [
['id' => 4, 'username' => 'cinerosimo', 'firstName' => 'Cine', 'lastName' => 'Rosimo', 'role' => 'Admin', 'email' => 'frosimo1@yopmail.com', 'status' => 'Active'], ['name' => 'Username', 'key' => 'username', 'sortable' => true],
['id' => 5, 'username' => 'graxia5', 'firstName' => 'Graxia', 'lastName' => 'Montino', 'role' => 'Admin', 'email' => 'business.analyst@unioil.com', 'status' => 'Inctive'], ['name' => 'First Name', 'key' => 'firstName', 'sortable' => true],
['id' => 6, 'username' => 'graxia6', 'firstName' => 'Graxia', 'lastName' => 'Montino', 'role' => 'Admin', 'email' => 'business.analyst@unioil.com', 'status' => 'Inctive'], ['name' => 'Last Name', 'key' => 'lastName', 'sortable' => true],
['id' => 7, 'username' => 'graxia7', 'firstName' => 'Graxia', 'lastName' => 'Montino', 'role' => 'Admin', 'email' => 'business.analyst@unioil.com', 'status' => 'Active'] ['name' => 'User Role', 'key' => 'role', 'sortable' => true],
]; ['name' => 'Email', 'key' => 'email', 'sortable' => true],
@endphp ['name' => 'Status', 'key' => 'status', 'sortable' => true]
],
'actions' => ['edit', 'view', 'delete'],
'showAddButton' => true,
'addButtonUrl' => '/add-user',
'showCheckboxes' => true,
'showBatchDelete' => true,
'showEditModal' => true,
'showViewModal' => true
])
<div id="no-data-message" style="display: none; text-align: center; margin-top: 20px;">
<p>No Data Found</p>
</div>
</div>
@include('components.table-component', [ <script>
'pageTitle' => 'User Management', document.addEventListener('DOMContentLoaded', function() {
'data' => $users, const apiBaseUrl = '{{ config('app.api_base_url') }}'; // Fetch base URL from config/app.php
'columns' => [ const apiEndpoint = `${apiBaseUrl}/api/cms/admin`; // Construct the full API URL
['name' => 'Username', 'key' => 'username', 'sortable' => true],
['name' => 'First Name', 'key' => 'firstName', 'sortable' => true], fetch(apiEndpoint, {
['name' => 'Last Name', 'key' => 'lastName', 'sortable' => true], method: 'GET',
['name' => 'User Role', 'key' => 'role', 'sortable' => true], headers: {
['name' => 'Email', 'key' => 'email', 'sortable' => true], 'Accept': 'application/json',
['name' => 'Status', 'key' => 'status', 'sortable' => true] 'Authorization': 'Bearer ' + localStorage.getItem('token') // Adjust if authentication is needed
], }
'actions' => ['edit', 'view', 'delete'], })
'showAddButton' => true, .then(response => response.json())
'addButtonUrl' => '/add-user', .then(data => {
'showCheckboxes' => true, const noDataMessage = document.getElementById('no-data-message');
'showBatchDelete' => true, const tableComponent = document.querySelector('table-component');
'showEditModal' => true,
'showViewModal' => true if (data.data && Array.isArray(data.data) && data.data.length > 0) {
]) const users = data.data.map(admin => ({
id: admin.admin_id,
username: admin.username,
firstName: admin.firstname,
lastName: admin.lastname,
role: 'Admin', // Adjust if the API provides roles
email: admin.email,
status: admin.is_active ? 'Active' : 'Inactive'
}));
// Update the table component with the fetched data
if (tableComponent) {
tableComponent.setAttribute('data', JSON.stringify(users));
}
noDataMessage.style.display = 'none'; // Hide the message
} else {
console.log('No data found or invalid response:', data);
noDataMessage.style.display = 'block'; // Show the message
}
})
.catch(error => {
console.error('Error fetching data:', error);
const noDataMessage = document.getElementById('no-data-message');
noDataMessage.style.display = 'block'; // Show the message on error
});
});
</script>
@endsection @endsection

View File

@ -11,25 +11,15 @@ Route::get('/', function () {
return redirect()->route('login'); return redirect()->route('login');
}); });
// Show login form
Route::get('/login', [AuthController::class, 'showLoginForm'])->name('login'); Route::get('/login', [AuthController::class, 'showLoginForm'])->name('login');
// Handle login form submission
Route::post('/login', [AuthController::class, 'login'])->name('login'); Route::post('/login', [AuthController::class, 'login'])->name('login');
// Show change password form
Route::get('/change-password', [AuthController::class, 'showChangePasswordForm'])->name('password.change.form'); Route::get('/change-password', [AuthController::class, 'showChangePasswordForm'])->name('password.change.form');
// Handle change password form submission
Route::post('/change-password', [AuthController::class, 'changePassword'])->name('password.change'); Route::post('/change-password', [AuthController::class, 'changePassword'])->name('password.change');
// Redirect to my-profile (adjust as needed)
Route::get('/my-profile', [AuthController::class, 'showMyProfile'])->name('my-profile')->middleware('auth'); Route::get('/my-profile', [AuthController::class, 'showMyProfile'])->name('my-profile')->middleware('auth');
// Handle logout
Route::post('/logout', [AuthController::class, 'logout'])->name('logout'); Route::post('/logout', [AuthController::class, 'logout'])->name('logout');
Route::get('/dashboard', function () { Route::get('/dashboard', function () {
return view('dashboard'); return view('dashboard');
}); });