V1.2
This commit is contained in:
1 parent
7fc7653e6f
commit
d8759eee29
24 files changed
+316
-119
No files matched your search
+2
-6
@@ -26,9 +26,7 @@
|
|||||||
"input": "public"
|
"input": "public"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": ["src/styles.scss"],
|
||||||
"src/styles.scss"
|
|
||||||
],
|
|
||||||
"server": "src/main.server.ts",
|
"server": "src/main.server.ts",
|
||||||
"outputMode": "server",
|
"outputMode": "server",
|
||||||
"ssr": {
|
"ssr": {
|
||||||
@@ -90,9 +88,7 @@
|
|||||||
"input": "public"
|
"input": "public"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": ["src/styles.scss"]
|
||||||
"src/styles.scss"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-9
@@ -7,16 +7,16 @@ services:
|
|||||||
container_name: vac-optimizer-prod
|
container_name: vac-optimizer-prod
|
||||||
restart: always
|
restart: always
|
||||||
ports:
|
ports:
|
||||||
- "80:4000"
|
- '80:4000'
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- PORT=4000
|
- PORT=4000
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
[
|
[
|
||||||
"CMD",
|
'CMD',
|
||||||
"node",
|
'node',
|
||||||
"-e",
|
'-e',
|
||||||
"require('http').get('http://localhost:4000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})",
|
"require('http').get('http://localhost:4000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})",
|
||||||
]
|
]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
@@ -26,10 +26,10 @@ services:
|
|||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpus: "1.0"
|
cpus: '1.0'
|
||||||
memory: 512M
|
memory: 512M
|
||||||
reservations:
|
reservations:
|
||||||
cpus: "0.5"
|
cpus: '0.5'
|
||||||
memory: 256M
|
memory: 256M
|
||||||
restart_policy:
|
restart_policy:
|
||||||
condition: on-failure
|
condition: on-failure
|
||||||
@@ -37,10 +37,10 @@ services:
|
|||||||
max_attempts: 3
|
max_attempts: 3
|
||||||
window: 120s
|
window: 120s
|
||||||
logging:
|
logging:
|
||||||
driver: "json-file"
|
driver: 'json-file'
|
||||||
options:
|
options:
|
||||||
max-size: "10m"
|
max-size: '10m'
|
||||||
max-file: "3"
|
max-file: '3'
|
||||||
networks:
|
networks:
|
||||||
- vac-optimizer-network
|
- vac-optimizer-network
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -7,16 +7,16 @@ services:
|
|||||||
container_name: vac-optimizer
|
container_name: vac-optimizer
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "4000:4000"
|
- '4000:4000'
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- PORT=4000
|
- PORT=4000
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
[
|
[
|
||||||
"CMD",
|
'CMD',
|
||||||
"node",
|
'node',
|
||||||
"-e",
|
'-e',
|
||||||
"require('http').get('http://localhost:4000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})",
|
"require('http').get('http://localhost:4000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})",
|
||||||
]
|
]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 156 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 484 KiB |
+2
-1
@@ -1,8 +1,9 @@
|
|||||||
|
<app-dark-light-mode-button class="modeButton"></app-dark-light-mode-button>
|
||||||
<main class="main">
|
<main class="main">
|
||||||
<h1>{{ title() }}</h1>
|
<h1>{{ title() }}</h1>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<app-user-input></app-user-input>
|
<app-user-input></app-user-input>
|
||||||
<mat-divider [vertical]="true" style="height: 80%;"></mat-divider>
|
<mat-divider [vertical]="true" style="height: 80%"></mat-divider>
|
||||||
<app-calendar-year></app-calendar-year>
|
<app-calendar-year></app-calendar-year>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
@@ -3,6 +3,6 @@ import { RenderMode, ServerRoute } from '@angular/ssr';
|
|||||||
export const serverRoutes: ServerRoute[] = [
|
export const serverRoutes: ServerRoute[] = [
|
||||||
{
|
{
|
||||||
path: '**',
|
path: '**',
|
||||||
renderMode: RenderMode.Prerender
|
renderMode: RenderMode.Client
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
+16
-4
@@ -3,14 +3,26 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100vw;
|
min-height: 100vh;
|
||||||
height: 100vh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: space-evenly;
|
||||||
gap: 2rem;
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.content {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.modeButton {
|
||||||
|
position: fixed;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
z-index: 1000;
|
||||||
}
|
}
|
||||||
+10
-2
@@ -3,11 +3,19 @@ import { MatDatepickerModule } from '@angular/material/datepicker';
|
|||||||
import { provideNativeDateAdapter } from '@angular/material/core';
|
import { provideNativeDateAdapter } from '@angular/material/core';
|
||||||
import { MatDivider } from '@angular/material/divider';
|
import { MatDivider } from '@angular/material/divider';
|
||||||
import { UserInput } from './components/user-input/user-input';
|
import { UserInput } from './components/user-input/user-input';
|
||||||
import { CalendarYear } from "./components/calendar-year/calendar-year";
|
import { CalendarYear } from './components/calendar-year/calendar-year';
|
||||||
|
import { DarkLightModeButton } from './components/dark-light-mode-button/dark-light-mode-button';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
imports: [MatDatepickerModule, MatDivider, UserInput, CalendarYear],
|
imports: [
|
||||||
|
MatDatepickerModule,
|
||||||
|
MatDivider,
|
||||||
|
UserInput,
|
||||||
|
CalendarYear,
|
||||||
|
DarkLightModeButton,
|
||||||
|
DarkLightModeButton,
|
||||||
|
],
|
||||||
templateUrl: './app.html',
|
templateUrl: './app.html',
|
||||||
styleUrl: './app.scss',
|
styleUrl: './app.scss',
|
||||||
providers: [provideNativeDateAdapter()],
|
providers: [provideNativeDateAdapter()],
|
||||||
|
|||||||
@@ -1,26 +1,28 @@
|
|||||||
<div class="calendar">
|
<div class="calendar">
|
||||||
<h3>{{ getMonthName() }} {{ year }}</h3>
|
<h3>{{ getMonthName() }} {{ year }}</h3>
|
||||||
<div class="row header">
|
<div>
|
||||||
<p class="day">L</p>
|
<div class="row header">
|
||||||
<p class="day">M</p>
|
<p class="day">L</p>
|
||||||
<p class="day">M</p>
|
<p class="day">M</p>
|
||||||
<p class="day">J</p>
|
<p class="day">M</p>
|
||||||
<p class="day">V</p>
|
<p class="day">J</p>
|
||||||
<p class="day">S</p>
|
<p class="day">V</p>
|
||||||
<p class="day">D</p>
|
<p class="day">S</p>
|
||||||
</div>
|
<p class="day">D</p>
|
||||||
<div class="cols">
|
</div>
|
||||||
@for (week of weeksInAMonth; track $index) {
|
<div class="cols">
|
||||||
<div class="row week">
|
@for (week of weeksInAMonth; track $index) {
|
||||||
@for (day of week; track $index) {
|
<div class="row week">
|
||||||
@if (day === null) {
|
@for (day of week; track $index) {
|
||||||
<p class="day empty"></p>
|
@if (day === null) {
|
||||||
} @else {
|
<p class="day empty"></p>
|
||||||
<p [class.past]="day < getNow()" [class.start]="selectedDates.isStart(day)" [class.end]="selectedDates.isEnd(day)" [class.selected]="selectedDates.isSelected(day)"
|
} @else {
|
||||||
[class]="selectedDates.getClasses(day)" class="day number" [matTooltip]="selectedDates.getTooltip(day)" [matTooltipShowDelay]="500">{{ day.getDate() }}</p>
|
<p [class.past]="day < getNow()" [class.start]="selectedDates.isStart(day)" [class.end]="selectedDates.isEnd(day)" [class.selected]="selectedDates.isSelected(day)"
|
||||||
}
|
[class]="selectedDates.getClasses(day)" class="day number" [matTooltip]="selectedDates.getTooltip(day)" [matTooltipShowDelay]="500">{{ day.getDate() }}</p>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,16 +1,11 @@
|
|||||||
.calendar {
|
.calendar {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: center;
|
||||||
justify-content: flex-start;
|
gap: 16px;
|
||||||
|
|
||||||
mat-card {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 400px;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3 {
|
h3 {
|
||||||
margin: 0 0 8px 0;
|
margin: 0;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,18 +31,22 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
border-radius: 40%;
|
border-radius: 30%;
|
||||||
|
color: var(--number-color);
|
||||||
|
|
||||||
&.empty {
|
&.empty {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.number:hover {
|
&.number:hover {
|
||||||
background-color: #e0e0e0;
|
background-color: var(--number-bg-hover);
|
||||||
color: black;
|
color: var(--number-color-hover);
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.past {
|
||||||
|
color: var(--past-color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.selected {
|
.selected {
|
||||||
@@ -58,50 +57,49 @@
|
|||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
>.start:not(.end) {
|
> .start:not(.end) {
|
||||||
border-radius: 40% 0 0 40%;
|
border-radius: 30% 0 0 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
>.end:not(.start) {
|
> .end:not(.start) {
|
||||||
border-radius: 0 40% 40% 0;
|
border-radius: 0 30% 30% 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.today {
|
.today {
|
||||||
border-color: #1976d2;
|
border-color: var(--today-border-color);
|
||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
width: 26px !important;
|
width: 26px !important;
|
||||||
height: 22px !important;
|
height: 22px !important;
|
||||||
border-style: dashed !important;
|
border-style: dashed !important;
|
||||||
|
|
||||||
|
:has(.dark-mode) {
|
||||||
|
border-color: #0b385c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.other-month {
|
.other-month {
|
||||||
color: #9e9e9e;
|
color: var(--other-month-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.weekend {
|
.weekend {
|
||||||
background-color: #ffca39;
|
background-color: var(--weekend-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.closed-day {
|
.closed-day {
|
||||||
border: 2px solid #0ee3ff;
|
border: 2px solid var(--closed-day-bg);
|
||||||
width: 26px !important;
|
width: 26px !important;
|
||||||
height: 22px !important;
|
height: 22px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rtt {
|
.rtt {
|
||||||
background-color: #99ff87;
|
background-color: var(--rtt-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cp {
|
.cp {
|
||||||
background-color: #eca0ff;
|
background-color: var(--cp-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.other {
|
.other {
|
||||||
background-color: #ff9b9b;
|
background-color: var(--other-bg);
|
||||||
}
|
|
||||||
|
|
||||||
.past {
|
|
||||||
color: #b0b0b0;
|
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
@if (isLoading()) {
|
@if (isLoading()) {
|
||||||
<div class="loading-overlay">
|
<div class="loading-overlay">
|
||||||
<div class="loading-spinner">
|
<div class="loading-spinner">
|
||||||
<div class="spinner"></div>
|
<mat-spinner></mat-spinner>
|
||||||
<p>Calcul en cours...</p>
|
<p>Calcul en cours...</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@for (month of months; track $index) {
|
@for (month of months; track $index) {
|
||||||
<mat-card>
|
<mat-card class="card">
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<app-calendar-month [monthIndex]="month" [year]="getYear(month)" [selectedDates]="selectedDates"></app-calendar-month>
|
<app-calendar-month [monthIndex]="month" [year]="getYear(month)" [selectedDates]="selectedDates"></app-calendar-month>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
|
@use '@angular/material' as mat;
|
||||||
|
|
||||||
.calendar-year {
|
.calendar-year {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
justify-content: center;
|
justify-content: space-evenly;
|
||||||
gap: 16px;
|
max-width: 65vw;
|
||||||
max-width: 60vw;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.calendar-year {
|
||||||
|
max-width: 100vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.loading-overlay {
|
.loading-overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -20,6 +27,10 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
background-color: rgba(0, 0, 0, 0.7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-spinner {
|
.loading-spinner {
|
||||||
@@ -33,16 +44,15 @@
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: #333;
|
color: #333;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
color: #ddd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.spinner {
|
.card {
|
||||||
width: 40px;
|
margin: 16px;
|
||||||
height: 40px;
|
|
||||||
border: 4px solid #f3f3f3;
|
|
||||||
border-top: 4px solid #3498db;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 1s linear infinite;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
@@ -54,3 +64,7 @@
|
|||||||
transform: rotate(360deg);
|
transform: rotate(360deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
@include mat.progress-spinner-overrides((size: 0.5rem, active-indicator-width: 0.25rem));
|
||||||
|
}
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
import { Component, OnInit, effect, signal } from '@angular/core';
|
import { Component, effect, signal } from '@angular/core';
|
||||||
import { UserInputService } from '../../services/user-input-service';
|
import { UserInputService } from '../../services/user-input-service';
|
||||||
import { MatCard, MatCardContent } from '@angular/material/card';
|
import { MatCard, MatCardContent } from '@angular/material/card';
|
||||||
import { CalendarMonth } from "../calendar-month/calendar-month";
|
import { CalendarMonth } from "../calendar-month/calendar-month";
|
||||||
import { CalendarService, SelectedDates } from '../../services/calendar-service';
|
import { CalendarService, SelectedDates } from '../../services/calendar-service';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { MatProgressSpinner } from '@angular/material/progress-spinner';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-calendar-year',
|
selector: 'app-calendar-year',
|
||||||
imports: [MatCard, CalendarMonth, MatCardContent, CommonModule],
|
imports: [MatCard, CalendarMonth, MatCardContent, CommonModule, MatProgressSpinner],
|
||||||
templateUrl: './calendar-year.html',
|
templateUrl: './calendar-year.html',
|
||||||
styleUrl: './calendar-year.scss',
|
styleUrl: './calendar-year.scss',
|
||||||
})
|
})
|
||||||
export class CalendarYear implements OnInit {
|
export class CalendarYear {
|
||||||
protected isLoading = signal(true);
|
protected isLoading = signal(true);
|
||||||
|
|
||||||
constructor(private userInput: UserInputService, private calendarService: CalendarService) {
|
constructor(private userInput: UserInputService, private calendarService: CalendarService) {
|
||||||
@@ -38,8 +39,4 @@ export class CalendarYear implements OnInit {
|
|||||||
|
|
||||||
// months starting from actual date
|
// months starting from actual date
|
||||||
protected months: number[] = Array.from({ length: 12 }, (_, i) => (new Date().getMonth() + i) % 12);
|
protected months: number[] = Array.from({ length: 12 }, (_, i) => (new Date().getMonth() + i) % 12);
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
this.selectedDates = this.calendarService.getSelectedDatesForYear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
@if (lightMode()) {
|
||||||
|
<button
|
||||||
|
animate.enter="enter-animation"
|
||||||
|
mat-fab
|
||||||
|
color="primary"
|
||||||
|
(click)="toggleTheme()"
|
||||||
|
aria-label="Toggle light mode"
|
||||||
|
>
|
||||||
|
<mat-icon aria-hidden="false" aria-label="Dark mode icon" fontIcon="dark_mode"></mat-icon>
|
||||||
|
</button>
|
||||||
|
} @else {
|
||||||
|
<button
|
||||||
|
animate.enter="enter-animation"
|
||||||
|
mat-fab
|
||||||
|
color="accent"
|
||||||
|
(click)="toggleTheme()"
|
||||||
|
aria-label="Toggle dark mode"
|
||||||
|
>
|
||||||
|
<mat-icon aria-hidden="false" aria-label="Light mode icon" fontIcon="light_mode"></mat-icon>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
button {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: rgba(0, 0, 0, 0);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.enter-animation {
|
||||||
|
animation: slide-fade 1s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slide-fade {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(20px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { DarkLightModeButton } from './dark-light-mode-button';
|
||||||
|
|
||||||
|
describe('DarkLightModeButton', () => {
|
||||||
|
let component: DarkLightModeButton;
|
||||||
|
let fixture: ComponentFixture<DarkLightModeButton>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [DarkLightModeButton],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(DarkLightModeButton);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { ThemeService } from '../../services/theme-service';
|
||||||
|
import { MatIcon } from '@angular/material/icon';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-dark-light-mode-button',
|
||||||
|
imports: [MatIcon],
|
||||||
|
templateUrl: './dark-light-mode-button.html',
|
||||||
|
styleUrl: './dark-light-mode-button.scss',
|
||||||
|
})
|
||||||
|
export class DarkLightModeButton {
|
||||||
|
constructor(private themeService: ThemeService) {}
|
||||||
|
|
||||||
|
lightMode(): boolean {
|
||||||
|
return this.themeService.isLightMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleTheme(): void {
|
||||||
|
this.themeService.toggleTheme();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,7 +36,7 @@ export class UserInput implements OnInit, OnDestroy {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.userInputForm.valueChanges
|
this.userInputForm.valueChanges
|
||||||
.pipe(
|
.pipe(
|
||||||
debounceTime(2500),
|
debounceTime(1500),
|
||||||
takeUntil(this.destroy$)
|
takeUntil(this.destroy$)
|
||||||
)
|
)
|
||||||
.subscribe(() => this.submitForm());
|
.subscribe(() => this.submitForm());
|
||||||
|
|||||||
@@ -31,24 +31,25 @@ export class CalendarService {
|
|||||||
if (day) {
|
if (day) {
|
||||||
this.setWeekendSelection(day, selectedDates);
|
this.setWeekendSelection(day, selectedDates);
|
||||||
if (holidays.some(holiday => holiday.getTime() === day.getTime())) {
|
if (holidays.some(holiday => holiday.getTime() === day.getTime())) {
|
||||||
selectedDates.push(new SelectedDate(DayType.CLOSED_DAY, new DateRange<Date>(day, day)));
|
selectedDates._datesSelected.push(new SelectedDate(DayType.CLOSED_DAY, new DateRange<Date>(day, day)));
|
||||||
}
|
}
|
||||||
if (day.getDate() === new Date().getDate() && day.getMonth() === new Date().getMonth() && day.getFullYear() === new Date().getFullYear()) {
|
if (day.getDate() === new Date().getDate() && day.getMonth() === new Date().getMonth() && day.getFullYear() === new Date().getFullYear()) {
|
||||||
selectedDates.push(new SelectedDate(DayType.TODAY, new DateRange<Date>(day, day)));
|
selectedDates._datesSelected.push(new SelectedDate(DayType.TODAY, new DateRange<Date>(day, day)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
selectedDates.update();
|
||||||
return selectedDates;
|
return selectedDates;
|
||||||
}
|
}
|
||||||
|
|
||||||
setWeekendSelection(date: Date, selectedDates: SelectedDates) {
|
setWeekendSelection(date: Date, selectedDates: SelectedDates) {
|
||||||
if (date.getDay() === 6) {
|
if (date.getDay() === 6) {
|
||||||
selectedDates.push(new SelectedDate(DayType.WEEKEND, new DateRange<Date>(date, new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1))));
|
selectedDates._datesSelected.push(new SelectedDate(DayType.WEEKEND, new DateRange<Date>(date, new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1))));
|
||||||
}
|
}
|
||||||
if (date.getDate() === 1 && date.getDay() === 0) {
|
if (date.getDate() === 1 && date.getDay() === 0) {
|
||||||
selectedDates.push(new SelectedDate(DayType.WEEKEND, new DateRange<Date>(new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1), date)));
|
selectedDates._datesSelected.push(new SelectedDate(DayType.WEEKEND, new DateRange<Date>(new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1), date)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,6 +227,11 @@ export class SelectedDates implements SelectedDateInterface {
|
|||||||
_datesSelected: SelectedDate[] = [];
|
_datesSelected: SelectedDate[] = [];
|
||||||
datesSelected: SelectedDate[] = [];
|
datesSelected: SelectedDate[] = [];
|
||||||
|
|
||||||
|
update(): void {
|
||||||
|
this.datesSelected = this._datesSelected.slice();
|
||||||
|
this.grouping();
|
||||||
|
}
|
||||||
|
|
||||||
push(selectedDate: SelectedDate) {
|
push(selectedDate: SelectedDate) {
|
||||||
this._datesSelected.push(selectedDate);
|
this._datesSelected.push(selectedDate);
|
||||||
this.datesSelected = this._datesSelected.slice();
|
this.datesSelected = this._datesSelected.slice();
|
||||||
@@ -436,21 +442,21 @@ export class SelectedDates implements SelectedDateInterface {
|
|||||||
optimizeVacations(vacationsNumber: VacationsNumber): void {
|
optimizeVacations(vacationsNumber: VacationsNumber): void {
|
||||||
this.samediMalin(vacationsNumber);
|
this.samediMalin(vacationsNumber);
|
||||||
while (vacationsNumber.cp > 0) {
|
while (vacationsNumber.cp > 0) {
|
||||||
const result = this.lookForVacationRec(DayType.CP);
|
const result = this.lookForVacation(DayType.CP);
|
||||||
if (result.heuristic === -1) {
|
if (result.heuristic === -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vacationsNumber.cp -= 1;
|
vacationsNumber.cp -= 1;
|
||||||
}
|
}
|
||||||
while (vacationsNumber.rtt > 0) {
|
while (vacationsNumber.rtt > 0) {
|
||||||
const result = this.lookForVacationRec(DayType.RTT);
|
const result = this.lookForVacation(DayType.RTT);
|
||||||
if (result.heuristic === -1) {
|
if (result.heuristic === -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vacationsNumber.rtt -= 1;
|
vacationsNumber.rtt -= 1;
|
||||||
}
|
}
|
||||||
while (vacationsNumber.other > 0) {
|
while (vacationsNumber.other > 0) {
|
||||||
const result = this.lookForVacationRec(DayType.OTHER);
|
const result = this.lookForVacation(DayType.OTHER);
|
||||||
if (result.heuristic === -1) {
|
if (result.heuristic === -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -570,7 +576,7 @@ export class SelectedDates implements SelectedDateInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lookForVacationRec(vacType: DayType): { apply: () => void; heuristic: number } {
|
lookForVacation(vacType: DayType): { apply: () => void; heuristic: number } {
|
||||||
const daysOfYear = CalendarService.monthsInAYearFromNow();
|
const daysOfYear = CalendarService.monthsInAYearFromNow();
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
now.setHours(0, 0, 0, 0);
|
now.setHours(0, 0, 0, 0);
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ThemeService } from './theme-service';
|
||||||
|
|
||||||
|
describe('ThemeService', () => {
|
||||||
|
let service: ThemeService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(ThemeService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Injectable, signal } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class ThemeService {
|
||||||
|
private lightModeMedia = window.matchMedia('(prefers-color-scheme: light)');
|
||||||
|
isLightMode = signal(this.lightModeMedia.matches);
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.toggleTheme(this.isLightMode());
|
||||||
|
this.lightModeMedia.addEventListener('change', (e) => {
|
||||||
|
this.isLightMode.set(e.matches);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleTheme(forceLight?: boolean) {
|
||||||
|
const isLight = forceLight ?? !this.isLightMode();
|
||||||
|
this.isLightMode.set(isLight);
|
||||||
|
document.body.classList.toggle('light-mode', isLight);
|
||||||
|
document.body.classList.toggle('dark-mode', !isLight);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
import { Injectable, signal, PLATFORM_ID, inject } from '@angular/core';
|
import { Injectable, signal, PLATFORM_ID, inject } from '@angular/core';
|
||||||
import { isPlatformBrowser } from '@angular/common';
|
|
||||||
import Holidays, { HolidaysTypes } from 'date-holidays';
|
|
||||||
import { VacationsNumber } from './calendar-service';
|
import { VacationsNumber } from './calendar-service';
|
||||||
|
|
||||||
|
|
||||||
@@ -9,24 +7,16 @@ import { VacationsNumber } from './calendar-service';
|
|||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class UserInputService {
|
export class UserInputService {
|
||||||
private platformId = inject(PLATFORM_ID);
|
|
||||||
|
|
||||||
private getRandomNumber(): number {
|
private getRandomNumber(): number {
|
||||||
return Math.floor(Math.random() * 9) + 1;
|
return Math.floor(Math.random() * 9) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getInitialValues(): VacationsNumber {
|
private getInitialValues(): VacationsNumber {
|
||||||
if (isPlatformBrowser(this.platformId)) {
|
|
||||||
return {
|
|
||||||
cp: this.getRandomNumber(),
|
|
||||||
rtt: this.getRandomNumber(),
|
|
||||||
other: this.getRandomNumber()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
cp: 0,
|
cp: this.getRandomNumber(),
|
||||||
rtt: 0,
|
rtt: this.getRandomNumber(),
|
||||||
other: 0
|
other: this.getRandomNumber()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+44
-4
@@ -6,19 +6,59 @@
|
|||||||
@use '@angular/material' as mat;
|
@use '@angular/material' as mat;
|
||||||
|
|
||||||
html {
|
html {
|
||||||
@include mat.theme((color: (primary: mat.$azure-palette,
|
@include mat.theme(
|
||||||
|
(
|
||||||
|
color: (
|
||||||
|
primary: mat.$azure-palette,
|
||||||
tertiary: mat.$blue-palette,
|
tertiary: mat.$blue-palette,
|
||||||
),
|
),
|
||||||
typography: Roboto,
|
typography: Roboto,
|
||||||
density: 0,
|
density: 0,
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--number-bg-hover: #e0e0e0;
|
||||||
|
--number-color: black;
|
||||||
|
--number-color-hover: black;
|
||||||
|
--past-color: #b0b0b0;
|
||||||
|
|
||||||
|
--today-border-color: #1976d2;
|
||||||
|
--other-month-color: #9e9e9e;
|
||||||
|
--weekend-bg: #ffca39;
|
||||||
|
--closed-day-bg: #0ee3ff;
|
||||||
|
--rtt-bg: #99ff87;
|
||||||
|
--cp-bg: #eca0ff;
|
||||||
|
--other-bg: #ff9b9b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark-mode {
|
||||||
|
--number-bg-hover: #424242;
|
||||||
|
--number-color: white;
|
||||||
|
--number-color-hover: white;
|
||||||
|
--past-color: #757575;
|
||||||
|
|
||||||
|
--today-border-color: #0b385c;
|
||||||
|
--other-month-color: #757575;
|
||||||
|
--weekend-bg: #b17927;
|
||||||
|
--closed-day-bg: #098a9b;
|
||||||
|
--rtt-bg: #468149;
|
||||||
|
--cp-bg: #703e79;
|
||||||
|
--other-bg: #9b3939;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
// Default the application to a light color theme. This can be changed to
|
// Default the application to a light color theme. This can be changed to
|
||||||
// `dark` to enable the dark color theme, or to `light dark` to defer to the
|
// `dark` to enable the dark color theme, or to `light dark` to defer to the
|
||||||
// user's system settings.
|
// user's system settings.
|
||||||
color-scheme: light;
|
&.dark-mode {
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.light-mode {
|
||||||
|
color-scheme: light;
|
||||||
|
}
|
||||||
|
|
||||||
// Set a default background, font and text colors for the application using
|
// Set a default background, font and text colors for the application using
|
||||||
// Angular Material's system-level CSS variables. Learn more about these
|
// Angular Material's system-level CSS variables. Learn more about these
|
||||||
@@ -40,5 +80,5 @@ body {
|
|||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: Roboto, "Helvetica Neue", sans-serif;
|
font-family: Roboto, 'Helvetica Neue', sans-serif;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user