Spaces:
Running
Running
File size: 8,095 Bytes
6683b00 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | <!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin - Gerenciar Projetos</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<style>
.glass-effect {
background: rgba(74, 47, 144, 0.15);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.gradient-bg {
background: linear-gradient(135deg, #4a2f90 0%, #1a1a40 100%);
}
</style>
</head>
<body class="min-h-screen gradient-bg text-white font-sans">
<!-- Check if admin is logged in -->
<div id="loginCheck" class="hidden"></div>
<nav class="glass-effect rounded-full mx-4 mt-4 p-3 mb-8">
<div class="container mx-auto flex justify-between items-center">
<div class="flex items-center">
<i data-feather="settings" class="text-purple-400 mr-2"></i>
<span class="text-xl font-bold">Admin - Gerenciar Projetos</span>
</div>
<div class="flex space-x-4">
<a href="projetos.html" class="hover:text-purple-300 transition-colors">Ver Projetos</a>
<a href="index.html" class="hover:text-purple-300 transition-colors">Voltar ao Site</a>
<button onclick="logout()" class="bg-red-600 hover:bg-red-700 px-4 py-2 rounded-full transition-colors">
Sair
</button>
</div>
</div>
</nav>
<main class="container mx-auto px-4">
<div class="glass-effect rounded-2xl p-8 mb-8">
<h2 class="text-3xl font-bold mb-6">Adicionar Novo Projeto</h2>
<form id="addProjectForm" class="grid md:grid-cols-2 gap-6">
<div>
<label class="block mb-2 font-semibold">Título do Projeto</label>
<input type="text" id="projectTitle" required class="w-full p-3 rounded-lg bg-purple-800/30 border border-purple-600">
</div>
<div>
<label class="block mb-2 font-semibold">Categoria</label>
<select id="projectCategory" required class="w-full p-3 rounded-lg bg-purple-800/30 border border-purple-600">
<option value="">Selecione a Categoria</option>
<option value="Website">Website</option>
<option value="Aplicativo">Aplicativo</option>
<option value="Cardápio">Cardápio Digital</option>
<option value="Sistema">Sistema Personalizado</option>
<option value="E-commerce">E-commerce</option>
<option value="API">API</option>
</select>
</div>
<div class="md:col-span-2">
<label class="block mb-2 font-semibold">Descrição</label>
<textarea id="projectDescription" required rows="3" class="w-full p-3 rounded-lg bg-purple-800/30 border border-purple-600"></textarea>
</div>
<div>
<label class="block mb-2 font-semibold">URL da Imagem</label>
<input type="url" id="projectImage" required class="w-full p-3 rounded-lg bg-purple-800/30 border border-purple-600" placeholder="http://static.photos/technology/640x360/1">
</div>
<div>
<label class="block mb-2 font-semibold">Tecnologias (separadas por vírgula)</label>
<input type="text" id="projectTechnologies" required class="w-full p-3 rounded-lg bg-purple-800/30 border border-purple-600" placeholder="React, Node.js, MongoDB">
</div>
<div class="md:col-span-2">
<button type="submit" class="w-full bg-purple-600 hover:bg-purple-700 py-3 rounded-lg font-semibold">
Adicionar Projeto
</button>
</div>
</form>
</div>
<div class="glass-effect rounded-2xl p-8">
<h2 class="text-3xl font-bold mb-6">Projetos Existentes</h2>
<div id="projectsList" class="space-y-4">
<!-- Projects will be listed here -->
<div class="text-center text-purple-300">Carregando projetos...</div>
</div>
</div>
</main>
<script>
// Check if admin is logged in
function checkAdminLogin() {
const isLoggedIn = localStorage.getItem('adminLoggedIn') === 'true';
if (!isLoggedIn) {
alert('Acesso não autorizado. Redirecionando...');
window.location.href = 'index.html';
}
}
// Logout function
function logout() {
localStorage.removeItem('adminLoggedIn');
window.location.href = 'index.html';
}
// Load existing projects
function loadProjects() {
const projectsList = document.getElementById('projectsList');
const projects = JSON.parse(localStorage.getItem('projects')) || [];
if (projects.length === 0) {
projectsList.innerHTML = '<div class="text-center text-purple-300">Nenhum projeto cadastrado ainda.</div>';
return;
}
projectsList.innerHTML = '';
projects.forEach((project, index) => {
projectsList.innerHTML += `
<div class="glass-effect rounded-xl p-4 flex justify-between items-center">
<div>
<h3 class="font-semibold">${project.title}</h3>
<span class="text-sm text-purple-300">${project.category}</span>
</div>
<button onclick="deleteProject(${index})" class="bg-red-600 hover:bg-red-700 px-3 py-1 rounded transition-colors">
<i data-feather="trash-2" class="w-4 h-4"></i>
</button>
</div>
`;
});
feather.replace();
}
// Add new project
function addProject(event) {
event.preventDefault();
const newProject = {
title: document.getElementById('projectTitle').value,
category: document.getElementById('projectCategory').value,
description: document.getElementById('projectDescription').value,
image: document.getElementById('projectImage').value,
technologies: document.getElementById('projectTechnologies').value.split(',').map(tech => tech.trim())
};
const projects = JSON.parse(localStorage.getItem('projects')) || [];
projects.push(newProject);
localStorage.setItem('projects', JSON.stringify(projects));
// Reset form
document.getElementById('addProjectForm').reset();
// Reload projects list
loadProjects();
alert('Projeto adicionado com sucesso!');
}
// Delete project
function deleteProject(index) {
if (confirm('Tem certeza que deseja excluir este projeto?')) {
const projects = JSON.parse(localStorage.getItem('projects')) || [];
projects.splice(index, 1);
localStorage.setItem('projects', JSON.stringify(projects));
loadProjects();
}
}
// Initialize
document.addEventListener('DOMContentLoaded', function() {
checkAdminLogin();
feather.replace();
loadProjects();
document.getElementById('addProjectForm').addEventListener('submit', addProject);
});
</script>
</body>
</html> |