config.jsoneditor.html
2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{% extends cp_views_dir + "/template.html" %}
{% block head %}
<link href="/control-panel/jsoneditor/jsoneditor.css" rel="stylesheet" type="text/css">
<script src="/control-panel/jsoneditor/jsoneditor.js"></script>
{% endblock %}
{% block content %}
<h2>{{ page_title }}</h2>
<div id="jsoneditor"></div>
<script>
    function saveData() {
        //window.alert(JSON.stringify(editor.get()));
        jQuery.ajax({
            type: "POST",
            url: '/config/data',
            contentType: 'application/json',
            data: JSON.stringify(editor.get()),
            success: function(responseBody, textStatus, jqXHR) {
                window.alert(responseBody);
                location.reload();
            }
        });
    }
    function loadData() {
        jQuery.ajax('/config/data').done(function(data) {
            editor.setName('CONFIG');
            editor.set(data);
            editor.expandAll();
        });
    }
    var container = document.getElementById("jsoneditor");
    var options = {
        mode: '{{ jsoneditor_mode }}',
        modes: ["form", "tree", "code"],
        onChange: function() {
            $("#buttonSubmit").removeAttr('disabled');
        }
    };
    var editor = new JSONEditor(container, options);
    loadData();
</script>
<br><br>
<div class="panel panel-default">
    <div class="panel-body">
        <button id="buttonSubmit" type="submit" class="btn btn-primary"
            onclick="saveData()"
            disabled
        >
            Eksekusi dan Simpan
        </button>
        <button id="buttonSubmit" type="submit" class="btn btn-primary"
            onclick="location.reload()"
        >
            Reload Konfigurasi
        </button>
        <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#restartConfirmationModal">
            Restart Aplikasi
        </button>
    </div>
</div>
{% include cp_views_dir + "/restart.confirmation.modal.html" %}
{% include "views/config.help.html" ignore missing %}
{% endblock %}