Skip to content

Commit

Permalink
fix: crud statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraFerrando committed Dec 18, 2024
1 parent 6728982 commit 4ca3f86
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

# * @Projecte-UrbanTree/coordinacio @Projecte-UrbanTree/correctors-ortografics
# * @Projecte-UrbanTree/coordinacio @Projecte-UrbanTree/correctors-ortoStats
* @Projecte-UrbanTree/alumnat
/.git* @Projecte-UrbanTree/coordinacio @Projecte-UrbanTree/professorat
/.vscode @Projecte-UrbanTree/coordinacio @Projecte-UrbanTree/testers-de-qualitat

/public/assets/ @Projecte-UrbanTree/coordinacio @Projecte-UrbanTree/especialistes-multimedia
*.md @Projecte-UrbanTree/coordinacio @Projecte-UrbanTree/correctors-ortografics
*.md @Projecte-UrbanTree/coordinacio @Projecte-UrbanTree/correctors-ortoStats
30 changes: 0 additions & 30 deletions app/src/app/Controllers/Admin/EstadistiquesController.php

This file was deleted.

30 changes: 30 additions & 0 deletions app/src/app/Controllers/Admin/StatsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Controllers\Admin;

use App\Core\View;
use App\Models\Contract;
use App\Models\TreeType;

class StatsController
{
public function index($queryParams = [])

Check warning on line 11 in app/src/app/Controllers/Admin/StatsController.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Controllers/Admin/StatsController.php#L11

Added line #L11 was not covered by tests
{
// Obtenim les dades del model correcte
$totalContracts = Contract::count();
$contractsName = Contract::findAll();

Check warning on line 15 in app/src/app/Controllers/Admin/StatsController.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Controllers/Admin/StatsController.php#L14-L15

Added lines #L14 - L15 were not covered by tests


// Comprova si $Stats és null i assegura't que sigui un array



// Renderitzem la vista amb les dades
View::render([
'view' => 'Admin/Stats',
'title' => 'Stats',
'layout' => 'Admin/AdminLayout',
'data' => ['totalContracts' => $totalContracts, 'nomsContractes' => $contractsName],
]);

Check warning on line 28 in app/src/app/Controllers/Admin/StatsController.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Controllers/Admin/StatsController.php#L23-L28

Added lines #L23 - L28 were not covered by tests
}
}
13 changes: 3 additions & 10 deletions app/src/app/Layouts/Admin/AdminLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,6 @@ class="link-primary <?= ($currentPath == '/admin/task-types') ? 'active' : ''; ?
</a>
</div>

<div class="submenu-item">
<a href="/admin/stats"
class="link-primary <?= ($currentPath == '/admin/stats') ? 'active' : ''; ?>">
<i class="fas fa-chart-column md:block"></i>
<span class="text-sm font-medium whitespace-nowrap">Estadísticas</span>
</a>
</div>

<div class="submenu-item">
<a href="/admin/users" class="link-primary <?= ($currentPath == '/admin/users') ? 'active' : ''; ?>">
<i class="fas fa-users md:block"></i>
Expand All @@ -146,8 +138,9 @@ class="link-primary <?= ($currentPath == '/admin/stats') ? 'active' : ''; ?>">
</div>

<div class="submenu-item">
<a href="/admin/stats" class="link-primary <?= ($currentPath == '/admin/stats') ? 'active' : ''; ?>">
<i class="fas fa-chart-bar md:block"></i>
<a href="/admin/stats"
class="link-primary <?= ($currentPath == '/admin/stats') ? 'active' : ''; ?>">

Check warning on line 142 in app/src/app/Layouts/Admin/AdminLayout.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Layouts/Admin/AdminLayout.php#L142

Added line #L142 was not covered by tests
<i class="fas fa-chart-column md:block"></i>
<span class="text-sm font-medium whitespace-nowrap">Estadísticas</span>
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
Seleccionar Contrato
</button>
<div id="dropdown-menu" class="absolute bg-white border rounded shadow-lg mt-2 w-48 hidden">
<?php
<?php

Check warning on line 27 in app/src/app/Views/Admin/Stats.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Stats.php#L2-L27

Added lines #L2 - L27 were not covered by tests
// Generem els items del desplegable amb PHP
foreach ($nomsContractes as $contracte):
foreach ($nomsContractes as $contracte):

Check warning on line 29 in app/src/app/Views/Admin/Stats.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Stats.php#L29

Added line #L29 was not covered by tests
?>
<div class="dropdown-item text-left px-4 py-2 w-full hover:bg-gray-100 cursor-pointer">
<?php echo htmlspecialchars($contracte->name); ?>
Expand All @@ -42,16 +42,16 @@
<div class="col" id="app3"></div>
</div>
</div>

Check warning on line 44 in app/src/app/Views/Admin/Stats.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Stats.php#L38-L44

Added lines #L38 - L44 were not covered by tests
</body>

<!-- Incloure el fitxer JavaScript -->

Check warning on line 46 in app/src/app/Views/Admin/Stats.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Stats.php#L46

Added line #L46 was not covered by tests
<script src="app/src/public/assets/js/app.js"></script>

<script>
// Inicialitzar el codi de dropdown quan es carregui la pàgina
document.addEventListener('DOMContentLoaded', function () {
initDropdown('menuButton', 'dropdown-menu', '.dropdown-item');
});
</script>

Check warning on line 53 in app/src/app/Views/Admin/Stats.php

View check run for this annotation

Codecov / codecov/patch

app/src/app/Views/Admin/Stats.php#L48-L53

Added lines #L48 - L53 were not covered by tests
</body>

</html>
<script>
const menuButton = document.getElementById('menuButton');
Expand All @@ -69,11 +69,11 @@ function toggleDropdown() {
<script>
window.Promise ||
document.write(
'<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
'<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
);
window.Promise ||
document.write(
'<script src="https://cdn.jsdelivr.net/npm/[email protected]/classList.min.js"><\/script>'
'<script src="https://cdn.jsdelivr.net/npm/[email protected]/classList.min.js"><\/script>'
);
window.Promise ||
document.write(
Expand Down
6 changes: 3 additions & 3 deletions app/src/routes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use App\Controllers\Admin\TreeTypeController;
use App\Controllers\Admin\UserController;
use App\Controllers\Admin\WorkOrderController;
use App\Controllers\Admin\EstadistiquesController;
use App\Controllers\Admin\StatsController;
use App\Controllers\Admin\ZoneController;
use App\Middlewares\AdminMiddleware;

Expand Down Expand Up @@ -210,8 +210,8 @@
],

// Estadistiques
'/admin/grafics' => [
'controller' => EstadistiquesController::class,
'/admin/stats' => [
'controller' => StatsController::class,
'method' => 'index',
'middlewares' => [AdminMiddleware::class],
],
Expand Down

0 comments on commit 4ca3f86

Please sign in to comment.