mirror of
https://github.com/danbulant/mysqlExporter
synced 2026-06-18 22:21:15 +00:00
Styles + table comments
This commit is contained in:
parent
962ebf5b98
commit
6d2865bac6
3 changed files with 78 additions and 47 deletions
15
index.js
15
index.js
|
|
@ -37,6 +37,10 @@ app.get("/", (req, res) => {
|
|||
});
|
||||
});
|
||||
|
||||
app.get("/fieldsIgnored", (req, res) => {
|
||||
res.json(config.fields_ignored);
|
||||
});
|
||||
|
||||
app.get("/tables", (req, res) => {
|
||||
pool.query("SHOW tables", async (err, resp, fields) => {
|
||||
if(err) {
|
||||
|
|
@ -51,8 +55,17 @@ app.get("/tables", (req, res) => {
|
|||
|
||||
var obj = {};
|
||||
for(var r of result) {
|
||||
obj[r] = {
|
||||
name: r,
|
||||
comment: "",
|
||||
columns: []
|
||||
};
|
||||
try {
|
||||
obj[r] = await query(pool, "SHOW FULL COLUMNS FROM " + r);
|
||||
obj[r].columns = await query(pool, "SHOW FULL COLUMNS FROM " + r);
|
||||
obj[r].comment = await query(pool, `SELECT table_comment
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE table_schema=?
|
||||
AND table_name=?`, [config.mysql.database, r]);
|
||||
} catch(e){
|
||||
console.error(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,62 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>MySQL exporter</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app">Loading...</div>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 30px auto;
|
||||
max-width: 800px;
|
||||
line-height: 1.6;
|
||||
font-size: 18px;
|
||||
color: #444;
|
||||
padding: 0 10px
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3 {
|
||||
font-family: Simplifica;
|
||||
line-height: 1.2
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: rgb(0, 140, 255);
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: rgb(153, 0, 255);
|
||||
}
|
||||
|
||||
table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid black;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
th {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background-color: #444;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
const app = document.getElementById("app");
|
||||
|
||||
|
|
@ -38,6 +88,18 @@
|
|||
title.innerText = table;
|
||||
app.appendChild(title);
|
||||
|
||||
if(!data.columns) {
|
||||
console.error(data);
|
||||
app.appendChild(htmlToElement("<p>" + data + "<p>"));
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
var comment = document.createElement("p");
|
||||
comment.innerText = data.comment[0].table_comment;
|
||||
app.appendChild(comment);
|
||||
} catch(e) { }
|
||||
|
||||
var head = htmlToElement(`
|
||||
<tr>
|
||||
<th>Field</th>
|
||||
|
|
@ -52,7 +114,7 @@
|
|||
`);
|
||||
|
||||
tableEl.appendChild(head);
|
||||
for(var field of data) {
|
||||
for(var field of data.columns) {
|
||||
tableEl.appendChild(htmlToElement(`
|
||||
<tr>
|
||||
<td>${field.Field}</td>
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
body {
|
||||
margin: 30px auto;
|
||||
max-width: 650px;
|
||||
line-height: 1.6;
|
||||
font-size: 18px;
|
||||
color: #444;
|
||||
padding: 0 10px
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3 {
|
||||
font-family: Simplifica;
|
||||
line-height: 1.2
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: rgb(0, 140, 255);
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: rgb(153, 0, 255);
|
||||
}
|
||||
|
||||
table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid black;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
th {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
tr:hover {
|
||||
background-color: #444;
|
||||
color: white;
|
||||
}
|
||||
Loading…
Reference in a new issue