Very rough base implementation of file renaming

This commit is contained in:
Dane Everitt 2016-10-01 14:34:18 -04:00
parent 3dbe89969e
commit d812e1a23c
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
5 changed files with 287 additions and 138 deletions

View file

@ -23,6 +23,12 @@
Managing Files for: {{ $server->name }}
@endsection
@section('scripts')
@parent
{!! Theme::js('js/vendor/async/async.min.js') !!}
{!! Theme::js('js/vendor/lodash/lodash.js') !!}
@endsection
@section('content')
<div class="col-md-12">
<div class="row">
@ -50,128 +56,21 @@
</div>
</div>
</div>
<ul id="fileOptionMenu" class="dropdown-menu" role="menu" style="display:none" >
<li data-action="move"><a tabindex="-1" href="#"><i class="fa fa-arrow-right"></i> Move</a></li>
<li data-action="rename"><a tabindex="-1" href="#"><i class="fa fa-pencil-square-o"></i> Rename</a></li>
<li><a tabindex="-1" href="#"><i class="fa fa-file-archive-o"></i> Compress</a></li>
<li class="divider"></li>
<li><a tabindex="-1" href="#"><i class="fa fa-download"></i> Download</a></li>
<li><a tabindex="-1" href="#"><i class="fa fa-trash-o"></i> Delete</a></li>
</ul>
</div>
<script src="{{ route('server.js', [$server->uuidShort, 'filemanager', 'index.js']) }}"></script>
<script src="{{ route('server.js', [$server->uuidShort, 'filemanager', 'actions.js']) }}"></script>
<script src="{{ route('server.js', [$server->uuidShort, 'filemanager', 'contextmenu.js']) }}"></script>
<script>
$(document).ready(function () {
$('.server-files').addClass('active');
});
$(window).load(function(){
var doneLoad = false;
// Show Loading Animation
function handleLoader (show) {
// Hide animation if no files displayed.
if ($('#load_files').height() < 5) { return; }
// Show Animation
if (show === true){
var height = $('#load_files').height();
var width = $('.ajax_loading_box').width();
var center_height = (height / 2) - 30;
var center_width = (width / 2) - 30;
$('#position_me').css({
'top': center_height,
'left': center_width,
'font-size': '60px'
});
$(".ajax_loading_box").css('height', (height + 5)).fadeIn();
} else {
$('.ajax_loading_box').fadeOut(100);
}
}
function reloadActions () {
reloadActionClick();
reloadActionDelete();
}
// Handle folder clicking to load new contents
function reloadActionClick () {
$('a.load_new').click(function (e) {
e.preventDefault();
window.history.pushState(null, null, $(this).attr('href'));
loadDirectoryContents($.urlParam('dir', $(this).attr('href')));
});
}
// Handle Deleting Files
function reloadActionDelete () {
$('[data-action="delete_file"]').click(function (e) {
e.preventDefault();
var clicked = $(this);
var deleteItemPath = $(this).attr('href');
swal({
type: 'warning',
title: '',
text: 'Are you sure you want to delete <code>' + clicked.data('name') + '</code>?',
html: true,
showCancelButton: true,
showConfirmButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true
}, function () {
$.ajax({
type: 'DELETE',
url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/' + deleteItemPath,
headers: {
'X-Access-Token': '{{ $server->daemonSecret }}',
'X-Access-Server': '{{ $server->uuid }}'
}
}).done(function (data) {
clicked.parent().parent().parent().parent().fadeOut();
swal({
type: 'success',
title: 'File Deleted'
});
}).fail(function (jqXHR) {
console.error(jqXHR);
swal({
type: 'error',
title: 'Whoops!',
html: true,
text: 'An error occured while attempting to delete this file. Please try again.',
});
});
});
});
}
// Handle Loading Contents
function loadDirectoryContents (dir) {
handleLoader(true);
var outputContent;
var urlDirectory = (dir === null) ? '/' : dir;
$.ajax({
type: 'POST',
url: '{{ route('server.files.directory-list', $server->uuidShort) }}',
headers: { 'X-CSRF-Token': '{{ csrf_token() }}' },
data: { directory: urlDirectory }
}).done(function (data) {
handleLoader(false);
$("#load_files").slideUp(function () {
$("#load_files").html(data).slideDown();
$('[data-toggle="tooltip"]').tooltip();
$('#internal_alert').slideUp();
// Run Actions Again
reloadActions();
});
}).fail(function (jqXHR) {
$("#internal_alert").html('<div class="alert alert-danger">An error occured while attempting to process this request. Please try again.</div>').show();
console.log(jqXHR);
});
}
// Load on Initial Page Load
loadDirectoryContents($.urlParam('dir'));
});
$(window).load(function () {
$('.server-files').addClass('active');
});
</script>
@endsection