Failed to initialize application: Failed to bundle using Rollup v2.79.2: the file imports a not supported node.js built-in module "net". If you believe this to be an issue with jsDelivr, and not with the package itself, please open an issue at https://github.com/jsdelivr/jsdelivr. Using demo data.
Browse files- api/tables.json +8 -0
- index.html +1 -2
- script.js +9 -32
api/tables.json
CHANGED
|
@@ -4,6 +4,14 @@
|
|
| 4 |
{
|
| 5 |
"table_name": "documents",
|
| 6 |
"table_schema": "Contains all document records with metadata and content"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
}
|
| 8 |
]
|
| 9 |
}
|
|
|
|
| 4 |
{
|
| 5 |
"table_name": "documents",
|
| 6 |
"table_schema": "Contains all document records with metadata and content"
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"table_name": "users",
|
| 10 |
+
"table_schema": "Stores user account information"
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"table_name": "sessions",
|
| 14 |
+
"table_schema": "Tracks user login sessions"
|
| 15 |
}
|
| 16 |
]
|
| 17 |
}
|
index.html
CHANGED
|
@@ -92,8 +92,7 @@
|
|
| 92 |
// Implement search functionality here
|
| 93 |
});
|
| 94 |
</script>
|
| 95 |
-
<script
|
| 96 |
<script src="components/documents-table.js"></script>
|
| 97 |
-
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 98 |
</body>
|
| 99 |
</html>
|
|
|
|
| 92 |
// Implement search functionality here
|
| 93 |
});
|
| 94 |
</script>
|
| 95 |
+
<script src="script.js"></script>
|
| 96 |
<script src="components/documents-table.js"></script>
|
|
|
|
| 97 |
</body>
|
| 98 |
</html>
|
script.js
CHANGED
|
@@ -3,35 +3,18 @@
|
|
| 3 |
const dbTables = [
|
| 4 |
{ table_name: 'documents', table_schema: 'Stores all document records' }
|
| 5 |
];
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
//
|
| 8 |
-
const dbConfig = {
|
| 9 |
-
host: 'pg-90c016a-mozmail-fead.i.aivencloud.com',
|
| 10 |
-
port: 15173,
|
| 11 |
-
user: 'avnadmin',
|
| 12 |
-
password: 'AVNS_4wOfQguMcSX18XkXZYL',
|
| 13 |
-
database: 'defaultdb',
|
| 14 |
-
ssl: { rejectUnauthorized: false }
|
| 15 |
-
};
|
| 16 |
-
|
| 17 |
-
// Function to fetch tables using direct PostgreSQL connection
|
| 18 |
async function fetchTables() {
|
| 19 |
try {
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
const
|
| 23 |
-
|
| 24 |
-
await client.connect();
|
| 25 |
-
const res = await client.query(`
|
| 26 |
-
SELECT table_name, table_schema
|
| 27 |
-
FROM information_schema.tables
|
| 28 |
-
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
|
| 29 |
-
`);
|
| 30 |
-
await client.end();
|
| 31 |
-
|
| 32 |
-
return res.rows.length ? res.rows : dbTables;
|
| 33 |
} catch (error) {
|
| 34 |
-
console.error('
|
| 35 |
showError(`Failed to fetch tables: ${error.message}. Using default table.`);
|
| 36 |
return dbTables;
|
| 37 |
}
|
|
@@ -74,14 +57,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|
| 74 |
|
| 75 |
const loading = document.getElementById('loading');
|
| 76 |
try {
|
| 77 |
-
// Load pg module only when needed
|
| 78 |
-
if (!window.pg) {
|
| 79 |
-
const pg = await import('https://cdn.jsdelivr.net/npm/pg@8.11.3/+esm');
|
| 80 |
-
window.pg = pg;
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
const tables = await fetchTables();
|
| 84 |
-
|
| 85 |
} catch (error) {
|
| 86 |
console.error('Initialization error:', error);
|
| 87 |
showError(`Failed to initialize application: ${error.message}. Using demo data.`);
|
|
|
|
| 3 |
const dbTables = [
|
| 4 |
{ table_name: 'documents', table_schema: 'Stores all document records' }
|
| 5 |
];
|
| 6 |
+
// Mock API endpoint for tables data
|
| 7 |
+
const API_URL = 'https://my-json-server.typicode.com/yourusername/yourrepo/tables';
|
| 8 |
|
| 9 |
+
// Function to fetch tables from mock API
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
async function fetchTables() {
|
| 11 |
try {
|
| 12 |
+
const response = await fetch(API_URL);
|
| 13 |
+
if (!response.ok) throw new Error('Network response was not ok');
|
| 14 |
+
const data = await response.json();
|
| 15 |
+
return data.tables || dbTables;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
} catch (error) {
|
| 17 |
+
console.error('API fetch error:', error);
|
| 18 |
showError(`Failed to fetch tables: ${error.message}. Using default table.`);
|
| 19 |
return dbTables;
|
| 20 |
}
|
|
|
|
| 57 |
|
| 58 |
const loading = document.getElementById('loading');
|
| 59 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
const tables = await fetchTables();
|
| 61 |
+
displayTables(tables);
|
| 62 |
} catch (error) {
|
| 63 |
console.error('Initialization error:', error);
|
| 64 |
showError(`Failed to initialize application: ${error.message}. Using demo data.`);
|