abite 7c30fc4a0c
feat: implement asset and component duplication feature (#79) (#93)
* feat: implement asset and component duplication feature (#79)

Add comprehensive duplication functionality allowing users to create multiple
copies of existing assets and components with sequential naming and sanitized data.

- **Duplicate Buttons**: Added duplicate buttons between Save/Cancel in asset and sub-asset modals
- **Smart Visibility**: Buttons only appear in edit mode (not when creating new items)
- **Sequential Naming**: Duplicates automatically named with incremental numbers (e.g., "Asset Name (1)", "Asset Name (2)")
- **Input Validation**: Users can create 1-100 duplicates with proper validation
- **Data Sanitization**: Excludes serial numbers, warranty info, files, and maintenance events from duplicates
- **Bulk Operations**: Efficient server-side bulk creation endpoints

- **public/index.html**:
  - Added duplicate buttons to asset and sub-asset modal form-actions
  - Added duplicate confirmation modal with count input
  - Updated help text to explain sequential naming and data exclusions

- **public/styles.css**:
  - Added styling for duplicate buttons with hover states
  - Added duplicate modal and input styling
  - Added responsive design support

- **public/managers/modalManager.js**:
  - Extended with complete duplication functionality
  - Added duplicate modal management methods
  - Implemented sequential naming logic
  - Added data sanitization for duplicates

- **public/script.js**:
  - Added duplicate modal to escape key handler
  - Added click-off-to-close functionality
  - Exposed refreshAllData for ModalManager access

- **server.js**:
  - Added `/api/assets/bulk` endpoint for bulk asset creation
  - Added `/api/subassets/bulk` endpoint for bulk sub-asset creation
  - Added validation for bulk operations (max 100 items)
  - Added notification support for bulk operations
  - Restored accidentally removed endpoints (settings, uploads, etc.)

- **Data Processing**: Strips sensitive data while preserving core asset information
- **Error Handling**: Comprehensive validation and user feedback
- **Performance**: Bulk server operations for efficiency
- **UX**: Loading states, success messages, keyboard shortcuts

Perfect for scenarios like:
- Creating multiple identical hard drives with different serial numbers
- Duplicating network equipment across locations
- Bulk adding similar components to inventory
- Setting up template assets for mass deployment

Resolves #79

* reorg styles.css

* Add properties grid to duplicate asset/subasset modal

* Add components and sub components duplication option to duplicate grid

* update file previews for subcomponents to support multiple file paths

* minor updates to duplicate modal styling

* update duplicate sub asset button icon

* Add duplicate button to asset / subasset actions

* apply svg styles to duplicate asset-actions buttons

* Fix component's sub component duplication

* Fix rendering proper asset / subasset after duplication

* refactor duplication/clone assets code into it's own manager class as well as closing asset modals after performing duplication

* fix asset navigation after duplicating an asset

---------

Co-authored-by: gitmotion <43588713+gitmotion@users.noreply.github.com>
2025-06-16 12:18:01 -07:00
2025-06-03 12:31:25 -04:00
2025-05-25 22:20:26 -05:00
2025-04-27 12:16:44 -05:00
2025-04-27 12:16:44 -05:00
2025-05-08 19:40:50 -07:00
2025-04-29 12:38:41 -05:00
2025-04-27 12:16:44 -05:00
2025-06-03 12:31:25 -04:00
2025-06-12 13:49:24 -07:00

DumbAssets

A stupid simple asset tracker for keeping track of your physical assets, their components, and applicable warranties and routine maintenance.

GitHub package.json version Docker Image Version Docker Pulls License GitHub Actions Workflow Status Static Badge

Explore the Demo


Table of Contents


Quick Start

Prerequisites

  • Docker (recommended)
  • Node.js >=14.0.0 (for local development)

Option 1: Docker (For Dummies)

docker run -p 3000:3000 -v ./data:/app/data dumbwareio/dumbassets:latest
  1. Go to http://localhost:3000
  2. Add assets, upload photos/receipts, and track warranties
  3. Celebrate how dumb easy this was

Option 2: Docker Compose (For Dummies who like customizing)

Create a docker-compose.yml file:

services:
  dumbassets:
    container_name: dumbassets
    image: dumbwareio/dumbassets:latest
    restart: unless-stopped
    ports: 
      - ${DUMBASSETS_PORT:-3000}:3000
    volumes:
      - ${DUMBASSETS_DATA_PATH:-./data}:/app/data
    environment:
      NODE_ENV: ${DUMBASSETS_NODE_ENV:-production}
      DEBUG: ${DUMBASSETS_DEBUG:-true}
      SITE_TITLE: ${DUMBASSETS_SITE_TITLE:-DumbAssets}
      BASE_URL: ${DUMBASSETS_BASE_URL:-http://localhost:3000}
      DUMBASSETS_PIN: ${DUMBASSETS_PIN:-1234}
      ALLOWED_ORIGINS: ${DUMBASSETS_ALLOWED_ORIGINS:-*}
      APPRISE_URL: ${DUMBASSETS_APPRISE_URL:-}
      CURRENCY_CODE: ${DUMBASSETS_CURRENCY_CODE:-USD}
      CURRENCY_LOCALE: ${DUMBASSETS_CURRENCY_LOCALE:-en-US}
      # ...other env vars

Then run:

docker compose up -d
  1. Go to http://localhost:3000
  2. Add and manage your assets

Option 3: Running Locally (For Developers)

git clone https://github.com/yourusername/DumbAssets.git
cd DumbAssets
npm install
npm start

Open your browser to http://localhost:3000


Features

  • 🚀 Track assets with detailed info (model, serial, warranty, etc.)
  • 🧩 Add components and sub-components
  • 🖼️ Upload and store photos and receipts
  • 🔍 Search by name, model, serial, or description
  • 🏷️ Hierarchical organization of components
  • 📅 Warranty expiration notifications (configurable)
  • 🔧 Maintenance event notifications
  • 🏷️ Flexible tagging system for better organization
  • 🔔 Built in Apprise notification integration
  • 🌗 Light/Dark mode with theme persistence
  • 🛡️ PIN authentication with brute force protection
  • 📦 Docker support for easy deployment
  • 🔗 Direct Asset Linking: Notifications include links to the specific asset

Configuration

Environment Variables

Variable Description Default Required
PORT Server port 3000 No
DUMBASSETS_PIN PIN protection (4+ digits) None No
APPRISE_URL Apprise URL for notifications None No
TZ Container timezone America/Chicago No
BASE_URL Base URL for the application http://localhost No
SITE_TITLE Site title shown in browser tab and header DumbAssets No
ALLOWED_ORIGINS Origins allowed to visit your instance '*' No
DEMO_MODE Enables read-only mode false No
CURRENCY_CODE ISO 4217 currency code for price formatting USD No
CURRENCY_LOCALE Locale for currency formatting en-US No

Tip

Apprise integration is built-in to DumbAssets, allowing you to simply add your Discord/ntfy/Telegram/etc link WITHOUT having to run Apprise as a separate service!

💰 Currency Configuration

DumbAssets supports multiple currencies via environment variables. The application uses the standard ISO 4217 currency codes and locale formatting.

Environment Variables

CURRENCY_CODE

  • Default: USD
  • Description: The ISO 4217 currency code for price formatting
  • Examples: USD, EUR, GBP, CAD, AUD, JPY

CURRENCY_LOCALE

  • Default: en-US
  • Description: The locale for currency formatting (affects number formatting, decimal separators, etc.)
  • Examples: en-US, en-GB, de-DE, fr-FR, ja-JP

Usage Examples

US Dollar (Default)

# No configuration needed - this is the default

Euro (Germany)

export CURRENCY_CODE=EUR
export CURRENCY_LOCALE=de-DE

British Pound

export CURRENCY_CODE=GBP
export CURRENCY_LOCALE=en-GB

Canadian Dollar

export CURRENCY_CODE=CAD
export CURRENCY_LOCALE=en-CA

Japanese Yen

export CURRENCY_CODE=JPY
export CURRENCY_LOCALE=ja-JP

Docker Configuration

Docker Compose

services:
  dumbassets:
    environment:
      - CURRENCY_CODE=EUR
      - CURRENCY_LOCALE=de-DE

Docker Run

docker run -e CURRENCY_CODE=EUR -e CURRENCY_LOCALE=de-DE dumbassets

Currency Format Examples

Different locales will format the same amount differently:

Locale Currency Amount: 1234.56 Formatted Output
en-US USD 1234.56 $1,234.56
de-DE EUR 1234.56 1.234,56 €
en-GB GBP 1234.56 £1,234.56
fr-FR EUR 1234.56 1 234,56 €
ja-JP JPY 1234.56 ¥1,235

Supported Currency Codes

Any valid ISO 4217 currency code is supported. Common examples include:

  • USD - US Dollar
  • EUR - Euro
  • GBP - British Pound
  • CAD - Canadian Dollar
  • AUD - Australian Dollar
  • JPY - Japanese Yen
  • CHF - Swiss Franc
  • CNY - Chinese Yuan
  • INR - Indian Rupee
  • BRL - Brazilian Real
  • MXN - Mexican Peso
  • SEK - Swedish Krona
  • NOK - Norwegian Krone
  • DKK - Danish Krone

For a complete list, refer to the ISO 4217 standard.

Data Storage

All data is stored in JSON files in the /data directory:

  • /data/Assets.json - All asset data
  • /data/SubAssets.json - All component data
  • /data/Images - Uploaded photos
  • /data/Receipts - Uploaded receipts
  • /data/config.json - Notification and app config

Security

  • Variable-length PIN support (4+ digits)
  • Constant-time PIN comparison
  • Brute force protection (lockout after too many attempts)
  • Secure session cookies
  • No client-side PIN storage
  • Rate limiting

Technical Details

Stack

  • Backend: Node.js (>=14.0.0) with Express
  • Frontend: Vanilla JavaScript (ES6+)
  • Container: Docker with Alpine base
  • Notifications: Apprise integration (via Python)
  • Uploads: Multer for file handling
  • Scheduling: node-cron for warranty & Maintenance notifications

Dependencies

  • express: Web framework for Node.js
  • multer: File upload handling and multipart/form-data parsing
  • apprise: Notification system integration for alerts
  • cors: Cross-origin resource sharing middleware
  • dotenv: Environment variable configuration management
  • express-rate-limit: Rate limiting middleware for API protection
  • express-session: Session management and authentication
  • cookie-parser: Cookie parsing middleware
  • node-cron: Task scheduling for notifications
  • uuid: Unique ID generation for assets
  • sharp: Image processing and optimization
  • compression: Response compression middleware
  • helmet: Security headers middleware
  • fs-extra: Enhanced filesystem operations
  • path: Path manipulation utilities

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes using Conventional Commits
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

See the Development Guide for local setup and guidelines.


Support the Project

Buy Me A Coffee

Made with ❤️ by DumbWare.io

Description
Languages
JavaScript 78%
CSS 11.6%
HTML 10.3%
Dockerfile 0.1%