feat: enhance sidebar functionality and styling
- Updated sidebar component to support dynamic width based on collapsed state. - Improved sidebar icon rendering and added user account management features. - Introduced new trend chart settings component for better user interaction. - Added utility functions for engineering units and trend chart settings. - Implemented color assignment logic for trend series to enhance visual representation. - Enhanced CSS styles for better responsiveness and usability across different screen sizes. - Introduced new configuration for Vite server to allow shared directory access. - Added .dockerignore file to optimize Docker build context.
This commit is contained in:
1 parent
2f5f86452f
commit
3203577a9d
28 files changed
+1508
-758
No files matched your search
+20
-5
@@ -1,8 +1,9 @@
|
||||
import mysql from "mysql2/promise";
|
||||
import { config } from "./config.js";
|
||||
import { setUtcSession } from "../../shared/trend-time.mjs";
|
||||
|
||||
function createPool(password) {
|
||||
return mysql.createPool({
|
||||
const pool = mysql.createPool({
|
||||
host: config.dbHost,
|
||||
port: config.dbPort,
|
||||
user: config.dbUser,
|
||||
@@ -13,7 +14,10 @@ function createPool(password) {
|
||||
namedPlaceholders: true,
|
||||
multipleStatements: true,
|
||||
charset: "utf8mb4",
|
||||
timezone: "Z",
|
||||
});
|
||||
pool.on("connection", setUtcSession);
|
||||
return pool;
|
||||
}
|
||||
|
||||
const candidatePasswords = [...new Set([config.dbPassword, config.dbPasswordFallback].filter(Boolean))];
|
||||
@@ -32,9 +36,19 @@ function delay(milliseconds) {
|
||||
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
||||
}
|
||||
|
||||
async function queryWithCredentials(sql, values) {
|
||||
async function execute(pool, sql, values, isolated) {
|
||||
if (!isolated) return pool.query(sql, values);
|
||||
const connection = await pool.getConnection();
|
||||
try {
|
||||
return await activePool.query(sql, values);
|
||||
return await connection.query(sql);
|
||||
} finally {
|
||||
connection.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
async function queryWithCredentials(sql, values, isolated) {
|
||||
try {
|
||||
return await execute(activePool, sql, values, isolated);
|
||||
} catch (error) {
|
||||
if (!isAccessDenied(error) || candidatePasswords.length < 2) {
|
||||
throw error;
|
||||
@@ -44,7 +58,7 @@ async function queryWithCredentials(sql, values) {
|
||||
if (password === activePassword) continue;
|
||||
const fallbackPool = createPool(password);
|
||||
try {
|
||||
const result = await fallbackPool.query(sql, values);
|
||||
const result = await execute(fallbackPool, sql, values, isolated);
|
||||
const previousPool = activePool;
|
||||
activePool = fallbackPool;
|
||||
activePassword = password;
|
||||
@@ -74,4 +88,5 @@ async function query(sql, values) {
|
||||
throw lastError;
|
||||
}
|
||||
|
||||
export const pool = { query };
|
||||
export const pool = { query };
|
||||
export const importSql = (sql) => queryWithCredentials(sql, undefined, true);
|
||||
Reference in new issue
Block a user