+
This commit is contained in:
@ -4,11 +4,7 @@ import java.io.FileInputStream;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.PublicKey;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.*;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@ -65,6 +61,7 @@ public class EngineController implements ServletContextAware {
|
||||
@Autowired
|
||||
public EngineController(NamedParameterJdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
this.m_props = new Properties();
|
||||
}
|
||||
|
||||
private PublicKey getPublicKey(){
|
||||
@ -116,7 +113,7 @@ public class EngineController implements ServletContextAware {
|
||||
long country_id=0;
|
||||
try {
|
||||
String sql="""
|
||||
select language_id,country_id from main._users where id=user_id
|
||||
select language_id,country_id from main._users where id=:user_id
|
||||
""";
|
||||
MapSqlParameterSource parameters = new MapSqlParameterSource();
|
||||
parameters.addValue("user_id", claims.getBody().get("user_id"));
|
||||
@ -354,12 +351,13 @@ public class EngineController implements ServletContextAware {
|
||||
}*/
|
||||
|
||||
//Для перевода выбираю всё что под номером 1 в переводе
|
||||
|
||||
try {
|
||||
String sql="""
|
||||
select identifier,translation from main._translations t where t.del=false and t.language_id=:language_id and translation_type_id=1
|
||||
select identifier,translation from main._translations t where t.del=false and t.language_id=:language_id and translation_type_id=1;
|
||||
""";
|
||||
MapSqlParameterSource parameters = new MapSqlParameterSource();
|
||||
parameters.addValue("language_id", language_id);
|
||||
parameters.addValue("language_id", language_id, Types.INTEGER);
|
||||
List<String> ret = jdbcTemplate.query(sql, parameters, new DBTools.JsonRowMapper());
|
||||
for (int i = 0; i < ret.size(); i++) {
|
||||
JSONObject obj = new JSONObject(ret.get(i));
|
||||
@ -401,9 +399,9 @@ public class EngineController implements ServletContextAware {
|
||||
for (int i = 0; i < ret.size(); i++) {
|
||||
JSONObject obj = new JSONObject(ret.get(i));
|
||||
//m_props.setProperty(obj.getString("identifier"), obj.getString("translation"));
|
||||
Substrate_head+=" <option value=\""+obj.getString("id")+"\">"+obj.getString("description")+"</option>\n";
|
||||
Substrate_head+=" <option value=\""+obj.getInt("id")+"\">"+obj.getString("description")+"</option>\n";
|
||||
|
||||
Substrate_tail+="g_Layouts[\""+obj.getString("id")+"\"] = new ol.source.XYZ({\n";
|
||||
Substrate_tail+="g_Layouts[\""+obj.getInt("id")+"\"] = new ol.source.XYZ({\n";
|
||||
Substrate_tail+=" url: '"+obj.getString("path")+"',\n";
|
||||
if(!obj.isNull("projection") && obj.getString("projection").indexOf("EPSG:")!=-1)
|
||||
Substrate_tail+=" projection: '"+obj.getString("projection")+"',\n";
|
||||
|
||||
@ -1,11 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<html xmlns:th="http://www.thymeleaf.org" lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title th:text="${Authorization}">Authorization</title>
|
||||
<link rel="icon" href="../resources/favicon.ico" type="image/x-icon">
|
||||
<link rel="stylesheet" href="../resources/engine/css/buttons.css?v=8">
|
||||
<link rel="stylesheet" href="../resources/engine/normalize.css?v=8">
|
||||
<link rel="stylesheet" type="text/css" href="../resources/engine/index.css?v=14"/>
|
||||
<link rel="stylesheet" type="text/css" href="../resources/metadata/dbms/dbms.css?v=14"/>
|
||||
<script type="text/javascript" src="../translation?v=9"></script>
|
||||
<script type="text/javascript" src="../resources/metadata/dbms/tools.js?v=14"></script>
|
||||
<script type="text/javascript" src="../resources/metadata/dbms/window.js?v=14"></script>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
@ -13,6 +19,7 @@
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column; /* Вертикальная ориентация */
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
@ -79,11 +86,38 @@
|
||||
margin-top: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Custom style for checkbox */
|
||||
.checkbox-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.checkbox-group input {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.centered-text {
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
margin-top: auto; /* Этот стиль заставит блок с .centered-text быть внизу */
|
||||
}
|
||||
|
||||
.centered-text a {
|
||||
color: #007bff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.centered-text a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="login-container">
|
||||
<!-- Форма авторизации -->
|
||||
<div class="login-container" id="loginForm">
|
||||
<h2 th:text="${Authorization}">Authorization</h2>
|
||||
<div>
|
||||
<div class="form-group">
|
||||
@ -110,59 +144,115 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Форма регистрации -->
|
||||
<div class="login-container" style="display: none;" id="registrationForm">
|
||||
<h2 th:text="${Registration}">Registration</h2>
|
||||
<div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="3_country_id"><span th:text="${Country}">Country</span> *</label>
|
||||
<input type="text" id="3_country_id" name="country" maxlength="50" placeholder="Country">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="3_lastname"><span th:text="${Surname}">Surname</span></label>
|
||||
<input type="text" id="3_lastname" name="lastname" maxlength="50" placeholder="Surname">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="3_firstname"><span th:text="${Name}">Name</span> *</label>
|
||||
<input type="text" id="3_firstname" name="firstname" maxlength="50" placeholder="Name">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="3_company"><span th:text="${Company}">Company</span></label>
|
||||
<input type="text" id="3_company" name="company" maxlength="50" placeholder="Company">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="3_position"><span th:text="${Position}">Position</span></label>
|
||||
<input type="text" id="3_position" name="position" maxlength="50" placeholder="Position">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="3_phone"><span th:text="${Phone}">Phone</span></label>
|
||||
<input type="text" id="3_phone" name="phone" maxlength="50" placeholder="Phone">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="3_email"><span th:text="${E_mail}">Email</span> *</label>
|
||||
<input type="text" id="3_email" name="email" maxlength="50" placeholder="E-mail">
|
||||
</div>
|
||||
|
||||
<!-- Checkbox for Privacy Policy -->
|
||||
<div class="form-group checkbox-group">
|
||||
<input type="checkbox" id="privacyPolicy" onclick="toggleRegisterButton()">
|
||||
<label for="privacyPolicy">
|
||||
Я согласен с <a href="#">политикой конфиденциальности</a>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<button id="registerBtn" class="button" th:text="${Registration}" disabled>Registration</button>
|
||||
</div>
|
||||
|
||||
<div class="progress-bar" id="progressBar2">
|
||||
<span>Загрузка...</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Password recovery -->
|
||||
<div class="login-container" style="display: none;" id="registrationForm">
|
||||
<h2 th:text="${Password_recovery}">Password_recovery</h2>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ссылки для переключения -->
|
||||
<div class="centered-text">
|
||||
<p><a href="#" onclick="showForm(1);" th:text="${Authorization}">Authorization</a></p>
|
||||
<p><a href="#" onclick="showForm(2);" th:text="${Create_a_new_user}">Create a new user</a></p>
|
||||
<p><a href="#" onclick="showForm(3);" th:text="${Password_recovery}">Password recovery</a></p>
|
||||
<p><a href="#" onclick="showForm(4);" th:text="${Change_password}">Change password</a></p>
|
||||
<p><a href="#" onclick="showForm(5);" th:text="${Get_new_TOTP_key}">Get new TOTP key</a></p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Функция для отправки данных на сервер
|
||||
function postJsonData(url, data, callback) {
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => callback(true, data))
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
callback(false, { error_message: 'Что-то пошло не так. Попробуйте еще раз.' });
|
||||
});
|
||||
// Функция для отображения формы авторизации
|
||||
function showForm(num) {
|
||||
document.getElementById('loginForm').style.display = num === 1 ? 'block' : 'none';
|
||||
document.getElementById('registrationForm').style.display = num === 2 ? 'block' : 'none';
|
||||
}
|
||||
|
||||
|
||||
// Функция для включения/выключения кнопки регистрации в зависимости от состояния галочки
|
||||
function toggleRegisterButton() {
|
||||
const checkbox = document.getElementById('privacyPolicy');
|
||||
const registerBtn = document.getElementById('registerBtn');
|
||||
registerBtn.disabled = !checkbox.checked;
|
||||
}
|
||||
|
||||
// Функция для обработки авторизации
|
||||
function authorizeUser() {
|
||||
const login = document.getElementById('login0').value;
|
||||
const password = document.getElementById('password0').value;
|
||||
|
||||
const obj = {
|
||||
login: login,
|
||||
password: password,
|
||||
appid: 'ccalm'
|
||||
};
|
||||
|
||||
// Отправляем запрос на сервер для авторизации
|
||||
const obj = { login, password, appid: 'ccalm' };
|
||||
postJsonData('/api/authorization/v02/login', obj, (ok, data) => {
|
||||
if (ok) {
|
||||
if (data.error_code == 0) {
|
||||
window.location.href = "/engine";
|
||||
} else {
|
||||
alert2(trt('Alert'), data.error_message);
|
||||
alert2(trt('Alert'), trt(data.error_message));
|
||||
}
|
||||
}else{
|
||||
alert2(trt('Error'),data);
|
||||
} else {
|
||||
alert2(trt('Alert'), trt('Error: Unable to authorize.'));
|
||||
}
|
||||
document.getElementById('progressBar').style.display = 'none'; // Скрываем прогресс-бар
|
||||
});
|
||||
document.getElementById('progressBar').style.display = 'block';
|
||||
|
||||
}
|
||||
|
||||
// Функция для восстановления пароля
|
||||
function showRestoreForm() {
|
||||
alert('Форма восстановления пароля будет здесь!');
|
||||
}
|
||||
|
||||
// Обработчик клика на кнопку "Войти"
|
||||
document.getElementById('loginBtn').onclick = authorizeUser;
|
||||
// Изначально показываем форму авторизации
|
||||
showLoginForm();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user