{% extends base %}

{% block body_left %}

{% include common/script/load_select2.html %}
{% include system/component/system_css.html %}

<!-- TODO d3.js 展示内存和CPU日志 -->
{% import web %}

<div class="card">
    {% include common/title/base_title.html %}
</div>

{% include settings/page/settings_tab.html %}

<div class="col-md-12 card">
    {% render list_view %}
</div>

<script type="text/javascript">
    function updateSetting(key, value, type, p) {
        xnote.http.post("/system/config", 
            {key: key, value: value, type: type, p:p}, 
            function (data) {
                if (data.success) {
                    window.location.reload();
                } else {
                    xnote.alert(data.message);
                }
        }).fail(function (resp) {
            console.log(resp);
            xnote.alert(resp.message);
        });
    }

    $("[type=radio]").on("change", function (e) {
        var val = $(e.target).val();
        var key = $(e.target).attr("name");
        var type = $(this).attr("data-type");
        var p = $(this).attr("data-p");
        // alert(val);
        updateSetting(key, val, type, p);
    });

    $("select").change(function (e) {
        var key = $(this).attr("name");
        var val = $(this).val();
        var type = $(this).attr("data-type");
        var p = $(this).attr("data-p");
        updateSetting(key, val, type, p);
    });
</script>

{% end %}

{% block body_right %}
    {% include settings/page/settings_sidebar.html %}
{% end %}