Major UI overhaul: bigger icons, creative inventory tabs, grouped smelting, alerts popup, analytics, mod icons
- Inventory: Bigger item icons (48px) filling their slots, MC-style hover tooltips - Creative inventory category tabs (All/Blocks/Tools/Combat/Food/Redstone/Materials/Misc) - Smelting recipes grouped by output item with collapsible sections - Alerts moved from full tab to popup overlay triggered from header bell icon - New Analytics tab with SVG charts (storage over time, top items, item trend lookup) - Mod icon support for ComputerCraft (CC:Tweaked) via GitHub CDN fallback - Server: new /api/history-summary endpoint for aggregate storage history - Store: fetchHistorySummary and fetchItemHistory for analytics data
This commit is contained in:
@@ -124,6 +124,13 @@ const getItemHistory = db.prepare(`
|
||||
LIMIT ?
|
||||
`);
|
||||
|
||||
const getHistorySummaryStmt = db.prepare(`
|
||||
SELECT recorded_at as recordedAt, SUM(count) as total
|
||||
FROM item_history
|
||||
GROUP BY recorded_at
|
||||
ORDER BY recorded_at ASC
|
||||
`);
|
||||
|
||||
// Cleanup old history (keep last 7 days)
|
||||
const cleanupHistory = db.prepare(`
|
||||
DELETE FROM item_history WHERE recorded_at < ?
|
||||
@@ -292,6 +299,13 @@ export function getHistory(itemName, limit = 100) {
|
||||
return getItemHistory.all(itemName, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get aggregate total item count over time
|
||||
*/
|
||||
export function getHistorySummary() {
|
||||
return getHistorySummaryStmt.all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the full last-known inventory state from DB
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import { createServer } from 'http';
|
||||
import {
|
||||
loadFullState, saveFullState, recordItemHistory,
|
||||
saveItems, saveFurnaces, saveAlerts, saveState,
|
||||
getHistory, closeDb, flushPendingSave,
|
||||
getHistory, getHistorySummary, closeDb, flushPendingSave,
|
||||
} from './db.js';
|
||||
|
||||
const app = express();
|
||||
@@ -118,6 +118,12 @@ app.get('/api/history/:itemName', (req, res) => {
|
||||
res.json({ item: req.params.itemName, history });
|
||||
});
|
||||
|
||||
// Get aggregate storage history (total items over time)
|
||||
app.get('/api/history-summary', (req, res) => {
|
||||
const summary = getHistorySummary();
|
||||
res.json({ history: summary });
|
||||
});
|
||||
|
||||
// Get recipes (smeltable + craftable)
|
||||
app.get('/api/recipes', (req, res) => {
|
||||
res.json({
|
||||
|
||||
Reference in New Issue
Block a user