Versie 0.3.3
This commit is contained in:
1 parent
1cf6eeed29
commit
6e741a51fe
57 files changed
+1362
-2135
No files matched your search
@@ -1,4 +1,4 @@
|
||||
// Generated, do not edit. sha256:329990ff910102e84cb67048624a913db4948fa6ef673de3eb40c65c633864ba
|
||||
// Generated, do not edit. sha256:bf3b89b4669e19b78df9f4741f695e6025ab616c2c0a5f205b84e84c1ce21f92
|
||||
import * as db from '../db.js';
|
||||
import { ASSET_DEFINITIONS, DASHBOARD } from '../../shared/config.js';
|
||||
import { toSearchName } from '../../shared/search-name.js';
|
||||
@@ -38,6 +38,8 @@ async function ensureAccount({ name, kind }) {
|
||||
return createAccount({ name, kind, isOwnCustody: own, scanEnabled: false, taxCategory: null });
|
||||
}
|
||||
|
||||
const SETUP_SPAN = 4;
|
||||
|
||||
function placeInFreeSpace(rows, items) {
|
||||
const cols = DASHBOARD.GRID_COLUMNS;
|
||||
const heightOf = (type, h) => (h > 0 ? h : DASHBOARD.WIDGETS[type]?.defaultH || 1);
|
||||
@@ -47,7 +49,7 @@ function placeInFreeSpace(rows, items) {
|
||||
for (let c = r.gridX; c < Math.min(cols, r.gridX + r.spanWidth); c++) bottom[c] = Math.max(bottom[c], end);
|
||||
}
|
||||
return items.map(({ prefer, ...w }) => {
|
||||
const span = DASHBOARD.WIDGETS[w.type].defaultSpan;
|
||||
const span = w.spanWidth ?? DASHBOARD.WIDGETS[w.type].defaultSpan;
|
||||
let bestX = 0, bestY = Infinity;
|
||||
for (let x = 0; x + span <= cols; x++) {
|
||||
const y = Math.max(...bottom.slice(x, x + span));
|
||||
@@ -74,7 +76,7 @@ export async function completeSetup({ assets = [], persona = 'broad', accounts =
|
||||
const add = [];
|
||||
if (widgets.includes('standing')) add.push({ type: 'standing', prefer: 4 });
|
||||
if (widgets.includes('signal') && persona === 'bitcoin') add.push({ type: 'signal', prefer: 4 });
|
||||
if (widgets.includes('spot')) assetIds.forEach(id => add.push({ type: 'spot', instanceKey: `spot-${id}`, assetId: id, prefer: 0, settings: { momentum: false } }));
|
||||
if (widgets.includes('spot')) assetIds.forEach(id => add.push({ type: 'spot', instanceKey: `spot-${id}`, assetId: id, prefer: 0, settings: { momentum: false }, spanWidth: SETUP_SPAN }));
|
||||
let widgetCount = 0;
|
||||
for (const w of placeInFreeSpace(listWidgets(profileId), add)) if (await addWidget(profileId, w)) widgetCount++;
|
||||
|
||||
|
||||
Reference in new issue
Block a user