Moved showHidden check box to Profile Settings.

Saving the `showHidden` attribute to the backend database as
a part of the user schema.

Sending the attribute from the auth endpoint as a part of userInfo
This commit is contained in:
Tiger Nie 2020-09-21 22:17:00 +08:00
parent 84a9d09aad
commit 20be1027d6
6 changed files with 20 additions and 18 deletions

View File

@ -58,8 +58,7 @@
"size": "Size", "size": "Size",
"sortByName": "Sort by name", "sortByName": "Sort by name",
"sortBySize": "Sort by size", "sortBySize": "Sort by size",
"sortByLastModified": "Sort by last modified", "sortByLastModified": "Sort by last modified"
"showHiddenFiles": "Show hidden files"
}, },
"help": { "help": {
"click": "select file or directory", "click": "select file or directory",
@ -174,6 +173,7 @@
"globalRules": "This is a global set of allow and disallow rules. They apply to every user. You can define specific rules on each user's settings to override this ones.", "globalRules": "This is a global set of allow and disallow rules. They apply to every user. You can define specific rules on each user's settings to override this ones.",
"allowSignup": "Allow users to signup", "allowSignup": "Allow users to signup",
"createUserDir": "Auto create user home dir while adding new user", "createUserDir": "Auto create user home dir while adding new user",
"showHidden": "Show hidden files",
"insertRegex": "Insert regex expression", "insertRegex": "Insert regex expression",
"insertPath": "Insert the path", "insertPath": "Insert the path",
"userUpdated": "User updated!", "userUpdated": "User updated!",

View File

@ -10,13 +10,6 @@
<router-link :to="link.url">{{ link.name }}</router-link> <router-link :to="link.url">{{ link.name }}</router-link>
</span> </span>
<span style="margin-left:auto;">
<input
type="checkbox"
v-model="showHidden">
<span>{{ $t('files.showHiddenFiles') }}</span>
</span>
</div> </div>
<div v-if="error"> <div v-if="error">
@ -189,7 +182,7 @@ export default {
return return
} }
if (res.isDir && !this.showHidden) { if (res.isDir && !this.user.showHidden) {
res = pruneHiddenFiles(res) res = pruneHiddenFiles(res)
} }

View File

@ -6,6 +6,9 @@
</div> </div>
<div class="card-content"> <div class="card-content">
<p><input type="checkbox" v-model="showHidden"> {{ $t('settings.showHidden') }}</p>
<h3>{{ $t('settings.language') }}</h3> <h3>{{ $t('settings.language') }}</h3>
<languages class="input input--block" :locale.sync="locale"></languages> <languages class="input input--block" :locale.sync="locale"></languages>
</div> </div>
@ -67,6 +70,7 @@ export default {
}, },
created () { created () {
this.locale = this.user.locale this.locale = this.user.locale
this.showHidden = this.user.showHidden
}, },
methods: { methods: {
...mapMutations([ 'updateUser' ]), ...mapMutations([ 'updateUser' ]),
@ -90,8 +94,8 @@ export default {
event.preventDefault() event.preventDefault()
try { try {
const data = { id: this.user.id, locale: this.locale } const data = { id: this.user.id, locale: this.locale, showHidden: this.showHidden }
await api.update(data, ['locale']) await api.update(data, ['locale', 'showHidden'])
this.updateUser(data) this.updateUser(data)
this.$showSuccess(this.$t('settings.settingsUpdated')) this.$showSuccess(this.$t('settings.settingsUpdated'))
} catch (e) { } catch (e) {

View File

@ -26,6 +26,7 @@ type userInfo struct {
Perm users.Permissions `json:"perm"` Perm users.Permissions `json:"perm"`
Commands []string `json:"commands"` Commands []string `json:"commands"`
LockPassword bool `json:"lockPassword"` LockPassword bool `json:"lockPassword"`
ShowHidden bool `json:"showHidden"`
} }
type authToken struct { type authToken struct {
@ -175,6 +176,7 @@ func printToken(w http.ResponseWriter, _ *http.Request, d *data, user *users.Use
Perm: user.Perm, Perm: user.Perm,
LockPassword: user.LockPassword, LockPassword: user.LockPassword,
Commands: user.Commands, Commands: user.Commands,
ShowHidden: user.ShowHidden,
}, },
StandardClaims: jwt.StandardClaims{ StandardClaims: jwt.StandardClaims{
IssuedAt: time.Now().Unix(), IssuedAt: time.Now().Unix(),

View File

@ -8,12 +8,13 @@ import (
// UserDefaults is a type that holds the default values // UserDefaults is a type that holds the default values
// for some fields on User. // for some fields on User.
type UserDefaults struct { type UserDefaults struct {
Scope string `json:"scope"` Scope string `json:"scope"`
Locale string `json:"locale"` Locale string `json:"locale"`
ViewMode users.ViewMode `json:"viewMode"` ViewMode users.ViewMode `json:"viewMode"`
Sorting files.Sorting `json:"sorting"` Sorting files.Sorting `json:"sorting"`
Perm users.Permissions `json:"perm"` Perm users.Permissions `json:"perm"`
Commands []string `json:"commands"` Commands []string `json:"commands"`
ShowHidden bool `json:"showHidden"`
} }
// Apply applies the default options to a user. // Apply applies the default options to a user.
@ -24,4 +25,5 @@ func (d *UserDefaults) Apply(u *users.User) {
u.Perm = d.Perm u.Perm = d.Perm
u.Sorting = d.Sorting u.Sorting = d.Sorting
u.Commands = d.Commands u.Commands = d.Commands
u.ShowHidden = d.ShowHidden
} }

View File

@ -33,6 +33,7 @@ type User struct {
Sorting files.Sorting `json:"sorting"` Sorting files.Sorting `json:"sorting"`
Fs afero.Fs `json:"-" yaml:"-"` Fs afero.Fs `json:"-" yaml:"-"`
Rules []rules.Rule `json:"rules"` Rules []rules.Rule `json:"rules"`
ShowHidden bool `json:"showHidden"`
} }
// GetRules implements rules.Provider. // GetRules implements rules.Provider.