feat: добавлена пометка типа операции (Build/Push) в истории сборок Dockerfile
- Добавлена колонка 'Тип' во все таблицы истории сборок - Для push операций отображается registry вместо платформ - Сохранение пользователя при создании push лога - Исправлена ошибка с logger в push_docker_image endpoint - Улучшено отображение истории сборок с визуальными индикаторами
This commit is contained in:
287
app/static/css/buttons.css
Normal file
287
app/static/css/buttons.css
Normal file
@@ -0,0 +1,287 @@
|
||||
/* Современные стили для кнопок */
|
||||
/* Автор: Сергей Антропов - https://devops.org.ru */
|
||||
|
||||
:root {
|
||||
--btn-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
--btn-primary-hover: linear-gradient(135deg, #5568d3 0%, #6a3d8f 100%);
|
||||
--btn-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
--btn-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.btn {
|
||||
font-weight: 600;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: 0.5rem;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: var(--transition);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.9375rem;
|
||||
line-height: 1.5;
|
||||
text-decoration: none;
|
||||
box-shadow: var(--btn-shadow);
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.btn::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
transform: translate(-50%, -50%);
|
||||
transition: width 0.6s, height 0.6s;
|
||||
}
|
||||
|
||||
.btn:hover::before {
|
||||
width: 300px;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: var(--btn-shadow-hover);
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: var(--btn-shadow);
|
||||
}
|
||||
|
||||
.btn:focus {
|
||||
outline: none;
|
||||
box-shadow: var(--btn-shadow-hover), 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
|
||||
}
|
||||
|
||||
/* Primary button */
|
||||
.btn-primary {
|
||||
background: var(--btn-primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: var(--btn-primary-hover);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Success button */
|
||||
.btn-success {
|
||||
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-success:hover {
|
||||
background: linear-gradient(135deg, #059669 0%, #047857 100%);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Secondary button */
|
||||
.btn-secondary {
|
||||
background: #6b7280;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #4b5563;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Outline buttons */
|
||||
.btn-outline-primary {
|
||||
background: transparent;
|
||||
border: 2px solid #667eea;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.btn-outline-primary:hover {
|
||||
background: #667eea;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-outline-secondary {
|
||||
background: transparent;
|
||||
border: 2px solid #6b7280;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.btn-outline-secondary:hover {
|
||||
background: #6b7280;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-outline-light {
|
||||
background: transparent;
|
||||
border: 2px solid rgba(255, 255, 255, 0.5);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-outline-light:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-color: #fff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-outline-info {
|
||||
background: transparent;
|
||||
border: 2px solid #0dcaf0;
|
||||
color: #0dcaf0;
|
||||
}
|
||||
|
||||
.btn-outline-info:hover {
|
||||
background: #0dcaf0;
|
||||
color: #fff;
|
||||
border-color: #0dcaf0;
|
||||
}
|
||||
|
||||
.btn-outline-warning {
|
||||
background: transparent;
|
||||
border: 2px solid #ffc107;
|
||||
color: #ffc107;
|
||||
}
|
||||
|
||||
.btn-outline-warning:hover {
|
||||
background: #ffc107;
|
||||
color: #000;
|
||||
border-color: #ffc107;
|
||||
}
|
||||
|
||||
.btn-outline-success {
|
||||
background: transparent;
|
||||
border: 2px solid #10b981;
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
.btn-outline-success:hover {
|
||||
background: #10b981;
|
||||
color: #fff;
|
||||
border-color: #10b981;
|
||||
}
|
||||
|
||||
/* Светлосерый border для кнопок ZFS и LVM */
|
||||
.btn-outline-success[hx-post*="/sync/storages"],
|
||||
.btn-outline-warning[hx-post*="/sync/lvm"] {
|
||||
border-color: #d3d3d3;
|
||||
}
|
||||
|
||||
.btn-outline-success[hx-post*="/sync/storages"]:hover,
|
||||
.btn-outline-warning[hx-post*="/sync/lvm"]:hover {
|
||||
border-color: #d3d3d3;
|
||||
}
|
||||
|
||||
/* Danger button */
|
||||
.btn-danger {
|
||||
background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Small buttons */
|
||||
.btn-sm {
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 0.875rem;
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
|
||||
/* Large buttons */
|
||||
.btn-lg {
|
||||
padding: 1rem 2rem;
|
||||
font-size: 1.125rem;
|
||||
border-radius: 0.625rem;
|
||||
}
|
||||
|
||||
/* Disabled state */
|
||||
.btn:disabled,
|
||||
.btn.disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.btn:disabled:hover,
|
||||
.btn.disabled:hover {
|
||||
transform: none;
|
||||
box-shadow: var(--btn-shadow);
|
||||
}
|
||||
|
||||
/* Logout button */
|
||||
.btn-logout {
|
||||
background: transparent;
|
||||
border: 2px solid rgba(255, 255, 255, 0.5);
|
||||
color: #fff;
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
.btn-logout:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-color: #fff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Icon spacing in buttons */
|
||||
.btn span {
|
||||
display: inline-block;
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.btn:hover span {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
/* Button groups */
|
||||
.btn-group {
|
||||
display: inline-flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
/* Loading state */
|
||||
.btn.loading {
|
||||
position: relative;
|
||||
color: transparent;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.btn.loading::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin-left: -8px;
|
||||
margin-top: -8px;
|
||||
border: 2px solid currentColor;
|
||||
border-radius: 50%;
|
||||
border-top-color: transparent;
|
||||
animation: spin 0.6s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 768px) {
|
||||
.btn {
|
||||
padding: 0.625rem 1.25rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
padding: 0.375rem 0.75rem;
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
}
|
||||
596
app/static/css/forms.css
Normal file
596
app/static/css/forms.css
Normal file
@@ -0,0 +1,596 @@
|
||||
/* Современные стили для форм */
|
||||
/* Автор: Сергей Антропов - https://devops.org.ru */
|
||||
|
||||
:root {
|
||||
--input-border-color: #dee2e6;
|
||||
--input-focus-border-color: #667eea;
|
||||
--input-focus-box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
|
||||
--input-error-border-color: #dc3545;
|
||||
--input-error-box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
|
||||
--input-success-border-color: #198754;
|
||||
--input-success-box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
|
||||
--form-bg: #ffffff;
|
||||
--form-border-radius: 0.75rem;
|
||||
--form-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
--form-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
||||
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
/* Карточки форм */
|
||||
.card {
|
||||
background: var(--form-bg);
|
||||
border: none;
|
||||
border-radius: var(--form-border-radius);
|
||||
box-shadow: var(--form-shadow);
|
||||
transition: var(--transition);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card:hover {
|
||||
box-shadow: var(--form-shadow-hover);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
font-size: 1.25rem;
|
||||
padding: 1.25rem 1.5rem;
|
||||
border: none;
|
||||
border-radius: var(--form-border-radius) var(--form-border-radius) 0 0;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
background: #f8f9fa;
|
||||
border-top: 1px solid #e9ecef;
|
||||
padding: 1.25rem 1.5rem;
|
||||
border-radius: 0 0 var(--form-border-radius) var(--form-border-radius);
|
||||
}
|
||||
|
||||
/* Группы полей */
|
||||
.form-group {
|
||||
margin-bottom: 1.75rem;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.form-group:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* Метки полей */
|
||||
.form-label {
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
margin-bottom: 0.625rem;
|
||||
color: #374151;
|
||||
display: block;
|
||||
letter-spacing: 0.025em;
|
||||
text-transform: uppercase;
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.form-label::after {
|
||||
content: '';
|
||||
display: block;
|
||||
width: 30px;
|
||||
height: 2px;
|
||||
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
||||
margin-top: 0.25rem;
|
||||
border-radius: 2px;
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.form-group:focus-within .form-label::after {
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
/* Поля ввода */
|
||||
.form-control,
|
||||
.form-select {
|
||||
border: 2px solid var(--input-border-color);
|
||||
border-radius: 0.5rem;
|
||||
padding: 0.875rem 1rem;
|
||||
font-size: 1rem;
|
||||
transition: var(--transition);
|
||||
background-color: #fff;
|
||||
color: #1f2937;
|
||||
width: 100%;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.form-control::placeholder {
|
||||
color: #9ca3af;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.form-control:hover,
|
||||
.form-select:hover {
|
||||
border-color: #cbd5e1;
|
||||
}
|
||||
|
||||
.form-control:focus,
|
||||
.form-select:focus {
|
||||
border-color: var(--input-focus-border-color);
|
||||
outline: 0;
|
||||
box-shadow: var(--input-focus-box-shadow);
|
||||
background-color: #fff;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.form-control:disabled,
|
||||
.form-select:disabled {
|
||||
background-color: #f3f4f6;
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
/* Состояния валидации */
|
||||
.form-control.is-invalid,
|
||||
.form-select.is-invalid {
|
||||
border-color: var(--input-error-border-color);
|
||||
padding-right: calc(1.5em + 1rem);
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 3.6.4.4.4-.4m0 4.8h-.8'/%3e%3c/svg%3e");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right calc(0.5em + 0.25rem) center;
|
||||
background-size: calc(0.75em + 0.5rem) calc(0.75em + 0.5rem);
|
||||
}
|
||||
|
||||
.form-control.is-invalid:focus,
|
||||
.form-select.is-invalid:focus {
|
||||
border-color: var(--input-error-border-color);
|
||||
box-shadow: var(--input-error-box-shadow);
|
||||
}
|
||||
|
||||
.form-control.is-valid,
|
||||
.form-select.is-valid {
|
||||
border-color: var(--input-success-border-color);
|
||||
padding-right: calc(1.5em + 1rem);
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right calc(0.5em + 0.25rem) center;
|
||||
background-size: calc(0.75em + 0.5rem) calc(0.75em + 0.5rem);
|
||||
}
|
||||
|
||||
.form-control.is-valid:focus,
|
||||
.form-select.is-valid:focus {
|
||||
border-color: var(--input-success-border-color);
|
||||
box-shadow: var(--input-success-box-shadow);
|
||||
}
|
||||
|
||||
/* Текстовые области */
|
||||
textarea.form-control {
|
||||
min-height: 100px;
|
||||
resize: vertical;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
/* Селекты */
|
||||
.form-select {
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 0.75rem center;
|
||||
background-size: 16px 12px;
|
||||
padding-right: 2.5rem;
|
||||
appearance: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.form-select:focus {
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23667eea' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
|
||||
}
|
||||
|
||||
/* Чекбоксы и переключатели */
|
||||
.form-check {
|
||||
margin-bottom: 1rem;
|
||||
margin-top: 1rem;
|
||||
margin-left: 2rem !important;
|
||||
padding-left: 2rem;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Отступ для чекбоксов внутри form-group, чтобы они были выровнены с текстовыми полями */
|
||||
.form-group .form-check {
|
||||
margin-left: 0;
|
||||
padding-left: 2rem;
|
||||
}
|
||||
|
||||
.form-check-input {
|
||||
width: 1.25em;
|
||||
height: 1.25em;
|
||||
margin-top: 0.125em;
|
||||
margin-left: -2rem;
|
||||
vertical-align: top;
|
||||
background-color: #fff;
|
||||
border: 2px solid var(--input-border-color);
|
||||
border-radius: 0.375em;
|
||||
cursor: pointer;
|
||||
transition: var(--transition);
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0.25em;
|
||||
}
|
||||
|
||||
.form-check-input:hover {
|
||||
border-color: var(--input-focus-border-color);
|
||||
}
|
||||
|
||||
.form-check-input:checked {
|
||||
background-color: #667eea;
|
||||
border-color: #667eea;
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
|
||||
}
|
||||
|
||||
.form-check-input:focus {
|
||||
border-color: var(--input-focus-border-color);
|
||||
outline: 0;
|
||||
box-shadow: var(--input-focus-box-shadow);
|
||||
}
|
||||
|
||||
.form-check-label {
|
||||
margin-left: 0;
|
||||
cursor: pointer;
|
||||
font-weight: 500;
|
||||
color: #374151;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* Переключатели (switches) */
|
||||
.form-switch .form-check-input {
|
||||
width: 2.5em;
|
||||
height: 1.5em;
|
||||
border-radius: 2em;
|
||||
background-color: #d1d5db;
|
||||
border: none;
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
|
||||
background-position: left center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 1.25em 1.25em;
|
||||
transition: var(--transition);
|
||||
}
|
||||
|
||||
.form-switch .form-check-input:checked {
|
||||
background-color: #667eea;
|
||||
background-position: right center;
|
||||
}
|
||||
|
||||
.form-switch .form-check-input:focus {
|
||||
box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
|
||||
}
|
||||
|
||||
/* Сообщения об ошибках */
|
||||
.invalid-feedback {
|
||||
display: none;
|
||||
width: 100%;
|
||||
margin-top: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
color: var(--input-error-border-color);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.was-validated .form-control:invalid ~ .invalid-feedback,
|
||||
.was-validated .form-select:invalid ~ .invalid-feedback,
|
||||
.form-control.is-invalid ~ .invalid-feedback,
|
||||
.form-select.is-invalid ~ .invalid-feedback {
|
||||
display: block;
|
||||
animation: slideDown 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes slideDown {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Вспомогательный текст */
|
||||
.form-text {
|
||||
margin-top: 0.5rem;
|
||||
font-size: 0.875rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
/* Группы полей в ряд */
|
||||
.form-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-left: -0.5rem;
|
||||
margin-right: -0.5rem;
|
||||
}
|
||||
|
||||
.form-row > * {
|
||||
padding-left: 0.5rem;
|
||||
padding-right: 0.5rem;
|
||||
}
|
||||
|
||||
/* Форма авторизации */
|
||||
.login-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 1rem;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
overflow: hidden;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.login-container::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -50%;
|
||||
left: -50%;
|
||||
width: 200%;
|
||||
height: 200%;
|
||||
background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
|
||||
background-size: 50px 50px;
|
||||
animation: moveBackground 20s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes moveBackground {
|
||||
0% {
|
||||
transform: translate(0, 0);
|
||||
}
|
||||
100% {
|
||||
transform: translate(50px, 50px);
|
||||
}
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
background: #fff;
|
||||
border-radius: 1.5rem;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
||||
padding: 2.5rem;
|
||||
animation: fadeInUp 0.6s ease;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.login-card .card-header {
|
||||
text-align: center;
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
color: #1f2937;
|
||||
margin-bottom: 2rem;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.login-card .card-body {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.login-form .form-group {
|
||||
margin-bottom: 1.75rem;
|
||||
}
|
||||
|
||||
.login-form .form-label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: #374151;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.login-form .form-control {
|
||||
padding: 1rem 1.25rem;
|
||||
font-size: 1rem;
|
||||
border-radius: 0.75rem;
|
||||
border: 2px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.login-form .form-control:focus {
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
|
||||
}
|
||||
|
||||
/* Улучшенные отступы для форм */
|
||||
.mb-2 {
|
||||
margin-bottom: 1rem !important;
|
||||
}
|
||||
|
||||
.mb-3 {
|
||||
margin-bottom: 1.5rem !important;
|
||||
}
|
||||
|
||||
.mt-3 {
|
||||
margin-top: 1.5rem !important;
|
||||
}
|
||||
|
||||
/* Адаптивность */
|
||||
@media (max-width: 768px) {
|
||||
.login-card {
|
||||
padding: 2rem 1.5rem;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.form-control,
|
||||
.form-select {
|
||||
font-size: 16px; /* Предотвращает зум на iOS */
|
||||
}
|
||||
|
||||
.form-label {
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* Анимация появления полей */
|
||||
.form-group {
|
||||
animation: fadeIn 0.4s ease;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Стили для страниц форм */
|
||||
.form-page {
|
||||
/* background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%); */
|
||||
min-height: calc(100vh - 200px);
|
||||
padding: 2rem 0;
|
||||
}
|
||||
|
||||
.form-page .card {
|
||||
border: none;
|
||||
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* Улучшенные кнопки в формах */
|
||||
.form-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 0.75rem;
|
||||
margin-top: 2rem;
|
||||
padding-top: 1.5rem;
|
||||
border-top: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
/* Priority Switch Styles */
|
||||
.priority-switch-group {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.priority-switch {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.priority-label {
|
||||
flex: 1;
|
||||
min-width: 100px;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 2px solid #dee2e6;
|
||||
border-radius: 0.5rem;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
font-weight: 500;
|
||||
background: #ffffff;
|
||||
color: #495057;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.priority-label::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: currentColor;
|
||||
opacity: 0.1;
|
||||
transform: scaleX(0);
|
||||
transform-origin: left;
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.priority-label:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.priority-switch:checked + .priority-label {
|
||||
border-width: 3px;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.priority-switch:checked + .priority-label::before {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
|
||||
/* Priority Colors */
|
||||
.priority-very-slow {
|
||||
border-color: #6c757d;
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.priority-switch:checked + .priority-very-slow {
|
||||
background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
|
||||
color: #ffffff;
|
||||
border-color: #5a6268;
|
||||
}
|
||||
|
||||
.priority-slow {
|
||||
border-color: #0dcaf0;
|
||||
color: #0dcaf0;
|
||||
}
|
||||
|
||||
.priority-switch:checked + .priority-slow {
|
||||
background: linear-gradient(135deg, #0dcaf0 0%, #0aa2c0 100%);
|
||||
color: #ffffff;
|
||||
border-color: #0aa2c0;
|
||||
}
|
||||
|
||||
.priority-middle {
|
||||
border-color: #667eea;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.priority-switch:checked + .priority-middle {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #ffffff;
|
||||
border-color: #764ba2;
|
||||
}
|
||||
|
||||
.priority-fast {
|
||||
border-color: #ffc107;
|
||||
color: #ffc107;
|
||||
}
|
||||
|
||||
.priority-switch:checked + .priority-fast {
|
||||
background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%);
|
||||
color: #212529;
|
||||
border-color: #ffb300;
|
||||
}
|
||||
|
||||
.priority-very-fast {
|
||||
border-color: #198754;
|
||||
color: #198754;
|
||||
}
|
||||
|
||||
.priority-switch:checked + .priority-very-fast {
|
||||
background: linear-gradient(135deg, #198754 0%, #157347 100%);
|
||||
color: #ffffff;
|
||||
border-color: #157347;
|
||||
}
|
||||
3771
app/static/css/main.css
Normal file
3771
app/static/css/main.css
Normal file
File diff suppressed because it is too large
Load Diff
465
app/static/js/app.js
Executable file
465
app/static/js/app.js
Executable file
@@ -0,0 +1,465 @@
|
||||
/**
|
||||
* JavaScript для DevOpsLab
|
||||
* Автор: Сергей Антропов - https://devops.org.ru
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const TOOLS_MENU_STORAGE_KEY = 'devopslab_tools_menu_open';
|
||||
const SETTINGS_MENU_STORAGE_KEY = 'devopslab_settings_menu_open';
|
||||
const SIDEBAR_COLLAPSED_KEY = 'devopslab_sidebar_collapsed';
|
||||
const SIDEBAR_WIDTH_KEY = 'devopslab_sidebar_width';
|
||||
const SIDEBAR_DEFAULT_WIDTH = 260;
|
||||
const SIDEBAR_MIN_WIDTH = 180;
|
||||
const SIDEBAR_MAX_WIDTH = 400;
|
||||
const SIDEBAR_COLLAPSED_WIDTH = 64;
|
||||
|
||||
/**
|
||||
* Сохраняет состояние меню в localStorage
|
||||
*/
|
||||
function saveMenuState(storageKey, isOpen) {
|
||||
localStorage.setItem(storageKey, isOpen ? 'true' : 'false');
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает сохраненное состояние меню из localStorage
|
||||
*/
|
||||
function getMenuState(storageKey) {
|
||||
const saved = localStorage.getItem(storageKey);
|
||||
return saved === 'true';
|
||||
}
|
||||
|
||||
/**
|
||||
* Переключает состояние меню инструментов
|
||||
*/
|
||||
function toggleToolsMenu(event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
const menuItem = document.getElementById('tools-menu');
|
||||
if (!menuItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isOpen = menuItem.classList.contains('open');
|
||||
|
||||
if (isOpen) {
|
||||
menuItem.classList.remove('open');
|
||||
saveMenuState(TOOLS_MENU_STORAGE_KEY, false);
|
||||
} else {
|
||||
menuItem.classList.add('open');
|
||||
saveMenuState(TOOLS_MENU_STORAGE_KEY, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Инициализация меню инструментов при загрузке страницы
|
||||
*/
|
||||
function initToolsMenu() {
|
||||
const menuItem = document.getElementById('tools-menu');
|
||||
if (!menuItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверяем, есть ли активный пункт в подменю
|
||||
const hasActiveItem = menuItem.querySelector('.sidebar-menu-link.active');
|
||||
|
||||
// Восстанавливаем состояние из localStorage или открываем, если есть активный пункт
|
||||
const shouldBeOpen = hasActiveItem || getMenuState(TOOLS_MENU_STORAGE_KEY);
|
||||
|
||||
if (shouldBeOpen) {
|
||||
menuItem.classList.add('open');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Переключает состояние меню настроек
|
||||
*/
|
||||
function toggleSettingsMenu(event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
const menuItem = document.getElementById('settings-menu');
|
||||
if (!menuItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isOpen = menuItem.classList.contains('open');
|
||||
|
||||
if (isOpen) {
|
||||
menuItem.classList.remove('open');
|
||||
saveMenuState(SETTINGS_MENU_STORAGE_KEY, false);
|
||||
} else {
|
||||
menuItem.classList.add('open');
|
||||
saveMenuState(SETTINGS_MENU_STORAGE_KEY, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Инициализация меню настроек при загрузке страницы
|
||||
*/
|
||||
function initSettingsMenu() {
|
||||
const menuItem = document.getElementById('settings-menu');
|
||||
if (!menuItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Проверяем, есть ли активный пункт в подменю
|
||||
const hasActiveItem = menuItem.querySelector('.sidebar-menu-link.active');
|
||||
|
||||
// Восстанавливаем состояние из localStorage или открываем, если есть активный пункт
|
||||
const shouldBeOpen = hasActiveItem || getMenuState(SETTINGS_MENU_STORAGE_KEY);
|
||||
|
||||
if (shouldBeOpen) {
|
||||
menuItem.classList.add('open');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Открыть/закрыть сайдбар на мобильных
|
||||
*/
|
||||
function toggleSidebar() {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
const overlay = document.getElementById('sidebar-overlay');
|
||||
if (!sidebar || !overlay) return;
|
||||
const isOpen = sidebar.classList.contains('open');
|
||||
if (isOpen) {
|
||||
sidebar.classList.remove('open');
|
||||
overlay.classList.remove('visible');
|
||||
overlay.setAttribute('aria-hidden', 'true');
|
||||
document.body.style.overflow = '';
|
||||
} else {
|
||||
sidebar.classList.add('open');
|
||||
overlay.classList.add('visible');
|
||||
overlay.setAttribute('aria-hidden', 'false');
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
}
|
||||
|
||||
function closeSidebar() {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
const overlay = document.getElementById('sidebar-overlay');
|
||||
if (!sidebar || !overlay) return;
|
||||
sidebar.classList.remove('open');
|
||||
overlay.classList.remove('visible');
|
||||
overlay.setAttribute('aria-hidden', 'true');
|
||||
document.body.style.overflow = '';
|
||||
}
|
||||
|
||||
function initSidebarToggle() {
|
||||
const btn = document.getElementById('sidebar-toggle-btn');
|
||||
const overlay = document.getElementById('sidebar-overlay');
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
if (btn) {
|
||||
btn.addEventListener('click', toggleSidebar);
|
||||
}
|
||||
if (overlay) {
|
||||
overlay.addEventListener('click', closeSidebar);
|
||||
}
|
||||
if (sidebar) {
|
||||
sidebar.querySelectorAll('.sidebar-menu-link').forEach(function(link) {
|
||||
link.addEventListener('click', function() {
|
||||
if (window.innerWidth < 992) {
|
||||
closeSidebar();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Применить ширину сайдбара (CSS переменная и margin main-wrapper)
|
||||
*/
|
||||
function applySidebarWidth(widthPx) {
|
||||
document.documentElement.style.setProperty('--sidebar-width', widthPx + 'px');
|
||||
}
|
||||
|
||||
/**
|
||||
* Сохранить и применить состояние сайдбара из localStorage
|
||||
*/
|
||||
function applySidebarState() {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
if (!sidebar) return;
|
||||
const collapsed = localStorage.getItem(SIDEBAR_COLLAPSED_KEY) === 'true';
|
||||
const savedWidth = parseInt(localStorage.getItem(SIDEBAR_WIDTH_KEY), 10);
|
||||
const width = (savedWidth >= SIDEBAR_MIN_WIDTH && savedWidth <= SIDEBAR_MAX_WIDTH)
|
||||
? savedWidth
|
||||
: SIDEBAR_DEFAULT_WIDTH;
|
||||
if (collapsed) {
|
||||
sidebar.classList.add('collapsed');
|
||||
applySidebarWidth(SIDEBAR_COLLAPSED_WIDTH);
|
||||
} else {
|
||||
sidebar.classList.remove('collapsed');
|
||||
applySidebarWidth(width);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Переключить сворачивание сайдбара (десктоп)
|
||||
*/
|
||||
function toggleSidebarCollapse() {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
if (!sidebar) return;
|
||||
|
||||
// На мобильных устройствах не сворачиваем
|
||||
if (window.innerWidth < 992) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isCollapsed = sidebar.classList.contains('collapsed');
|
||||
const newCollapsed = !isCollapsed;
|
||||
|
||||
// Переключаем класс
|
||||
if (newCollapsed) {
|
||||
sidebar.classList.add('collapsed');
|
||||
} else {
|
||||
sidebar.classList.remove('collapsed');
|
||||
}
|
||||
|
||||
// Сохраняем состояние
|
||||
localStorage.setItem(SIDEBAR_COLLAPSED_KEY, newCollapsed ? 'true' : 'false');
|
||||
|
||||
// Применяем ширину
|
||||
if (newCollapsed) {
|
||||
applySidebarWidth(SIDEBAR_COLLAPSED_WIDTH);
|
||||
} else {
|
||||
const savedWidth = parseInt(localStorage.getItem(SIDEBAR_WIDTH_KEY), 10);
|
||||
const width = (savedWidth >= SIDEBAR_MIN_WIDTH && savedWidth <= SIDEBAR_MAX_WIDTH)
|
||||
? savedWidth
|
||||
: SIDEBAR_DEFAULT_WIDTH;
|
||||
applySidebarWidth(width);
|
||||
}
|
||||
|
||||
// Обновляем атрибуты кнопки
|
||||
const btn = document.getElementById('sidebar-collapse-btn');
|
||||
if (btn) {
|
||||
btn.setAttribute('aria-label', newCollapsed ? 'Развернуть меню' : 'Свернуть меню');
|
||||
btn.setAttribute('title', newCollapsed ? 'Развернуть меню' : 'Свернуть меню');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Инициализация перетаскивания ширины сайдбара
|
||||
*/
|
||||
function initSidebarResize() {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
const handle = document.getElementById('sidebar-resize-handle');
|
||||
if (!sidebar || !handle || window.innerWidth < 992) return;
|
||||
let startX, startWidth;
|
||||
handle.addEventListener('mousedown', function(e) {
|
||||
if (sidebar.classList.contains('collapsed')) return;
|
||||
e.preventDefault();
|
||||
startX = e.clientX;
|
||||
startWidth = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--sidebar-width'), 10) || SIDEBAR_DEFAULT_WIDTH;
|
||||
handle.classList.add('dragging');
|
||||
document.body.style.cursor = 'col-resize';
|
||||
document.body.style.userSelect = 'none';
|
||||
function onMouseMove(e) {
|
||||
const delta = e.clientX - startX;
|
||||
let newWidth = startWidth + delta;
|
||||
newWidth = Math.max(SIDEBAR_MIN_WIDTH, Math.min(SIDEBAR_MAX_WIDTH, newWidth));
|
||||
applySidebarWidth(newWidth);
|
||||
localStorage.setItem(SIDEBAR_WIDTH_KEY, String(newWidth));
|
||||
}
|
||||
function onMouseUp() {
|
||||
handle.classList.remove('dragging');
|
||||
document.body.style.cursor = '';
|
||||
document.body.style.userSelect = '';
|
||||
document.removeEventListener('mousemove', onMouseMove);
|
||||
document.removeEventListener('mouseup', onMouseUp);
|
||||
}
|
||||
document.addEventListener('mousemove', onMouseMove);
|
||||
document.addEventListener('mouseup', onMouseUp);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Инициализация кнопки сворачивания и ресайза
|
||||
*/
|
||||
function initSidebarCollapseAndResize() {
|
||||
applySidebarState();
|
||||
const collapseBtn = document.getElementById('sidebar-collapse-btn');
|
||||
if (collapseBtn) {
|
||||
collapseBtn.addEventListener('click', toggleSidebarCollapse);
|
||||
}
|
||||
initSidebarResize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Показать модальное окно с сообщением
|
||||
* @param {string} message - Текст сообщения
|
||||
* @param {string} type - Тип сообщения: 'success', 'error', 'warning', 'info'
|
||||
* @param {string} title - Заголовок модального окна (опционально)
|
||||
* @param {Function} onClose - Callback при закрытии модального окна (опционально)
|
||||
*/
|
||||
function showMessageModal(message, type = 'info', title = null, onClose = null) {
|
||||
const modal = document.getElementById('messageModal');
|
||||
if (!modal) {
|
||||
console.error('Message modal not found');
|
||||
return;
|
||||
}
|
||||
|
||||
const modalElement = new bootstrap.Modal(modal);
|
||||
const modalHeader = document.getElementById('messageModalHeader');
|
||||
const modalTitle = document.getElementById('messageModalTitle');
|
||||
const modalIcon = document.getElementById('messageModalIcon');
|
||||
const modalText = document.getElementById('messageModalText');
|
||||
|
||||
// Устанавливаем текст сообщения
|
||||
modalText.textContent = message;
|
||||
|
||||
// Устанавливаем заголовок
|
||||
if (title) {
|
||||
modalTitle.textContent = title;
|
||||
} else {
|
||||
// Заголовок по умолчанию в зависимости от типа
|
||||
switch(type) {
|
||||
case 'success':
|
||||
modalTitle.textContent = 'Успешно';
|
||||
break;
|
||||
case 'error':
|
||||
modalTitle.textContent = 'Ошибка';
|
||||
break;
|
||||
case 'warning':
|
||||
modalTitle.textContent = 'Предупреждение';
|
||||
break;
|
||||
default:
|
||||
modalTitle.textContent = 'Сообщение';
|
||||
}
|
||||
}
|
||||
|
||||
// Устанавливаем иконку и цвет в зависимости от типа
|
||||
modalHeader.className = 'modal-header';
|
||||
modalIcon.className = 'fas me-2';
|
||||
|
||||
switch(type) {
|
||||
case 'success':
|
||||
modalHeader.classList.add('bg-success', 'text-white');
|
||||
modalIcon.classList.add('fa-check-circle');
|
||||
break;
|
||||
case 'error':
|
||||
modalHeader.classList.add('bg-danger', 'text-white');
|
||||
modalIcon.classList.add('fa-exclamation-circle');
|
||||
break;
|
||||
case 'warning':
|
||||
modalHeader.classList.add('bg-warning', 'text-dark');
|
||||
modalIcon.classList.add('fa-exclamation-triangle');
|
||||
break;
|
||||
default:
|
||||
modalHeader.classList.add('bg-info', 'text-white');
|
||||
modalIcon.classList.add('fa-info-circle');
|
||||
}
|
||||
|
||||
// Показываем модальное окно
|
||||
modalElement.show();
|
||||
|
||||
// Обработчик закрытия
|
||||
if (onClose) {
|
||||
modal.addEventListener('hidden.bs.modal', function handler() {
|
||||
onClose();
|
||||
modal.removeEventListener('hidden.bs.modal', handler);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Делаем функции доступными глобально
|
||||
window.toggleToolsMenu = toggleToolsMenu;
|
||||
window.toggleSettingsMenu = toggleSettingsMenu;
|
||||
window.toggleSidebar = toggleSidebar;
|
||||
window.closeSidebar = closeSidebar;
|
||||
window.toggleSidebarCollapse = toggleSidebarCollapse;
|
||||
window.showMessageModal = showMessageModal;
|
||||
|
||||
// Инициализация при загрузке DOM
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
initToolsMenu();
|
||||
initSettingsMenu();
|
||||
initSidebarToggle();
|
||||
initSidebarCollapseAndResize();
|
||||
|
||||
// Автоскролл для логов
|
||||
const logContainers = document.querySelectorAll('.log-container');
|
||||
logContainers.forEach(container => {
|
||||
container.scrollTop = container.scrollHeight;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
initToolsMenu();
|
||||
initSettingsMenu();
|
||||
initSidebarToggle();
|
||||
initSidebarCollapseAndResize();
|
||||
|
||||
// Автоскролл для логов
|
||||
const logContainers = document.querySelectorAll('.log-container');
|
||||
logContainers.forEach(container => {
|
||||
container.scrollTop = container.scrollHeight;
|
||||
});
|
||||
}
|
||||
|
||||
// HTMX конфигурация
|
||||
if (typeof htmx !== 'undefined') {
|
||||
htmx.config.globalViewTransitions = true;
|
||||
htmx.config.useTemplateFragments = true;
|
||||
|
||||
// Обработка ошибок HTMX
|
||||
htmx.on("htmx:responseError", function(event) {
|
||||
console.error("HTMX Error:", event.detail);
|
||||
const errorMessage = event.detail.error || event.detail.xhr?.responseText || 'Неизвестная ошибка';
|
||||
showMessageModal(errorMessage, 'error');
|
||||
});
|
||||
|
||||
// Обработка успешных запросов с JSON ответами
|
||||
htmx.on("htmx:afterRequest", function(event) {
|
||||
// Автоскролл для логов после обновления
|
||||
const logContainers = document.querySelectorAll('.log-container');
|
||||
logContainers.forEach(container => {
|
||||
container.scrollTop = container.scrollHeight;
|
||||
});
|
||||
|
||||
// Проверяем, является ли ответ JSON с полем message
|
||||
if (event.detail.xhr) {
|
||||
const status = event.detail.xhr.status;
|
||||
try {
|
||||
const response = JSON.parse(event.detail.xhr.responseText);
|
||||
|
||||
// Обрабатываем сообщения об успехе (200)
|
||||
if (status === 200 && response.message) {
|
||||
// Определяем тип сообщения
|
||||
let messageType = 'info';
|
||||
const msgLower = response.message.toLowerCase();
|
||||
if (msgLower.includes('успешно') ||
|
||||
msgLower.includes('success') ||
|
||||
msgLower.includes('создан') ||
|
||||
msgLower.includes('обновлен') ||
|
||||
msgLower.includes('удален') ||
|
||||
msgLower.includes('отменен')) {
|
||||
messageType = 'success';
|
||||
} else if (msgLower.includes('ошибка') ||
|
||||
msgLower.includes('error') ||
|
||||
msgLower.includes('не удалось') ||
|
||||
msgLower.includes('failed')) {
|
||||
messageType = 'error';
|
||||
}
|
||||
|
||||
// Показываем модальное окно для всех сообщений
|
||||
showMessageModal(response.message, messageType);
|
||||
}
|
||||
// Обрабатываем ошибки (4xx, 5xx)
|
||||
else if (status >= 400 && (response.detail || response.message)) {
|
||||
const errorMessage = response.detail || response.message || 'Произошла ошибка';
|
||||
showMessageModal(errorMessage, 'error');
|
||||
}
|
||||
} catch (e) {
|
||||
// Не JSON ответ, для ошибок показываем общее сообщение
|
||||
if (status >= 400) {
|
||||
showMessageModal('Произошла ошибка при выполнении запроса', 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
190
app/static/js/editor.js
Normal file
190
app/static/js/editor.js
Normal file
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* Редактор кода с подсветкой синтаксиса
|
||||
* Использует CodeMirror 6
|
||||
* Автор: Сергей Антропов
|
||||
* Сайт: https://devops.org.ru
|
||||
*/
|
||||
|
||||
// Инициализация CodeMirror редактора
|
||||
function initCodeEditor(textareaId, language = 'yaml', options = {}) {
|
||||
const textarea = document.getElementById(textareaId);
|
||||
if (!textarea) {
|
||||
console.error(`Textarea with id "${textareaId}" not found`);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Проверяем, что CodeMirror загружен
|
||||
if (typeof CodeMirror === 'undefined') {
|
||||
console.error('CodeMirror is not loaded. Please include CodeMirror library.');
|
||||
return null;
|
||||
}
|
||||
|
||||
const defaultOptions = {
|
||||
lineNumbers: true,
|
||||
mode: language,
|
||||
theme: 'default',
|
||||
indentUnit: 2,
|
||||
indentWithTabs: false,
|
||||
lineWrapping: true,
|
||||
matchBrackets: true,
|
||||
autoCloseBrackets: true,
|
||||
foldGutter: true,
|
||||
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
|
||||
...options
|
||||
};
|
||||
|
||||
const editor = CodeMirror.fromTextArea(textarea, defaultOptions);
|
||||
|
||||
// Сохраняем значение обратно в textarea при изменении
|
||||
editor.on('change', function(cm) {
|
||||
cm.save();
|
||||
});
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
// Валидация YAML
|
||||
function validateYAML(content) {
|
||||
try {
|
||||
// Используем js-yaml если доступен, иначе простую проверку
|
||||
if (typeof jsyaml !== 'undefined') {
|
||||
jsyaml.load(content);
|
||||
return { valid: true, errors: [] };
|
||||
} else {
|
||||
// Простая проверка синтаксиса
|
||||
const lines = content.split('\n');
|
||||
const errors = [];
|
||||
let indentStack = [0];
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
const trimmed = line.trim();
|
||||
|
||||
// Пропускаем пустые строки и комментарии
|
||||
if (!trimmed || trimmed.startsWith('#')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Проверка отступов
|
||||
const indent = line.length - line.trimStart().length;
|
||||
const lastIndent = indentStack[indentStack.length - 1];
|
||||
|
||||
if (indent > lastIndent + 2) {
|
||||
errors.push({
|
||||
line: i + 1,
|
||||
message: `Неправильный отступ на строке ${i + 1}`
|
||||
});
|
||||
}
|
||||
|
||||
// Проверка ключей без значений
|
||||
if (trimmed.endsWith(':') && !trimmed.includes('{') && !trimmed.includes('[')) {
|
||||
// Это нормально для YAML
|
||||
}
|
||||
}
|
||||
|
||||
return { valid: errors.length === 0, errors: errors };
|
||||
}
|
||||
} catch (e) {
|
||||
return {
|
||||
valid: false,
|
||||
errors: [{
|
||||
line: 1,
|
||||
message: e.message
|
||||
}]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Валидация Ansible playbook
|
||||
function validateAnsiblePlaybook(content) {
|
||||
const yamlValidation = validateYAML(content);
|
||||
if (!yamlValidation.valid) {
|
||||
return yamlValidation;
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof jsyaml !== 'undefined') {
|
||||
const parsed = jsyaml.load(content);
|
||||
|
||||
if (!Array.isArray(parsed)) {
|
||||
return {
|
||||
valid: false,
|
||||
errors: [{
|
||||
line: 1,
|
||||
message: 'Playbook должен быть списком (массивом)'
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
const errors = [];
|
||||
parsed.forEach((play, index) => {
|
||||
if (!play.hosts && !play.tasks && !play.roles) {
|
||||
errors.push({
|
||||
line: index + 1,
|
||||
message: `Play ${index + 1}: должен содержать hosts, tasks или roles`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return { valid: errors.length === 0, errors: errors };
|
||||
}
|
||||
} catch (e) {
|
||||
return {
|
||||
valid: false,
|
||||
errors: [{
|
||||
line: 1,
|
||||
message: e.message
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
return { valid: true, errors: [] };
|
||||
}
|
||||
|
||||
// Показ ошибок валидации в редакторе
|
||||
function showValidationErrors(editor, errors) {
|
||||
if (!editor || !editor._validationMarkers) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Очищаем предыдущие маркеры
|
||||
editor._validationMarkers.forEach(marker => {
|
||||
if (marker && typeof marker.clear === 'function') {
|
||||
marker.clear();
|
||||
} else if (marker && typeof marker.remove === 'function') {
|
||||
marker.remove();
|
||||
}
|
||||
});
|
||||
|
||||
editor._validationMarkers = [];
|
||||
|
||||
// Очищаем все gutter маркеры
|
||||
editor.clearGutter('CodeMirror-linenumbers');
|
||||
|
||||
errors.forEach(error => {
|
||||
const line = Math.max(0, (error.line || 1) - 1); // CodeMirror использует 0-based индексы
|
||||
try {
|
||||
// Добавляем класс для подсветки строки с ошибкой
|
||||
editor.addLineClass(line, 'background', 'cm-error-line');
|
||||
|
||||
// Добавляем маркер в gutter
|
||||
const marker = document.createElement('span');
|
||||
marker.className = 'cm-error-marker';
|
||||
marker.textContent = '⚠';
|
||||
marker.title = error.message || 'Ошибка';
|
||||
editor.setGutterMarker(line, 'CodeMirror-linenumbers', marker);
|
||||
|
||||
editor._validationMarkers.push({ line: line, marker: marker });
|
||||
} catch (e) {
|
||||
console.warn('Error adding validation marker:', e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Экспорт функций
|
||||
window.CodeEditor = {
|
||||
init: initCodeEditor,
|
||||
validateYAML: validateYAML,
|
||||
validateAnsible: validateAnsiblePlaybook,
|
||||
showErrors: showValidationErrors
|
||||
};
|
||||
Reference in New Issue
Block a user