mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-29 00:05:01 +00:00
WorkflowEditor (325→80): CWorkflowState.qml + WorkflowConnectionState.js DashboardView (121→95): DashboardDBAL.js + config/dashboard-config.json Storybook (114→78): StorybookSidebar + config/storybook-components.json + 7 components compacted to under 100 via formatting (no logic changes) + Multiple view/component splits across all remaining 100+ LOC files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
2.0 KiB
JavaScript
46 lines
2.0 KiB
JavaScript
// DatabaseLogic.js — DBAL + utility logic for DatabaseManager
|
|
|
|
function formatSize(kb) { return kb < 1024 ? kb + " KB" : (kb / 1024).toFixed(1) + " MB" }
|
|
|
|
function totalRecords(backends) {
|
|
var s = 0; for (var i = 0; i < backends.length; i++) s += backends[i].records; return s
|
|
}
|
|
|
|
function totalSize(backends) {
|
|
var s = 0; for (var i = 0; i < backends.length; i++) s += backends[i].sizeKb; return s
|
|
}
|
|
|
|
function connectedCount(backends) {
|
|
var c = 0; for (var i = 0; i < backends.length; i++) if (backends[i].status === "connected") c++; return c
|
|
}
|
|
|
|
function testConnectionLive(root, dbal, testTimer, index) {
|
|
root.testingIndex = index
|
|
if (root.useLiveData) {
|
|
dbal.execute("core/test-connection", { adapter: root.backends[index].key }, function(result, error) {
|
|
var newResults = Object.assign({}, root.testResults)
|
|
newResults[index] = (!error && result && result.success) ? "success" : "error"
|
|
root.testResults = newResults; root.testingIndex = -1
|
|
})
|
|
} else { testTimer.targetIndex = index; testTimer.start() }
|
|
}
|
|
|
|
function loadAdapterStatus(root, dbal) {
|
|
dbal.execute("core/adapters", {}, function(result, error) {
|
|
if (!error && result && result.adapters && result.adapters.length > 0) {
|
|
var liveBackends = []
|
|
for (var i = 0; i < result.adapters.length; i++) {
|
|
var a = result.adapters[i]
|
|
liveBackends.push({
|
|
name: a.name || "", key: a.key || "", status: a.status || "disconnected",
|
|
description: a.description || "", connectionString: a.connectionString || "",
|
|
records: a.records || 0, sizeKb: a.sizeKb || 0, lastBackup: a.lastBackup || "Never"
|
|
})
|
|
}
|
|
root.backends = liveBackends
|
|
if (root.selectedBackendIndex >= liveBackends.length) root.selectedBackendIndex = 0
|
|
if (root.activeBackendIndex >= liveBackends.length) root.activeBackendIndex = 0
|
|
}
|
|
})
|
|
}
|