From 061869384ae641ef1b4e3e59b845613274213e12 Mon Sep 17 00:00:00 2001 From: setonc Date: Fri, 27 Mar 2026 09:41:30 -0400 Subject: [PATCH] Remove unused defaultCustomerId/Name config; add README --- README.md | 90 ++++++++++++++++++++++++++++++++++++++++++++ public/api/syncro.js | 7 +--- public/config.js | 2 - 3 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..2efb57d --- /dev/null +++ b/README.md @@ -0,0 +1,90 @@ +# Asset Browser + +A self-hosted web application for browsing and managing assets pulled from Syncro MSP. Provides role-based access for technicians and clients, barcode label generation, and a label queue for batch printing. + +Built by Carmichael Computing. + +--- + +## Requirements + +- Node.js 22 or higher +- PM2 (`npm install -g pm2`) +- A Syncro MSP account with API access +- A reverse proxy (nginx recommended) for production + +--- + +## Installation + +**1. Clone the repository and install dependencies** + +``` +git clone https://git.farmtowntech.com/setonc/asset_browser.git +cd asset_browser +npm install +``` + +**2. Configure environment** + +``` +cp .env.example .env +``` + +Edit `.env` and fill in the following: + +- `SESSION_SECRET` — a long random string, generate one with: + ``` + node -e "console.log(require('crypto').randomBytes(64).toString('hex'))" + ``` +- `SYNCRO_BASE_URL` — your Syncro API base URL, e.g. `https://yoursubdomain.syncromsp.com/api/v1` +- `SYNCRO_API_KEY` — your Syncro API key + +**3. Configure the client** + +Edit `public/config.js` and update the `syncro` block with your Syncro subdomain and base URL. + +**4. Update the PM2 config** + +Edit `ecosystem.config.js` and set `cwd` to the absolute path of the installation directory, and update `name` if desired. + +**5. Create the first admin user** + +``` +npm run create-user +``` + +Follow the prompts. Choose the `superduperadmin` role for full access. + +**6. Start the server** + +``` +pm2 start ecosystem.config.js +pm2 save +``` + +The server listens on port 3000 by default. Point your reverse proxy at it. + +--- + +## User Management + +The `create-user` script handles all user management from the command line: + +``` +npm run create-user # create a new user (interactive) +npm run create-user list # list all users +npm run create-user deactivate # deactivate a user +npm run create-user reset # reset a user's password +``` + +--- + +## Roles + +| Role | Access | +|------------------|---------------------------------------------| +| superduperadmin | Full access including server management | +| admin | User management and all standard features | +| tech | Asset browsing, label printing | +| client | Read-only access scoped to their company | diff --git a/public/api/syncro.js b/public/api/syncro.js index 66cbaf7..5490073 100755 --- a/public/api/syncro.js +++ b/public/api/syncro.js @@ -1,7 +1,4 @@ import { apiRequest } from './utils.js'; -import CONFIG from '../config.js'; - -const { defaultCustomerId } = CONFIG.app; // ── Assets ─────────────────────────────────────────────────────────────────── @@ -28,7 +25,7 @@ export async function updateAsset(id, fields, customerId) { // ── Contacts ───────────────────────────────────────────────────────────────── // Fetches via Node.js server cache — server handles pagination internally -export async function getContacts(customerId = defaultCustomerId) { +export async function getContacts(customerId) { const res = await fetch(`/api/contacts/${customerId}`, { credentials: 'same-origin', headers: { Accept: 'application/json' }, @@ -63,7 +60,7 @@ export async function getCustomerAssets(customerId) { // ── Tickets ────────────────────────────────────────────────────────────────── -export async function getTickets(customerId = defaultCustomerId) { +export async function getTickets(customerId) { const data = await apiRequest('GET', '/tickets', null, { customer_id: customerId, per_page: 100, // fetch enough to filter client-side by contact diff --git a/public/config.js b/public/config.js index 42459f3..e527b65 100755 --- a/public/config.js +++ b/public/config.js @@ -7,8 +7,6 @@ const CONFIG = { }, app: { idleTimeout: 180000, // ms before returning to scan mode (3 minutes) - defaultCustomerId: 33332476, - defaultCustomerName: 'Prime Home Health', }, };