("$showError")!;
@@ -108,7 +108,7 @@ onMounted(() => {
value: fileContent,
showPrintMargin: false,
readOnly: fileStore.req?.type === "textImmutable",
- theme: "ace/theme/chrome",
+ theme: getEditorTheme(authStore.user?.aceEditorTheme ?? ""),
mode: modelist.getModeForPath(fileStore.req!.name).mode,
wrap: true,
enableBasicAutocompletion: true,
@@ -116,10 +116,6 @@ onMounted(() => {
enableSnippets: true,
});
- if (getTheme() === "dark") {
- editor.value!.setTheme("ace/theme/twilight");
- }
-
editor.value.focus();
});
diff --git a/frontend/src/views/settings/Profile.vue b/frontend/src/views/settings/Profile.vue
index c677092f..1b079473 100644
--- a/frontend/src/views/settings/Profile.vue
+++ b/frontend/src/views/settings/Profile.vue
@@ -24,6 +24,13 @@
class="input input--block"
v-model:locale="locale"
>
+
+ {{ t("settings.aceEditorTheme") }}
+
@@ -81,6 +88,7 @@
import { useAuthStore } from "@/stores/auth";
import { useLayoutStore } from "@/stores/layout";
import { users as api } from "@/api";
+import AceEditorTheme from "@/components/settings/AceEditorTheme.vue";
import Languages from "@/components/settings/Languages.vue";
import { computed, inject, onMounted, ref } from "vue";
import { useI18n } from "vue-i18n";
@@ -98,6 +106,7 @@ const hideDotfiles = ref(false);
const singleClick = ref(false);
const dateFormat = ref(false);
const locale = ref("");
+const aceEditorTheme = ref("");
const passwordClass = computed(() => {
const baseClass = "input input--block";
@@ -113,13 +122,14 @@ const passwordClass = computed(() => {
return `${baseClass} input--red`;
});
-onMounted(() => {
+onMounted(async () => {
layoutStore.loading = true;
if (authStore.user === null) return false;
locale.value = authStore.user.locale;
hideDotfiles.value = authStore.user.hideDotfiles;
singleClick.value = authStore.user.singleClick;
dateFormat.value = authStore.user.dateFormat;
+ aceEditorTheme.value = authStore.user.aceEditorTheme;
layoutStore.loading = false;
return true;
});
@@ -163,6 +173,7 @@ const updateSettings = async (event: Event) => {
hideDotfiles: hideDotfiles.value,
singleClick: singleClick.value,
dateFormat: dateFormat.value,
+ aceEditorTheme: aceEditorTheme.value,
};
await api.update(data, [
@@ -170,6 +181,7 @@ const updateSettings = async (event: Event) => {
"hideDotfiles",
"singleClick",
"dateFormat",
+ "aceEditorTheme",
]);
authStore.updateUser(data);
$showSuccess(t("settings.settingsUpdated"));
diff --git a/http/auth.go b/http/auth.go
index 304762c8..23e0925e 100644
--- a/http/auth.go
+++ b/http/auth.go
@@ -21,15 +21,16 @@ const (
)
type userInfo struct {
- ID uint `json:"id"`
- Locale string `json:"locale"`
- ViewMode users.ViewMode `json:"viewMode"`
- SingleClick bool `json:"singleClick"`
- Perm users.Permissions `json:"perm"`
- Commands []string `json:"commands"`
- LockPassword bool `json:"lockPassword"`
- HideDotfiles bool `json:"hideDotfiles"`
- DateFormat bool `json:"dateFormat"`
+ ID uint `json:"id"`
+ Locale string `json:"locale"`
+ ViewMode users.ViewMode `json:"viewMode"`
+ SingleClick bool `json:"singleClick"`
+ Perm users.Permissions `json:"perm"`
+ Commands []string `json:"commands"`
+ LockPassword bool `json:"lockPassword"`
+ HideDotfiles bool `json:"hideDotfiles"`
+ DateFormat bool `json:"dateFormat"`
+ AceEditorTheme string `json:"aceEditorTheme"`
}
type authToken struct {
@@ -189,15 +190,16 @@ func renewHandler(tokenExpireTime time.Duration) handleFunc {
func printToken(w http.ResponseWriter, _ *http.Request, d *data, user *users.User, tokenExpirationTime time.Duration) (int, error) {
claims := &authToken{
User: userInfo{
- ID: user.ID,
- Locale: user.Locale,
- ViewMode: user.ViewMode,
- SingleClick: user.SingleClick,
- Perm: user.Perm,
- LockPassword: user.LockPassword,
- Commands: user.Commands,
- HideDotfiles: user.HideDotfiles,
- DateFormat: user.DateFormat,
+ ID: user.ID,
+ Locale: user.Locale,
+ ViewMode: user.ViewMode,
+ SingleClick: user.SingleClick,
+ Perm: user.Perm,
+ LockPassword: user.LockPassword,
+ Commands: user.Commands,
+ HideDotfiles: user.HideDotfiles,
+ DateFormat: user.DateFormat,
+ AceEditorTheme: user.AceEditorTheme,
},
RegisteredClaims: jwt.RegisteredClaims{
IssuedAt: jwt.NewNumericDate(time.Now()),
diff --git a/settings/defaults.go b/settings/defaults.go
index d60e36dc..5b6c3f2a 100644
--- a/settings/defaults.go
+++ b/settings/defaults.go
@@ -8,15 +8,16 @@ import (
// UserDefaults is a type that holds the default values
// for some fields on User.
type UserDefaults struct {
- Scope string `json:"scope"`
- Locale string `json:"locale"`
- ViewMode users.ViewMode `json:"viewMode"`
- SingleClick bool `json:"singleClick"`
- Sorting files.Sorting `json:"sorting"`
- Perm users.Permissions `json:"perm"`
- Commands []string `json:"commands"`
- HideDotfiles bool `json:"hideDotfiles"`
- DateFormat bool `json:"dateFormat"`
+ Scope string `json:"scope"`
+ Locale string `json:"locale"`
+ ViewMode users.ViewMode `json:"viewMode"`
+ SingleClick bool `json:"singleClick"`
+ Sorting files.Sorting `json:"sorting"`
+ Perm users.Permissions `json:"perm"`
+ Commands []string `json:"commands"`
+ HideDotfiles bool `json:"hideDotfiles"`
+ DateFormat bool `json:"dateFormat"`
+ AceEditorTheme string `json:"aceEditorTheme"`
}
// Apply applies the default options to a user.
@@ -30,4 +31,5 @@ func (d *UserDefaults) Apply(u *users.User) {
u.Commands = d.Commands
u.HideDotfiles = d.HideDotfiles
u.DateFormat = d.DateFormat
+ u.AceEditorTheme = d.AceEditorTheme
}
diff --git a/users/users.go b/users/users.go
index e0310f21..020faf11 100644
--- a/users/users.go
+++ b/users/users.go
@@ -20,21 +20,22 @@ const (
// User describes a user.
type User struct {
- ID uint `storm:"id,increment" json:"id"`
- Username string `storm:"unique" json:"username"`
- Password string `json:"password"`
- Scope string `json:"scope"`
- Locale string `json:"locale"`
- LockPassword bool `json:"lockPassword"`
- ViewMode ViewMode `json:"viewMode"`
- SingleClick bool `json:"singleClick"`
- Perm Permissions `json:"perm"`
- Commands []string `json:"commands"`
- Sorting files.Sorting `json:"sorting"`
- Fs afero.Fs `json:"-" yaml:"-"`
- Rules []rules.Rule `json:"rules"`
- HideDotfiles bool `json:"hideDotfiles"`
- DateFormat bool `json:"dateFormat"`
+ ID uint `storm:"id,increment" json:"id"`
+ Username string `storm:"unique" json:"username"`
+ Password string `json:"password"`
+ Scope string `json:"scope"`
+ Locale string `json:"locale"`
+ LockPassword bool `json:"lockPassword"`
+ ViewMode ViewMode `json:"viewMode"`
+ SingleClick bool `json:"singleClick"`
+ Perm Permissions `json:"perm"`
+ Commands []string `json:"commands"`
+ Sorting files.Sorting `json:"sorting"`
+ Fs afero.Fs `json:"-" yaml:"-"`
+ Rules []rules.Rule `json:"rules"`
+ HideDotfiles bool `json:"hideDotfiles"`
+ DateFormat bool `json:"dateFormat"`
+ AceEditorTheme string `json:"aceEditorTheme"`
}
// GetRules implements rules.Provider.