Просмотр архива 3X-UI bot
Файл bot/module/templates/bot-settings.html
Вес запакованого файла 2.5Kb (2523 b)
Вес распакованого файла: 11.1Kb (11415 b)
Метод сжатия: 8
Вес запакованого файла 2.5Kb (2523 b)
Вес распакованого файла: 11.1Kb (11415 b)
Метод сжатия: 8
{% extends "base.html" %}
{% block title %}Настройки бота - Админ Панель{% endblock %}
{% block page_title %}<i class="mdi mdi-robot mr-2"></i>Настройки бота{% endblock %}
{% block breadcrumb %}
<li class="breadcrumb-item active">Настройки бота</li>
{% endblock %}
{% block content %}
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h4 class="mt-0 header-title">Настройки Telegram бота</h4>
<p class="text-muted">Управление основными параметрами бота</p>
</div>
</div>
<div class="alert alert-dark border-0">
<i class="mdi mdi-information-outline mr-2"></i>
После изменения настроек необходимо перезапустить бота, чтобы изменения вступили в силу.
</div>
<div class="table-responsive">
<table class="table table-bordered mb-0">
<thead>
<tr>
<th>API токен</th>
<th>Администратор</th>
<th class="text-center">Оповещения о регистрации</th>
<th class="text-center">Оповещения об оплате</th>
<th class="text-center">Статус</th>
<th class="text-center">Действия</th>
</tr>
</thead>
<tbody>
{% if settings %}
<tr>
<td>{{ settings.bot_token[:10] }}...{{ settings.bot_token[-5:] }}</td>
<td>{{ settings.admin_id }}</td>
<td class="text-center">
{% if settings.reg_notify %}
<span class="badge badge-success">Включены ({{ settings.reg_notify }})</span>
{% else %}
<span class="badge badge-danger">Отключены</span>
{% endif %}
</td>
<td class="text-center">
{% if settings.pay_notify %}
<span class="badge badge-success">Включены ({{ settings.pay_notify }})</span>
{% else %}
<span class="badge badge-danger">Отключены</span>
{% endif %}
</td>
<td class="text-center">
{% if settings.is_enable == 1 %}
<span class="badge badge-success">Активен</span>
{% else %}
<span class="badge badge-danger">Отключен</span>
{% endif %}
</td>
<td class="text-center">
<button type="button" class="btn btn-primary btn-square btn-outline-dashed waves-effect waves-light edit-settings">
<i class="mdi mdi-pencil mr-2"></i>Редактировать
</button>
</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="text-center">Настройки бота не найдены</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="editSettingsModal" tabindex="-1" role="dialog" aria-labelledby="editSettingsModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editSettingsModalLabel">Изменение настроек бота</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="editSettingsForm">
<div class="form-group">
<label for="bot_token">API токен</label>
<input type="text" class="form-control" id="bot_token" value="{{ settings.bot_token if settings else '' }}" required>
<small class="form-text text-muted">Токен, полученный от BotFather</small>
</div>
<div class="form-group">
<label for="admin_id">Администратор</label>
<input type="text" class="form-control" id="admin_id" value="{{ settings.admin_id if settings else '' }}" required>
<small class="form-text text-muted">Telegram ID администратора бота</small>
</div>
<div class="form-group">
<label for="reg_notify">ID для оповещений о регистрации</label>
<input type="text" class="form-control" id="reg_notify" value="{{ settings.reg_notify if settings else '' }}">
<small class="form-text text-muted">Оставьте пустым или 0, чтобы отключить</small>
</div>
<div class="form-group">
<label for="pay_notify">ID для оповещений об оплате</label>
<input type="text" class="form-control" id="pay_notify" value="{{ settings.pay_notify if settings else '' }}">
<small class="form-text text-muted">Оставьте пустым или 0, чтобы отключить</small>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="is_enable" {% if settings and settings.is_enable == 1 %}checked{% endif %}>
<label class="form-check-label" for="is_enable">Бот активен</label>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Отмена</button>
<button type="button" class="btn btn-primary" id="saveSettingsBtn">Сохранить</button>
</div>
</div>
</div>
</div>
{% endblock %}
{% block extra_js %}
<script>
$(document).ready(function() {
function showNotification(message, type = 'success') {
if (typeof toastr !== 'undefined') {
toastr.options = {
"closeButton": true,
"progressBar": true,
"positionClass": "toast-top-right",
"timeOut": "3000"
};
if (type === 'success') {
toastr.success(message);
} else if (type === 'error') {
toastr.error(message);
}
} else {
if (type === 'error') {
alert('Ошибка: ' + message);
} else {
alert(message);
}
}
}
$('.edit-settings').on('click', function() {
$('#editSettingsModal').modal('show');
});
$('#saveSettingsBtn').on('click', function() {
var formData = {
bot_token: $('#bot_token').val().trim(),
admin_id: $('#admin_id').val().trim(),
reg_notify: $('#reg_notify').val().trim() || 0,
pay_notify: $('#pay_notify').val().trim() || 0,
is_enable: $('#is_enable').is(':checked')
};
if (!formData.bot_token || !formData.admin_id) {
showNotification('API токен и ID администратора обязательны для заполнения', 'error');
return;
}
var $btn = $(this);
var originalHtml = $btn.html();
$btn.html('<i class="mdi mdi-loading mdi-spin"></i> Сохранение...');
$btn.prop('disabled', true);
$.ajax({
url: "{{ url_for('bot_settings.update_settings') }}",
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(formData),
success: function(response) {
$btn.html(originalHtml);
$btn.prop('disabled', false);
if (response.success) {
$('#editSettingsModal').modal('hide');
showNotification(response.message || 'Настройки бота успешно обновлены');
setTimeout(function() {
window.location.reload();
}, 1500);
} else {
showNotification(response.message || 'Ошибка при обновлении настроек', 'error');
}
},
error: function(xhr, status, error) {
$btn.html(originalHtml);
$btn.prop('disabled', false);
console.error('Ошибка при обновлении настроек:', status, error);
var errorMessage = 'Произошла ошибка при обновлении настроек';
try {
var response = JSON.parse(xhr.responseText);
if (response.message) {
errorMessage = response.message;
}
} catch(e) {}
showNotification(errorMessage, 'error');
}
});
});
});
</script>
{% endblock %}
Онлайн: 1