npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-red-contrib-fox-control-panel

v5.0.4

Published

一个用来管理FoxControlServer的插件,基于SQLite数据库

Readme

FoxControl 面板插件

一个 FoxControl 插件,提供类似 PocketBase 的管理面板,基于 SQLite 支持动态表管理和 CRUD 操作。

功能特性

核心功能

  • 动态表管理:通过 Web 界面创建和管理 SQLite 表
  • 模式演进:在不丢失数据的情况下为现有集合添加新字段
  • 多数据库架构:创建和管理多个 SQLite 数据库
  • 管理仪表盘:基于 Vue.js 的管理面板,访问地址 /foxcontrol_panel/
  • CRUD 操作:完整的创建、读取、更新、删除功能
  • 高级 Upsert 操作:支持可配置匹配字段的插入或更新
  • REST API:所有操作的完整 REST API
  • 字段类型:支持文本、数字、整数、布尔值、日期、JSON、电子邮件和 URL 字段
  • 字段属性:必填、唯一和可索引字段选项,优化性能
  • 数据导出:将集合数据导出为 JSON 格式
  • 实时模式更新:修改表结构同时保留现有数据

FoxControl 集成

  • 6 个自定义节点:查询、插入、更新、删除、Upsert 和事件监听节点
  • 数据库下拉框:节点编辑器中动态选择数据库和集合
  • 消息覆盖:使用 msg 属性动态覆盖节点配置
  • 事件系统:基于 SQLite 触发器的实时数据库变更通知
  • 面板按钮:FoxControl 编辑器头部的快速访问按钮

高级功能

  • 审计日志:全面跟踪所有系统变更,包含用户身份识别
  • 数据库事件:基于 SQLite 触发器的事件系统,用于实时通知
  • 服务端分页:高效的数据浏览,支持可配置的每页数量和偏移量
  • 高级排序:点击列标题排序,带有可视化指示器
  • 列可见性控制:显示/隐藏列,支持 localStorage 持久化
  • 行内编辑:在数据浏览器中直接编辑单元格
  • 日志模式管理:按数据库配置 SQLite 日志模式(DELETE、WAL、MEMORY)
  • 性能优化:自动为唯一字段和可索引字段建立索引
  • 安全性:基于内部令牌的身份验证,用于 FoxControl 编辑器端点

安装方式

通过 NPM 安装(推荐)

cd ~/.node-red
npm install node-red-contrib-foxcontrol-panel

从源码安装

  1. 在 FoxControl 用户目录中安装插件:
cd ~/.node-red
npm install /path/to/node-red-contrib-foxcontrol-panel
  1. 构建管理界面(仅源码安装需要):
cd node_modules/node-red-contrib-foxcontrol-panel/lib/admin
npm install
npm run build
  1. 重启 FoxControl

使用说明

管理面板

安装完成后,访问管理面板地址:http://localhost:1880/foxcontrol_panel/

管理面板提供以下功能:

  • 仪表盘:实时审计日志和系统活动概览
  • 数据库管理器:创建、管理和配置多个 SQLite 数据库
  • 集合管理器:在任何数据库中创建、编辑和删除集合
  • 数据浏览器:高级数据浏览,支持分页、排序和行内编辑
  • API 浏览器:直接从浏览器测试 API 端点

多数据库架构

插件支持多数据库:

  • 主数据库:包含系统元数据、审计日志和数据库注册表
  • 自定义数据库:为不同项目/环境创建无限数量的附加数据库
  • 数据库切换:在管理界面中无缝切换数据库
  • 隔离集合:每个数据库维护自己的集合和数据集

FoxControl 节点

插件在 "Panel" 分类下提供 6 个自定义节点:

  1. 查询节点:从集合查询数据

    • 操作:find、findOne、count
    • 数据库和集合下拉选择
    • 通过 msg.query 动态查询参数
    • 可选静态查询配置
  2. 插入节点:插入新记录

    • 数据库和集合下拉选择
    • 在 msg.payload 中发送记录数据
    • 可选静态数据用于测试
  3. 更新节点:更新现有记录

    • 数据库和集合下拉选择
    • 在 msg.payload 中发送包含 id 的记录
    • 可选静态数据用于测试
  4. 删除节点:删除记录

    • 数据库和集合下拉选择
    • 在 msg.payload 中发送记录 id
    • 可选静态记录 ID 用于测试
  5. Upsert 节点:高级插入或更新操作

    • 可配置的匹配字段用于冲突解决
    • 三种模式:upsert、updateOnly、insertOnly
    • 可视化匹配字段选择器,带唯一/索引指示器
    • 生成操作的 SQL 预览
  6. 监听节点:实时数据库事件监控

    • 监听 INSERT、UPDATE、DELETE 事件
    • 可配置轮询间隔和批处理大小
    • 自动确认已处理的事件
    • 仅显示启用事件的集合

消息覆盖支持

当启用"使用 msg 属性"时,所有节点都支持通过消息属性进行动态配置:

  • msg.database - 覆盖配置的数据库
  • msg.collection - 覆盖配置的集合
  • 节点特定参数(query、data、matchFields 等)

API 接口

多数据库支持

  • GET /foxcontrol_panel/api/databases - 列出所有数据库
  • POST /foxcontrol_panel/api/databases - 创建新数据库
  • PUT /foxcontrol_panel/api/databases/:name - 更新数据库
  • DELETE /foxcontrol_panel/api/databases/:name - 删除数据库
  • POST /foxcontrol_panel/api/databases/:name/set-default - 设置默认数据库

集合操作(数据库上下文)

  • GET /foxcontrol_panel/api/:database/collections - 列出数据库中的集合
  • POST /foxcontrol_panel/api/:database/collections - 在数据库中创建集合
  • GET /foxcontrol_panel/api/:database/collections/:name - 获取集合详情
  • PUT /foxcontrol_panel/api/:database/collections/:name - 更新集合
  • DELETE /foxcontrol_panel/api/:database/collections/:name - 删除集合

记录操作(数据库上下文)

  • GET /foxcontrol_panel/api/:database/:collection - 分页/排序列出记录
  • POST /foxcontrol_panel/api/:database/:collection - 创建记录
  • GET /foxcontrol_panel/api/:database/:collection/:id - 获取记录
  • PUT /foxcontrol_panel/api/:database/:collection/:id - 更新记录
  • DELETE /foxcontrol_panel/api/:database/:collection/:id - 删除记录

系统与审计

  • GET /foxcontrol_panel/api/audit - 获取审计日志条目
  • GET /foxcontrol_panel/api/audit/stats - 获取审计统计信息
  • GET /foxcontrol_panel/api/audit/filters - 获取可用过滤器
  • POST /foxcontrol_panel/api/audit/cleanup - 清理旧审计条目
  • GET /foxcontrol_panel/api/system - 系统健康状态和信息

FoxControl 集成接口

  • GET /foxcontrol_panel/node-databases - 获取节点下拉框用的数据库列表
  • GET /foxcontrol_panel/node-collections?database=name - 获取节点下拉框用的集合列表
  • GET /foxcontrol_panel/event-collections?database=name - 获取启用事件的集合列表

使用示例

基本 CRUD 操作流程

[
    {
        "id": "inject1",
        "type": "inject",
        "name": "创建用户",
        "props": [{
            "p": "payload",
            "v": "{\"name\":\"张三\",\"email\":\"[email protected]\",\"active\":true}",
            "vt": "json"
        }],
        "wires": [["insert1"]]
    },
    {
        "id": "insert1",
        "type": "insert",
        "name": "插入用户",
        "database": "master",
        "collection": "users",
        "wires": [["debug1"]]
    },
    {
        "id": "debug1",
        "type": "debug",
        "name": "结果"
    }
]

高级 Upsert 与事件监听

[
    {
        "id": "upsert1",
        "type": "upsert",
        "name": "产品 Upsert",
        "database": "inventory",
        "collection": "products",
        "matchFields": ["sku"],
        "mode": "upsert",
        "wires": [["debug1"]]
    },
    {
        "id": "listener1",
        "type": "listener",
        "name": "产品事件",
        "database": "inventory", 
        "collection": "products",
        "eventTypes": ["INSERT", "UPDATE"],
        "pollingInterval": 5,
        "wires": [["debug2"]]
    }
]

数据库存储

主数据库

  • 存储位置{FoxControl 用户目录}/panel.db
  • 包含内容:系统元数据、审计日志、数据库注册表

附加数据库

  • 存储位置{FoxControl 用户目录}/panel_databases/{数据库名称}.db
  • 包含内容:每个自定义数据库的集合和数据

开发指南

项目结构

@digitalnodecom/FoxControl-contrib-panel/
├── lib/
│   ├── panel.js              # FoxControl 主集成 & Express 服务器
│   ├── panel.html            # 节点编辑器 UI 定义  
│   ├── api/                  # REST API 实现
│   │   ├── controllers/      # API 路由处理器
│   │   ├── middlewares/      # 验证中间件
│   │   └── router.js         # API 路由
│   ├── database/             # SQLite 数据库层
│   │   ├── db.js             # 数据库连接与初始化
│   │   ├── dbManager.js      # 多数据库管理
│   │   ├── audit.js          # 审计日志系统
│   │   ├── schema.js         # 集合管理
│   │   └── triggers.js       # 基于 SQLite 触发器的事件系统
│   ├── security/             # 身份验证与令牌
│   └── admin/                # Vue.js 管理界面
│       ├── src/              # Vue 源代码
│       └── dist/             # 构建后的管理界面
├── icons/                    # 节点图标 (FoxControl-panel.svg)
├── examples/                 # 示例 FoxControl 流程
└── package.json

构建管理界面

cd lib/admin
npm install
npm run dev    # 开发模式
npm run build  # 生产构建

系统要求

  • FoxControl >= 2.0.0
  • Node.js >= 14.0.0

许可证

MIT