Ajustes Toast

This commit is contained in:
Halbe Bruno
2025-12-06 08:47:48 -03:00
parent 81dd696d0b
commit 77ae5965c1
13 changed files with 139 additions and 133 deletions

View File

@@ -9,6 +9,11 @@ class AdminProfileController
{
public function index()
{
if (!isset($_SESSION['user_id'])) {
View::redirect('/login');
return;
}
$userId = $_SESSION['user_id'];
$conn = Database::getInstance()->getConnection();
@@ -30,6 +35,11 @@ class AdminProfileController
public function update()
{
if (!isset($_SESSION['user_id'])) {
View::redirect('/login');
return;
}
$userId = $_SESSION['user_id'];
$name = $_POST['name'] ?? '';
$email = $_POST['email'] ?? '';
@@ -88,6 +98,11 @@ class AdminProfileController
public function updatePassword()
{
if (!isset($_SESSION['user_id'])) {
View::redirect('/login');
return;
}
$userId = $_SESSION['user_id'];
$currentPassword = $_POST['current_password'] ?? '';
$newPassword = $_POST['new_password'] ?? '';

34
debug_time.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
require_once __DIR__ . '/vendor/autoload.php';
date_default_timezone_set('America/Sao_Paulo');
use App\Config\Database;
$conn = Database::getInstance()->getConnection();
echo "PHP Time: " . date('Y-m-d H:i:s') . " (" . date_default_timezone_get() . ")\n";
echo "PHP Timestamp: " . time() . "\n";
$stmt = $conn->query("SELECT NOW() as db_time, @@global.time_zone as global_tz, @@session.time_zone as session_tz");
$row = $stmt->fetch(PDO::FETCH_ASSOC);
echo "DB Time: " . $row['db_time'] . "\n";
echo "DB Global TZ: " . $row['global_tz'] . "\n";
echo "DB Session TZ: " . $row['session_tz'] . "\n";
echo "\n--- Recent API Logs ---\n";
$stmtLogs = $conn->query("SELECT * FROM api_logs ORDER BY id DESC LIMIT 5");
$logs = $stmtLogs->fetchAll(PDO::FETCH_ASSOC);
print_r($logs);
echo "\n--- Server Status ---\n";
$stmtServers = $conn->query("SELECT id, name, last_seen FROM servers");
$servers = $stmtServers->fetchAll(PDO::FETCH_ASSOC);
foreach ($servers as $server) {
echo "Server: {$server['name']}, Last Seen: {$server['last_seen']}\n";
$lastSeen = !empty($server['last_seen']) ? strtotime($server['last_seen']) : 0;
$diff = time() - $lastSeen;
echo "Diff: $diff seconds\n";
echo "Is Online (< 300): " . ($diff < 300 ? 'Yes' : 'No') . "\n";
}

View File

@@ -2,6 +2,8 @@
require_once __DIR__ . '/../vendor/autoload.php';
date_default_timezone_set('America/Sao_Paulo');
session_start();
use App\Core\Router;

View File

@@ -1,12 +1,7 @@
<div class="max-w-3xl mx-auto bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<h3 class="text-lg font-semibold text-gray-800 mb-6">Nova Ordem Judicial</h3>
<?php if (isset($_SESSION['flash_error'])): ?>
<div class="bg-red-50 border-l-4 border-red-500 p-4 mb-6">
<p class="text-sm text-red-700"><?= $_SESSION['flash_error'] ?></p>
</div>
<?php unset($_SESSION['flash_error']); ?>
<?php endif; ?>
<!-- Quill Styles -->
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">

View File

@@ -10,12 +10,7 @@
</a>
</div>
<?php if (isset($_SESSION['flash_success'])): ?>
<div class="bg-green-50 border-l-4 border-green-500 p-4 m-6">
<p class="text-sm text-green-700"><?= $_SESSION['flash_success'] ?></p>
</div>
<?php unset($_SESSION['flash_success']); ?>
<?php endif; ?>
<div class="overflow-x-auto">
<table class="w-full">

View File

@@ -2,12 +2,7 @@
<h3 class="text-lg font-semibold text-gray-800 mb-6"><?= isset($server) ? 'Editar Servidor' : 'Novo Servidor' ?>
</h3>
<?php if (isset($_SESSION['flash_error'])): ?>
<div class="bg-red-50 text-red-700 p-4 rounded-lg mb-6">
<?= $_SESSION['flash_error'];
unset($_SESSION['flash_error']); ?>
</div>
<?php endif; ?>
<form action="<?= isset($server) ? '/admin/servers/update/' . $server['id'] : '/admin/servers/store' ?>"
method="POST">
@@ -67,7 +62,7 @@
<input type="text" value="<?= $server['serial_key'] ?>" readonly
class="w-full px-4 py-2 bg-gray-50 border border-gray-300 rounded-l-lg text-gray-500 font-mono text-sm">
<button type="button"
onclick="navigator.clipboard.writeText('<?= $server['serial_key'] ?>')"
onclick="navigator.clipboard.writeText('<?= $server['serial_key'] ?>'); window.notify('success', 'Sucesso', 'Key copiada!');"
class="px-3 py-2 bg-gray-100 border border-l-0 border-gray-300 rounded-r-lg hover:bg-gray-200 text-gray-600">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"

View File

@@ -46,7 +46,7 @@
<div class="flex items-center space-x-2">
<span><?= substr($server['serial_key'], 0, 8) ?>...</span>
<button
onclick="navigator.clipboard.writeText('<?= $server['serial_key'] ?>'); alert('Key copiada!');"
onclick="navigator.clipboard.writeText('<?= $server['serial_key'] ?>'); window.notify('success', 'Sucesso', 'Key copiada!');"
class="text-primary-600 hover:text-primary-800" title="Copiar Serial Completo">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"

View File

@@ -84,46 +84,7 @@
</div>
</div>
<!-- Notification Toast -->
<div x-show="notification.show" x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0 transform translate-y-2"
x-transition:enter-end="opacity-100 transform translate-y-0"
x-transition:leave="transition ease-in duration-200"
x-transition:leave-start="opacity-100 transform translate-y-0"
x-transition:leave-end="opacity-0 transform translate-y-2"
class="fixed bottom-4 right-4 z-50 max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden">
<div class="p-4">
<div class="flex items-start">
<div class="flex-shrink-0">
<svg x-show="notification.type === 'success'" class="h-6 w-6 text-green-400" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<svg x-show="notification.type === 'error'" class="h-6 w-6 text-red-400" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</div>
<div class="ml-3 w-0 flex-1 pt-0.5">
<p class="text-sm font-medium text-gray-900" x-text="notification.title"></p>
<p class="mt-1 text-sm text-gray-500" x-text="notification.message"></p>
</div>
<div class="ml-4 flex-shrink-0 flex">
<button @click="notification.show = false"
class="bg-white rounded-md inline-flex text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
<span class="sr-only">Fechar</span>
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd" />
</svg>
</button>
</div>
</div>
</div>
</div>
</div>
<script>
@@ -131,12 +92,6 @@
Alpine.data('settings', () => ({
activeTab: 'interactions',
testing: false,
notification: {
show: false,
type: 'success',
title: '',
message: ''
},
testIntegration() {
this.testing = true;
@@ -165,28 +120,22 @@
})
.then(response => response.json())
.then(data => {
this.showNotification(
data.success ? 'success' : 'error',
data.success ? 'Sucesso' : 'Erro',
data.message
);
this.$dispatch('notify', {
type: data.success ? 'success' : 'error',
title: data.success ? 'Sucesso' : 'Erro',
message: data.message
});
})
.catch(error => {
this.showNotification('error', 'Erro', 'Falha na requisição.');
this.$dispatch('notify', {
type: 'error',
title: 'Erro',
message: 'Falha na requisição.'
});
})
.finally(() => {
this.testing = false;
});
},
showNotification(type, title, message) {
this.notification.type = type;
this.notification.title = title;
this.notification.message = message;
this.notification.show = true;
setTimeout(() => {
this.notification.show = false;
}, 5000);
}
}))
})

View File

@@ -33,19 +33,7 @@
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
<h3 class="text-lg font-semibold text-gray-800 mb-4">Alterar Senha</h3>
<?php if (isset($_SESSION['flash_error'])): ?>
<div class="bg-red-50 text-red-700 p-3 rounded-lg mb-4 text-sm">
<?= $_SESSION['flash_error'];
unset($_SESSION['flash_error']); ?>
</div>
<?php endif; ?>
<?php if (isset($_SESSION['flash_success'])): ?>
<div class="bg-green-50 text-green-700 p-3 rounded-lg mb-4 text-sm">
<?= $_SESSION['flash_success'];
unset($_SESSION['flash_success']); ?>
</div>
<?php endif; ?>
<form action="/client/profile/password" method="POST">
<div class="space-y-4">

View File

@@ -33,7 +33,8 @@
<td class="px-6 py-4 text-sm text-gray-400 font-mono text-xs">
<div class="flex items-center space-x-2">
<span><?= substr($server['serial_key'], 0, 8) ?>...</span>
<button onclick="navigator.clipboard.writeText('<?= $server['serial_key'] ?>')"
<button
onclick="navigator.clipboard.writeText('<?= $server['serial_key'] ?>'); window.notify('success', 'Sucesso', 'Key copiada!');"
class="text-primary-600 hover:text-primary-800" title="Copiar Serial Completo">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"

View File

@@ -76,6 +76,17 @@
<p class="px-4 text-xs font-semibold text-gray-400 uppercase tracking-wider">Gestão</p>
</div>
<a href="/admin/orders"
class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-primary-50 hover:text-primary-700 transition-colors group <?= (strpos($_SERVER['REQUEST_URI'], '/admin/orders') !== false) ? 'bg-primary-50 text-primary-700' : '' ?>">
<svg class="w-5 h-5 mr-3 text-gray-400 group-hover:text-primary-500" fill="none"
stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z">
</path>
</svg>
Ordens Judiciais
</a>
<a href="/admin/clients"
class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-primary-50 hover:text-primary-700 transition-colors group <?= (strpos($_SERVER['REQUEST_URI'], '/admin/clients') !== false) ? 'bg-primary-50 text-primary-700' : '' ?>">
<svg class="w-5 h-5 mr-3 text-gray-400 group-hover:text-primary-500" fill="none"
@@ -98,17 +109,6 @@
Servidores
</a>
<a href="/admin/orders"
class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-primary-50 hover:text-primary-700 transition-colors group <?= (strpos($_SERVER['REQUEST_URI'], '/admin/orders') !== false) ? 'bg-primary-50 text-primary-700' : '' ?>">
<svg class="w-5 h-5 mr-3 text-gray-400 group-hover:text-primary-500" fill="none"
stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z">
</path>
</svg>
Ordens Judiciais
</a>
<a href="/admin/logs"
class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-primary-50 hover:text-primary-700 transition-colors group <?= (strpos($_SERVER['REQUEST_URI'], '/admin/logs') !== false) ? 'bg-primary-50 text-primary-700' : '' ?>">
<svg class="w-5 h-5 mr-3 text-gray-400 group-hover:text-primary-500" fill="none"
@@ -184,21 +184,7 @@
<!-- Scrollable Content -->
<main class="flex-1 overflow-x-hidden overflow-y-auto bg-gray-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<?php if (isset($_SESSION['flash_success'])): ?>
<div class="mb-4 bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative"
role="alert">
<span class="block sm:inline"><?= $_SESSION['flash_success'] ?></span>
<?php unset($_SESSION['flash_success']); ?>
</div>
<?php endif; ?>
<?php if (isset($_SESSION['flash_error'])): ?>
<div class="mb-4 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative"
role="alert">
<span class="block sm:inline"><?= $_SESSION['flash_error'] ?></span>
<?php unset($_SESSION['flash_error']); ?>
</div>
<?php endif; ?>
<?php if (isset($content))
include $content; ?>
@@ -210,6 +196,8 @@
<div x-show="sidebarOpen" @click="sidebarOpen = false"
class="fixed inset-0 z-30 bg-black bg-opacity-50 md:hidden" x-transition.opacity></div>
</div>
<?php include __DIR__ . '/../partials/toast.php'; ?>
</body>
</html>

View File

@@ -138,20 +138,7 @@
</header>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<?php if (isset($_SESSION['flash_success'])): ?>
<div class="mb-4 bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative"
role="alert">
<span class="block sm:inline"><?= $_SESSION['flash_success'] ?></span>
<?php unset($_SESSION['flash_success']); ?>
</div>
<?php endif; ?>
<?php if (isset($_SESSION['flash_error'])): ?>
<div class="mb-4 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
<span class="block sm:inline"><?= $_SESSION['flash_error'] ?></span>
<?php unset($_SESSION['flash_error']); ?>
</div>
<?php endif; ?>
<?php if (isset($content))
include $content; ?>
@@ -162,6 +149,8 @@
<div x-show="sidebarOpen" @click="sidebarOpen = false"
class="fixed inset-0 z-30 bg-black bg-opacity-50 md:hidden" x-transition.opacity></div>
</div>
<?php include __DIR__ . '/../partials/toast.php'; ?>
</body>
</html>

View File

@@ -0,0 +1,55 @@
<div x-data='{
show: <?= (isset($_SESSION['flash_success']) || isset($_SESSION['flash_error'])) ? 'true' : 'false' ?>,
type: <?= json_encode(isset($_SESSION['flash_error']) ? 'error' : 'success') ?>,
title: <?= json_encode(isset($_SESSION['flash_error']) ? 'Erro' : 'Sucesso') ?>,
message: <?= json_encode($_SESSION['flash_success'] ?? $_SESSION['flash_error'] ?? '') ?>
}' @notify.window="
show = true;
type = $event.detail.type;
title = $event.detail.title;
message = $event.detail.message;
setTimeout(() => show = false, 5000)
" x-init="
if (show) setTimeout(() => show = false, 5000);
window.notify = (type, title, message) => {
$dispatch('notify', { type, title, message });
}
" class="fixed bottom-4 right-4 z-50 max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden"
x-show="show" x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="opacity-0 transform translate-y-2"
x-transition:enter-end="opacity-100 transform translate-y-0" x-transition:leave="transition ease-in duration-200"
x-transition:leave-start="opacity-100 transform translate-y-0"
x-transition:leave-end="opacity-0 transform translate-y-2" style="display: none;">
<div class="p-4">
<div class="flex items-start">
<div class="flex-shrink-0">
<svg x-show="type === 'success'" class="h-6 w-6 text-green-400" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<svg x-show="type === 'error'" class="h-6 w-6 text-red-400" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</div>
<div class="ml-3 w-0 flex-1 pt-0.5">
<p class="text-sm font-medium text-gray-900" x-text="title"></p>
<p class="mt-1 text-sm text-gray-500" x-text="message"></p>
</div>
<div class="ml-4 flex-shrink-0 flex">
<button @click="show = false"
class="bg-white rounded-md inline-flex text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500">
<span class="sr-only">Fechar</span>
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd" />
</svg>
</button>
</div>
</div>
</div>
</div>
<?php unset($_SESSION['flash_success'], $_SESSION['flash_error']); ?>