Skip to content

Commit 7a176d2

Browse files
committed
Merge pull request #16 from tsawler/Development
Improve folder display
2 parents 8933f25 + f3b81b8 commit 7a176d2

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

src/controllers/FolderController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Support\Str;
99
use Illuminate\Support\Facades\Session;
1010
use Illuminate\Support\Facades\View;
11+
use Illuminate\Support\Facades\Log;
1112

1213
/**
1314
* Class FolderController
@@ -57,12 +58,13 @@ public function getFolders()
5758
public function getAddfolder()
5859
{
5960
$folder_name = Str::slug(Input::get('name'));
61+
$working_dir = Input::get('dir');
6062

61-
$path = base_path($this->file_location);
63+
$path = base_path($this->file_location . $working_dir);
6264

63-
if (!File::exists($path . $folder_name))
65+
if (!File::exists($path . "/" . $folder_name))
6466
{
65-
File::makeDirectory($path . $folder_name, $mode = 0777, true, true);
67+
File::makeDirectory($path . "/" . $folder_name, $mode = 0777, true, true);
6668
return "OK";
6769
} else
6870
{

src/views/index.blade.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<div class="col-md-2 col-lg-2 col-sm-2 col-xs-2 left-nav fill" id="lfm-leftcol">
2323
<div id="tree1">
2424
</div>
25+
<a href="#!" id="add-folder" class="add-folder btn btn-default btn-xs"><i class="fa fa-plus"></i> New Folder</a>
2526
</div>
2627
<div class="col-md-10 col-lg-10 col-sm-10 col-xs-10 right-nav" id="right-nav">
2728
<nav class="navbar navbar-default">
@@ -41,10 +42,6 @@
4142
<a href="#!" id="upload" data-toggle="modal" data-target="#uploadModal"><i
4243
class="fa fa-upload"></i> Upload</a>
4344
</li>
44-
<li>
45-
<a href="#!" class="add-folder" id="add-folder"><i
46-
class="fa fa-plus"></i> New Folder</a>
47-
</li>
4845
<li>
4946
<a href="#!" class="thumbnail-display" id="thumbnail-display"><i
5047
class="fa fa-picture-o"></i> Thumbnails</a>
@@ -153,6 +150,7 @@ class="fa fa-list"></i> List</a>
153150
$("#tree1").html(data);
154151
});
155152
loadImages();
153+
refreshFolders();
156154
});
157155
158156
$("#upload-btn").click(function () {
@@ -225,6 +223,7 @@ function loadImages() {
225223
$("#content").html(data);
226224
$("#nav-buttons").removeClass("hidden");
227225
$(".dropdown-toggle").dropdown();
226+
refreshFolders();
228227
});
229228
}
230229
@else
@@ -242,6 +241,7 @@ function loadImages() {
242241
$("#content").html(data);
243242
$("#nav-buttons").removeClass("hidden");
244243
$(".dropdown-toggle").dropdown();
244+
refreshFolders();
245245
});
246246
}
247247
@endif
@@ -270,7 +270,6 @@ function trash(x) {
270270
});
271271
}
272272
273-
274273
function loadFiles() {
275274
$.ajax({
276275
type: "GET",
@@ -286,6 +285,14 @@ function loadFiles() {
286285
});
287286
}
288287
288+
function refreshFolders(){
289+
var wd = $("#working_dir").val();
290+
if (wd != "/") {
291+
$('#' + wd + '-folder').removeClass('fa-folder');
292+
$('#' + wd + '-folder').addClass('fa-folder-open');
293+
}
294+
}
295+
289296
function cropImage(x) {
290297
$.ajax({
291298
type: "GET",
@@ -305,7 +312,7 @@ function notImp() {
305312
bootbox.alert('Not yet implemented!');;
306313
}
307314
308-
$(".add-folder").click(function () {
315+
$("#add-folder").click(function () {
309316
bootbox.prompt("Folder name:", function (result) {
310317
if (result === null) {
311318
} else {
@@ -314,13 +321,15 @@ function notImp() {
314321
dataType: "text",
315322
url: "/laravel-filemanager/newfolder",
316323
data: {
317-
name: result
324+
name: result,
325+
dir: $("#working_dir").val()
318326
},
319327
cache: false
320328
}).done(function (data) {
321329
if (data == "OK") {
322330
loadFiles();
323331
loadImages();
332+
refreshFolders();
324333
} else {
325334
notify(data);
326335
}

src/views/tree.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@foreach($dirs as $key => $dir)
88
<li>
99
<a class="pointer" id="folder_{{ $key }}" data-id="{{ $dir }}" onclick="clickFolder('folder_{{ $key }}', 0)">
10-
<i class="fa fa-folder folder-item" data-id="{{ $dir }}"></i> {!! $dir !!}
10+
<i class="fa fa-folder folder-item" data-id="{{ $dir }}" id="{{ $dir }}-folder"></i> {!! $dir !!}
1111
</a>
1212
</li>
1313
@endforeach

0 commit comments

Comments
 (0)