Skip to content
Snippets Groups Projects
Commit 85f0e86a authored by Korvin's avatar Korvin
Browse files

final changes

parent 5f3cd5c7
Branches issue241_config_page
No related merge requests found
$(() => {
$('#config-save-button').click(function () {
$('.config-container input').change(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 => {
let type = $(this).attr("type");
let data;
if (type == "checkbox")
data = $(this).prop('checked');
else
data = $(this).val();
let id = $(this).attr("id");
$.post(URLdir + 'handler/config/index', {id, type, data}).done(_ => {
Popup.success('Изменения сохранены');
location.reload();
}).fail(result => {
}).fail(_ => {
Popup.error('Произошла ошибка');
}).always(_ => {
$(this).prop('disabled', false);
});
});
});
\ No newline at end of file
......@@ -4,17 +4,16 @@ 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;
}
$id = $this->post["id"];
$data = $this->post["data"];
$type = $this->post["type"];
if ($type === "checkbox")
$data === "true" ? $data = true : $data = false;
$json_a[$id] = $data;
$string = json_encode($json_a, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
file_put_contents(APPPATH . "/config/general.json", $string);
......
......@@ -49,10 +49,6 @@
<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