add raw file editing to configuration page in webfront

This commit is contained in:
RaidMax
2021-09-16 16:27:40 -05:00
parent 68c1151191
commit 33c63f01db
8 changed files with 307 additions and 81 deletions

View File

@ -37,6 +37,10 @@ a.nav-link {
border-bottom: 1px solid $primary !important;
}
.border-bottom-dark {
border-bottom: 1px solid $body-bg !important;
}
.server-history {
background-color: $big-dark;
}

View File

@ -73,4 +73,49 @@
return false;
});
});
hljs.highlightAll();
$('.edit-file' ).on('keydown .editable', function(e){
if(e.keyCode === 9) {
document.execCommand ( 'styleWithCSS', true, null )
document.execCommand ( 'insertText', true, ' ' )
e.preventDefault()
}
});
$('.expand-file-icon').click((e) => {
const selector = $(e.target).data('editor-id');
$(selector).toggleClass('d-none').toggleClass('d-flex');
$(e.target).toggleClass('oi-expand-up', 'oi-expand-down');
});
$('.file-save-button').click(e => {
const id = $(e.target).prev().find('.editable').attr('id');
const content = document.getElementById(id).textContent;
const file = $(e.target).data('file-name');
$.ajax({
data: content,
type: 'PATCH',
url: 'File/' + file,
contentType: 'text/plain',
complete: function(response) {
if (response.status !== 204) {
$('#actionModal').modal();
$('#actionModal .modal-message').text(response.responseText);
$('#actionModal .modal-message').addClass('text-danger');
$('#actionModal .modal-message').fadeIn('fast');
$(e.target).toggleClass('btn-danger');
return;
}
$(e.target).removeClass('btn-danger')
$(e.target).toggleClass('btn-success')
window.setTimeout(function() {
$(e.target).toggleClass('btn-success');
}, 500);
}
});
});
});