|
@@ -46,9 +46,6 @@
|
|
|
|
|
|
{% block sonata_wrapper %}
|
|
|
{{ parent() }}
|
|
|
-{# <footer class="footer">
|
|
|
- <span id="statusBar" class="statusBar"></span>
|
|
|
-</footer> #}
|
|
|
{% endblock %}
|
|
|
|
|
|
{% block content %}
|
|
@@ -69,6 +66,9 @@
|
|
|
{{ form_widget(form) }}
|
|
|
<br />
|
|
|
<textarea id="textarea_ace_editor"></textarea>
|
|
|
+ <div id="result_load" style="display:none">
|
|
|
+ <pre id="result_load_pre"></pre>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -80,15 +80,18 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="sonata-ba-form-actions well well-small form-actions">
|
|
|
- <button class="btn btn-success" type="submit" id="btn_get_config">
|
|
|
+ <button class="btn btn-success" type="submit" id="btn_get_config" onclick="bclick('btn_get_config','get');">
|
|
|
<i class="fa fa-download" aria-hidden="true"></i> {{ 'get_config'|trans({}, 'KeaBundle') }}
|
|
|
</button>
|
|
|
- <button class="btn btn-success" type="submit" id="btn_generate_config">
|
|
|
- <i class="fa fas fa-cog" aria-hidden="true"></i> {{ 'generate_config'|trans({}, 'KeaBundle') }}
|
|
|
+ <button class="btn btn-success" type="submit" id="btn_generate_config" onclick="bclick('btn_generate_config','generate');">
|
|
|
+ <i class="fa fa-cog" aria-hidden="true"></i> {{ 'generate_config'|trans({}, 'KeaBundle') }}
|
|
|
</button>
|
|
|
- <button class="btn btn-success" type="submit" id="btn_set_config">
|
|
|
+ <button class="btn btn-success" type="submit" id="btn_set_config" onclick="bclick('btn_set_config','set');">
|
|
|
<i class="fa fa-upload" aria-hidden="true"></i> {{ 'set_config'|trans({}, 'KeaBundle') }}
|
|
|
</button>
|
|
|
+ <button class="btn btn-success" type="submit" id="btn_save_config" onclick="bclick('btn_save_config','save');">
|
|
|
+ <i class="fa fa-save" aria-hidden="true"></i> {{ 'save_config'|trans({}, 'KeaBundle') }}
|
|
|
+ </button>
|
|
|
</div>
|
|
|
|
|
|
|
|
@@ -106,73 +109,37 @@ $(document).ready(function() {
|
|
|
editor.getSession().setTabSize(2);
|
|
|
editor.getSession().setUseSoftTabs(true);
|
|
|
editor.getSession().setUseWrapMode(true);
|
|
|
+});
|
|
|
|
|
|
- $("#btn_get_config").click(function(){
|
|
|
- $("#btn_get_config").attr('disabled','disabled');
|
|
|
-
|
|
|
- dhcpId = $("#form_dhcpId").val();
|
|
|
-
|
|
|
- if(!dhcpId) {
|
|
|
- $("#btn_get_config").removeAttr('disabled');
|
|
|
- alert("{{ 'alert_select_dhcp'|trans({}, 'KeaBundle') }}");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- result = getConfig(dhcpId, 'get');
|
|
|
-
|
|
|
- $("#btn_get_config").removeAttr('disabled');
|
|
|
- });
|
|
|
-
|
|
|
- $("#btn_generate_config").click(function(){
|
|
|
- $("#btn_generate_config").attr('disabled','disabled');
|
|
|
-
|
|
|
- dhcpId = $("#form_dhcpId").val();
|
|
|
-
|
|
|
- if(!dhcpId) {
|
|
|
- $("#btn_generate_config").removeAttr('disabled');
|
|
|
- alert("{{ 'alert_select_dhcp'|trans({}, 'KeaBundle') }}");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- result = getConfig(dhcpId, 'generate');
|
|
|
-
|
|
|
- $("#btn_generate_config").removeAttr('disabled');
|
|
|
- });
|
|
|
-
|
|
|
- $("#btn_set_config").click(function(){
|
|
|
- $("#btn_set_config").attr('disabled','disabled');
|
|
|
-
|
|
|
- dhcpId = $("#form_dhcpId").val();
|
|
|
-
|
|
|
- if(!dhcpId) {
|
|
|
- $("#btn_set_config").removeAttr('disabled');
|
|
|
- alert("{{ 'alert_select_dhcp'|trans({}, 'KeaBundle') }}");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- result = getConfig(dhcpId, 'set');
|
|
|
-
|
|
|
- $("#btn_set_config").removeAttr('disabled');
|
|
|
- });
|
|
|
-
|
|
|
+function bclick(id, action) {
|
|
|
+ $("#"+id).attr('disabled','disabled');
|
|
|
|
|
|
-});
|
|
|
+ dhcpId = $("#form_dhcpId").val();
|
|
|
+ if(!dhcpId) {
|
|
|
+ $("#"+id).removeAttr('disabled');
|
|
|
+ alert("{{ 'alert_select_dhcp'|trans({}, 'KeaBundle') }}");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ result = getConfig(dhcpId, action);
|
|
|
+ $("#"+id).removeAttr('disabled');
|
|
|
+}
|
|
|
|
|
|
function getConfig(dhcpId, action) {
|
|
|
-
|
|
|
- var r = false;
|
|
|
+
|
|
|
params = editor.getSession().getValue();
|
|
|
+ $("#result_load").hide();
|
|
|
|
|
|
- $.ajax({
|
|
|
- method: "POST",
|
|
|
- async: false,
|
|
|
- cache: false,
|
|
|
+ $.ajax({method: "POST",async: false,cache: false,
|
|
|
url: "{{url('kea_get_config')}}?_=" + new Date().getTime(),
|
|
|
data: { dhcpId: dhcpId, action: action, params: params }
|
|
|
}).done(function( result ) {
|
|
|
- editor.setValue(result, -1);
|
|
|
+ if(action == "set" || action == "save") {
|
|
|
+ $("#result_load_pre").html(result);
|
|
|
+ $("#result_load").show();
|
|
|
+ } else {
|
|
|
+ editor.setValue(result, -1);
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
return true;
|
|
|
}
|
|
|
|