Skip to content

Commit

Permalink
feat: add ability to select file modified time format (#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilihx committed Sep 11, 2021
1 parent 0358e42 commit 0426629
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions frontend/src/components/files/ListingItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export default {
return filesize(this.size);
},
humanTime: function () {
if (this.user.dateFormat) {
return moment(this.modified).format("L LT");
}
return moment(this.modified).fromNow();
},
dragStart: function () {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
"rules": "Rules",
"rulesHelp": "Here you can define a set of allow and disallow rules for this specific user. The blocked files won't show up in the listings and they wont be accessible to the user. We support regex and paths relative to the users scope.\n",
"scope": "Scope",
"setDateFormat": "Set exact date format",
"settingsUpdated": "Settings updated!",
"shareDuration": "Share Duration",
"shareManagement": "Share Management",
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/views/settings/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<input type="checkbox" v-model="singleClick" />
{{ $t("settings.singleClick") }}
</p>
<p>
<input type="checkbox" v-model="dateFormat" />
{{ $t("settings.setDateFormat") }}
</p>
<h3>{{ $t("settings.language") }}</h3>
<languages
class="input input--block"
Expand Down Expand Up @@ -83,6 +87,7 @@ export default {
passwordConf: "",
hideDotfiles: false,
singleClick: false,
dateFormat: false,
locale: "",
};
},
Expand All @@ -107,6 +112,7 @@ export default {
this.locale = this.user.locale;
this.hideDotfiles = this.user.hideDotfiles;
this.singleClick = this.user.singleClick;
this.dateFormat = this.user.dateFormat;
},
methods: {
...mapMutations(["updateUser", "setLoading"]),
Expand Down Expand Up @@ -135,8 +141,9 @@ export default {
locale: this.locale,
hideDotfiles: this.hideDotfiles,
singleClick: this.singleClick,
dateFormat: this.dateFormat,
};
await api.update(data, ["locale", "hideDotfiles", "singleClick"]);
await api.update(data, ["locale", "hideDotfiles", "singleClick", "dateFormat"]);
this.updateUser(data);
this.$showSuccess(this.$t("settings.settingsUpdated"));
} catch (e) {
Expand Down
2 changes: 2 additions & 0 deletions http/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type userInfo struct {
Commands []string `json:"commands"`
LockPassword bool `json:"lockPassword"`
HideDotfiles bool `json:"hideDotfiles"`
DateFormat bool `json:"dateFormat"`
}

type authToken struct {
Expand Down Expand Up @@ -184,6 +185,7 @@ func printToken(w http.ResponseWriter, _ *http.Request, d *data, user *users.Use
LockPassword: user.LockPassword,
Commands: user.Commands,
HideDotfiles: user.HideDotfiles,
DateFormat: user.DateFormat,
},
StandardClaims: jwt.StandardClaims{
IssuedAt: time.Now().Unix(),
Expand Down
2 changes: 2 additions & 0 deletions settings/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type UserDefaults struct {
Perm users.Permissions `json:"perm"`
Commands []string `json:"commands"`
HideDotfiles bool `json:"hideDotfiles"`
DateFormat bool `json:"dateFormat"`
}

// Apply applies the default options to a user.
Expand All @@ -28,4 +29,5 @@ func (d *UserDefaults) Apply(u *users.User) {
u.Sorting = d.Sorting
u.Commands = d.Commands
u.HideDotfiles = d.HideDotfiles
u.DateFormat = d.DateFormat
}
1 change: 1 addition & 0 deletions users/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type User struct {
Fs afero.Fs `json:"-" yaml:"-"`
Rules []rules.Rule `json:"rules"`
HideDotfiles bool `json:"hideDotfiles"`
DateFormat bool `json:"dateFormat"`
}

// GetRules implements rules.Provider.
Expand Down

0 comments on commit 0426629

Please sign in to comment.