More updates to file manager
Not doing individual commits for this, tons of changes for tons of different aspects across multiple files.
This commit is contained in:
parent
fe9c573533
commit
fb4d122a2a
12 changed files with 308 additions and 164 deletions
|
@ -26,65 +26,52 @@
|
|||
@section('content')
|
||||
<div class="col-md-12">
|
||||
<h3 class="nopad"><small>Editing File: /home/container/{{ $file }}</small></h3>
|
||||
<form method="post" id="editing_file">
|
||||
<div class="form-group">
|
||||
<div>
|
||||
@if (in_array($extension, ['yaml', 'yml']))
|
||||
<div class="alert alert-info">
|
||||
{!! trans('server.files.yaml_notice', [
|
||||
'dropdown' => '<select id="space_yaml">
|
||||
<option value="2">2</option>
|
||||
<option value="4" selected="selected">4</option>
|
||||
<option value="8">8</option>
|
||||
</select>'
|
||||
]) !!}
|
||||
</div>
|
||||
@endif
|
||||
<textarea name="file_contents" id="fileContent" style="border: 1px solid #dddddd;height:500px;" class="form-control console">{{ $contents }}</textarea>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="editor" style="height:500px;">{{ $contents }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@can('save-files', $server)
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<hr />
|
||||
<input type="hidden" name="file" value="{{ $file }}" />
|
||||
<button class="btn btn-primary btn-sm" id="save_file" type="submit">{{ trans('strings.save') }}</button>
|
||||
<a href="/server/{{ $server->uuidShort }}/files?dir={{ rawurlencode($directory) }}" class="text-muted pull-right"><small>{{ trans('server.files.back') }}</small></a>
|
||||
</div>
|
||||
</div>
|
||||
@can('save-files', $server)
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<input type="hidden" name="file" value="{{ $file }}" />
|
||||
{!! csrf_field() !!}
|
||||
<button class="btn btn-primary btn-sm" id="save_file" type="submit">{{ trans('strings.save') }}</button>
|
||||
<a href="/server/{{ $server->uuidShort }}/files?dir={{ rawurlencode($directory) }}" class="text-muted pull-right"><small>{{ trans('server.files.back') }}</small></a>
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
</form>
|
||||
@endcan
|
||||
</div>
|
||||
{!! Theme::js('js/vendor/ace/ace.js') !!}
|
||||
{!! Theme::js('js/vendor/ace/ext-modelist.js') !!}
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('.server-files').addClass('active');
|
||||
$('textarea').keydown(function (e) {
|
||||
if (e.keyCode === 9) {
|
||||
const Editor = ace.edit('editor');
|
||||
const Modelist = ace.require('ace/ext/modelist')
|
||||
|
||||
var start = this.selectionStart;
|
||||
var end = this.selectionEnd;
|
||||
var value = $(this).val();
|
||||
var joinYML = '\t';
|
||||
var yamlSpaces = 1;
|
||||
Editor.setTheme('ace/theme/github');
|
||||
Editor.getSession().setMode(Modelist.getModeForPath('{{ $stat->name }}').mode);
|
||||
Editor.getSession().setUseWrapMode(true);
|
||||
Editor.setShowPrintMargin(false);
|
||||
|
||||
@if (in_array($extension, ['yaml', 'yml']))
|
||||
yamlSpaces = parseInt($("#space_yaml").val());
|
||||
joinYML = Array(yamlSpaces + 1).join(" ");
|
||||
@endif
|
||||
|
||||
$(this).val(value.substring(0, start) + joinYML + value.substring(end));
|
||||
this.selectionStart = this.selectionEnd = start + yamlSpaces;
|
||||
e.preventDefault();
|
||||
|
||||
}
|
||||
});
|
||||
@can('save-files', $server)
|
||||
$('#save_file').click(function (e) {
|
||||
Editor.commands.addCommand({
|
||||
name: 'save',
|
||||
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
|
||||
exec: function(editor) {
|
||||
save();
|
||||
},
|
||||
readOnly: false
|
||||
});
|
||||
|
||||
$('#save_file').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
save();
|
||||
});
|
||||
|
||||
function save() {
|
||||
var fileName = $('input[name="file"]').val();
|
||||
var fileContents = $('#fileContent').val();
|
||||
|
||||
$('#save_file').append(' <i class="fa fa-spinner fa fa-spin"></i>').addClass('disabled');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
|
@ -92,17 +79,24 @@ $(document).ready(function () {
|
|||
headers: { 'X-CSRF-Token': '{{ csrf_token() }}' },
|
||||
data: {
|
||||
file: fileName,
|
||||
contents: fileContents
|
||||
contents: Editor.getValue()
|
||||
}
|
||||
}).done(function (data) {
|
||||
$('#tpl_messages').html('<div class="alert alert-success">{{ trans('server.files.saved') }}</div>').show().delay(3000).slideUp();
|
||||
$.notify({
|
||||
message: '{{ trans('server.files.saved') }}'
|
||||
}, {
|
||||
type: 'success'
|
||||
});
|
||||
}).fail(function (jqXHR) {
|
||||
$('#tpl_messages').html('<div class="alert alert-danger">' + jqXHR.responseText + '</div>');
|
||||
$.notify({
|
||||
message: jqXHR.responseText
|
||||
}, {
|
||||
type: 'danger'
|
||||
});
|
||||
}).always(function () {
|
||||
$('#save_file').html('{{ trans('strings.save') }}').removeClass('disabled');
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
@endcan
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -17,63 +17,109 @@
|
|||
{{-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --}}
|
||||
{{-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --}}
|
||||
{{-- SOFTWARE. --}}
|
||||
<h4 class="nopad">/home/container{{ $directory['header'] }} <small><a href="/server/{{ $server->uuidShort }}/files/add/@if($directory['header'] !== '')?dir={{ $directory['header'] }}@endif" class="text-muted"><i class="fa fa-plus" data-toggle="tooltip" data-placement="top" title="Add New File(s)"></i></a></small></h4>
|
||||
<table class="table table-striped table-bordered table-hover" id="file_listing">
|
||||
<table class="table table-hover" id="file_listing">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:2%;text-align:center;"></th>
|
||||
<th style="width:45%">File Name</th>
|
||||
<th style="width:15%">Size</th>
|
||||
<th style="width:20%">Last Modified</th>
|
||||
{{-- <th style="width:20%;text-align:center;">Options</th> --}}
|
||||
</tr>
|
||||
<tr>
|
||||
<th><i class="fa fa-folder-open"></i></th>
|
||||
<th colspan="3">
|
||||
<code>/home/container{{ $directory['header'] }}</code>
|
||||
<small>
|
||||
<a href="/server/{{ $server->uuidShort }}/files/add/@if($directory['header'] !== '')?dir={{ $directory['header'] }}@endif" class="text-muted">
|
||||
<i class="fa fa-plus" data-toggle="tooltip" data-placement="top" title="Add New File(s)"></i>
|
||||
</a>
|
||||
</small>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if (isset($directory['first']) && $directory['first'] === true)
|
||||
<tr data-type="disabled">
|
||||
<td><i class="fa fa-folder-open" style="margin-left: 0.859px;"></i></td>
|
||||
<td><i class="fa fa-folder" style="margin-left: 0.859px;"></i></td>
|
||||
<td><a href="/server/{{ $server->uuidShort }}/files" data-action="directory-view">←</a></a></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
{{-- <td></td> --}}
|
||||
</tr>
|
||||
@endif
|
||||
@if (isset($directory['show']) && $directory['show'] === true)
|
||||
<tr data-type="disabled">
|
||||
<td><i class="fa fa-folder-open" style="margin-left: 0.859px;"></i></td>
|
||||
<td><a href="/server/{{ $server->uuidShort }}/files?dir={{ rawurlencode($directory['link']) }}" data-action="directory-view">← {{ $directory['link_show'] }}</a></a></td>
|
||||
<td><i class="fa fa-folder" style="margin-left: 0.859px;"></i></td>
|
||||
<td data-name="{{ rawurlencode($directory['link']) }}">
|
||||
<a href="/server/{{ $server->uuidShort }}/files" data-action="directory-view">← {{ $directory['link_show'] }}</a>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
{{-- <td></td> --}}
|
||||
</tr>
|
||||
@endif
|
||||
@foreach ($folders as $folder)
|
||||
<tr class="align-middle" data-type="folder" data-path="@if($folder['directory'] !== ''){{ rawurlencode($folder['directory']) }}/@endif{{ rawurlencode($folder['entry']) }}">
|
||||
<td data-identifier="type"><i class="fa fa-folder-open" style="margin-left: 0.859px;"></i></td>
|
||||
<td data-identifier="name" data-hash="@if($folder['directory'] !== ''){{ rawurlencode($folder['directory']) }}/@endif{{ rawurlencode($folder['entry']) }}">
|
||||
<tr class="align-middle" data-type="folder">
|
||||
<td data-identifier="type"><i class="fa fa-folder" style="margin-left: 0.859px;"></i></td>
|
||||
<td data-identifier="name" data-name="{{ rawurlencode($folder['entry']) }}" data-path="@if($folder['directory'] !== ''){{ rawurlencode($folder['directory']) }}@endif/">
|
||||
<a href="/server/{{ $server->uuidShort }}/files" data-action="directory-view">{{ $folder['entry'] }}</a>
|
||||
</td>
|
||||
<td data-identifier="size">{{ $folder['size'] }}</td>
|
||||
<td data-identifier="modified">{{ date('m/d/y H:i:s', $folder['date']) }}</td>
|
||||
{{-- <td class="text-center">
|
||||
<div class="row" style="text-align:center;">
|
||||
<div class="col-md-3 hidden-xs hidden-sm"></div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
@can('delete-files', $server)
|
||||
<a href="@if($folder['directory'] !== ''){{ rawurlencode($folder['directory']) }}/@endif{{ rawurlencode($folder['entry']) }}" data-action="delete_file" data-name="{{ $folder['entry'] }}"><button class="btn btn-danger btn-xxs"><i class="fa fa-trash-o"></i></button></a>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td> --}}
|
||||
</tr>
|
||||
@endforeach
|
||||
@foreach ($files as $file)
|
||||
<tr class="align-middle" data-type="file" data-mime="{{ $file['mime'] }}">
|
||||
<td data-identifier="type"><i class="fa fa-file-text" style="margin-left: 2px;"></i></td>
|
||||
<td data-identifier="name" data-hash="@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}/@endif{{ rawurlencode($file['entry']) }}">
|
||||
@if(in_array($file['extension'], $extensions))
|
||||
<td data-identifier="type">
|
||||
{{-- oh boy --}}
|
||||
@if(in_array($file['mime'], [
|
||||
'application/x-7z-compressed',
|
||||
'application/zip',
|
||||
'application/x-compressed-zip',
|
||||
'application/x-tar',
|
||||
'application/x-gzip',
|
||||
'application/x-bzip',
|
||||
'application/x-bzip2',
|
||||
'application/java-archive'
|
||||
]))
|
||||
<i class="fa fa-file-archive-o" style="margin-left: 2px;"></i>
|
||||
@elseif(in_array($file['mime'], [
|
||||
'application/json',
|
||||
'application/javascript',
|
||||
'application/xml',
|
||||
'application/xhtml+xml',
|
||||
'text/xml',
|
||||
'text/css',
|
||||
'text/html',
|
||||
'text/x-perl',
|
||||
'text/x-shellscript'
|
||||
]))
|
||||
<i class="fa fa-file-code-o" style="margin-left: 2px;"></i>
|
||||
@elseif(starts_with($file['mime'], 'image'))
|
||||
<i class="fa fa-file-image-o" style="margin-left: 2px;"></i>
|
||||
@elseif(starts_with($file['mime'], 'video'))
|
||||
<i class="fa fa-file-video-o" style="margin-left: 2px;"></i>
|
||||
@elseif(starts_with($file['mime'], 'video'))
|
||||
<i class="fa fa-file-audio-o" style="margin-left: 2px;"></i>
|
||||
@elseif(starts_with($file['mime'], 'application/vnd.ms-powerpoint'))
|
||||
<i class="fa fa-file-powerpoint-o" style="margin-left: 2px;"></i>
|
||||
@elseif(in_array($file['mime'], [
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
'application/msword'
|
||||
]) || starts_with($file['mime'], 'application/vnd.ms-word'))
|
||||
<i class="fa fa-file-word-o" style="margin-left: 2px;"></i>
|
||||
@elseif(in_array($file['mime'], [
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
|
||||
]) || starts_with($file['mime'], 'application/vnd.ms-excel'))
|
||||
<i class="fa fa-file-excel-o" style="margin-left: 2px;"></i>
|
||||
@elseif($file['mime'] === 'application/pdf')
|
||||
<i class="fa fa-file-pdf-o" style="margin-left: 2px;"></i>
|
||||
@else
|
||||
<i class="fa fa-file-text-o" style="margin-left: 2px;"></i>
|
||||
@endif
|
||||
</td>
|
||||
<td data-identifier="name" data-name="{{ rawurlencode($file['entry']) }}" data-path="@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}@endif/">
|
||||
@if(in_array($file['mime'], $editableMime))
|
||||
@can('edit-files', $server)
|
||||
<a href="/server/{{ $server->uuidShort }}/files/edit/@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}/@endif{{ rawurlencode($file['entry']) }}" class="edit_file">{{ $file['entry'] }}</a>
|
||||
@else
|
||||
|
@ -85,22 +131,6 @@
|
|||
</td>
|
||||
<td data-identifier="size">{{ $file['size'] }}</td>
|
||||
<td data-identifier="modified">{{ date('m/d/y H:i:s', $file['date']) }}</td>
|
||||
{{-- <td style="text-align:center;">
|
||||
<div class="row" style="text-align:center;">
|
||||
<div class="col-md-3 hidden-xs hidden-sm">
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm">
|
||||
@can('download-files', $server)
|
||||
<a href="/server/{{ $server->uuidShort }}/files/download/@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}/@endif{{ rawurlencode($file['entry']) }}"><span class="badge"><i class="fa fa-download"></i></span></a>
|
||||
@endcan
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
@can('delete-files', $server)
|
||||
<a href="@if($file['directory'] !== ''){{ rawurlencode($file['directory']) }}/@endif{{ rawurlencode($file['entry']) }}" data-action="delete_file" data-name="{{ $file['entry'] }}"><span class="badge label-danger"><i class="fa fa-trash-o"></i></span>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</td> --}}
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
|
|
Reference in a new issue