Skip to content

Commit

Permalink
Merge pull request #32 from nikistag/nshare-folder-color
Browse files Browse the repository at this point in the history
Nshare folder color
  • Loading branch information
nikistag authored Jun 8, 2024
2 parents 3fe347d + 0d6f892 commit 18555f1
Show file tree
Hide file tree
Showing 17 changed files with 554 additions and 318 deletions.
89 changes: 73 additions & 16 deletions app/Http/Controllers/FolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public function root(Request $request)
'extension' => $extensionWithDot,
'fileimageurl' => $this->getThumbnailImage($extensionWithDot, $path, $fullfilename, $filename),
'filevideourl' => $this->getThumbnailVideo($extensionWithDot, $path, $fullfilename, $filename),
'filesize' => $this->getFileSize($file)
'filesize' => $this->getFileSize($file),
'filedate' => date("Y.m.d", filemtime(Storage::path($file)))
]);
}

Expand Down Expand Up @@ -600,17 +601,41 @@ public function searchForm(Request $request)
{
$current_folder = $request->current_folder;

$parent_folder = $this->getParentFolder($current_folder);

$path = $this->getPath($current_folder);

$breadcrumbs = $this->getBreadcrumbs($current_folder);

//Directory paths for options to move files and folders
$full_private_directory_paths = Storage::allDirectories(auth()->user()->name);
$share_directory_paths = Storage::allDirectories('NShare');
if (count($share_directory_paths) == 0) {
$share_directory_paths = ["NShare"];
}
//Delete expired local shares
$expiredShares = Ushare::where("expiration", "<", time())->get();
if (count($expiredShares) >= 1) {
foreach ($expiredShares as $expired) {
$expired->delete();
}
}

//Get folders an fils of current directory
//Get info about local shares
$usershares = null;
//if ($current_folder == null) {
$ushares = Ushare::where('wuser_id', auth()->user()->id)->get();
//}
if (count($ushares) > 0) {
$usershares = count($ushares->unique("user_id")) . " shares";
$usershares_directories = [];
foreach ($ushares as $ush) {
array_push($usershares_directories, [0 => substr($ush->path, 1, strlen($ush->path))]);
array_push($usershares_directories, Storage::allDirectories($ush->path));
}
$usershares_directory_merged = array_merge(...$usershares_directories);
$usershares_directory_paths = $this->prependStringToArrayElements($usershares_directory_merged, "UShare/");
}

//Get folders an files of current directory
$dirs = Storage::directories($path);
$fls = Storage::files($path);
$directories = [];
Expand All @@ -626,6 +651,7 @@ public function searchForm(Request $request)
$NShare['foldersize'] = $this->getFolderSize('NShare');
$ztemp['foldersize'] = $this->getFolderSize(auth()->user()->name . '/ZTemp');

/* Process files */
$files = [];
foreach ($fls as $file) {
$fullfilename = substr($file, strlen($path));
Expand All @@ -638,8 +664,9 @@ public function searchForm(Request $request)
'shortfilename' => strlen($filename) > 30 ? substr($filename, 0, 25) . "*~" : $filename,
'extension' => $extensionWithDot,
'fileimageurl' => $this->getThumbnailImage($extensionWithDot, $path, $fullfilename, $filename),
'filevideourl' => $this->getPreviewVideo($extensionWithDot, $path, $fullfilename, $filename),
'filesize' => $this->getFileSize($file)
'filevideourl' => $this->getThumbnailVideo($extensionWithDot, $path, $fullfilename, $filename),
'filesize' => $this->getFileSize($file),
'filedate' => date("Y.m.d", filemtime(Storage::path($file)))
]);
}

Expand All @@ -665,18 +692,27 @@ public function searchForm(Request $request)

$userRoot = $this->convertPathsToTree($treeCollection)->first();
$folderTreeView = '<li><span class="folder-tree-root"></span>';
$folderTreeView .= '<a class="blue-grey-text text-darken-3" href="' . route('folder.root', ['current_folder' => '']) . '" data-folder="Root" data-folder-view="Root">Root</a></li>';
$folderTreeView .= '<a class="blue-grey-text text-darken-3" href="' . route('folder.root', ['current_folder' => '']) . '" data-folder="Root" data-folder-view="Root"><b><i>Root</i></b></a></li>';
$folderTreeView .= $this->generateViewTree($userRoot['children'], $current_folder, $activeBranch);

$treeMoveFolder = str_replace("blue-grey-text text-darken-3", "collection-item blue-grey-text text-darken-3 tree-move-folder", $folderTreeView);
$treeMoveFile = str_replace("blue-grey-text text-darken-3", "collection-item blue-grey-text text-darken-3 tree-move-file", $folderTreeView);
$treeMoveMulti = str_replace("blue-grey-text text-darken-3", "collection-item blue-grey-text text-darken-3 tree-move-multi", $folderTreeView);

//Add UShare folder to folder tree view
//Generate folder tree view - collection for UShare
if (count($ushares) > 0) {
$ushareCollection = collect($usershares_directory_paths);
$treeCollection_ushare = $ushareCollection->map(function ($item) {
return explode('/', '/' . $item);
});
$userRootShare = $this->convertPathsToTree($treeCollection_ushare)->first();
$folderTreeView .= $this->generateShareViewTree($userRootShare['children'], $ushares);
}
return view('folder.searchForm', compact(
'directories',
'files',
'current_folder',
'parent_folder',
'NShare',
'ztemp',
'path',
Expand Down Expand Up @@ -739,7 +775,8 @@ public function search(Request $request)
'filename' => $trueFileName,
'shortfilename' => strlen($trueFileName) > 25 ? substr($trueFileName, 0, 20) . "*~" : $trueFileName,
'extension' => strrchr($file, "."),
'filesize' => $this->getFileSize($file)
'filesize' => $this->getFileSize($file),
'filedate' => date("Y.m.d", filemtime(Storage::path($file)))
]);
} else {
if (strstr(strtolower($trueFileName), $searchstring) !== false) {
Expand All @@ -750,7 +787,8 @@ public function search(Request $request)
'filename' => $trueFileName,
'shortfilename' => strlen($trueFileName) > 25 ? substr($trueFileName, 0, 20) . "*~" : $trueFileName,
'extension' => strrchr($file, "."),
'filesize' => $this->getFileSize($file)
'filesize' => $this->getFileSize($file),
'filedate' => date("Y.m.d", filemtime(Storage::path($file)))
]);
}
}
Expand Down Expand Up @@ -1233,27 +1271,40 @@ private function generateViewTree($directories, $current_folder, $activeBranch)
count($activeBranch) == 0 ?
$view .= '<span class="folder-tree-down-active"></span><a class="pink-text text-darken-3" href="'
:
$view .= '<span class="folder-tree-down"></span><a class="blue-grey-text text-darken-3" href="';
$view .= '<span ';
$this->startsWithNShare($directory['path']) ?
$view .= 'class="folder-tree-nshare-down">' : $view .= 'class="folder-tree-down">'; //Check if NShare
$view .= '</span><a class="blue-grey-text text-darken-3" href="';
$view .= route('folder.root', ['current_folder' => $directory['path']]) .
'" data-folder="' . $directory['path'] . '" data-folder-view ="' . $directory['label'] . '">';
$view .= '<b><i>' . $directory['label'] . '</i></b></a>';
$view .= '<ul class="active-tree browser-default" style="padding-left: 20px;">';
$this->startsWithNShare($directory['path']) ?
$view .= '<ul class="active-tree-nshare browser-default" style="padding-left: 20px;">' :
$view .= '<ul class="active-tree browser-default" style="padding-left: 20px;">';
$view .= $this->generateViewTree($directory['children'], $current_folder, $activeBranch);
$view .= '</ul>';
} else {
$view .= '<span class="folder-tree"></span>';
$this->startsWithNShare($directory['path']) ?
$view .= '<span class="folder-tree-nshare"></span>' :
$view .= '<span class="folder-tree"></span>';
$view .= '<a class="blue-grey-text text-darken-3" href="' . route('folder.root', ['current_folder' => $directory['path']]) . '" data-folder="' . $directory['path'] . '" data-folder-view ="' . $directory['label'] . '">';
$view .= '<b><i>' . $directory['label'] . '</i></b></a>';
$view .= '<ul class="nested browser-default" style="padding-left: 20px;">';
$this->startsWithNShare($directory['path']) ?
$view .= '<ul class="nested-nshare browser-default" style="padding-left: 20px;">' :
$view .= '<ul class="nested browser-default" style="padding-left: 20px;">';
$view .= $this->generateViewTree($directory['children'], $current_folder, $activeBranch);
$view .= '</ul>';
}
} else {

if ((count($activeBranch) > 0) && ($activeBranch[0] == $directory["label"])) {
$view .= '<span class="folder-tree-empty-active"></span><a class="pink-text text-darken-3" href="';
$this->startsWithNShare($directory['path']) ?
$view .= '<span class="folder-tree-nshare-empty-active"></span><a class="pink-text text-darken-3" href="' :
$view .= '<span class="folder-tree-empty-active"></span><a class="blue-grey-text text-darken-3" href="';
} else {
$view .= '<span class="folder-tree-empty"></span><a class="blue-grey-text text-darken-3" href="';
$this->startsWithNShare($directory['path']) ?
$view .= '<span class="folder-tree-nshare-empty"></span><a class="blue-grey-text text-darken-3" href="' :
$view .= '<span class="folder-tree-empty"></span><a class="blue-grey-text text-darken-3" href="';
}
$view .= route('folder.root', ['current_folder' => $directory['path']]) . '" data-folder="' . $directory['path'] . '" data-folder-view ="' . $directory['label'] . '">';
$view .= '<b><i>' . $directory['label'] . '</i></b></a>';
Expand Down Expand Up @@ -1355,4 +1406,10 @@ private function prependStringToArrayElements($array, $string)
}
return $newArray;
}


function startsWithNShare($path)
{
return strpos($path, "/NShare") === 0;
}
}
17 changes: 13 additions & 4 deletions app/Http/Controllers/UshareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1033,20 +1033,25 @@ private function getStreamHeaders($path)

private function generateViewTree($directories)
{
// dd($directories);
$view = '';
foreach ($directories as $directory) {
$withChildren = count($directory['children']) > 0 ? true : false;
$view .= '<li>';
if ($withChildren) {
$view .= '<span class="folder-tree"></span>';
$this->startsWithNShare($directory['path']) ?
$view .= '<span class="folder-tree-nshare"></span>' :
$view .= '<span class="folder-tree"></span>';
$view .= '<a class="blue-grey-text text-darken-3" href="' . route('folder.root', ['current_folder' => $directory['path']]) . '" data-folder="' . $directory['path'] . '" data-folder-view ="' . $directory['label'] . '">';
$view .= '<b><i>' . $directory['label'] . '</i></b></a>';
$view .= '<ul class="nested browser-default" style="padding-left: 20px;">';
$this->startsWithNShare($directory['path']) ?
$view .= '<ul class="nested-nshare browser-default" style="padding-left: 20px;">' :
$view .= '<ul class="nested browser-default" style="padding-left: 20px;">';
$view .= $this->generateViewTree($directory['children']);
$view .= '</ul>';
} else {
$view .= '<span class="folder-tree-empty"></span>';
$this->startsWithNShare($directory['path']) ?
$view .= '<span class="folder-tree-nshare-empty"></span>' :
$view .= '<span class="folder-tree-empty"></span>';
$view .= '<a class="blue-grey-text text-darken-3" href="' . route('folder.root', ['current_folder' => $directory['path']]) . '" data-folder="' . $directory['path'] . '" data-folder-view ="' . $directory['label'] . '">';
$view .= '<b><i>' . $directory['label'] . '</i></b></a>';
}
Expand Down Expand Up @@ -1208,4 +1213,8 @@ private function getPath($current_folder)
}
return $path;
}
function startsWithNShare($path)
{
return strpos($path, "/NShare") === 0;
}
}
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
|
*/

'version' => '0.10.10',
'version' => '0.10.11',

/*
|--------------------------------------------------------------------------
Expand Down
71 changes: 71 additions & 0 deletions public/css/prvstorage.css
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,62 @@ ul,
vertical-align: middle;
}

.folder-tree-nshare {
cursor: pointer;
user-select: none;
/* Prevent text selection */
}

.folder-tree-nshare::before {
font-family: "Material Icons";
font-size: 25px;
content: "create_new_folder";
color: indigo;
display: inline-block;
margin-right: 6px;
vertical-align: middle;
}

.folder-tree-nshare-down::before {
font-family: "Material Icons";
font-size: 25px;
content: "folder_open";
color: indigo;
display: inline-block;
margin-right: 6px;
vertical-align: middle;
}

.folder-tree-nshare-down-active::before {
font-family: "Material Icons";
font-size: 25px;
content: "folder_open";
color: #ad1457;
display: inline-block;
margin-right: 6px;
vertical-align: middle;
}

.folder-tree-nshare-empty::before {
font-family: "Material Icons";
font-size: 25px;
content: "folder";
color: indigo;
display: inline-block;
margin-right: 6px;
vertical-align: middle;
}

.folder-tree-nshare-empty-active::before {
font-family: "Material Icons";
font-size: 25px;
content: "folder";
color: #ad1457;
display: inline-block;
margin-right: 6px;
vertical-align: middle;
}

/* Hide the nested list */
.nested {
display: none;
Expand All @@ -216,6 +272,10 @@ ul,
display: none;
}

.nested-nshare {
display: none;
}

/* Show the nested list when the user clicks on the caret/arrow (with JavaScript) */
.active-tree {
display: block;
Expand All @@ -225,6 +285,10 @@ ul,
display: block;
}

.active-tree-nshare {
display: block;
}

/* Inactive links */
.inactive {
color: #292a2b;
Expand All @@ -240,6 +304,13 @@ ul,
-webkit-tap-highlight-color: transparent;
}

.inactive-nshare {
color: #292a2b;
cursor: none;
text-decoration: none;
-webkit-tap-highlight-color: transparent;
}

/* SIDE NAVIGATION FOR FOLDER TREE */

.sidenav-tree {
Expand Down
7 changes: 4 additions & 3 deletions resources/views/folder/_fileView.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class="{{$file['fileimageurl']['original'] == true ? 'media-preview-trigger' : '
</div>
</div>
<div class="col s4">
<span class="new badge" data-badge-caption="{{ $file['filesize']['type']}}">{{
$file['filesize']['size']}}</span>
<span class="new badge" data-badge-caption="{{ $file['filesize']['type']}}">{{$file['filesize']['size']}}</span>
<br />
<span class="new badge blue-grey" data-badge-caption="{{$file['filedate']}}"></span>
</div>
<div class="col s4 right-align">
@if($current_folder == '/ZTemp')
Expand Down Expand Up @@ -70,7 +71,7 @@ class="tooltipped" data-tooltip="Play"><i class="material-icons blue-text">play_
@if($current_folder == '/ZTemp')
@else

<div class="row center left-align blue-grey lighten-4">
<div class="row center left-align blue-grey lighten-4" style="margin-bottom:0px;">
<div class="selectedaction blue-grey lighten-4" id="selectedaction">
&nbsp;
<a href="#copy" class="move-files tooltipped" data-tooltip="Move/Copy"><i
Expand Down
2 changes: 1 addition & 1 deletion resources/views/folder/_topActionBar.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="row">
<div class="row" style="margin-bottom:0px;">
@if(($current_folder != "/ZTemp") && (substr($current_folder, 0, 7) != "/NShare"))

<!-- For large displays -->
Expand Down
Loading

0 comments on commit 18555f1

Please sign in to comment.