Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Commit

Permalink
Improve volume directory browser
Browse files Browse the repository at this point in the history
It now only shows avaliable storage disks and has a new button to
choose the current directory.
  • Loading branch information
mzur committed Mar 21, 2018
1 parent 8e794f0 commit 5f7e2cb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Http/Controllers/VolumeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ public function create(Request $request)
{
$project = Project::findOrFail($request->input('project'));
$this->authorize('update', $project);
$disks = array_intersect(array_keys(config('filesystems.disks')), config('volumes.browser_disks'));

return view('volumes::create', [
'project' => $project,
'mediaTypes' => MediaType::all(),
'hasBrowser' => config('volumes.browser'),
'disks' => config('volumes.browser_disks'),
'disks' => $disks,
]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/public/assets/scripts/main.js

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion src/resources/assets/js/createVolumeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ biigle.$viewModel('create-volume-form', function (element) {
canGoBack: function () {
return this.breadCrumbs.length > 0 || disks.length > 1;
},
hasCurrentDirectory: function () {
return this.breadCrumbs.length > 0;
},
currentDirectory: function () {
if (this.hasCurrentDirectory) {
return this.breadCrumbs[this.breadCrumbs.length - 1];
}

return null;
},
},
methods: {
toggleBrowse: function () {
Expand Down Expand Up @@ -89,7 +99,9 @@ biigle.$viewModel('create-volume-form', function (element) {
},
selectDirectory: function (directory) {
var crumbs = this.breadCrumbs.slice();
crumbs.push(directory);
if (directory) {
crumbs.push(directory);
}
this.fetchImages(this.storageDisk, crumbs.join('/'))
.then(this.setImages)
.then(function () {
Expand Down
7 changes: 5 additions & 2 deletions src/resources/views/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@
</span>
<div class="list-group file-browser__dirs">
<a href="#" v-for="directory in currentDirectories" v-on:click="openDirectory(directory)" class="list-group-item" title="Open this directory">
<button type="button" class="btn btn-default btn-xs pull-right" v-on:click.stop="selectDirectory(directory)" title="Select this directory for the new volume"><i class="fa fa-check"></i></button>
<button type="button" class="btn btn-default btn-xs pull-right" v-on:click.stop="selectDirectory(directory)" v-bind:title="'Select '+directory+' for the new volume'"><i class="fa fa-check"></i></button>
@{{directory}}
</a>
<a v-if="!hasDirectories" href="#" class="list-group-item disabled">No directories</a>
<a v-if="!hasDirectories" href="#" class="list-group-item disabled">
<button v-if="hasCurrentDirectory" type="button" class="btn btn-default btn-xs pull-right" v-on:click.stop="selectDirectory()" v-bind:title="'Select '+currentDirectory+' for the new volume'"><i class="fa fa-check"></i></button>
No directories
</a>
</div>
</div>
</div>
Expand Down

0 comments on commit 5f7e2cb

Please sign in to comment.