fix: remove duplicate showToast declaration causing JavaScript error
Root cause: admin_pricing.html declared 'const showToast' while base.html already defined 'function showToast', causing SyntaxError that prevented all JavaScript from executing on the admin pricing page. Changes: - Removed duplicate showToast declaration from admin_pricing.html (lines 206-210) - Removed debug logging added in previous commit - Kept immediate function calls in base.html to ensure early initialization This fixes the issue where username and "Администратор цен" link disappeared when navigating to /admin/pricing. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -203,12 +203,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Fallback showToast function for cases where base.html isn't loaded properly
|
|
||||||
const showToast = window.showToast || function(msg, type) {
|
|
||||||
// Simple fallback: just alert the message
|
|
||||||
alert(`${type ? type + ': ' : ''}${msg}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
let currentTab = 'alerts';
|
let currentTab = 'alerts';
|
||||||
let currentPage = 1;
|
let currentPage = 1;
|
||||||
let totalPages = 1;
|
let totalPages = 1;
|
||||||
|
|||||||
@@ -159,21 +159,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function checkDbStatus() {
|
async function checkDbStatus() {
|
||||||
console.log('[DEBUG] checkDbStatus called');
|
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/db-status');
|
const resp = await fetch('/api/db-status');
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
console.log('[DEBUG] checkDbStatus response:', data);
|
|
||||||
const statusEl = document.getElementById('db-status');
|
const statusEl = document.getElementById('db-status');
|
||||||
const countsEl = document.getElementById('db-counts');
|
const countsEl = document.getElementById('db-counts');
|
||||||
const userEl = document.getElementById('db-user');
|
const userEl = document.getElementById('db-user');
|
||||||
console.log('[DEBUG] userEl:', userEl);
|
|
||||||
|
|
||||||
if (data.connected) {
|
if (data.connected) {
|
||||||
statusEl.innerHTML = '<span class="text-green-400">БД: подключено</span>';
|
statusEl.innerHTML = '<span class="text-green-400">БД: подключено</span>';
|
||||||
if (data.db_user) {
|
if (data.db_user) {
|
||||||
userEl.innerHTML = '<span class="text-gray-500">@</span>' + data.db_user;
|
userEl.innerHTML = '<span class="text-gray-500">@</span>' + data.db_user;
|
||||||
console.log('[DEBUG] username set to:', data.db_user);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
statusEl.innerHTML = '<span class="text-red-400">БД: ошибка - ' + data.error + '</span>';
|
statusEl.innerHTML = '<span class="text-red-400">БД: ошибка - ' + data.error + '</span>';
|
||||||
@@ -181,27 +177,20 @@
|
|||||||
|
|
||||||
countsEl.textContent = 'lot: ' + data.lot_count + ' | lot_log: ' + data.lot_log_count + ' | metadata: ' + data.metadata_count;
|
countsEl.textContent = 'lot: ' + data.lot_count + ' | lot_log: ' + data.lot_log_count + ' | metadata: ' + data.metadata_count;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error('[DEBUG] checkDbStatus error:', e);
|
|
||||||
document.getElementById('db-status').innerHTML = '<span class="text-red-400">БД: нет связи</span>';
|
document.getElementById('db-status').innerHTML = '<span class="text-red-400">БД: нет связи</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkWritePermission() {
|
async function checkWritePermission() {
|
||||||
console.log('[DEBUG] checkWritePermission called');
|
|
||||||
try {
|
try {
|
||||||
const resp = await fetch('/api/pricelists/can-write');
|
const resp = await fetch('/api/pricelists/can-write');
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
console.log('[DEBUG] checkWritePermission response:', data);
|
|
||||||
if (data.can_write) {
|
if (data.can_write) {
|
||||||
const link = document.getElementById('admin-pricing-link');
|
const link = document.getElementById('admin-pricing-link');
|
||||||
console.log('[DEBUG] admin-pricing-link element:', link);
|
if (link) link.classList.remove('hidden');
|
||||||
if (link) {
|
|
||||||
link.classList.remove('hidden');
|
|
||||||
console.log('[DEBUG] admin-pricing-link shown');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error('[DEBUG] checkWritePermission error:', e);
|
console.error('Failed to check write permission:', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user