fix: avoid null error
All checks were successful
Deploy MinIO Explorer / deploy (push) Successful in 44s
All checks were successful
Deploy MinIO Explorer / deploy (push) Successful in 44s
This commit is contained in:
71
script.js
71
script.js
@@ -21,14 +21,24 @@ function initializeApp() {
|
|||||||
|
|
||||||
function setupEventListeners() {
|
function setupEventListeners() {
|
||||||
// Formulaire de développement
|
// Formulaire de développement
|
||||||
document.getElementById('url-form').addEventListener('submit', handleUrlFormSubmit);
|
const urlForm = document.getElementById('url-form');
|
||||||
|
if (urlForm) {
|
||||||
|
urlForm.addEventListener('submit', handleUrlFormSubmit);
|
||||||
|
}
|
||||||
|
|
||||||
// Gestion de la navigation arrière/avant du navigateur
|
// Gestion de la navigation arrière/avant du navigateur
|
||||||
window.addEventListener('popstate', handlePopState);
|
window.addEventListener('popstate', handlePopState);
|
||||||
|
|
||||||
// Gestionnaires pour la prévisualisation
|
// Gestionnaires pour la prévisualisation
|
||||||
document.getElementById('close-preview').addEventListener('click', hidePreview);
|
const closePreview = document.getElementById('close-preview');
|
||||||
document.getElementById('download-file').addEventListener('click', downloadCurrentFile);
|
if (closePreview) {
|
||||||
|
closePreview.addEventListener('click', hidePreview);
|
||||||
|
}
|
||||||
|
|
||||||
|
const downloadFile = document.getElementById('download-file');
|
||||||
|
if (downloadFile) {
|
||||||
|
downloadFile.addEventListener('click', downloadCurrentFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePopState(event) {
|
function handlePopState(event) {
|
||||||
@@ -67,6 +77,8 @@ function handleUrlFormSubmit(event) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const urlInput = document.getElementById('minio-url');
|
const urlInput = document.getElementById('minio-url');
|
||||||
|
if (!urlInput) return;
|
||||||
|
|
||||||
const minioUrl = urlInput.value.trim();
|
const minioUrl = urlInput.value.trim();
|
||||||
|
|
||||||
if (!minioUrl) {
|
if (!minioUrl) {
|
||||||
@@ -112,7 +124,9 @@ function updateConfigDisplay() {
|
|||||||
|
|
||||||
function showDevForm() {
|
function showDevForm() {
|
||||||
const devForm = document.getElementById('dev-form');
|
const devForm = document.getElementById('dev-form');
|
||||||
devForm.style.display = 'block';
|
if (devForm) {
|
||||||
|
devForm.style.display = 'block';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -120,31 +134,38 @@ function showError(message) {
|
|||||||
const errorSection = document.getElementById('error-section');
|
const errorSection = document.getElementById('error-section');
|
||||||
const errorMessage = document.getElementById('error-message');
|
const errorMessage = document.getElementById('error-message');
|
||||||
|
|
||||||
errorMessage.textContent = message;
|
if (errorMessage) {
|
||||||
errorSection.style.display = 'block';
|
errorMessage.textContent = message;
|
||||||
|
}
|
||||||
|
|
||||||
// Masquer l'erreur après 5 secondes
|
if (errorSection) {
|
||||||
setTimeout(() => {
|
errorSection.style.display = 'block';
|
||||||
errorSection.style.display = 'none';
|
|
||||||
}, 5000);
|
// Masquer l'erreur après 5 secondes
|
||||||
|
setTimeout(() => {
|
||||||
|
errorSection.style.display = 'none';
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showLoading(show = true) {
|
function showLoading(show = true) {
|
||||||
const loading = document.getElementById('loading');
|
const loading = document.getElementById('loading');
|
||||||
const table = document.getElementById('files-table');
|
const table = document.getElementById('files-table');
|
||||||
|
|
||||||
if (show) {
|
if (loading) {
|
||||||
loading.style.display = 'block';
|
loading.style.display = show ? 'block' : 'none';
|
||||||
table.style.display = 'none';
|
}
|
||||||
} else {
|
|
||||||
loading.style.display = 'none';
|
if (table) {
|
||||||
table.style.display = 'table';
|
table.style.display = show ? 'none' : 'table';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateCurrentPathDisplay() {
|
function updateCurrentPathDisplay() {
|
||||||
const pathDisplay = document.getElementById('current-path');
|
const pathDisplay = document.getElementById('current-path');
|
||||||
pathDisplay.textContent = '/' + config.currentPath;
|
if (pathDisplay) {
|
||||||
|
pathDisplay.textContent = '/' + config.currentPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadBucketContents(path = '', pushToHistory = true) {
|
async function loadBucketContents(path = '', pushToHistory = true) {
|
||||||
@@ -292,6 +313,8 @@ function parseMinioXML(xmlText) {
|
|||||||
|
|
||||||
function displayContents(contents) {
|
function displayContents(contents) {
|
||||||
const tbody = document.getElementById('files-tbody');
|
const tbody = document.getElementById('files-tbody');
|
||||||
|
if (!tbody) return;
|
||||||
|
|
||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
// Bouton parent directory si on n'est pas à la racine
|
// Bouton parent directory si on n'est pas à la racine
|
||||||
@@ -314,7 +337,10 @@ function displayContents(contents) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Afficher le tableau
|
// Afficher le tableau
|
||||||
document.getElementById('files-table').style.display = 'table';
|
const filesTable = document.getElementById('files-table');
|
||||||
|
if (filesTable) {
|
||||||
|
filesTable.style.display = 'table';
|
||||||
|
}
|
||||||
|
|
||||||
// Chercher et ouvrir automatiquement index.rst s'il existe
|
// Chercher et ouvrir automatiquement index.rst s'il existe
|
||||||
autoOpenIndexRst(contents.files);
|
autoOpenIndexRst(contents.files);
|
||||||
@@ -473,6 +499,11 @@ function showPreview(fileUrl, fileName) {
|
|||||||
const previewTitle = document.getElementById('preview-title');
|
const previewTitle = document.getElementById('preview-title');
|
||||||
const previewContent = document.getElementById('preview-content');
|
const previewContent = document.getElementById('preview-content');
|
||||||
|
|
||||||
|
if (!previewSection || !previewTitle || !previewContent) {
|
||||||
|
console.error('Éléments de prévisualisation non trouvés');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
previewTitle.textContent = `Prévisualisation: ${fileName}`;
|
previewTitle.textContent = `Prévisualisation: ${fileName}`;
|
||||||
previewContent.innerHTML = '<div style="text-align: center; padding: 20px;">Chargement...</div>';
|
previewContent.innerHTML = '<div style="text-align: center; padding: 20px;">Chargement...</div>';
|
||||||
|
|
||||||
@@ -585,7 +616,9 @@ function showUnsupportedPreview(fileName, container) {
|
|||||||
|
|
||||||
function hidePreview() {
|
function hidePreview() {
|
||||||
const previewSection = document.getElementById('preview-section');
|
const previewSection = document.getElementById('preview-section');
|
||||||
previewSection.style.display = 'none';
|
if (previewSection) {
|
||||||
|
previewSection.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
currentPreviewFile = { url: '', name: '' };
|
currentPreviewFile = { url: '', name: '' };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user