web_plsql 1.0.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -13
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/frontend/assets/main-0oxRTIkL.js +147 -0
- package/dist/frontend/assets/main-0oxRTIkL.js.br +0 -0
- package/dist/frontend/assets/main-0oxRTIkL.js.gz +0 -0
- package/dist/frontend/assets/main-TYgLak6O.css +1 -0
- package/dist/frontend/assets/main-TYgLak6O.css.br +0 -0
- package/dist/frontend/assets/main-TYgLak6O.css.gz +0 -0
- package/dist/frontend/index.html +516 -0
- package/dist/frontend/index.html.br +0 -0
- package/dist/frontend/index.html.gz +0 -0
- package/dist/index.d.mts +646 -0
- package/dist/index.mjs +3548 -0
- package/dist/index.mjs.map +1 -0
- package/dist/oracledb-mock-Dn8aHtd7.mjs +68 -0
- package/dist/oracledb-mock-Dn8aHtd7.mjs.map +1 -0
- package/examples/config-apex.js +1 -1
- package/examples/config-docker.js +1 -2
- package/package.json +45 -32
- package/examples/config-native.js +0 -68
- package/src/admin/client/charts.ts +0 -299
- package/src/admin/client/main.js +0 -3
- package/src/admin/client/tailwind.css +0 -41
- package/src/admin/index.html +0 -315
- package/src/admin/js/api.ts +0 -95
- package/src/admin/js/app.ts +0 -306
- package/src/admin/js/eslint.config.js +0 -74
- package/src/admin/js/schemas.ts +0 -153
- package/src/admin/js/templates/config.ts +0 -146
- package/src/admin/js/templates/errorRow.ts +0 -18
- package/src/admin/js/templates/index.ts +0 -3
- package/src/admin/js/templates/poolCard.ts +0 -61
- package/src/admin/js/tsconfig.json +0 -24
- package/src/admin/js/types.ts +0 -223
- package/src/admin/js/ui/theme.ts +0 -93
- package/src/admin/js/ui/views.ts +0 -164
- package/src/admin/js/util/format.ts +0 -27
- package/src/admin/lib/assets/main-zpdhQ1gD.css +0 -1
- package/src/admin/lib/chart.bundle.js +0 -139
- package/src/admin/style.css +0 -1321
- package/src/bin/load-test.js +0 -202
- package/src/handler/handlerAdmin.js +0 -198
- package/src/handler/handlerLogger.js +0 -21
- package/src/handler/handlerMetrics.js +0 -68
- package/src/handler/handlerUpload.js +0 -26
- package/src/handler/plsql/cgi.js +0 -131
- package/src/handler/plsql/errorPage.js +0 -117
- package/src/handler/plsql/handlerPlSql.js +0 -90
- package/src/handler/plsql/parsePage.js +0 -213
- package/src/handler/plsql/procedure.js +0 -356
- package/src/handler/plsql/procedureError.js +0 -40
- package/src/handler/plsql/procedureNamed.js +0 -268
- package/src/handler/plsql/procedureSanitize.js +0 -262
- package/src/handler/plsql/procedureVariable.js +0 -54
- package/src/handler/plsql/request.js +0 -124
- package/src/handler/plsql/requestError.js +0 -23
- package/src/handler/plsql/sendResponse.js +0 -136
- package/src/handler/plsql/stream.js +0 -28
- package/src/handler/plsql/upload.js +0 -109
- package/src/index.js +0 -20
- package/src/server/config.js +0 -57
- package/src/server/connections.js +0 -40
- package/src/server/server.js +0 -289
- package/src/types.js +0 -150
- package/src/util/cache.js +0 -123
- package/src/util/errorToString.js +0 -24
- package/src/util/file.js +0 -91
- package/src/util/html.js +0 -53
- package/src/util/jsonLogger.js +0 -47
- package/src/util/oracle.js +0 -80
- package/src/util/shutdown.js +0 -44
- package/src/util/trace.js +0 -325
- package/src/util/type.js +0 -6
- package/src/util/util.js +0 -66
- package/src/version.js +0 -5
- package/types/handler/handlerAdmin.d.ts +0 -9
- package/types/handler/handlerLogger.d.ts +0 -2
- package/types/handler/handlerMetrics.d.ts +0 -25
- package/types/handler/handlerUpload.d.ts +0 -7
- package/types/handler/plsql/cgi.d.ts +0 -4
- package/types/handler/plsql/errorPage.d.ts +0 -11
- package/types/handler/plsql/handlerPlSql.d.ts +0 -13
- package/types/handler/plsql/parsePage.d.ts +0 -3
- package/types/handler/plsql/procedure.d.ts +0 -12
- package/types/handler/plsql/procedureError.d.ts +0 -23
- package/types/handler/plsql/procedureNamed.d.ts +0 -14
- package/types/handler/plsql/procedureSanitize.d.ts +0 -11
- package/types/handler/plsql/procedureVariable.d.ts +0 -10
- package/types/handler/plsql/request.d.ts +0 -9
- package/types/handler/plsql/requestError.d.ts +0 -8
- package/types/handler/plsql/sendResponse.d.ts +0 -6
- package/types/handler/plsql/upload.d.ts +0 -5
- package/types/index.d.ts +0 -11
- package/types/server/config.d.ts +0 -2
- package/types/server/server.d.ts +0 -74
- package/types/types.d.ts +0 -328
- package/types/util/cache.d.ts +0 -69
- package/types/util/errorToString.d.ts +0 -1
- package/types/util/file.d.ts +0 -6
- package/types/util/html.d.ts +0 -3
- package/types/util/jsonLogger.d.ts +0 -45
- package/types/util/oracle.d.ts +0 -5
- package/types/util/shutdown.d.ts +0 -2
- package/types/util/trace.d.ts +0 -22
- package/types/util/type.d.ts +0 -1
- package/types/util/util.d.ts +0 -3
- package/types/version.d.ts +0 -1
- /package/{src/admin/favicon.svg → dist/frontend/assets/favicon-mQAM4tVu.svg} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oracledb-mock-Dn8aHtd7.mjs","names":[],"sources":["../src/backend/util/oracledb-mock.ts"],"sourcesContent":["import type {Connection, Pool, Lob, Result, BindParameters, ExecuteOptions, DbType} from 'oracledb';\n\n// Mock implementation\nexport type ExecuteCallback = (sql: string, binds?: BindParameters) => Promise<Result<unknown>> | Result<unknown>;\nlet executeCallback: ExecuteCallback | null = null;\n\n/**\n * Test utility: Set the callback for execute calls.\n * @param cb - The callback\n */\nexport const setExecuteCallback = (cb: ExecuteCallback | null) => {\n\texecuteCallback = cb;\n};\n\n/**\n * Mock LOB class.\n */\nclass MockLob {\n\ttype: DbType | number;\n\tconstructor(type: DbType | number) {\n\t\tthis.type = type;\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tdestroy(): void {}\n}\n\n/**\n * Mock Connection class.\n */\nclass MockConnection {\n\tasync execute<T = unknown>(sql: string, bindParams?: BindParameters, _options?: ExecuteOptions): Promise<Result<T>> {\n\t\tif (executeCallback) {\n\t\t\treturn (await executeCallback(sql, bindParams)) as Result<T>;\n\t\t}\n\t\treturn {rows: []} as Result<T>;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/require-await\n\tasync createLob(type: DbType | number): Promise<Lob> {\n\t\treturn new MockLob(type) as unknown as Lob;\n\t}\n\n\tasync commit(): Promise<void> {\n\t\t// empty\n\t}\n\tasync rollback(): Promise<void> {\n\t\t// empty\n\t}\n\tasync release(): Promise<void> {\n\t\t// empty\n\t}\n}\n\n/**\n * Mock Pool class.\n */\nclass MockPool {\n\tconnectionsOpen = 0;\n\tconnectionsInUse = 0;\n\n\t// eslint-disable-next-line @typescript-eslint/require-await\n\tasync getConnection(): Promise<Connection> {\n\t\tthis.connectionsInUse++;\n\t\tthis.connectionsOpen = Math.max(this.connectionsOpen, this.connectionsInUse);\n\t\treturn new MockConnection() as unknown as Connection;\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/require-await\n\tasync close(_drainTime?: number): Promise<void> {\n\t\tthis.connectionsOpen = 0;\n\t\tthis.connectionsInUse = 0;\n\t}\n}\n\n/**\n * Mock createPool function.\n * @param _config - The configuration\n * @returns The pool\n */\n// eslint-disable-next-line @typescript-eslint/require-await\nexport async function createPool(_config: unknown): Promise<Pool> {\n\treturn new MockPool() as unknown as Pool;\n}\n\n// Default export mimics oracledb module structure for test mocking\nexport default {\n\t// Constants will be merged from actual oracledb by vi.importActual in test_setup.ts\n\tcreatePool,\n\tsetExecuteCallback,\n};\n"],"mappings":";;;;;;;AAIA,IAAI,kBAA0C;;;;;AAM9C,MAAa,sBAAsB,OAA+B;AACjE,mBAAkB;;;;;AAMnB,IAAM,UAAN,MAAc;CACb;CACA,YAAY,MAAuB;AAClC,OAAK,OAAO;;CAGb,UAAgB;;;;;AAMjB,IAAM,iBAAN,MAAqB;CACpB,MAAM,QAAqB,KAAa,YAA6B,UAA+C;AACnH,MAAI,gBACH,QAAQ,MAAM,gBAAgB,KAAK,WAAW;AAE/C,SAAO,EAAC,MAAM,EAAE,EAAC;;CAIlB,MAAM,UAAU,MAAqC;AACpD,SAAO,IAAI,QAAQ,KAAK;;CAGzB,MAAM,SAAwB;CAG9B,MAAM,WAA0B;CAGhC,MAAM,UAAyB;;;;;AAQhC,IAAM,WAAN,MAAe;CACd,kBAAkB;CAClB,mBAAmB;CAGnB,MAAM,gBAAqC;AAC1C,OAAK;AACL,OAAK,kBAAkB,KAAK,IAAI,KAAK,iBAAiB,KAAK,iBAAiB;AAC5E,SAAO,IAAI,gBAAgB;;CAI5B,MAAM,MAAM,YAAoC;AAC/C,OAAK,kBAAkB;AACvB,OAAK,mBAAmB;;;;;;;;AAU1B,eAAsB,WAAW,SAAiC;AACjE,QAAO,IAAI,UAAU"}
|
package/examples/config-apex.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web_plsql",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"author": "Dieter Oberkofler <dieter.oberkofler@gmail.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "The Express Middleware for Oracle PL/SQL",
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"homepage": "https://github.com/doberkofler/web_plsql",
|
|
20
20
|
"engines": {
|
|
21
|
-
"
|
|
22
|
-
"node": ">=22.0.0"
|
|
21
|
+
"node": ">=24"
|
|
23
22
|
},
|
|
24
23
|
"maintainers": [
|
|
25
24
|
{
|
|
@@ -35,67 +34,81 @@
|
|
|
35
34
|
"url": "git://github.com/doberkofler/web_plsql.git"
|
|
36
35
|
},
|
|
37
36
|
"files": [
|
|
38
|
-
"
|
|
39
|
-
"examples/"
|
|
40
|
-
"types"
|
|
37
|
+
"dist/",
|
|
38
|
+
"examples/"
|
|
41
39
|
],
|
|
42
|
-
"main": "./
|
|
43
|
-
"types": "./
|
|
40
|
+
"main": "./dist/index.mjs",
|
|
41
|
+
"types": "./dist/index.d.mts",
|
|
44
42
|
"type": "module",
|
|
45
43
|
"scripts": {
|
|
46
|
-
"build": "npm run build:
|
|
47
|
-
"build:
|
|
48
|
-
"
|
|
44
|
+
"build": "npm run build:backend && npm run build:frontend",
|
|
45
|
+
"build:backend": "tsdown",
|
|
46
|
+
"build:frontend": "vite build",
|
|
47
|
+
"dev": "concurrently -n backend,frontend -c blue,green \"npm:dev:backend\" \"npm:dev:frontend\"",
|
|
48
|
+
"dev:backend": "node --experimental-strip-types --no-warnings dev/server.ts",
|
|
49
|
+
"dev:frontend": "vite",
|
|
50
|
+
"lint": "tsc --noEmit && eslint --no-cache . && prettier --check .",
|
|
51
|
+
"knip:backend": "knip --config knip.backend.config.ts",
|
|
52
|
+
"knip:frontend": "knip --config knip.frontend.config.ts",
|
|
49
53
|
"test": "vitest run",
|
|
54
|
+
"test:perf": "vitest run tests/performance.test.ts",
|
|
50
55
|
"test:coverage": "vitest run --coverage",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
56
|
+
"test:e2e": "playwright test",
|
|
57
|
+
"test:e2e:ui": "playwright test --ui",
|
|
58
|
+
"test:e2e:debug": "playwright test --debug",
|
|
59
|
+
"stylelint": "stylelint \"src/frontend/**/*.css\"",
|
|
53
60
|
"clean": "shx rm -f *.tgz && shx rm -f *.log",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"image-build": "docker build --no-cache --progress=plain --tag=web_plsql .",
|
|
59
|
-
"image-save": "docker save web_plsql | gzip > web_plsql.tar.gz"
|
|
61
|
+
"ci": "npm run clean && npm run lint && npm run build && npm run stylelint && npm run knip:backend && npm run knip:frontend && npm run test:coverage && npm run test:e2e",
|
|
62
|
+
"image-build": "cd docker && docker build --no-cache --progress=plain --tag=web_plsql .",
|
|
63
|
+
"image-save": "cd docker && docker save web_plsql > web_plsql.tar",
|
|
64
|
+
"pack:dev": "VERSION=$(node -p 'require(\"./package.json\").version'); npm pack; mv web_plsql-$VERSION.tgz web_plsql-dev.tgz"
|
|
60
65
|
},
|
|
61
66
|
"peerDependencies": {
|
|
62
67
|
"oracledb": "6.10.0"
|
|
63
68
|
},
|
|
64
69
|
"dependencies": {
|
|
65
|
-
"chart.js": "
|
|
70
|
+
"chart.js": "4.5.1",
|
|
66
71
|
"compression": "1.8.1",
|
|
67
72
|
"cookie-parser": "1.4.7",
|
|
73
|
+
"cors": "2.8.6",
|
|
68
74
|
"debug": "4.4.3",
|
|
69
75
|
"express": "5.2.1",
|
|
70
|
-
"
|
|
76
|
+
"express-static-gzip": "3.0.0",
|
|
71
77
|
"morgan": "1.10.1",
|
|
72
78
|
"multer": "2.0.2",
|
|
73
79
|
"rotating-file-stream": "3.2.8",
|
|
74
|
-
"zod": "
|
|
80
|
+
"zod": "4.3.6"
|
|
75
81
|
},
|
|
76
82
|
"devDependencies": {
|
|
77
|
-
"@
|
|
83
|
+
"@playwright/test": "1.58.2",
|
|
84
|
+
"@tailwindcss/vite": "4.1.18",
|
|
78
85
|
"@types/compression": "1.8.1",
|
|
79
86
|
"@types/cookie-parser": "1.4.10",
|
|
87
|
+
"@types/cors": "2.8.19",
|
|
80
88
|
"@types/debug": "4.1.12",
|
|
81
89
|
"@types/morgan": "1.9.10",
|
|
82
90
|
"@types/multer": "2.0.0",
|
|
83
|
-
"@types/node": "25.2.
|
|
91
|
+
"@types/node": "25.2.3",
|
|
84
92
|
"@types/oracledb": "6.10.1",
|
|
85
93
|
"@types/supertest": "6.0.3",
|
|
86
|
-
"@vitest/coverage-v8": "
|
|
94
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
95
|
+
"cheerio": "1.2.0",
|
|
96
|
+
"concurrently": "9.2.1",
|
|
87
97
|
"eslint": "9.39.2",
|
|
88
|
-
"eslint-plugin-jsdoc": "62.5.
|
|
98
|
+
"eslint-plugin-jsdoc": "62.5.4",
|
|
99
|
+
"knip": "5.83.1",
|
|
89
100
|
"oracledb": "6.10.0",
|
|
90
101
|
"prettier": "3.8.1",
|
|
91
102
|
"shx": "0.4.0",
|
|
92
|
-
"stylelint": "
|
|
93
|
-
"stylelint-config-standard": "
|
|
103
|
+
"stylelint": "17.3.0",
|
|
104
|
+
"stylelint-config-standard": "40.0.0",
|
|
94
105
|
"supertest": "7.2.2",
|
|
95
|
-
"tailwindcss": "
|
|
106
|
+
"tailwindcss": "4.1.18",
|
|
107
|
+
"tsdown": "0.20.3",
|
|
96
108
|
"typescript": "5.9.3",
|
|
97
|
-
"typescript-eslint": "8.
|
|
98
|
-
"vite": "
|
|
99
|
-
"
|
|
109
|
+
"typescript-eslint": "8.55.0",
|
|
110
|
+
"vite": "7.3.1",
|
|
111
|
+
"vite-plugin-compression2": "2.4.0",
|
|
112
|
+
"vitest": "4.0.18"
|
|
100
113
|
}
|
|
101
114
|
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import {startServer} from '../src/index.js';
|
|
4
|
-
import oracledb from 'oracledb';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @param {import('oracledb').Connection} connection - Oracle DB connection.
|
|
8
|
-
* @returns {Promise<boolean>}
|
|
9
|
-
*/
|
|
10
|
-
const hasOpenTransaction = async (connection) => {
|
|
11
|
-
const sql = `SELECT COUNT(*) FROM sys.v_$transaction t JOIN sys.v_$session s ON t.ses_addr = s.saddr WHERE s.audsid = USERENV('SESSIONID')`;
|
|
12
|
-
/** @type {import('oracledb').Result<number>} */
|
|
13
|
-
let result;
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
result = await connection.execute(sql, [], {
|
|
17
|
-
outFormat: oracledb.OUT_FORMAT_ARRAY,
|
|
18
|
-
});
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error('hasOpenTransaction: error', error, sql);
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
!Array.isArray(result.rows) ||
|
|
26
|
-
result.rows.length !== 1 ||
|
|
27
|
-
!Array.isArray(result.rows[0]) ||
|
|
28
|
-
result.rows[0].length !== 1 ||
|
|
29
|
-
typeof result.rows[0][0] !== 'number'
|
|
30
|
-
) {
|
|
31
|
-
console.error('hasOpenTransaction: invalid result', result, sql);
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return result.rows[0] > 0;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
void startServer({
|
|
39
|
-
port: 8888,
|
|
40
|
-
routeStatic: [
|
|
41
|
-
{
|
|
42
|
-
route: '/static',
|
|
43
|
-
directoryPath: 'examples/static',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
routePlSql: [
|
|
47
|
-
{
|
|
48
|
-
route: '/sample',
|
|
49
|
-
user: 'sample', // PlsqlDatabaseUserName
|
|
50
|
-
password: 'sample', // PlsqlDatabasePassword
|
|
51
|
-
connectString: process.env.WEB_PLSQL_ORACLE_SERVER ?? 'localhost:1521/TEST', // PlsqlDatabaseConnectString
|
|
52
|
-
defaultPage: 'sample_pkg.page_index', // PlsqlDefaultPage
|
|
53
|
-
documentTable: 'doctable', // PlsqlDocumentTablename
|
|
54
|
-
exclusionList: ['sample_pkg.page_exclusion_list'], // PlsqlExclusionList
|
|
55
|
-
requestValidationFunction: 'sample_pkg.request_validation_function', // PlsqlRequestValidationFunction
|
|
56
|
-
pathAlias: 'myalias', // PlsqlPathAlias
|
|
57
|
-
pathAliasProcedure: 'sample_pkg.page_path_alias', // PlsqlPathAliasProcedure
|
|
58
|
-
//transactionMode: 'commit',
|
|
59
|
-
transactionMode: async (connection, procedure) => {
|
|
60
|
-
if (await hasOpenTransaction(connection)) {
|
|
61
|
-
console.log(`We detected an open transaction in "${procedure}"`);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
errorStyle: 'debug', // PlsqlErrorStyle
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
loggerFilename: 'access.log', // PlsqlLogEnable and PlsqlLogDirectory
|
|
68
|
-
});
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import {Chart, registerables} from 'chart.js';
|
|
2
|
-
import type {State, ChartInstance} from '../js/types.js';
|
|
3
|
-
import type {StatusResponse} from '../js/schemas.js';
|
|
4
|
-
|
|
5
|
-
// Register Chart.js components
|
|
6
|
-
Chart.register(...registerables);
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Cache pie chart instances.
|
|
10
|
-
*/
|
|
11
|
-
const cachePieInstances = new Map<HTMLCanvasElement, Chart>();
|
|
12
|
-
|
|
13
|
-
type PoolInfo = StatusResponse['pools'][number];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Chart colors based on theme mode.
|
|
17
|
-
*/
|
|
18
|
-
type ChartColors = {
|
|
19
|
-
gridColor: string;
|
|
20
|
-
textColor: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get chart colors for the current theme.
|
|
25
|
-
* @param isDark - Whether dark mode is active.
|
|
26
|
-
* @returns Chart color configuration.
|
|
27
|
-
*/
|
|
28
|
-
function getChartColors(isDark: boolean): ChartColors {
|
|
29
|
-
return {
|
|
30
|
-
gridColor: isDark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.1)',
|
|
31
|
-
textColor: isDark ? '#94a3b8' : '#475569',
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Initialize charts.
|
|
37
|
-
* @param state - Application state.
|
|
38
|
-
*/
|
|
39
|
-
export function initCharts(state: State): void {
|
|
40
|
-
const isDark = document.body.classList.contains('dark');
|
|
41
|
-
const colors = getChartColors(isDark);
|
|
42
|
-
|
|
43
|
-
const trafficEl = document.getElementById('traffic-chart') as HTMLCanvasElement | null;
|
|
44
|
-
if (trafficEl) {
|
|
45
|
-
const chartData = {
|
|
46
|
-
labels: [],
|
|
47
|
-
datasets: [
|
|
48
|
-
{
|
|
49
|
-
label: 'Requests/s',
|
|
50
|
-
data: [],
|
|
51
|
-
borderColor: '#3b82f6',
|
|
52
|
-
backgroundColor: 'rgba(59, 130, 246, 0.1)',
|
|
53
|
-
fill: true,
|
|
54
|
-
tension: 0.4,
|
|
55
|
-
yAxisID: 'y',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
label: 'Avg Response Time (ms)',
|
|
59
|
-
data: [],
|
|
60
|
-
borderColor: '#10b981',
|
|
61
|
-
backgroundColor: 'rgba(16, 185, 129, 0.1)',
|
|
62
|
-
fill: true,
|
|
63
|
-
tension: 0.4,
|
|
64
|
-
yAxisID: 'y1',
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const chartOptions = {
|
|
70
|
-
responsive: true,
|
|
71
|
-
maintainAspectRatio: false,
|
|
72
|
-
scales: {
|
|
73
|
-
x: {
|
|
74
|
-
grid: {color: colors.gridColor},
|
|
75
|
-
ticks: {
|
|
76
|
-
color: colors.textColor,
|
|
77
|
-
maxRotation: 0,
|
|
78
|
-
autoSkip: true,
|
|
79
|
-
maxTicksLimit: 10,
|
|
80
|
-
},
|
|
81
|
-
title: {
|
|
82
|
-
display: true,
|
|
83
|
-
text: 'Time',
|
|
84
|
-
color: colors.textColor,
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
y: {
|
|
88
|
-
type: 'linear' as const,
|
|
89
|
-
display: true,
|
|
90
|
-
position: 'left' as const,
|
|
91
|
-
grid: {color: colors.gridColor},
|
|
92
|
-
ticks: {color: colors.textColor},
|
|
93
|
-
beginAtZero: true,
|
|
94
|
-
title: {
|
|
95
|
-
display: true,
|
|
96
|
-
text: 'Requests/s',
|
|
97
|
-
color: colors.textColor,
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
y1: {
|
|
101
|
-
type: 'linear' as const,
|
|
102
|
-
display: true,
|
|
103
|
-
position: 'right' as const,
|
|
104
|
-
grid: {drawOnChartArea: false, color: colors.gridColor},
|
|
105
|
-
ticks: {color: '#10b981'},
|
|
106
|
-
beginAtZero: true,
|
|
107
|
-
title: {
|
|
108
|
-
display: true,
|
|
109
|
-
text: 'Avg Response Time (ms)',
|
|
110
|
-
color: '#10b981',
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
plugins: {
|
|
115
|
-
legend: {
|
|
116
|
-
labels: {color: colors.textColor},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
const chart = new Chart(trafficEl, {
|
|
122
|
-
type: 'line',
|
|
123
|
-
data: chartData,
|
|
124
|
-
options: chartOptions,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
state.charts.traffic = {
|
|
128
|
-
data: chartData,
|
|
129
|
-
options: chartOptions,
|
|
130
|
-
update: () => chart.update(),
|
|
131
|
-
} as ChartInstance;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const poolEl = document.getElementById('pool-chart') as HTMLCanvasElement | null;
|
|
135
|
-
if (poolEl) {
|
|
136
|
-
const chartData = {
|
|
137
|
-
labels: [],
|
|
138
|
-
datasets: [],
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const chartOptions = {
|
|
142
|
-
responsive: true,
|
|
143
|
-
maintainAspectRatio: false,
|
|
144
|
-
scales: {
|
|
145
|
-
x: {
|
|
146
|
-
grid: {color: colors.gridColor},
|
|
147
|
-
ticks: {
|
|
148
|
-
color: colors.textColor,
|
|
149
|
-
maxRotation: 0,
|
|
150
|
-
autoSkip: true,
|
|
151
|
-
maxTicksLimit: 10,
|
|
152
|
-
},
|
|
153
|
-
title: {
|
|
154
|
-
display: true,
|
|
155
|
-
text: 'Time',
|
|
156
|
-
color: colors.textColor,
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
y: {
|
|
160
|
-
grid: {color: colors.gridColor},
|
|
161
|
-
ticks: {color: colors.textColor},
|
|
162
|
-
beginAtZero: true,
|
|
163
|
-
title: {
|
|
164
|
-
display: true,
|
|
165
|
-
text: 'Connections',
|
|
166
|
-
color: colors.textColor,
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
plugins: {
|
|
171
|
-
legend: {
|
|
172
|
-
labels: {color: colors.textColor},
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const chart = new Chart(poolEl, {
|
|
178
|
-
type: 'line',
|
|
179
|
-
data: chartData,
|
|
180
|
-
options: chartOptions,
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
state.charts.pool = {
|
|
184
|
-
data: chartData,
|
|
185
|
-
options: chartOptions,
|
|
186
|
-
update: () => chart.update(),
|
|
187
|
-
} as ChartInstance;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Update charts with new data.
|
|
193
|
-
* @param state - Application state.
|
|
194
|
-
* @param timeLabel - Time label for the data point.
|
|
195
|
-
* @param reqPerSec - Requests per second.
|
|
196
|
-
* @param avgResponseTime - Average response time in ms.
|
|
197
|
-
* @param pools - Pool information.
|
|
198
|
-
*/
|
|
199
|
-
export function updateCharts(state: State, timeLabel: string, reqPerSec: number, avgResponseTime: number, pools: PoolInfo[]): void {
|
|
200
|
-
const maxPoints = state.maxHistoryPoints;
|
|
201
|
-
|
|
202
|
-
state.history.labels.push(timeLabel);
|
|
203
|
-
state.history.requests.push(reqPerSec);
|
|
204
|
-
state.history.avgResponseTimes.push(avgResponseTime);
|
|
205
|
-
|
|
206
|
-
if (state.history.labels.length > maxPoints) {
|
|
207
|
-
state.history.labels.shift();
|
|
208
|
-
state.history.requests.shift();
|
|
209
|
-
state.history.avgResponseTimes.shift();
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const trafficChart = state.charts.traffic;
|
|
213
|
-
if (trafficChart?.data.datasets[0] && trafficChart.data.datasets[1]) {
|
|
214
|
-
trafficChart.data.labels = state.history.labels;
|
|
215
|
-
trafficChart.data.datasets[0].data = state.history.requests;
|
|
216
|
-
trafficChart.data.datasets[1].data = state.history.avgResponseTimes;
|
|
217
|
-
trafficChart.update();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const poolChart = state.charts.pool;
|
|
221
|
-
if (poolChart) {
|
|
222
|
-
poolChart.data.labels = state.history.labels;
|
|
223
|
-
pools.forEach((p, i) => {
|
|
224
|
-
const poolName = p.name;
|
|
225
|
-
const history = state.history;
|
|
226
|
-
let usage = history.poolUsage[poolName];
|
|
227
|
-
if (!usage) {
|
|
228
|
-
usage = [];
|
|
229
|
-
history.poolUsage[poolName] = usage;
|
|
230
|
-
const colors = ['#10b981', '#f59e0b', '#3b82f6', '#8b5cf6', '#ec4899'];
|
|
231
|
-
const color = colors[i % colors.length];
|
|
232
|
-
if (color) {
|
|
233
|
-
poolChart.data.datasets.push({
|
|
234
|
-
label: poolName,
|
|
235
|
-
data: usage,
|
|
236
|
-
borderColor: color,
|
|
237
|
-
backgroundColor: undefined,
|
|
238
|
-
fill: undefined,
|
|
239
|
-
tension: 0.4,
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
usage.push(p.connectionsInUse);
|
|
244
|
-
if (usage.length > maxPoints) {
|
|
245
|
-
usage.shift();
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
poolChart.update();
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Create or update a pie chart for cache statistics.
|
|
254
|
-
* @param canvas - The canvas element.
|
|
255
|
-
*/
|
|
256
|
-
export function renderCachePie(canvas: HTMLCanvasElement): void {
|
|
257
|
-
const hits = parseInt(canvas.dataset.hits ?? '0');
|
|
258
|
-
const misses = parseInt(canvas.dataset.misses ?? '0');
|
|
259
|
-
|
|
260
|
-
const existingChart = cachePieInstances.get(canvas);
|
|
261
|
-
if (existingChart?.data.datasets[0]) {
|
|
262
|
-
existingChart.data.datasets[0].data = [hits, misses];
|
|
263
|
-
existingChart.update();
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const chart = new Chart(canvas, {
|
|
268
|
-
type: 'pie',
|
|
269
|
-
data: {
|
|
270
|
-
labels: ['Hits', 'Misses'],
|
|
271
|
-
datasets: [
|
|
272
|
-
{
|
|
273
|
-
data: [hits, misses],
|
|
274
|
-
backgroundColor: ['#10b981', '#ef4444'],
|
|
275
|
-
borderColor: 'transparent',
|
|
276
|
-
},
|
|
277
|
-
],
|
|
278
|
-
},
|
|
279
|
-
options: {
|
|
280
|
-
responsive: true,
|
|
281
|
-
maintainAspectRatio: true,
|
|
282
|
-
plugins: {
|
|
283
|
-
legend: {display: false},
|
|
284
|
-
tooltip: {
|
|
285
|
-
callbacks: {
|
|
286
|
-
label: (context) => {
|
|
287
|
-
const value = context.raw as number;
|
|
288
|
-
const total = hits + misses;
|
|
289
|
-
const pct = total > 0 ? ((value / total) * 100).toFixed(1) : '0';
|
|
290
|
-
return `${context.label}: ${value} (${pct}%)`;
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
cachePieInstances.set(canvas, chart);
|
|
299
|
-
}
|
package/src/admin/client/main.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
@import 'tailwindcss';
|
|
2
|
-
|
|
3
|
-
@theme {
|
|
4
|
-
--color-primary: #3b82f6;
|
|
5
|
-
--color-success: #10b981;
|
|
6
|
-
--color-warning: #f59e0b;
|
|
7
|
-
--color-danger: #ef4444;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
body {
|
|
11
|
-
font-family:
|
|
12
|
-
'Inter',
|
|
13
|
-
-apple-system,
|
|
14
|
-
BlinkMacSystemFont,
|
|
15
|
-
'Segoe UI',
|
|
16
|
-
Roboto,
|
|
17
|
-
Helvetica,
|
|
18
|
-
Arial,
|
|
19
|
-
sans-serif;
|
|
20
|
-
-webkit-font-smoothing: antialiased;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
body.dark {
|
|
24
|
-
--bg-main: #0f172a;
|
|
25
|
-
--bg-side: #1e293b;
|
|
26
|
-
--bg-card: #1e293b;
|
|
27
|
-
--bg-hover: #334155;
|
|
28
|
-
--text-main: #94a3b8;
|
|
29
|
-
--text-bright: #f8fafc;
|
|
30
|
-
--border: #334155;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
body:not(.dark) {
|
|
34
|
-
--bg-main: #f8fafc;
|
|
35
|
-
--bg-side: #ffffff;
|
|
36
|
-
--bg-card: #ffffff;
|
|
37
|
-
--bg-hover: #f1f5f9;
|
|
38
|
-
--text-main: #475569;
|
|
39
|
-
--text-bright: #0f172a;
|
|
40
|
-
--border: #e2e8f0;
|
|
41
|
-
}
|