-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-working.ps1
More file actions
120 lines (101 loc) · 4.49 KB
/
run-working.ps1
File metadata and controls
120 lines (101 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# HR Management System - Working Windows Runner
param(
[switch]$SkipBackend = $false,
[switch]$SkipFrontend = $false
)
Write-Host "🚀 Starting HR Management System..." -ForegroundColor Green
Write-Host ""
# Set Java environment
$env:JAVA_HOME = "C:\Program Files\Microsoft\jdk-17.0.16.8-hotspot"
$env:PATH = "$env:JAVA_HOME\bin;$env:PATH"
# Kill existing processes
Write-Host "🧹 Cleaning up existing processes..." -ForegroundColor Yellow
Get-Process | Where-Object {$_.ProcessName -match "java|node"} | Stop-Process -Force -ErrorAction SilentlyContinue
if (-not $SkipBackend) {
Write-Host "🔧 Starting Spring Boot server..." -ForegroundColor Blue
Write-Host "Java Home: $env:JAVA_HOME" -ForegroundColor Gray
# Test Java first
try {
$javaVersion = & java -version 2>&1
Write-Host "Java version: $($javaVersion[0])" -ForegroundColor Gray
} catch {
Write-Host "❌ Java not found!" -ForegroundColor Red
exit 1
}
# Start backend in new window
$backendArgs = @(
"-NoExit"
"-Command"
"`$env:JAVA_HOME = '$env:JAVA_HOME'; `$env:PATH = '`$env:JAVA_HOME\bin;`$env:PATH'; cd '$PWD\server'; Write-Host 'Backend starting...'; .\mvnw.cmd spring-boot:run"
)
Start-Process powershell -ArgumentList $backendArgs -WindowStyle Normal
Write-Host "⏳ Waiting for backend to start..." -ForegroundColor Yellow
$timeout = 60
$elapsed = 0
do {
Start-Sleep -Seconds 3
$elapsed += 3
try {
$response = Invoke-WebRequest -Uri "http://localhost:8080/api/departments" -TimeoutSec 3 -UseBasicParsing
if ($response.StatusCode -eq 200) {
Write-Host "✅ Backend is running!" -ForegroundColor Green
break
}
} catch {
Write-Host "." -NoNewline -ForegroundColor Gray
}
if ($elapsed -ge $timeout) {
Write-Host ""
Write-Host "⚠️ Backend taking longer than expected, continuing anyway..." -ForegroundColor Yellow
break
}
} while ($true)
}
if (-not $SkipFrontend) {
Write-Host ""
Write-Host "🎨 Starting Angular client..." -ForegroundColor Blue
# Start frontend in new window
$frontendArgs = @(
"-NoExit"
"-Command"
"cd '$PWD\client'; Write-Host 'Frontend starting...'; npm ci; npx ng serve --proxy-config proxy.conf.json --open"
)
Start-Process powershell -ArgumentList $frontendArgs -WindowStyle Normal
Write-Host "⏳ Waiting for frontend to start..." -ForegroundColor Yellow
Start-Sleep -Seconds 15
try {
$response = Invoke-WebRequest -Uri "http://localhost:4200" -TimeoutSec 5 -UseBasicParsing
if ($response.StatusCode -eq 200) {
Write-Host "✅ Frontend is running!" -ForegroundColor Green
}
} catch {
Write-Host "⏳ Frontend still starting..." -ForegroundColor Yellow
}
}
Write-Host ""
Write-Host "🎉 HR Management System startup complete!" -ForegroundColor Green
Write-Host ""
Write-Host "📱 URLs to test:" -ForegroundColor Cyan
Write-Host " Frontend App: http://localhost:4200" -ForegroundColor White
Write-Host " API Departments: http://localhost:8080/api/departments" -ForegroundColor White
Write-Host " API Employees: http://localhost:8080/api/employees" -ForegroundColor White
Write-Host " PDF Report: http://localhost:8080/api/reports/employees-by-department.pdf" -ForegroundColor White
Write-Host " Static Cards: http://localhost:8080/cards.html" -ForegroundColor White
Write-Host " H2 Console: http://localhost:8080/h2-console" -ForegroundColor White
Write-Host ""
# Open main URLs
Start-Process "http://localhost:4200"
if (-not $SkipBackend) {
Start-Sleep -Seconds 2
Start-Process "http://localhost:8080/api/departments"
}
Write-Host "🔧 Demo Instructions:" -ForegroundColor Cyan
Write-Host " 1. Open http://localhost:4200" -ForegroundColor White
Write-Host " 2. Type 'dept01' in search box and click Search" -ForegroundColor White
Write-Host " 3. Click 'View' on any employee to see details" -ForegroundColor White
Write-Host " 4. Try editing employee information" -ForegroundColor White
Write-Host " 5. Download PDF report from navigation" -ForegroundColor White
Write-Host " 6. Visit Cards Showcase in navigation" -ForegroundColor White
Write-Host ""
Write-Host "Press any key to exit..." -ForegroundColor Yellow
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")