Spaces:
Runtime error
Runtime error
Update templates/index.html
Browse files- templates/index.html +67 -6
templates/index.html
CHANGED
|
@@ -34,6 +34,7 @@
|
|
| 34 |
}
|
| 35 |
.result-table { margin-top: 20px; }
|
| 36 |
.error { color: #dc3545; font-weight: 500; }
|
|
|
|
| 37 |
.note { font-style: italic; color: #6c757d; }
|
| 38 |
.highlight {
|
| 39 |
background-color: #28a745;
|
|
@@ -84,19 +85,67 @@
|
|
| 84 |
border-radius: 5px;
|
| 85 |
}
|
| 86 |
.unpaid { color: #dc3545; font-weight: bold; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
</style>
|
| 88 |
</head>
|
| 89 |
<body>
|
| 90 |
<div class="container">
|
| 91 |
<h1 class="text-center mb-4">AI SQL Assistant</h1>
|
| 92 |
|
| 93 |
-
<
|
| 94 |
-
<
|
| 95 |
-
|
| 96 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
</div>
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
{% if summary %}
|
| 102 |
<div class="schema-box">
|
|
@@ -104,28 +153,39 @@
|
|
| 104 |
<div class="schema-summary">
|
| 105 |
<h4>Overview</h4>
|
| 106 |
<p>{{ summary.description }}</p>
|
|
|
|
| 107 |
<h4>Main Tables and Columns</h4>
|
| 108 |
<ul>
|
| 109 |
{% for table, columns in summary.main_tables.items() %}
|
| 110 |
<li><strong>{{ table }}</strong>: {{ columns | join(', ') }}</li>
|
| 111 |
{% endfor %}
|
| 112 |
</ul>
|
|
|
|
|
|
|
| 113 |
<h4>Key Relationships</h4>
|
| 114 |
<ul>
|
| 115 |
{% for relation in summary.relationships %}
|
| 116 |
<li>{{ relation }}</li>
|
| 117 |
{% endfor %}
|
| 118 |
</ul>
|
|
|
|
| 119 |
<h4>Suggestions</h4>
|
| 120 |
<p><span class="highlight {% if summary.suggestions.evaluation != 'Excellent' %}highlight-warning{% endif %}">{{ summary.suggestions.evaluation }}</span></p>
|
| 121 |
<p>{{ summary.suggestions.note }}</p>
|
|
|
|
| 122 |
<ul>
|
| 123 |
{% for rec in summary.suggestions.recommendations %}
|
| 124 |
<li>{{ rec }}</li>
|
| 125 |
{% endfor %}
|
| 126 |
</ul>
|
|
|
|
| 127 |
</div>
|
| 128 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
{% endif %}
|
| 130 |
|
| 131 |
<form method="post" class="mt-4">
|
|
@@ -176,6 +236,7 @@
|
|
| 176 |
{% endif %}
|
| 177 |
</div>
|
| 178 |
|
|
|
|
| 179 |
<script>
|
| 180 |
function toggleSection(id) {
|
| 181 |
const content = document.getElementById(id);
|
|
|
|
| 34 |
}
|
| 35 |
.result-table { margin-top: 20px; }
|
| 36 |
.error { color: #dc3545; font-weight: 500; }
|
| 37 |
+
.success { color: #28a745; font-weight: 500; }
|
| 38 |
.note { font-style: italic; color: #6c757d; }
|
| 39 |
.highlight {
|
| 40 |
background-color: #28a745;
|
|
|
|
| 85 |
border-radius: 5px;
|
| 86 |
}
|
| 87 |
.unpaid { color: #dc3545; font-weight: bold; }
|
| 88 |
+
.modal-content {
|
| 89 |
+
border-radius: 8px;
|
| 90 |
+
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
|
| 91 |
+
}
|
| 92 |
+
.modal-header {
|
| 93 |
+
background-color: #007bff;
|
| 94 |
+
color: white;
|
| 95 |
+
}
|
| 96 |
</style>
|
| 97 |
</head>
|
| 98 |
<body>
|
| 99 |
<div class="container">
|
| 100 |
<h1 class="text-center mb-4">AI SQL Assistant</h1>
|
| 101 |
|
| 102 |
+
<div class="mb-4">
|
| 103 |
+
<button type="button" class="btn btn-primary me-2" data-bs-toggle="modal" data-bs-target="#dbConfigModal">Configure MySQL Connection</button>
|
| 104 |
+
<form method="post" enctype="multipart/form-data" style="display: inline;">
|
| 105 |
+
<div class="mb-3 d-inline-block">
|
| 106 |
+
<label for="sql_file" class="form-label">Upload MySQL .sql File</label>
|
| 107 |
+
<input type="file" class="form-control" id="sql_file" name="sql_file" accept=".sql">
|
| 108 |
+
</div>
|
| 109 |
+
<button type="submit" class="btn btn-primary">Upload</button>
|
| 110 |
+
</form>
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
<!-- Modal for MySQL Connection -->
|
| 114 |
+
<div class="modal fade" id="dbConfigModal" tabindex="-1" aria-labelledby="dbConfigModalLabel" aria-hidden="true">
|
| 115 |
+
<div class="modal-dialog">
|
| 116 |
+
<div class="modal-content">
|
| 117 |
+
<div class="modal-header">
|
| 118 |
+
<h5 class="modal-title" id="dbConfigModalLabel">Configure MySQL Connection</h5>
|
| 119 |
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
| 120 |
+
</div>
|
| 121 |
+
<div class="modal-body">
|
| 122 |
+
<form method="post" action="/configure_db">
|
| 123 |
+
<div class="mb-3">
|
| 124 |
+
<label for="host" class="form-label">Host</label>
|
| 125 |
+
<input type="text" class="form-control" id="host" name="host" placeholder="e.g., localhost" required>
|
| 126 |
+
</div>
|
| 127 |
+
<div class="mb-3">
|
| 128 |
+
<label for="user" class="form-label">User</label>
|
| 129 |
+
<input type="text" class="form-control" id="user" name="user" placeholder="e.g., root" required>
|
| 130 |
+
</div>
|
| 131 |
+
<div class="mb-3">
|
| 132 |
+
<label for="password" class="form-label">Password</label>
|
| 133 |
+
<input type="password" class="form-control" id="password" name="password" placeholder="Enter password">
|
| 134 |
+
</div>
|
| 135 |
+
<div class="mb-3">
|
| 136 |
+
<label for="port" class="form-label">Port</label>
|
| 137 |
+
<input type="number" class="form-control" id="port" name="port" placeholder="3306" value="3306">
|
| 138 |
+
</div>
|
| 139 |
+
<button type="submit" class="btn btn-primary">Save Connection</button>
|
| 140 |
+
</form>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
</div>
|
| 144 |
+
</div>
|
| 145 |
+
|
| 146 |
+
{% if success %}
|
| 147 |
+
<p class="success mt-3">{{ success }}</p>
|
| 148 |
+
{% endif %}
|
| 149 |
|
| 150 |
{% if summary %}
|
| 151 |
<div class="schema-box">
|
|
|
|
| 153 |
<div class="schema-summary">
|
| 154 |
<h4>Overview</h4>
|
| 155 |
<p>{{ summary.description }}</p>
|
| 156 |
+
{% if summary.main_tables %}
|
| 157 |
<h4>Main Tables and Columns</h4>
|
| 158 |
<ul>
|
| 159 |
{% for table, columns in summary.main_tables.items() %}
|
| 160 |
<li><strong>{{ table }}</strong>: {{ columns | join(', ') }}</li>
|
| 161 |
{% endfor %}
|
| 162 |
</ul>
|
| 163 |
+
{% endif %}
|
| 164 |
+
{% if summary.relationships %}
|
| 165 |
<h4>Key Relationships</h4>
|
| 166 |
<ul>
|
| 167 |
{% for relation in summary.relationships %}
|
| 168 |
<li>{{ relation }}</li>
|
| 169 |
{% endfor %}
|
| 170 |
</ul>
|
| 171 |
+
{% endif %}
|
| 172 |
<h4>Suggestions</h4>
|
| 173 |
<p><span class="highlight {% if summary.suggestions.evaluation != 'Excellent' %}highlight-warning{% endif %}">{{ summary.suggestions.evaluation }}</span></p>
|
| 174 |
<p>{{ summary.suggestions.note }}</p>
|
| 175 |
+
{% if summary.suggestions.recommendations %}
|
| 176 |
<ul>
|
| 177 |
{% for rec in summary.suggestions.recommendations %}
|
| 178 |
<li>{{ rec }}</li>
|
| 179 |
{% endfor %}
|
| 180 |
</ul>
|
| 181 |
+
{% endif %}
|
| 182 |
</div>
|
| 183 |
</div>
|
| 184 |
+
{% elif schema %}
|
| 185 |
+
<div class="schema-box">
|
| 186 |
+
<h3>Database Summary</h3>
|
| 187 |
+
<p class="note">Schema loaded, but no summary available. Tables: {{ schema.keys() | join(', ') }}.</p>
|
| 188 |
+
</div>
|
| 189 |
{% endif %}
|
| 190 |
|
| 191 |
<form method="post" class="mt-4">
|
|
|
|
| 236 |
{% endif %}
|
| 237 |
</div>
|
| 238 |
|
| 239 |
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
| 240 |
<script>
|
| 241 |
function toggleSection(id) {
|
| 242 |
const content = document.getElementById(id);
|