Skip to content

Commit 1b3adef

Browse files
authored
Merge pull request #10 from NF-itmo/dev
Second iteration. For more info see pr
2 parents be77f49 + 29610b3 commit 1b3adef

29 files changed

Lines changed: 402 additions & 54 deletions

docker-compose.yaml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
services:
2-
apache-httpd:
3-
container_name: httpd-server
2+
# apache-httpd:
3+
# container_name: httpd-server-apache
4+
# build:
5+
# context: ./httpd/
6+
# dockerfile: ./Dockerfile-apache
7+
# args:
8+
# - APACHE_LOG_DIR="/var/log/httpd-server/"
9+
# restart: on-failure
10+
# ports:
11+
# - "8080:80"
12+
# networks:
13+
# - internal_net
14+
15+
nginx-httpd:
16+
container_name: httpd-server-nginx
417
build:
518
context: ./httpd/
6-
args:
7-
- APACHE_LOG_DIR="/var/log/httpd-server/"
19+
dockerfile: ./Dockerfile-nginx
820
restart: on-failure
921
ports:
1022
- "8080:80"
@@ -17,7 +29,8 @@ services:
1729
context: ./server/
1830
restart: on-failure
1931
depends_on:
20-
- apache-httpd
32+
# - apache-httpd
33+
- nginx-httpd
2134
networks:
2235
- internal_net
2336

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ COPY ./static/ /var/www/localhost/htdocs/static/
66

77
# add custom apache configs
88
RUN mkdir -p /etc/apache2/conf-custom
9-
COPY ./conf/custom/ /etc/apache2/conf-custom/
9+
COPY ./apache-conf/custom/ /etc/apache2/conf-custom/
1010

1111
# create logs directory (temporary disabled)
1212
ARG APACHE_LOG_DIR
1313
RUN mkdir -p ${APACHE_LOG_DIR}
1414
RUN chown www-data:www-data ${APACHE_LOG_DIR}
1515

1616
# setup main apache configuration
17-
COPY ./conf/httpd.conf /usr/local/apache2/conf/httpd.conf
17+
COPY ./apache-conf/httpd.conf /usr/local/apache2/conf/httpd.conf
1818

1919
EXPOSE 80

httpd/Dockerfile-nginx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM nginx:latest
2+
3+
COPY /nginx-conf/httpd.conf /etc/nginx/conf.d/default.conf
4+
COPY ./static/ /var/www/html/
5+
6+
EXPOSE 80
7+
#EXPOSE 443

httpd/conf/custom/apache-httpd-lab1.conf renamed to httpd/apache-conf/custom/apache-httpd-lab1.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
# FastCGI server setup start
1717
# ==========================
1818

19-
ProxyPass /fcgi-bin/ fcgi://fastcgi-server:55555/
20-
ProxyPassReverse /fcgi-bin/ fcgi://fastcgi-server:55555/
19+
ProxyPass /fcgi/ fcgi://fastcgi-server:55555/
20+
ProxyPassReverse /fcgi/ fcgi://fastcgi-server:55555/
2121

22-
<Location "/fcgi-bin/">
22+
<Location "/fcgi/">
2323
Require all granted
2424
</Location>
2525

httpd/nginx-conf/httpd.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
server {
2+
listen 80;
3+
4+
root /var/www/html;
5+
6+
# Обработка статических файлов
7+
location / {
8+
try_files $uri $uri/ =404;
9+
}
10+
11+
location /fcgi/ {
12+
# Базовые настройки FastCGI
13+
include fastcgi_params;
14+
15+
# Адрес FastCGI сервера
16+
fastcgi_pass fastcgi-server:55555;
17+
}
18+
}

httpd/static/index.html

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
--svg-axis-primary: oklch(75% 0.04 260);
2828
--svg-fill-area: oklch(52% 0.07 200);
2929

30+
--error-bg: oklch(55% 0.15 19);
31+
3032
/* Всякое разное */
3133
--btn-active-translateY: -2px;
3234

@@ -231,13 +233,9 @@
231233
}
232234

233235
.container {
234-
animation: fadeIn 0.6s ease-out;
236+
animation: containerFadeIn 0.6s ease-out;
235237
}
236238

237-
.form-row {
238-
animation: fadeIn 0.8s ease-out;
239-
}
240-
241239
/* Адаптивность */
242240
@media (max-width: 768px) {
243241
.form-grid {
@@ -375,7 +373,28 @@
375373
transform: translateY(var(--btn-active-translateY));
376374
}
377375

378-
/* Адаптивность */
376+
/* Сообщение об ошибке */
377+
.error-message {
378+
position: fixed;
379+
bottom: 20px;
380+
right: 20px;
381+
382+
background-color: var(--error-bg);
383+
color: var(--text-primary);
384+
385+
padding: 15px 20px;
386+
387+
border-radius: 8px;
388+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
389+
390+
z-index: 1000;
391+
392+
max-width: 350px;
393+
394+
animation: errorSlideIn 0.3s ease-out, errorFadeOut 0.5s ease-in 4.5s forwards;
395+
}
396+
397+
/* Адаптивность */
379398
@media (max-width: 968px) {
380399
.container {
381400
min-width: 95%;
@@ -404,7 +423,7 @@
404423
}
405424

406425
/* Анимации */
407-
@keyframes fadeIn {
426+
@keyframes containerFadeIn {
408427
from {
409428
opacity: 0;
410429
transform: translateY(20px);
@@ -414,6 +433,27 @@
414433
transform: translateY(0);
415434
}
416435
}
436+
437+
@keyframes errorSlideIn {
438+
from {
439+
transform: translateX(100%);
440+
opacity: 0;
441+
}
442+
to {
443+
transform: translateX(0);
444+
opacity: 1;
445+
}
446+
}
447+
448+
@keyframes errorFadeOut {
449+
from {
450+
opacity: 1;
451+
}
452+
to {
453+
opacity: 0;
454+
display: none;
455+
}
456+
}
417457
</style>
418458
</head>
419459
<body>
@@ -633,17 +673,43 @@ <h3 class="history-title">История введенных данных</h3>
633673
// Хранение истории данных
634674
let formHistory = JSON.parse(localStorage.getItem('formHistory')) || [];
635675

676+
const showError = (message) => {
677+
// Убираем существующие сообщения
678+
const existingErrors = document.querySelectorAll('.error-message');
679+
existingErrors.forEach(error => error.remove());
680+
681+
// Слздаём элемент
682+
const errorDiv = document.createElement('div');
683+
errorDiv.className = 'error-message';
684+
errorDiv.textContent = message;
685+
686+
// Вставка
687+
document.body.appendChild(errorDiv);
688+
689+
// Убираем по прошествии 5-ти секунд
690+
setTimeout(() => {
691+
if (errorDiv.parentNode) {
692+
errorDiv.parentNode.removeChild(errorDiv);
693+
}
694+
}, 5000);
695+
};
696+
636697
const FFCGIResponceHandler = (responce, X, Y, R) => {
637-
const JSONresponce = JSON.parse(responce);
698+
const JSONResponce = JSON.parse(responce);
699+
700+
if (JSONResponce.error) {
701+
showError(`Ошибка: ${JSONResponce.error}`);
702+
return;
703+
}
638704

639705
// Сохраняем данные в историю
640706
const formData = {
641707
timestamp: new Date().toISOString(),
642708
X: X,
643709
Y: Y,
644710
R: R,
645-
elapsedTimeNs: JSONresponce.elapsedTimeNs,
646-
isHitted: JSONresponce.result
711+
elapsedTimeNs: JSONResponce.elapsedTimeNs,
712+
isHitted: JSONResponce.result
647713
};
648714

649715
formHistory.push(formData);
@@ -666,7 +732,10 @@ <h3 class="history-title">История введенных данных</h3>
666732
const Y = document.getElementById('Y').value;
667733

668734
if (X && R && Y) {
669-
sendAJAXGETRequest("/fcgi-bin/", {"x": X, "y": Y, "r": R}, (resp) => {FFCGIResponceHandler(resp, X, Y, R)});
735+
736+
// Stub
737+
sendAJAXGETRequest("/fcgi/", {"x": X, "y": Y, "r": R}, (data) => {FFCGIResponceHandler(data, X,Y,R)});
738+
console.log(`Данные отправлены!\nX: ${X}\nY: ${Y}\nR: ${R}`);
670739

671740
// Очищаем форму
672741
this.reset();

server/.idea/misc.xml

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/.idea/vcs.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.validator;
2+
3+
import org.validator.validation.ValidationController;
4+
5+
import java.lang.reflect.Constructor;
6+
import java.lang.reflect.InvocationTargetException;
7+
8+
public class ValidatedRecordFactory {
9+
@SuppressWarnings("unchecked")
10+
public static <T extends Record> T create(Class<T> recordClass, Object... args) {
11+
try {
12+
Constructor<T> constructor = (Constructor<T>) recordClass.getDeclaredConstructors()[0];
13+
T record = constructor.newInstance(args);
14+
15+
ValidationController.validateObject(record);
16+
17+
return record;
18+
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
19+
throw new RuntimeException("Record can't be created", e);
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)