|
3 | 3 | <?php $this->start('active') ?>admin-feeds<?php $this->stop() ?> |
4 | 4 |
|
5 | 5 | <div class="card shadow-sm"> |
6 | | - <div class="card-header d-flex justify-content-between align-items-center"> |
| 6 | + <div class="card-header d-md-flex justify-content-between align-items-center"> |
7 | 7 | <div> |
8 | 8 | <h3 class="fs-5 fw-medium mb-0 mt-1"> |
9 | 9 | <i class="bi bi-grid me-1"></i> |
10 | 10 | Gerenciar Feeds |
11 | 11 | </h3> |
12 | 12 | </div> |
13 | | - <div> |
| 13 | + <div class="pt-2 pb-1 pt-md-0 pb-md-0"> |
14 | 14 | <a href="/admin/feeds/new" class="btn btn-primary d-inline-flex align-items-center"> |
15 | 15 | <i class="bi bi-plus-lg me-1"></i> |
16 | 16 | Adicionar Novo Feed |
|
35 | 35 | <th scope="col" class="small text-uppercase">Tipo</th> |
36 | 36 | <th scope="col" class="small text-uppercase">Idioma</th> |
37 | 37 | <th scope="col" class="small text-uppercase">Status</th> |
38 | | - <th scope="col" class="small text-uppercase">Última Verificação</th> |
39 | | - <th scope="col" class="small text-uppercase">Última Atualização</th> |
| 38 | + <th scope="col" class="small text-uppercase text-truncate">Última Verificação</th> |
| 39 | + <th scope="col" class="small text-uppercase text-truncate">Última Atualização</th> |
40 | 40 | <th scope="col" class="small text-uppercase">Itens</th> |
41 | 41 | <th scope="col"></th> |
42 | 42 | </tr> |
|
79 | 79 | </select> |
80 | 80 | </td> |
81 | 81 | <td class="align-middle small text-secondary"> |
82 | | - <?= $feed['last_checked'] ? date('j M Y H:i', strtotime($feed['last_checked'])) : 'Nunca' ?> |
| 82 | + <?= $feed['last_checked'] ? date('d/m/Y \à\s H:i', strtotime($feed['last_checked'])) : 'Nunca' ?> |
83 | 83 | </td> |
84 | 84 | <td class="align-middle small text-secondary"> |
85 | | - <?= $feed['last_updated'] ? date('j M Y H:i', strtotime($feed['last_updated'])) : 'Nunca' ?> |
| 85 | + <?= $feed['last_updated'] ? date('d/m/Y \à\s H:i', strtotime($feed['last_updated'])) : 'Nunca' ?> |
86 | 86 | </td> |
87 | 87 | <td class="align-middle small text-secondary"> |
88 | 88 | <?= $feed['item_count'] ?? 0 ?> |
89 | 89 | </td> |
90 | 90 | <td class="align-middle text-end"> |
91 | | - <a href="/admin/feeds/<?= $feed['id'] ?>/edit" class="d-inline-block btn btn-sm btn-outline-primary"> |
| 91 | + <div class="text-truncate"> |
| 92 | + <a href="/admin/feeds/<?= $feed['id'] ?>/edit" class="d-inline-block btn btn-sm btn-outline-primary me-2"> |
92 | 93 | <i class="bi bi-pencil"></i> |
93 | | - </a> |
94 | | - <button class="d-inline-block btn btn-sm btn-outline-danger delete-feed" data-feed-id="<?= $feed['id'] ?>"> |
| 94 | + </a><button class="d-inline-block btn btn-sm btn-outline-danger delete-feed" data-feed-id="<?= $feed['id'] ?>"> |
95 | 95 | <i class="bi bi-trash"></i> |
96 | 96 | </button> |
| 97 | + </div> |
97 | 98 | </td> |
98 | 99 | </tr> |
99 | 100 | <?php endforeach; ?> |
|
104 | 105 | <?php endif; ?> |
105 | 106 | </div> |
106 | 107 |
|
107 | | -<!-- Delete Confirmation Modal --> |
108 | 108 | <div class="modal fade" id="delete-modal" tabindex="-1" aria-labelledby="modal-title" aria-hidden="true"> |
109 | 109 | <div class="modal-dialog"> |
110 | 110 | <div class="modal-content"> |
|
115 | 115 | <div class="modal-body"> |
116 | 116 | <div class="d-flex"> |
117 | 117 | <div class="me-3"> |
118 | | - <div class="bg-danger bg-opacity-10 p-2 rounded-circle"> |
119 | | - <i class="bi bi-exclamation-triangle text-danger fs-4"></i> |
120 | | - </div> |
| 118 | + <i class="bi bi-exclamation-triangle text-danger fs-4"></i> |
121 | 119 | </div> |
122 | 120 | <div> |
123 | 121 | <p class="mb-0"> |
|
143 | 141 | <?php $this->start('scripts') ?> |
144 | 142 | <script> |
145 | 143 | document.addEventListener('DOMContentLoaded', function() { |
146 | | - // Modal elements |
147 | 144 | const deleteModal = new bootstrap.Modal(document.getElementById('delete-modal')); |
148 | 145 |
|
149 | | - // Buttons |
150 | 146 | const cancelDeleteButton = document.getElementById('cancel-delete'); |
151 | 147 | const confirmDeleteButton = document.getElementById('confirm-delete'); |
152 | 148 | const deleteFeedButtons = document.querySelectorAll('.delete-feed'); |
153 | 149 | const statusSelects = document.querySelectorAll('.status-select'); |
154 | 150 |
|
155 | | - // Delete feed |
156 | 151 | deleteFeedButtons.forEach(button => { |
157 | 152 | button.addEventListener('click', function() { |
158 | 153 | const feedId = this.dataset.feedId; |
|
161 | 156 | }); |
162 | 157 | }); |
163 | 158 |
|
164 | | - // Confirm delete |
165 | 159 | confirmDeleteButton.addEventListener('click', function() { |
166 | 160 | const feedId = this.dataset.feedId; |
167 | 161 |
|
|
171 | 165 | .then(response => response.json()) |
172 | 166 | .then(data => { |
173 | 167 | if (data.success) { |
174 | | - // Remove the row from the table |
175 | 168 | const row = document.querySelector(`tr[data-feed-id="${feedId}"]`); |
176 | 169 | row.remove(); |
177 | 170 |
|
178 | | - // Hide the modal |
179 | 171 | deleteModal.hide(); |
180 | 172 |
|
181 | | - // If no feeds left, refresh the page to show the empty state |
182 | 173 | if (document.querySelectorAll('tbody tr').length === 0) { |
183 | 174 | window.location.reload(); |
184 | 175 | } |
|
192 | 183 | }); |
193 | 184 | }); |
194 | 185 |
|
195 | | - // Update feed status |
196 | 186 | statusSelects.forEach(select => { |
197 | 187 | select.addEventListener('change', function() { |
198 | 188 | const feedId = this.dataset.feedId; |
|
211 | 201 | .then(response => response.json()) |
212 | 202 | .then(data => { |
213 | 203 | if (data.success) { |
214 | | - // Update the data attribute |
215 | 204 | this.dataset.originalValue = newStatus; |
| 205 | + alert('Status do feed atualizado com sucesso para: ' + newStatus); |
216 | 206 | } else { |
217 | | - // Revert to original value |
218 | 207 | this.value = originalValue; |
219 | 208 | alert('Erro ao atualizar status do feed: ' + data.message); |
220 | 209 | } |
221 | 210 | }) |
222 | 211 | .catch(error => { |
223 | | - // Revert to original value |
224 | 212 | this.value = originalValue; |
225 | 213 | console.error('Error:', error); |
226 | 214 | alert('Ocorreu um erro ao atualizar o status do feed.'); |
|
0 commit comments