Skip to content

Commit

Permalink
Moved show hidden files, new folder and delete folder options to its …
Browse files Browse the repository at this point in the history
…own panel

Changes:

* Added an advanced options panel, containing 'Show hidden files', 'New folder' and 'Delete folder'.
* Added alert box on error when trying to create a new folder.
* Closes #41
  • Loading branch information
pkrll committed Jun 17, 2018
1 parent 5c38274 commit ee5c244
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions client/src/components/Browser/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@
<div class="title">Set as favorite</div>
</div>

<div class="noselect" v-on:click="toggleAdvancedOptions" v-bind:class="{greyed: showAdvancedOptions}">
<font-awesome-icon icon="cogs"/>
<div class="title">Show advanced options</div>
</div>
</nav>
<nav class="options" v-show="showAdvancedOptions">
<div class="noselect" v-on:click="showHidden = !showHidden">
<font-awesome-icon v-bind:icon="(showHidden) ? 'toggle-on' : 'toggle-off'"/>
<div class="title">Show hidden files</div>
</div>

<div class="noselect" v-on:click="makeFolder">
<font-awesome-icon icon="folder"/>
<div class="title">Create folder</div>
<div class="title">New folder</div>
</div>

<div class="noselect" v-on:click="didClickDelete = !didClickDelete" v-bind:class="{greyed: didClickDelete}">
<font-awesome-icon icon="trash"/>
<div class="title">Delete folder</div>
</div>

</nav>

<component v-bind:is="middleComponent"
Expand Down Expand Up @@ -55,6 +60,7 @@ export default {
this.middleComponent = 'Spinner';
// Remove any old stuff before changing view
this.didClickDelete = false;
this.showAdvancedOptions = false;
this.isFavorite = this.$CookieManager.getBookmark() == this.prettyPath;
let path = (to.params.path != undefined) ? decodeURIComponent(to.params.path) : '/';
this.$APIManager.listDirectory(path, this.didFinishRequest);
Expand Down Expand Up @@ -86,6 +92,12 @@ export default {
this.isFavorite = !this.isFavorite;
},
/**
* Toggles the advanced options pane.
*/
toggleAdvancedOptions: function () {
this.showAdvancedOptions = !this.showAdvancedOptions
},
/**
* Invoked by listDirectory requests.
*
Expand Down Expand Up @@ -128,9 +140,12 @@ export default {
}
}.bind(this));
},
/**
* Invoked when user clicks the New Folder button.
*/
makeFolder: function () {
let folderName = prompt("Set folder name:");
if (folderName != null || folderName != "") {
if (folderName != null && folderName != "") {
let directory = this.prettyPath + '/' + folderName
this.$APIManager.createFolder(directory, function (response) {
if (response.status == 1) {
Expand All @@ -143,6 +158,7 @@ export default {
} else {
console.log("Error: ");
console.log(response);
alert(response.message)
}
}.bind(this));
}
Expand All @@ -157,6 +173,7 @@ export default {
showHidden: this.$CookieManager.loadCookie('showHidden'),
isFavorite: this.$CookieManager.getBookmark() == this.path,
didClickDelete: false,
showAdvancedOptions: false,
toggleHiddenIcon: 'toggle-off'
}
},
Expand Down

0 comments on commit ee5c244

Please sign in to comment.