From 19672b8559ea54910def9d775473f4baa79dafbe Mon Sep 17 00:00:00 2001 From: rbsetiawan Date: Thu, 9 Jul 2026 17:23:12 +0700 Subject: [PATCH] feat(GeoNetAgent): IT Support API, attachments, and asset ticket counts Add support case CRUD, photo attachments, change log, and global stats/list for PWA integration. Asset list exposes ticket count and active status. Includes migrations 008-010, collector UI, tests, ADR-004, and session handover. Co-authored-by: Cursor --- GeoNetAgent/agent/Collect-GeoNetReport.ps1 | 7 +- GeoNetAgent/agent/README.md | 1 + GeoNetAgent/agent/Send-GeoNetReport.ps1 | 16 +- GeoNetAgent/agent/VERSION | 2 +- GeoNetAgent/agent/install/index.html | 30 +- GeoNetAgent/agent/install/manifest.json | 2 +- GeoNetAgent/agent/lib/Agent-InstallCore.ps1 | 19 + GeoNetAgent/agent/lib/Get-GpuInfo.ps1 | 204 +++++- GeoNetAgent/collector/app/api/v1/assets.py | 17 +- .../collector/app/api/v1/attachments.py | 117 ++++ GeoNetAgent/collector/app/api/v1/router.py | 4 +- GeoNetAgent/collector/app/api/v1/support.py | 154 +++++ GeoNetAgent/collector/app/config.py | 16 + GeoNetAgent/collector/app/db/models.py | 81 +++ .../collector/app/schemas/asset_changes.py | 26 + GeoNetAgent/collector/app/schemas/assets.py | 3 + .../collector/app/schemas/attachments.py | 78 +++ GeoNetAgent/collector/app/schemas/support.py | 247 ++++++++ .../app/services/asset_change_service.py | 451 ++++++++++++++ .../app/services/asset_read_service.py | 71 ++- .../collector/app/services/asset_service.py | 21 + .../app/services/document_storage_service.py | 106 ++++ .../services/support_attachment_service.py | 202 ++++++ .../collector/app/services/support_service.py | 586 ++++++++++++++++++ GeoNetAgent/collector/pyproject.toml | 4 + GeoNetAgent/collector/static/app.js | 404 +++++++++++- GeoNetAgent/collector/static/index.html | 4 +- GeoNetAgent/collector/static/style.css | 157 +++++ .../tests/test_asset_change_service.py | 58 ++ .../tests/test_support_attachments.py | 10 + .../collector/tests/test_support_service.py | 17 + .../ADR-004-asset-support-troubleshooting.md | 44 ++ GeoNetAgent/docs/adr/README.md | 1 + GeoNetAgent/docs/ai-session-summary.md | 40 +- GeoNetAgent/docs/api/service-collector.md | 62 ++ GeoNetAgent/docs/changelog.md | 14 +- GeoNetAgent/docs/database.md | 71 +++ GeoNetAgent/docs/guide/README.md | 1 + .../guide/asset-support-troubleshooting.md | 74 +++ GeoNetAgent/docs/issues.md | 10 +- GeoNetAgent/docs/todo.md | 77 +-- GeoNetAgent/docs/version.md | 59 ++ .../infra/collector/docker-compose.yml | 2 + .../infra/collector/publish_agent_install.ps1 | 34 + GeoNetAgent/infra/db/README.md | 5 +- .../db/migrations/008_asset_change_events.sql | 29 + .../infra/db/migrations/009_asset_support.sql | 95 +++ .../db/migrations/010_support_attachments.sql | 49 ++ Workspace-Session.md | 43 +- 49 files changed, 3668 insertions(+), 157 deletions(-) create mode 100644 GeoNetAgent/collector/app/api/v1/attachments.py create mode 100644 GeoNetAgent/collector/app/api/v1/support.py create mode 100644 GeoNetAgent/collector/app/schemas/asset_changes.py create mode 100644 GeoNetAgent/collector/app/schemas/attachments.py create mode 100644 GeoNetAgent/collector/app/schemas/support.py create mode 100644 GeoNetAgent/collector/app/services/asset_change_service.py create mode 100644 GeoNetAgent/collector/app/services/document_storage_service.py create mode 100644 GeoNetAgent/collector/app/services/support_attachment_service.py create mode 100644 GeoNetAgent/collector/app/services/support_service.py create mode 100644 GeoNetAgent/collector/tests/test_asset_change_service.py create mode 100644 GeoNetAgent/collector/tests/test_support_attachments.py create mode 100644 GeoNetAgent/collector/tests/test_support_service.py create mode 100644 GeoNetAgent/docs/adr/ADR-004-asset-support-troubleshooting.md create mode 100644 GeoNetAgent/docs/guide/asset-support-troubleshooting.md create mode 100644 GeoNetAgent/infra/db/migrations/008_asset_change_events.sql create mode 100644 GeoNetAgent/infra/db/migrations/009_asset_support.sql create mode 100644 GeoNetAgent/infra/db/migrations/010_support_attachments.sql diff --git a/GeoNetAgent/agent/Collect-GeoNetReport.ps1 b/GeoNetAgent/agent/Collect-GeoNetReport.ps1 index a38b164..cffef1f 100644 --- a/GeoNetAgent/agent/Collect-GeoNetReport.ps1 +++ b/GeoNetAgent/agent/Collect-GeoNetReport.ps1 @@ -10,12 +10,12 @@ param( ) $ErrorActionPreference = 'Stop' -$AgentVersion = '0.1.10-phase0' $SchemaVersion = '1.0' $scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path $libPath = Join-Path $scriptRoot 'lib' +. (Join-Path $libPath 'Agent-InstallCore.ps1') . (Join-Path $libPath 'Format-IsoDateTime.ps1') . (Join-Path $libPath 'Format-Text.ps1') . (Join-Path $libPath 'Get-SystemInfo.ps1') @@ -31,6 +31,11 @@ $libPath = Join-Path $scriptRoot 'lib' . (Join-Path $libPath 'Get-SoftwareInfo.ps1') . (Join-Path $libPath 'Build-GeoNetReportPayload.ps1') +$AgentVersion = Get-GeoNetLocalAgentVersion -InstallRoot $scriptRoot +if ([string]::IsNullOrWhiteSpace($AgentVersion)) { + $AgentVersion = 'unknown' +} + if (-not $OutputDir) { $repoRoot = Split-Path -Parent $scriptRoot $OutputDir = Join-Path $repoRoot 'samples\agent-reports' diff --git a/GeoNetAgent/agent/README.md b/GeoNetAgent/agent/README.md index 67c1280..67c70bd 100644 --- a/GeoNetAgent/agent/README.md +++ b/GeoNetAgent/agent/README.md @@ -63,6 +63,7 @@ bash infra/collector/publish_agent_install.sh | Versi | Highlight | |-------|-----------| +| v0.1.15 | GPU VRAM akurat >4GB (`nvidia-smi`, registry `qwMemorySize`) | | v0.1.10 | `cpu{}` detail (cores, clock, cache, arch); `system.cpu_model` tetap | | v0.1.9 | `physical_disks[]`, DDR label, GPU driver/resolusi, `form_factor` Laptop/PC | | v0.1.8 | `gpus[]`, disk model, auto-update, interval task 3 jam | diff --git a/GeoNetAgent/agent/Send-GeoNetReport.ps1 b/GeoNetAgent/agent/Send-GeoNetReport.ps1 index 90c6e83..02c5ced 100644 --- a/GeoNetAgent/agent/Send-GeoNetReport.ps1 +++ b/GeoNetAgent/agent/Send-GeoNetReport.ps1 @@ -28,6 +28,7 @@ $libPath = Join-Path $scriptRoot 'lib' . (Join-Path $libPath 'Get-HealthInfo.ps1') . (Join-Path $libPath 'Get-PeripheralsInfo.ps1') . (Join-Path $libPath 'Get-SoftwareInfo.ps1') +. (Join-Path $libPath 'Agent-InstallCore.ps1') . (Join-Path $libPath 'Build-GeoNetReportPayload.ps1') . (Join-Path $libPath 'Send-CollectorReport.ps1') @@ -53,7 +54,10 @@ if (-not $CollectorUrl -or -not $AgentToken) { throw "CollectorUrl dan AgentToken wajib (parameter atau config.json)." } -$AgentVersion = '0.1.10-phase0' +$AgentVersion = Get-GeoNetLocalAgentVersion -InstallRoot $scriptRoot +if ([string]::IsNullOrWhiteSpace($AgentVersion)) { + $AgentVersion = 'unknown' +} $SchemaVersion = '1.0' $payload = Build-GeoNetReportPayload ` @@ -65,12 +69,4 @@ $payload = Build-GeoNetReportPayload ` Write-Host "Mengirim laporan ke $CollectorUrl ..." -ForegroundColor Cyan $result = Send-GeoNetCollectorReport -Payload $payload -CollectorUrl $CollectorUrl -AgentToken $AgentToken - -if ($result.Success) { - Write-Host "OK: $($result.Response | ConvertTo-Json -Compress)" -ForegroundColor Green - exit 0 -} - -Write-Host "GAGAL: $($result.Error)" -ForegroundColor Red -if ($result.Body) { Write-Host $result.Body -ForegroundColor Yellow } -exit 2 +Write-GeoNetReportOutcome -Result $result diff --git a/GeoNetAgent/agent/VERSION b/GeoNetAgent/agent/VERSION index 4ca719c..8a4acd9 100644 --- a/GeoNetAgent/agent/VERSION +++ b/GeoNetAgent/agent/VERSION @@ -1 +1 @@ -0.1.12-phase0 +0.1.15-phase0 diff --git a/GeoNetAgent/agent/install/index.html b/GeoNetAgent/agent/install/index.html index 13c8168..fef42b2 100644 --- a/GeoNetAgent/agent/install/index.html +++ b/GeoNetAgent/agent/install/index.html @@ -37,6 +37,12 @@ Tanpa Admin, Scheduled Task tidak terdaftar. +
+ ExecutionPolicy: Windows default sering Restricted — perintah + & "...\GeoNetAgent-Install.ps1" akan gagal. Selalu pakai baris 2a dengan + -ExecutionPolicy Bypass (sudah disertakan di bawah). +
+

Install atau update (disarankan)

Jalankan satu per satu — baris 1 dulu, tunggu selesai, lalu baris 2.

@@ -44,26 +50,28 @@
Invoke-WebRequest -Uri 'https://agent.gisportal.id/install/GeoNetAgent-Install.ps1' -OutFile "$env:TEMP\GeoNetAgent-Install.ps1" -UseBasicParsing

Baris 2a Install + kirim laporan pertama:

-
& "$env:TEMP\GeoNetAgent-Install.ps1"
- -

Baris 2a Install + kirim laporan pertama (Optional jika error):

powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$env:TEMP\GeoNetAgent-Install.ps1"
+

Baris 2a Alternatif (jika ExecutionPolicy sudah RemoteSigned / Bypass):

+
& "$env:TEMP\GeoNetAgent-Install.ps1"
+

Baris 2b Atau hanya pasang/update file + task (tanpa laporan sekarang):

-
& "$env:TEMP\GeoNetAgent-Install.ps1" -SkipInitialRun
+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$env:TEMP\GeoNetAgent-Install.ps1" -SkipInitialRun

Perintah yang sama dipakai untuk update agent. config.json lokal dipertahankan.

Harapan sukses: Scheduled Task OK: GeoNetAgent-Report, GeoNetAgent-Report-Startup, GeoNetAgent-Report-Shutdown +
Lalu laporan awal: OK: {"status":"accepted",...}

Cek setelah install

schtasks /Query /TN GeoNetAgent-Report
 schtasks /Query /TN GeoNetAgent-Report-Startup
-& "$env:ProgramData\GeoNetAgent\UserAgent.ps1"
-

Baris terakhir mengirim laporan manual ke collector (opsional).

+Get-Content "$env:ProgramData\GeoNetAgent\VERSION" +powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$env:ProgramData\GeoNetAgent\UserAgent.ps1" +

Baris VERSION harus sama dengan badge versi di atas. Baris terakhir mengirim laporan manual ke collector (opsional).

Yang terpasang otomatis