|
23 | 23 | Managing Files for: {{ $server->name }} |
24 | 24 | @endsection |
25 | 25 |
|
| 26 | +@section('scripts') |
| 27 | + @parent |
| 28 | + {!! Theme::js('js/vendor/async/async.min.js') !!} |
| 29 | + {!! Theme::js('js/vendor/lodash/lodash.js') !!} |
| 30 | +@endsection |
| 31 | + |
26 | 32 | @section('content') |
27 | 33 | <div class="col-md-12"> |
28 | 34 | <div class="row"> |
|
50 | 56 | </div> |
51 | 57 | </div> |
52 | 58 | </div> |
| 59 | + <ul id="fileOptionMenu" class="dropdown-menu" role="menu" style="display:none" > |
| 60 | + <li data-action="move"><a tabindex="-1" href="#"><i class="fa fa-arrow-right"></i> Move</a></li> |
| 61 | + <li data-action="rename"><a tabindex="-1" href="#"><i class="fa fa-pencil-square-o"></i> Rename</a></li> |
| 62 | + <li><a tabindex="-1" href="#"><i class="fa fa-file-archive-o"></i> Compress</a></li> |
| 63 | + <li class="divider"></li> |
| 64 | + <li><a tabindex="-1" href="#"><i class="fa fa-download"></i> Download</a></li> |
| 65 | + <li><a tabindex="-1" href="#"><i class="fa fa-trash-o"></i> Delete</a></li> |
| 66 | + </ul> |
53 | 67 | </div> |
| 68 | +<script src="{{ route('server.js', [$server->uuidShort, 'filemanager', 'index.js']) }}"></script> |
| 69 | +<script src="{{ route('server.js', [$server->uuidShort, 'filemanager', 'actions.js']) }}"></script> |
| 70 | +<script src="{{ route('server.js', [$server->uuidShort, 'filemanager', 'contextmenu.js']) }}"></script> |
54 | 71 | <script> |
55 | | - $(document).ready(function () { |
56 | | - $('.server-files').addClass('active'); |
57 | | - }); |
58 | | - $(window).load(function(){ |
59 | | - var doneLoad = false; |
60 | | -
|
61 | | - // Show Loading Animation |
62 | | - function handleLoader (show) { |
63 | | -
|
64 | | - // Hide animation if no files displayed. |
65 | | - if ($('#load_files').height() < 5) { return; } |
66 | | -
|
67 | | - // Show Animation |
68 | | - if (show === true){ |
69 | | - var height = $('#load_files').height(); |
70 | | - var width = $('.ajax_loading_box').width(); |
71 | | - var center_height = (height / 2) - 30; |
72 | | - var center_width = (width / 2) - 30; |
73 | | - $('#position_me').css({ |
74 | | - 'top': center_height, |
75 | | - 'left': center_width, |
76 | | - 'font-size': '60px' |
77 | | - }); |
78 | | - $(".ajax_loading_box").css('height', (height + 5)).fadeIn(); |
79 | | - } else { |
80 | | - $('.ajax_loading_box').fadeOut(100); |
81 | | - } |
82 | | -
|
83 | | - } |
84 | | -
|
85 | | - function reloadActions () { |
86 | | - reloadActionClick(); |
87 | | - reloadActionDelete(); |
88 | | - } |
89 | | -
|
90 | | - // Handle folder clicking to load new contents |
91 | | - function reloadActionClick () { |
92 | | - $('a.load_new').click(function (e) { |
93 | | - e.preventDefault(); |
94 | | - window.history.pushState(null, null, $(this).attr('href')); |
95 | | - loadDirectoryContents($.urlParam('dir', $(this).attr('href'))); |
96 | | - }); |
97 | | - } |
98 | | -
|
99 | | - // Handle Deleting Files |
100 | | - function reloadActionDelete () { |
101 | | - $('[data-action="delete_file"]').click(function (e) { |
102 | | - e.preventDefault(); |
103 | | - var clicked = $(this); |
104 | | - var deleteItemPath = $(this).attr('href'); |
105 | | -
|
106 | | - swal({ |
107 | | - type: 'warning', |
108 | | - title: '', |
109 | | - text: 'Are you sure you want to delete <code>' + clicked.data('name') + '</code>?', |
110 | | - html: true, |
111 | | - showCancelButton: true, |
112 | | - showConfirmButton: true, |
113 | | - closeOnConfirm: false, |
114 | | - showLoaderOnConfirm: true |
115 | | - }, function () { |
116 | | - $.ajax({ |
117 | | - type: 'DELETE', |
118 | | - url: '{{ $node->scheme }}://{{ $node->fqdn }}:{{ $node->daemonListen }}/server/file/' + deleteItemPath, |
119 | | - headers: { |
120 | | - 'X-Access-Token': '{{ $server->daemonSecret }}', |
121 | | - 'X-Access-Server': '{{ $server->uuid }}' |
122 | | - } |
123 | | - }).done(function (data) { |
124 | | - clicked.parent().parent().parent().parent().fadeOut(); |
125 | | - swal({ |
126 | | - type: 'success', |
127 | | - title: 'File Deleted' |
128 | | - }); |
129 | | - }).fail(function (jqXHR) { |
130 | | - console.error(jqXHR); |
131 | | - swal({ |
132 | | - type: 'error', |
133 | | - title: 'Whoops!', |
134 | | - html: true, |
135 | | - text: 'An error occured while attempting to delete this file. Please try again.', |
136 | | - }); |
137 | | - }); |
138 | | - }); |
139 | | -
|
140 | | - }); |
141 | | - } |
142 | | -
|
143 | | - // Handle Loading Contents |
144 | | - function loadDirectoryContents (dir) { |
145 | | -
|
146 | | - handleLoader(true); |
147 | | - var outputContent; |
148 | | - var urlDirectory = (dir === null) ? '/' : dir; |
149 | | -
|
150 | | - $.ajax({ |
151 | | - type: 'POST', |
152 | | - url: '{{ route('server.files.directory-list', $server->uuidShort) }}', |
153 | | - headers: { 'X-CSRF-Token': '{{ csrf_token() }}' }, |
154 | | - data: { directory: urlDirectory } |
155 | | - }).done(function (data) { |
156 | | - handleLoader(false); |
157 | | - $("#load_files").slideUp(function () { |
158 | | - $("#load_files").html(data).slideDown(); |
159 | | - $('[data-toggle="tooltip"]').tooltip(); |
160 | | - $('#internal_alert').slideUp(); |
161 | | -
|
162 | | - // Run Actions Again |
163 | | - reloadActions(); |
164 | | - }); |
165 | | - }).fail(function (jqXHR) { |
166 | | - $("#internal_alert").html('<div class="alert alert-danger">An error occured while attempting to process this request. Please try again.</div>').show(); |
167 | | - console.log(jqXHR); |
168 | | - }); |
169 | | -
|
170 | | - } |
171 | | -
|
172 | | - // Load on Initial Page Load |
173 | | - loadDirectoryContents($.urlParam('dir')); |
174 | | -
|
175 | | - }); |
| 72 | +$(window).load(function () { |
| 73 | + $('.server-files').addClass('active'); |
| 74 | +}); |
176 | 75 | </script> |
177 | 76 | @endsection |
0 commit comments