Skip to content

Commit

Permalink
Merge pull request #29 from wanderlust-group-project-1/nirmal
Browse files Browse the repository at this point in the history
feat:admin pages
  • Loading branch information
nsavinda authored Oct 27, 2023
2 parents ef93f70 + a807f15 commit 1298a4e
Show file tree
Hide file tree
Showing 12 changed files with 559 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Setup

Rename `example.env` to `.env`

Rename `database/example.env` to `database/.env`


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

class Home {
class Dashboard {
use Controller;

public function index(string $a = '', string $b = '', string $c = ''):void {
$this->view('admin/home');
$this->view('admin/dashboard');
}
}

Expand Down
15 changes: 15 additions & 0 deletions app/controllers/Admin/RentalServices.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

class RentalServices {
use Controller;

public function index(string $a = '', string $b = '', string $c = ''):void {
$this->view('admin/rentalServices');
}

public function item(string $a = '', string $b = '', string $c = ''):void {
$this->view('admin/item');
}}


?>
41 changes: 33 additions & 8 deletions app/core/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ public function loadController(): void {
require "../app/controllers/_404.php";
$this->controller = "_404";
}
$controller = new $this->controller;


if (!empty($URL[2])) {
if (method_exists($controller, $URL[2])) {
// show($URL[2]);
$this->method = $URL[2];
unset($URL[2]);
}
}



} else {
$filename = "../app/controllers/" . ucfirst($URL[0]) . ".php";
if (file_exists($filename)) {
Expand All @@ -67,6 +80,17 @@ public function loadController(): void {
require "../app/controllers/_404.php";
$this->controller = "_404";
}

$controller = new $this->controller;


if (!empty($URL[1])) {
if (method_exists($controller, $URL[1])) {
// show($URL[1]);
$this->method = $URL[1];
unset($URL[1]);
}
}
}

// $filename = "../app/controllers/" . ucfirst($URL[0]) . ".php";
Expand All @@ -81,15 +105,16 @@ public function loadController(): void {

// Run middleware before executing the controller's action

$controller = new $this->controller;
// $controller = new $this->controller;

// Select method
if (!empty($URL[1])) {
if (method_exists($controller, $URL[1])) {
$this->method = $URL[1];
unset($URL[1]);
}
}
// // Select method
// if (!empty($URL[1])) {
// if (method_exists($controller, $URL[1])) {
// // show($URL[1]);
// $this->method = $URL[1];
// unset($URL[1]);
// }
// }
// $this->runMiddleware();
AuthMiddleware::run_middleware($this->controller, $this->method);

Expand Down
12 changes: 12 additions & 0 deletions app/views/admin/dashboard.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
require_once('../app/views/admin/layout/header.php');
require_once('../app/views/admin/layout/sidebar.php');

?>


<?php
require_once('../app/views/admin/layout/footer.php');


?>
Empty file removed app/views/admin/home.view.php
Empty file.
108 changes: 108 additions & 0 deletions app/views/admin/item.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php
require_once('../app/views/admin/layout/header.php');
require_once('../app/views/admin/layout/sidebar.php');

?>

<div class="table-container">
<table class="data-table">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Doe</td>
<td>john@example.com</td>
<td><span class="status accepted">Accepted</span></td>
<td><button class="view-button">View</button></td>
</tr>
<tr>
<td>Jane Smith</td>
<td>jane@example.com</td>
<td><span class="status not-accepted">Not Accepted</span></td>
<td><button class="view-button">View</button></td>
</tr>
<tr>
<td>Bob Johnson</td>
<td>bob@example.com</td>
<td><span class="status waiting">Waiting</span></td>
<td><button class="view-button">View</button></td>
</tr>
<!-- Add more rows as needed -->
</tbody>
</table>
</div>

<!-- Modal -->
<div class="rental-services-modal" id="rental-services-modal">
<div class="modal-content">
<span class="close">&times;</span>
<div class="profile-info">
<img src="<?php echo ROOT_DIR?>/assets/images/dp.jpg" alt="Profile Image" class="profile-image">
<h2 id="profile-name">Sandali </h2>
<p id="profile-email">sandali@gmail.com</p>
<p id="profile-address">Maharagama</p>
<p id="profile-status" class="accepted">Accepted</p>
<div class="profile-links">
<a href="#" id="link-1">Link 1</a>
<a href="#" id="link-2">Link 2</a>
</div>
</div>
</div>
</div>


<script>

// Get the modal
var modal = document.getElementById("rental-services-modal");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// Get all view buttons
var viewButtons = document.querySelectorAll('.view-button');

// Function to handle modal display
function openModal(content) {
// document.getElementById("modal-content").innerHTML = content;
modal.style.display = "block";
}

// Add click event listener to view buttons
viewButtons.forEach(function(button) {
button.addEventListener('click', function() {

var name = this.parentElement.parentElement.querySelector('td:first-child').textContent;
var email = this.parentElement.parentElement.querySelector('td:nth-child(2)').textContent;
openModal("Name: " + name + "<br>Email: " + email);
});
});

// Close the modal when the close button is clicked
span.onclick = function() {
modal.style.display = "none";
}

// Close the modal if the user clicks outside of it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}

</script>




<?php
require_once('../app/views/admin/layout/footer.php');


?>
2 changes: 2 additions & 0 deletions app/views/admin/layout/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<head>
<title>Wanderlust</title>
<link rel="stylesheet" type="text/css" href="<?=ROOT_DIR ?>/assets/css/style.css">
<link rel="stylesheet" type="text/css" href="<?=ROOT_DIR ?>/assets/css/admin-style.css">

</head>
<body>

69 changes: 69 additions & 0 deletions app/views/admin/layout/sidebar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<nav class="sidebar sidebar-offcanvas" id="sidebar">
<ul class="nav">
<li class="nav-item">
<a class="nav-link" href="index.html">
<i class="ti-shield menu-icon"></i>
<span class="menu-title">Dashboard</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="rentalServices" aria-expanded="false" aria-controls="ui-basic">
<i class="ti-palette menu-icon"></i>
<span class="menu-title">Rental Services</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="ui-basic">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/buttons.html">Buttons</a></li>
<li class="nav-item"> <a class="nav-link" href="pages/ui-features/typography.html">Typography</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="rentalServices/1/Items">
<i class="ti-layout-list-post menu-icon"></i>
<span class="menu-title">Items</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="pages/charts/chartjs.html">
<i class="ti-pie-chart menu-icon"></i>
<span class="menu-title">Charts</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="pages/tables/basic-table.html">
<i class="ti-view-list-alt menu-icon"></i>
<span class="menu-title">Tables</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="pages/icons/themify.html">
<i class="ti-star menu-icon"></i>
<span class="menu-title">Icons</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="collapse" href="#auth" aria-expanded="false" aria-controls="auth">
<i class="ti-user menu-icon"></i>
<span class="menu-title">User Pages</span>
<i class="menu-arrow"></i>
</a>
<div class="collapse" id="auth">
<ul class="nav flex-column sub-menu">
<li class="nav-item"> <a class="nav-link" href="pages/samples/login.html"> Login </a></li>
<li class="nav-item"> <a class="nav-link" href="pages/samples/login-2.html"> Login 2 </a></li>
<li class="nav-item"> <a class="nav-link" href="pages/samples/register.html"> Register </a></li>
<li class="nav-item"> <a class="nav-link" href="pages/samples/register-2.html"> Register 2 </a></li>
<li class="nav-item"> <a class="nav-link" href="pages/samples/lock-screen.html"> Lockscreen </a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="documentation/documentation.html">
<i class="ti-write menu-icon"></i>
<span class="menu-title">Documentation</span>
</a>
</li>
</ul>
</nav>
Loading

0 comments on commit 1298a4e

Please sign in to comment.