phpserver/templates/admin/edit_phpserver.phtml

132 lines
4 KiB
PHTML

<%inherit file="dashboard.phtml"/>
<%block name="extra_css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ace-builds@1.43.4/css/ace.min.css">
</%block>
<%block name="content">
<p><a href="${url_for('phpserver_app.php_dashboard')}">${_('PHP servers list')}</a> &gt;&gt; ${_('Edit php.ini')}</p>
<h3>${_('Edit php.ini')} - ${domain}</h3>
<div class="form">
<div id="php_ini" style="height:600px;">
</div>
</div>
<p>
<form method="post" name="save_php_ini" id="save_php_ini" action="${url_for('phpserver_app.save_php_ini', php_server_id=php_server_id)}">
<input type="hidden" name="php_ini_file" id="php_ini_file" value="" />
<input type="submit" name="php_ini" value="${_('Save php.ini')}" id="php_ini" />
</form>
</p>
<p><a href="${url_for('phpserver_app.php_dashboard')}">${_('PHP servers list')}</a> &gt;&gt; ${_('Edit php.ini')}</p>
</%block>
<%block name="jscript_block">
<script language="Javascript" src="${make_media_url('js/jsutils/posting2.js', 'pastafari2')}"></script>
<script src=" https://cdnjs.cloudflare.com/ajax/libs/ace/1.43.3/ace.min.js"></script>
<script>
$(document).ready( function (e) {
$('#layer_loading').show();
$.ajax({
url: "${url_for('phpserver_app.get_php_server', php_server_id=php_server_id)}",
method: "GET",
dataType: "json",
data: {},
success: function (data) {
$('#layer_loading').hide();
console.log(data);
if(data.log.error) {
$('#php_ini').html(data.log.message);
}
else {
file=JSON.parse(data.result.message);
//console.log(file);
//$('#php_ini').html(file.file);
//editor.setValue(file.file, -1);
editor.session.setValue(file.file);
}
},
error: function (data) {
$('#layer_loading').hide();
alert('Error: '+data.status+' '+data.statusText);
}
});
editor = ace.edit("php_ini");
editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/ini");
/*$('#save_php_ini').submit( function (e) {
document.getElementById('php_ini_file').value=editor.getValue();
});*/
options={'url': '${url_for("phpserver_app.save_php_ini", php_server_id=php_server_id)}', 'loading': '#layer_loading', 'success': function (data) {
if(!data.error) {
window.location='${url_for("phpserver_app.php_dashboard")}';
}
else {
alert(_('I cannot modify the php configuration!. Please try later.'));
}
}, 'error': function (data) {
console.log('Retry send the file because a horrible bug in ace editor...');
if(data.hasOwnProperty('error_form')) {
if(data.error_form.hasOwnProperty('empty_file')) {
//Try send again.
$('#save_php_ini').submit();
}
}
},
'before_send': function (jxhr, settings) {
//$('#php_ini_file').val(editor.getValue());
document.getElementById('php_ini_file').value=editor.getValue();
/*if(document.getElementById('php_ini_file').value=='') {
jxhr.abort();
alert('No file');
}*/
//console.log(editor.getValue());
}
};
$('#save_php_ini').sendPost(options);
});
</script>
</%block>