A work shift scheduling application with intelligent staff assignment, rest period validation, and workload optimization.
The application now runs entirely in the browser with all schedule calculation logic implemented in TypeScript/Angular. No backend server is required!
You need to have
- Node.js 18.19+ or 20.9+
- npm 9+
You can start the app by installing all NPM packages once.
npm installThen, any time you want to run the app and debug it locally, run
npm startThen open your browser to: http://localhost:4200.
Alternatively, you can only use ng to build and serve statically (Production)
npm install
npm run buildThen serve the wwwroot directory with any static web server:
Using Python:
cd ../wwwroot
python -m http.server 8080Using Node.js http-server:
npm install -g http-server
cd ../wwwroot
http-server -p 8080Using live-server:
npm install -g live-server
cd ../wwwroot
live-server --port=8080Then open: http://localhost:8080.
The app is built using only Angular and all business logic is in the front-end files.
-
HolidayService (
holiday.service.ts)- Determines workdays and holidays
- Customizable holiday calendar
-
ScheduleCalculatorService (
schedule-calculator.service.ts)- Core scheduling algorithm
- Staff assignment logic
- Rest period validation
- Converted from C# to TypeScript
-
ScheduleService (
schedule.service.ts)- Wrapper service
- Now calls local calculator instead of API
Input Component
V
ScheduleService.calculateSchedule()
V
ScheduleCalculatorService.calculateSchedule()
V
HolidayService.isWorkday()
V
ScheduleResult (in memory)
V
Results Component
All features work identically to the backend version:
- 24-hour shift coverage scheduling
- Regular workday assignments
- Rest period enforcement
- Monthly extended hours limits
- Holiday and weekend handling
- Workload distribution optimization
- Violation detection and reporting
Edit /src/app/services/holiday.service.ts:
static getHolidays(year: number): Date[] {
const holidays: Date[] = [
new Date(year, 0, 1), // January 1
new Date(year, 11, 25), // December 25
// Add your holidays here
];
return holidays;
}The Angular app is configured in angular.json:
- Output directory:
../wwwroot - No server-side rendering
- Optimized for production builds
To publish on GitHub Pages, execute these commands:
# Install angular-cli-ghpages, if you do not have it yet
npm i -g angular-cli-ghpages
# Build the app
ng build --base-href https://miroj.github.io/work-shift-planning/
# Deploy wwwroot folder to GitHub Pages
npx angular-cli-ghpages --dir=dist/work-shift-planning/browser- Point to
/wwwrootdirectory - No build command needed (pre-built)
- Serve as SPA with fallback to
index.html
Upload the wwwroot folder contents with proper SPA routing configuration.
The frontend-only version is 100% compatible with the backend version. The same TypeScript interfaces are used, and results are identical.
What Changed:
- Removed: HTTP calls to
/api/schedule/calculate - Added: Local
ScheduleCalculatorService - Added:
HolidayServicefor date calculations- Same: All TypeScript models and interfaces
- Same: UI components and styling
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install
npm run buildThis project is licensed under the MIT License - see the LICENSE file for details.