Skip to content
Snippets Groups Projects
Commit 5f3cd5c7 authored by Korvin's avatar Korvin
Browse files

add_config_page

parent 7830c458
Branches
No related merge requests found
$(() => {
$('#config-save-button').click(function () {
$(this).prop('disabled', true);
let config = {
SemesterID : $("#SemesterID").val(),
HashKey : $("#HashKey").val(),
Logging : $("#Logging").prop('checked'),
SupportServiceEmail : $("#SupportServiceEmail").val(),
OpenIDAuthAllowed : $("#OpenIDAuthAllowed").prop('checked'),
GradeAuthAllowed : $("#GradeAuthAllowed").prop('checked'),
HTTPS : $("#HTTPS").prop('checked')
};
$.post(URLdir + 'handler/config/index', {config}).done(result => {
Popup.success('Изменения сохранены');
location.reload();
}).fail(result => {
Popup.error('Произошла ошибка');
});
});
});
\ No newline at end of file
......@@ -42,7 +42,7 @@
border: 1px solid @ColorGrey;
width: 100%;
}
input[type=text]&, input[type=password]&, textarea& {
input[type=text]&, input[type=password]&, textarea&, input[type=number]& {
padding: 7px;
border-radius: 3px;
border: 1px solid @ColorGrey;
......
.config-container {
padding: 30px;
label {
padding-bottom: 10px;
display: block;
}
}
\ No newline at end of file
<?php defined('SYSPATH') || die('No direct script access.');
class Controller_Handler_Config extends Controller_Handler_Api
{
public function action_index() {
$this->user->checkAccess(User::RIGHTS_ADMIN);
$config = $this->post["config"];
$string = file_get_contents(APPPATH . "/config/general.json");
$json_a = json_decode($string, true);
foreach ($config as $key => $value) {
if ($value === "false")
$value = false;
elseif ($value === "true")
$value = true;
$json_a[$key] = $value;
}
$string = json_encode($json_a, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
file_put_contents(APPPATH . "/config/general.json", $string);
}
}
\ No newline at end of file
<?php defined('SYSPATH') || die('No direct script access.');
class Controller_Office_Config extends Controller_Environment_Office
{
public function action_index() {
$string = file_get_contents(APPPATH . "/config/general.json");
$json_a = json_decode($string, true);
$this->twig->set([
'Tokens' => Model_Account::getAuthTokens(),
'Config' => $json_a,
])->set_filename(static::OFFICE . 'config/index');
}
}
\ No newline at end of file
{% extends 'office/base' %}
{% block title %}Конфигурация{% endblock %}
{% block office_media %} {# head -> css, js #}
{#{{ parent() }}#} {# fixme #}
{{ HTML.style('static/css/common/forms.css')|raw }}
{{ HTML.style('static/css/office/config.css')|raw }}
{{ HTML.script('static/js/office/config.js')|raw }}
{% endblock %}
{% block office_content %}
<div class="config-container">
<label>
Текущий семестр:
<input class="defaultForm P2Width" type="number" id="SemesterID" value="{{ Config.SemesterID }}">
</label>
<label>
Хэш-ключ:
<input class="defaultForm Width35" type="text" id="HashKey" value="{{ Config.HashKey }}">
</label>
<label>
Логгирование:
<input class="defaultForm" type="checkbox" id="Logging" {{ Config.Logging == true ? "checked" : "unchecked" }}>
</label>
<label>
Электронная почта поддержки
<input class="defaultForm Width35" type="text" id="SupportServiceEmail" value="{{ Config.SupportServiceEmail }}">
</label>
<label>
Авторизация через Open ID:
<input class="defaultForm" type="checkbox" id="OpenIDAuthAllowed" {{ Config.OpenIDAuthAllowed == true ? "checked" : "unchecked" }}>
</label>
<label>
Авторизация через локальную учетную запись:
<input class="defaultForm" type="checkbox" id="GradeAuthAllowed" {{ Config.GradeAuthAllowed == true ? "checked" : "unchecked"}}>
</label>
<label>
HTTPS:
<input class="defaultForm" type="checkbox" id="Https" {{ Config.Https == true ? "checked" : "unchecked"}}>
</label>
<button class="defaultForm BlueButton P2Width" id="config-save-button">
Сохранить
</button>
</div>
{% endblock %}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment