# Admin Panel — File Manager

A self-contained file manager for your Sapphire RP server.

## Setup

```bash
cd admin-panel
npm install
node server.js
```

Then open `http://YOUR_SERVER_IP:8080` in your browser.

## Config (`config.json`)

| Key | Default | Description |
|-----|---------|-------------|
| `port` | `8080` | Port to listen on |
| `host` | `0.0.0.0` | Bind address |
| `password` | `admin123` | **Change this!** Login password |
| `sessionSecret` | — | Random secret for sessions — change to a long random string |
| `rootDir` | `../` | Root directory to manage (relative to admin-panel/) |
| `allowedExtensions` | see file | File types allowed for download/view |

## Features

- **Browse** any folder on the server
- **Upload** files via button or drag & drop (up to 100 MB per file, 50 files at once)
- **Download** any file
- **Preview** images inline, edit text/JSON/JS/PHP/etc. in-browser
- **Replace** a file in place (keeps same filename)
- **Rename / Move** files and folders
- **Delete** files or entire folders
- **New Folder** creation
- **Multi-select** (Ctrl+Click) and bulk delete
- **Search** by filename recursively
- **Right-click** context menu on any item
- **Grid / List** view toggle (remembered across sessions)
- Quick-access sidebar for common folders

## nginx proxy (optional)

Add to your nginx config to serve behind `/admin/`:

```nginx
location /admin/ {
    proxy_pass http://127.0.0.1:8080/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
}
```

## Running as a service (Linux)

```bash
# /etc/systemd/system/admin-panel.service
[Unit]
Description=Admin Panel
After=network.target

[Service]
WorkingDirectory=/path/to/admin-panel
ExecStart=/usr/bin/node server.js
Restart=always
User=www-data

[Install]
WantedBy=multi-user.target
```

```bash
systemctl enable admin-panel
systemctl start admin-panel
```
