# DEV Portal - Dokumentation

## Oversigt

DEV Portal er en selvstændig app i BMC Hub til at planlægge og dokumentere udviklingsarbejde.

**URL**: [http://localhost:8001/devportal](http://localhost:8001/devportal)

**Adgang**: Via bruger dropdown menu → "DEV Portal"

## Funktioner

### 1. Roadmap (Kanban Board)
- **Version Tagging**: V1, V2, V3, osv.
- **Statuser**: 
  - ✅ Planlagt
  - ⏳ I Gang
  - ✅ Færdig
  - ⏸️ Sat på Pause
- **Prioritering**: 1-100 (lav-høj)
- **Datoer**: Forventet dato + afsluttet dato
- **Filtering**: Filtrer efter version (V1/V2/V3)

### 2. Idéer (Brainstorming)
- Opret nye idéer med titel, beskrivelse og kategori
- **Voting System**: Stem på gode idéer (thumbs up)
- **Kategorier**: UI/UX, Integration, Automatisering, Sikkerhed, Andet
- Sortering: Automatisk efter antal stemmer

### 3. Workflows (Diagram Editor)
- **Draw.io Integration**: Embedded diagram editor
- **Typer**: Flowchart, Proces, System Diagram
- **Lagring**: XML gemmes direkte i database
- **Redigering**: Klik "Rediger" for at åbne eksisterende workflow

## Database Struktur

### dev_features
```sql
- id (SERIAL PRIMARY KEY)
- title (VARCHAR(255))
- description (TEXT)
- version (VARCHAR(50)) -- V1, V2, V3, etc.
- status (VARCHAR(50)) -- planlagt, i gang, færdig, sat på pause
- priority (INTEGER) -- 1-100
- expected_date (DATE)
- completed_date (DATE)
- created_at, updated_at (TIMESTAMP)
```

### dev_ideas
```sql
- id (SERIAL PRIMARY KEY)
- title (VARCHAR(255))
- description (TEXT)
- category (VARCHAR(50))
- votes (INTEGER) -- voting system
- created_at, updated_at (TIMESTAMP)
```

### dev_workflows
```sql
- id (SERIAL PRIMARY KEY)
- title (VARCHAR(255))
- description (TEXT)
- category (VARCHAR(50))
- diagram_xml (TEXT) -- draw.io XML format
- thumbnail_url (VARCHAR(500))
- created_at, updated_at (TIMESTAMP)
```

## API Endpoints

### Features
- `GET /api/v1/devportal/features` - List alle features
  - Query params: `?version=V1&status=færdig`
- `GET /api/v1/devportal/features/{id}` - Hent specifik feature
- `POST /api/v1/devportal/features` - Opret ny feature
- `PUT /api/v1/devportal/features/{id}` - Opdater feature
- `DELETE /api/v1/devportal/features/{id}` - Slet feature

### Ideas
- `GET /api/v1/devportal/ideas` - List alle idéer
  - Query params: `?category=integration`
- `POST /api/v1/devportal/ideas` - Opret ny idé
- `POST /api/v1/devportal/ideas/{id}/vote` - Stem på idé
- `DELETE /api/v1/devportal/ideas/{id}` - Slet idé

### Workflows
- `GET /api/v1/devportal/workflows` - List alle workflows
  - Query params: `?category=process`
- `GET /api/v1/devportal/workflows/{id}` - Hent specifik workflow
- `POST /api/v1/devportal/workflows` - Opret ny workflow
- `PUT /api/v1/devportal/workflows/{id}` - Opdater workflow
- `DELETE /api/v1/devportal/workflows/{id}` - Slet workflow

### Stats
- `GET /api/v1/devportal/stats` - Hent statistik
  ```json
  {
    "features_count": 6,
    "ideas_count": 4,
    "workflows_count": 0,
    "features_by_status": [
      {"status": "færdig", "count": 3},
      {"status": "planlagt", "count": 3}
    ]
  }
  ```

## Frontend Routes

- `GET /devportal` - Hovedside med Kanban board, idéer og workflows
- `GET /devportal/editor?id={id}` - Workflow editor (draw.io)

## Draw.io Integration

### Embed URL
```
https://embed.diagrams.net/?embed=1&ui=kennedy&spin=1&proto=json
```

### postMessage API
```javascript
// Load existing diagram
iframe.contentWindow.postMessage(JSON.stringify({
    action: 'load',
    autosave: 1,
    xml: '<mxfile>...</mxfile>'
}), '*');

// Export diagram
iframe.contentWindow.postMessage(JSON.stringify({
    action: 'export',
    format: 'xml'
}), '*');
```

### Events
- `init` - Editor is ready
- `autosave` - Diagram changed (auto-save)
- `export` - Export completed (returns XML)
- `save` - User clicked save

## Eksempel Data

### Features (6 stk.)
1. **Dashboard Forbedringer** (V1, færdig)
2. **Global Søgning** (V1, færdig)
3. **Settings & Brugerstyring** (V1, færdig)
4. **vTiger CRM Integration** (V2, planlagt)
5. **e-conomic Integration** (V2, planlagt)
6. **Rapport Generator** (V3, planlagt)

### Ideas (4 stk.)
1. **Eksport til Excel** (15 votes)
2. **Mobile app** (12 votes)
3. **AI Assistent** (8 votes)
4. **Dark mode forbedringer** (5 votes)

## Fjernelse af DEV Portal

Da dette er en selvstændig app, kan den nemt fjernes:

1. **Fjern fra main.py**:
   ```python
   # Remove imports
   from app.devportal.backend import router as devportal_api
   from app.devportal.backend import views as devportal_views
   
   # Remove router registrations
   app.include_router(devportal_api.router, ...)
   app.include_router(devportal_views.router, ...)
   ```

2. **Fjern menu link** fra `app/shared/frontend/base.html`:
   ```html
   <li><a class="dropdown-item py-2" href="/devportal">...</a></li>
   ```

3. **Slet filer**:
   ```bash
   rm -rf app/devportal/
   ```

4. **Valgfri: Drop database tables**:
   ```sql
   DROP TABLE IF EXISTS dev_workflows CASCADE;
   DROP TABLE IF EXISTS dev_ideas CASCADE;
   DROP TABLE IF EXISTS dev_features CASCADE;
   ```

## Fremtidige Forbedringer

- [ ] Drag-and-drop i Kanban board (flyt features mellem kolonner)
- [ ] Workflow thumbnails (PNG preview fra XML)
- [ ] Export roadmap til PDF eller Excel
- [ ] GitHub/Gitea integration (link features til commits/PRs)
- [ ] Kommentarer på features og idéer
- [ ] Notifikationer ved status ændringer
- [ ] Tidsregistrering per feature
- [ ] Sprint planning funktionalitet
- [ ] Access control (admin-only vs alle brugere)

## Teknisk Implementation

### Filer Oprettet
```
migrations/007_dev_portal.sql          # Database schema
app/devportal/backend/router.py        # API endpoints (17 stk.)
app/devportal/backend/views.py         # Frontend routes (2 stk.)
app/devportal/frontend/portal.html     # Hovedside (Kanban + Ideas + Workflows)
app/devportal/frontend/editor.html     # Draw.io editor
```

### Dependencies
- Bootstrap 5.3.2 (UI komponenter)
- Draw.io Embed (workflow editor)
- Fetch API (AJAX requests)
- Jinja2 (template rendering)

### Browser Support
- Chrome/Edge 90+
- Firefox 88+
- Safari 14+

## Support

For problemer eller spørgsmål, kontakt udviklingsteamet eller opret en ny idé i DEV Portal.
