feat: add a new setting that disables the display of the disk usage (#2136)

pull/2345/head
Gabriel Alencar 2023-02-15 19:30:48 -03:00 committed by GitHub
parent 60d1e2d291
commit 428c1c606d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 71 additions and 26 deletions

View File

@ -45,6 +45,7 @@ func addConfigFlags(flags *pflag.FlagSet) {
flags.String("branding.color", "", "set the theme color") flags.String("branding.color", "", "set the theme color")
flags.String("branding.files", "", "path to directory with images and custom styles") flags.String("branding.files", "", "path to directory with images and custom styles")
flags.Bool("branding.disableExternal", false, "disable external links such as GitHub links") flags.Bool("branding.disableExternal", false, "disable external links such as GitHub links")
flags.Bool("branding.disableUsedPercentage", false, "disable used disk percentage graph")
} }
//nolint:gocyclo //nolint:gocyclo
@ -147,6 +148,7 @@ func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Aut
fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name) fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name)
fmt.Fprintf(w, "\tFiles override:\t%s\n", set.Branding.Files) fmt.Fprintf(w, "\tFiles override:\t%s\n", set.Branding.Files)
fmt.Fprintf(w, "\tDisable external links:\t%t\n", set.Branding.DisableExternal) fmt.Fprintf(w, "\tDisable external links:\t%t\n", set.Branding.DisableExternal)
fmt.Fprintf(w, "\tDisable used disk percentage graph:\t%t\n", set.Branding.DisableUsedPercentage)
fmt.Fprintf(w, "\tColor:\t%s\n", set.Branding.Color) fmt.Fprintf(w, "\tColor:\t%s\n", set.Branding.Color)
fmt.Fprintln(w, "\nServer:") fmt.Fprintln(w, "\nServer:")
fmt.Fprintf(w, "\tLog:\t%s\n", ser.Log) fmt.Fprintf(w, "\tLog:\t%s\n", ser.Log)

View File

@ -35,9 +35,10 @@ override the options.`,
AuthMethod: authMethod, AuthMethod: authMethod,
Defaults: defaults, Defaults: defaults,
Branding: settings.Branding{ Branding: settings.Branding{
Name: mustGetString(flags, "branding.name"), Name: mustGetString(flags, "branding.name"),
DisableExternal: mustGetBool(flags, "branding.disableExternal"), DisableExternal: mustGetBool(flags, "branding.disableExternal"),
Files: mustGetString(flags, "branding.files"), DisableUsedPercentage: mustGetBool(flags, "branding.DisableUsedPercentage"),
Files: mustGetString(flags, "branding.files"),
}, },
} }

View File

@ -55,6 +55,8 @@ you want to change. Other options will remain unchanged.`,
set.Branding.Color = mustGetString(flags, flag.Name) set.Branding.Color = mustGetString(flags, flag.Name)
case "branding.disableExternal": case "branding.disableExternal":
set.Branding.DisableExternal = mustGetBool(flags, flag.Name) set.Branding.DisableExternal = mustGetBool(flags, flag.Name)
case "branding.disableUsedPercentage":
set.Branding.DisableUsedPercentage = mustGetBool(flags, flag.Name)
case "branding.files": case "branding.files":
set.Branding.Files = mustGetString(flags, flag.Name) set.Branding.Files = mustGetString(flags, flag.Name)
} }

View File

@ -82,7 +82,9 @@
<div <div
class="credits" class="credits"
v-if="$router.currentRoute.path.includes('/files/')" v-if="
$router.currentRoute.path.includes('/files/') && !disableUsedPercentage
"
style="width: 90%; margin: 2em 2.5em 3em 2.5em" style="width: 90%; margin: 2em 2.5em 3em 2.5em"
> >
<progress-bar :val="usage.usedPercentage" size="small"></progress-bar> <progress-bar :val="usage.usedPercentage" size="small"></progress-bar>
@ -116,6 +118,7 @@ import {
version, version,
signup, signup,
disableExternal, disableExternal,
disableUsedPercentage,
noAuth, noAuth,
loginPage, loginPage,
} from "@/utils/constants"; } from "@/utils/constants";
@ -137,6 +140,7 @@ export default {
signup: () => signup, signup: () => signup,
version: () => version, version: () => version,
disableExternal: () => disableExternal, disableExternal: () => disableExternal,
disableUsedPercentage: () => disableUsedPercentage,
canLogout: () => !noAuth && loginPage, canLogout: () => !noAuth && loginPage,
}, },
asyncComputed: { asyncComputed: {
@ -146,6 +150,9 @@ export default {
? this.$route.path ? this.$route.path
: this.$route.path + "/"; : this.$route.path + "/";
let usageStats = { used: 0, total: 0, usedPercentage: 0 }; let usageStats = { used: 0, total: 0, usedPercentage: 0 };
if (this.disableUsedPercentage) {
return usageStats;
}
try { try {
let usage = await api.usage(path); let usage = await api.usage(path);
usageStats = { usageStats = {

View File

@ -178,6 +178,7 @@
"customStylesheet": "ستايل مخصص", "customStylesheet": "ستايل مخصص",
"defaultUserDescription": "This are the default settings for new users.", "defaultUserDescription": "This are the default settings for new users.",
"disableExternalLinks": "Disable external links (except documentation)", "disableExternalLinks": "Disable external links (except documentation)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "documentation", "documentation": "documentation",
"examples": "أمثلة", "examples": "أمثلة",
"executeOnShell": "Execute on shell", "executeOnShell": "Execute on shell",

View File

@ -187,6 +187,7 @@
"customStylesheet": "Individuelles Stylesheet", "customStylesheet": "Individuelles Stylesheet",
"defaultUserDescription": "Das sind die Standardeinstellung für Benutzer", "defaultUserDescription": "Das sind die Standardeinstellung für Benutzer",
"disableExternalLinks": "Externe Links deaktivieren (außer Dokumentation)", "disableExternalLinks": "Externe Links deaktivieren (außer Dokumentation)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "Dokumentation", "documentation": "Dokumentation",
"examples": "Beispiele", "examples": "Beispiele",
"executeOnShell": "In Shell ausführen", "executeOnShell": "In Shell ausführen",

View File

@ -190,6 +190,7 @@
"customStylesheet": "Custom Stylesheet", "customStylesheet": "Custom Stylesheet",
"defaultUserDescription": "This are the default settings for new users.", "defaultUserDescription": "This are the default settings for new users.",
"disableExternalLinks": "Disable external links (except documentation)", "disableExternalLinks": "Disable external links (except documentation)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "documentation", "documentation": "documentation",
"examples": "Examples", "examples": "Examples",
"executeOnShell": "Execute on shell", "executeOnShell": "Execute on shell",

View File

@ -190,6 +190,7 @@
"customStylesheet": "Modificar hoja de estilos", "customStylesheet": "Modificar hoja de estilos",
"defaultUserDescription": "Estas son las configuraciones por defecto para nuevos usuarios.", "defaultUserDescription": "Estas son las configuraciones por defecto para nuevos usuarios.",
"disableExternalLinks": "Deshabilitar enlaces externos (excepto documentación)", "disableExternalLinks": "Deshabilitar enlaces externos (excepto documentación)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "documentación", "documentation": "documentación",
"examples": "Ejemplos", "examples": "Ejemplos",
"executeOnShell": "Ejecutar en la shell", "executeOnShell": "Ejecutar en la shell",

View File

@ -187,6 +187,7 @@
"customStylesheet": "Feuille de style personnalisée", "customStylesheet": "Feuille de style personnalisée",
"defaultUserDescription": "Paramètres par défaut pour les nouveaux utilisateurs.", "defaultUserDescription": "Paramètres par défaut pour les nouveaux utilisateurs.",
"disableExternalLinks": "Désactiver les liens externes (sauf la documentation)", "disableExternalLinks": "Désactiver les liens externes (sauf la documentation)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "documentation", "documentation": "documentation",
"examples": "Exemples", "examples": "Exemples",
"executeOnShell": "Exécuter dans le shell", "executeOnShell": "Exécuter dans le shell",

View File

@ -178,6 +178,7 @@
"customStylesheet": "Custom Stylesheet", "customStylesheet": "Custom Stylesheet",
"defaultUserDescription": "Þetta eru sjálfgefnar stillingar fyrir nýja notendur.", "defaultUserDescription": "Þetta eru sjálfgefnar stillingar fyrir nýja notendur.",
"disableExternalLinks": "Sýna ytri-hlekki (fyrir utan leiðbeiningar)", "disableExternalLinks": "Sýna ytri-hlekki (fyrir utan leiðbeiningar)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "leiðbeiningar", "documentation": "leiðbeiningar",
"examples": "Dæmi", "examples": "Dæmi",
"executeOnShell": "Keyra í skel", "executeOnShell": "Keyra í skel",

View File

@ -178,6 +178,7 @@
"customStylesheet": "Foglio di stile personalizzato", "customStylesheet": "Foglio di stile personalizzato",
"defaultUserDescription": "Queste sono le impostazioni predefinite per i nuovi utenti.", "defaultUserDescription": "Queste sono le impostazioni predefinite per i nuovi utenti.",
"disableExternalLinks": "Disabilita link esterni (tranne per la documentazione)", "disableExternalLinks": "Disabilita link esterni (tranne per la documentazione)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "documentazione", "documentation": "documentazione",
"examples": "Esempi", "examples": "Esempi",
"executeOnShell": "Esegui nella shell", "executeOnShell": "Esegui nella shell",

View File

@ -178,6 +178,7 @@
"customStylesheet": "カスタムスタイルシ ート", "customStylesheet": "カスタムスタイルシ ート",
"defaultUserDescription": "This are the default settings for new users.", "defaultUserDescription": "This are the default settings for new users.",
"disableExternalLinks": "Disable external links (except documentation)", "disableExternalLinks": "Disable external links (except documentation)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "documentation", "documentation": "documentation",
"examples": "例", "examples": "例",
"executeOnShell": "Execute on shell", "executeOnShell": "Execute on shell",

View File

@ -178,6 +178,7 @@
"customStylesheet": "커스텀 스타일시트", "customStylesheet": "커스텀 스타일시트",
"defaultUserDescription": "아래 사항은 신규 사용자들에 대한 기본 설정입니다.", "defaultUserDescription": "아래 사항은 신규 사용자들에 대한 기본 설정입니다.",
"disableExternalLinks": "외부 링크 감추기", "disableExternalLinks": "외부 링크 감추기",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "문서", "documentation": "문서",
"examples": "예", "examples": "예",
"executeOnShell": "쉘에서 실행", "executeOnShell": "쉘에서 실행",

View File

@ -178,6 +178,7 @@
"customStylesheet": "Aangepast Stylesheet", "customStylesheet": "Aangepast Stylesheet",
"defaultUserDescription": "Dit zijn de standaardinstellingen voor nieuwe gebruikers.", "defaultUserDescription": "Dit zijn de standaardinstellingen voor nieuwe gebruikers.",
"disableExternalLinks": "Schakel externe links uit (behalve documentatie)", "disableExternalLinks": "Schakel externe links uit (behalve documentatie)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "Documentatie", "documentation": "Documentatie",
"examples": "Voorbeelden", "examples": "Voorbeelden",
"executeOnShell": "Uitvoeren in de shell", "executeOnShell": "Uitvoeren in de shell",

View File

@ -179,6 +179,7 @@
"customStylesheet": "Własny arkusz stylów", "customStylesheet": "Własny arkusz stylów",
"defaultUserDescription": "Oto domyślne ustawienia dla nowych użytkowników.", "defaultUserDescription": "Oto domyślne ustawienia dla nowych użytkowników.",
"disableExternalLinks": "Wyłącz linki zewnętrzne (z wyjątkiem dokumentacji)", "disableExternalLinks": "Wyłącz linki zewnętrzne (z wyjątkiem dokumentacji)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "dokumentacja", "documentation": "dokumentacja",
"examples": "Przykłady", "examples": "Przykłady",
"executeOnShell": "Wykonaj w powłoce", "executeOnShell": "Wykonaj w powłoce",
@ -258,4 +259,3 @@
"unit": "Jednostka czasu" "unit": "Jednostka czasu"
} }
} }

View File

@ -190,6 +190,7 @@
"customStylesheet": "Estilos personalizados", "customStylesheet": "Estilos personalizados",
"defaultUserDescription": "Estas são as configurações padrão para novos usuários.", "defaultUserDescription": "Estas são as configurações padrão para novos usuários.",
"disableExternalLinks": "Desabilitar links externos (exceto documentação)", "disableExternalLinks": "Desabilitar links externos (exceto documentação)",
"disableUsedDiskPercentage": "Desabilitar gráfico de porcentagem de disco usado",
"documentation": "documentação", "documentation": "documentação",
"examples": "Exemplos", "examples": "Exemplos",
"executeOnShell": "Executar no console", "executeOnShell": "Executar no console",

View File

@ -178,6 +178,7 @@
"customStylesheet": "Folha de estilos personalizada", "customStylesheet": "Folha de estilos personalizada",
"defaultUserDescription": "Estas são as configurações padrão para novos utilizadores.", "defaultUserDescription": "Estas são as configurações padrão para novos utilizadores.",
"disableExternalLinks": "Desativar links externos (exceto documentação)", "disableExternalLinks": "Desativar links externos (exceto documentação)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "documentação", "documentation": "documentação",
"examples": "Exemplos", "examples": "Exemplos",
"executeOnShell": "Executar na shell", "executeOnShell": "Executar na shell",

View File

@ -178,6 +178,7 @@
"customStylesheet": "CSS personalizat", "customStylesheet": "CSS personalizat",
"defaultUserDescription": "Acestea sunt setările implicite pentru noii utilizatori.", "defaultUserDescription": "Acestea sunt setările implicite pentru noii utilizatori.",
"disableExternalLinks": "Dezactivează linkurile externe (exceptând documentația)", "disableExternalLinks": "Dezactivează linkurile externe (exceptând documentația)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "documentație", "documentation": "documentație",
"examples": "Exemple", "examples": "Exemple",
"executeOnShell": "Execută in linia de comandă", "executeOnShell": "Execută in linia de comandă",

View File

@ -186,6 +186,7 @@
"customStylesheet": "Свой стиль", "customStylesheet": "Свой стиль",
"defaultUserDescription": "Это настройки по умолчанию для новых пользователей.", "defaultUserDescription": "Это настройки по умолчанию для новых пользователей.",
"disableExternalLinks": "Отключить внешние ссылки (кроме документации)", "disableExternalLinks": "Отключить внешние ссылки (кроме документации)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "документация", "documentation": "документация",
"examples": "Примеры", "examples": "Примеры",
"executeOnShell": "Выполнить в командной строке", "executeOnShell": "Выполнить в командной строке",

View File

@ -186,6 +186,7 @@
"customStylesheet": "Vlastný Stylesheet", "customStylesheet": "Vlastný Stylesheet",
"defaultUserDescription": "Toto sú predvolané nastavenia nového používateľa.", "defaultUserDescription": "Toto sú predvolané nastavenia nového používateľa.",
"disableExternalLinks": "Vypnúť externé odkazy (okrem dokumentácie)", "disableExternalLinks": "Vypnúť externé odkazy (okrem dokumentácie)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "dokumentácia", "documentation": "dokumentácia",
"examples": "Príklady", "examples": "Príklady",
"executeOnShell": "Vykonať cez shell", "executeOnShell": "Vykonať cez shell",

View File

@ -178,6 +178,7 @@
"customStylesheet": "Anpassad formatmall", "customStylesheet": "Anpassad formatmall",
"defaultUserDescription": "Detta är standard inställningar för användare.", "defaultUserDescription": "Detta är standard inställningar för användare.",
"disableExternalLinks": "Inaktivera externa länkar (förutom dokumentation)", "disableExternalLinks": "Inaktivera externa länkar (förutom dokumentation)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "dokumentation", "documentation": "dokumentation",
"examples": "Exempel", "examples": "Exempel",
"executeOnShell": "Exekvera på skal", "executeOnShell": "Exekvera på skal",

View File

@ -184,6 +184,7 @@
"customStylesheet": "Özel CSS", "customStylesheet": "Özel CSS",
"defaultUserDescription": "Bu, yeni kullanıcılar için varsayılan ayarlardır.", "defaultUserDescription": "Bu, yeni kullanıcılar için varsayılan ayarlardır.",
"disableExternalLinks": "Harici bağlantıları devre dışı bırakın (dökümantasyon hariç)", "disableExternalLinks": "Harici bağlantıları devre dışı bırakın (dökümantasyon hariç)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "dökümantasyon", "documentation": "dökümantasyon",
"examples": "Örnekler", "examples": "Örnekler",
"executeOnShell": "Komut satırında çalıştır", "executeOnShell": "Komut satırında çalıştır",

View File

@ -186,6 +186,7 @@
"customStylesheet": "Свій стиль", "customStylesheet": "Свій стиль",
"defaultUserDescription": "Це налаштування за замовчуванням для нових користувачів.", "defaultUserDescription": "Це налаштування за замовчуванням для нових користувачів.",
"disableExternalLinks": "Вимкнути зовнішні посилання (крім документації)", "disableExternalLinks": "Вимкнути зовнішні посилання (крім документації)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "документація", "documentation": "документація",
"examples": "Приклади", "examples": "Приклади",
"executeOnShell": "Виконати в командному рядку", "executeOnShell": "Виконати в командному рядку",

View File

@ -186,6 +186,7 @@
"customStylesheet": "自定义样式表CSS", "customStylesheet": "自定义样式表CSS",
"defaultUserDescription": "这些是新用户的默认设置。", "defaultUserDescription": "这些是新用户的默认设置。",
"disableExternalLinks": "禁止外部链接(帮助文档除外)", "disableExternalLinks": "禁止外部链接(帮助文档除外)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "帮助文档", "documentation": "帮助文档",
"examples": "例子", "examples": "例子",
"executeOnShell": "在 Shell 中执行", "executeOnShell": "在 Shell 中执行",

View File

@ -178,6 +178,7 @@
"customStylesheet": "自定義樣式表", "customStylesheet": "自定義樣式表",
"defaultUserDescription": "這些是新使用者的預設設定。", "defaultUserDescription": "這些是新使用者的預設設定。",
"disableExternalLinks": "禁止外部連結(幫助文件除外)", "disableExternalLinks": "禁止外部連結(幫助文件除外)",
"disableUsedDiskPercentage": "Disable used disk percentage graph",
"documentation": "幫助文件", "documentation": "幫助文件",
"examples": "範例", "examples": "範例",
"executeOnShell": "在Shell中執行", "executeOnShell": "在Shell中執行",

View File

@ -1,5 +1,6 @@
const name = window.FileBrowser.Name || "File Browser"; const name = window.FileBrowser.Name || "File Browser";
const disableExternal = window.FileBrowser.DisableExternal; const disableExternal = window.FileBrowser.DisableExternal;
const disableUsedPercentage = window.FileBrowser.DisableUsedPercentage;
const baseURL = window.FileBrowser.BaseURL; const baseURL = window.FileBrowser.BaseURL;
const staticURL = window.FileBrowser.StaticURL; const staticURL = window.FileBrowser.StaticURL;
const recaptcha = window.FileBrowser.ReCaptcha; const recaptcha = window.FileBrowser.ReCaptcha;
@ -19,6 +20,7 @@ const origin = window.location.origin;
export { export {
name, name,
disableExternal, disableExternal,
disableUsedPercentage,
baseURL, baseURL,
logoURL, logoURL,
recaptcha, recaptcha,

View File

@ -62,6 +62,15 @@
{{ $t("settings.disableExternalLinks") }} {{ $t("settings.disableExternalLinks") }}
</p> </p>
<p>
<input
type="checkbox"
v-model="settings.branding.disableUsedPercentage"
id="branding-links"
/>
{{ $t("settings.disableUsedDiskPercentage") }}
</p>
<p> <p>
<label for="theme">{{ $t("settings.themes.title") }}</label> <label for="theme">{{ $t("settings.themes.title") }}</label>
<themes <themes

View File

@ -27,22 +27,23 @@ func handleWithStaticData(w http.ResponseWriter, _ *http.Request, d *data, fSys
} }
data := map[string]interface{}{ data := map[string]interface{}{
"Name": d.settings.Branding.Name, "Name": d.settings.Branding.Name,
"DisableExternal": d.settings.Branding.DisableExternal, "DisableExternal": d.settings.Branding.DisableExternal,
"Color": d.settings.Branding.Color, "DisableUsedPercentage": d.settings.Branding.DisableUsedPercentage,
"BaseURL": d.server.BaseURL, "Color": d.settings.Branding.Color,
"Version": version.Version, "BaseURL": d.server.BaseURL,
"StaticURL": path.Join(d.server.BaseURL, "/static"), "Version": version.Version,
"Signup": d.settings.Signup, "StaticURL": path.Join(d.server.BaseURL, "/static"),
"NoAuth": d.settings.AuthMethod == auth.MethodNoAuth, "Signup": d.settings.Signup,
"AuthMethod": d.settings.AuthMethod, "NoAuth": d.settings.AuthMethod == auth.MethodNoAuth,
"LoginPage": auther.LoginPage(), "AuthMethod": d.settings.AuthMethod,
"CSS": false, "LoginPage": auther.LoginPage(),
"ReCaptcha": false, "CSS": false,
"Theme": d.settings.Branding.Theme, "ReCaptcha": false,
"EnableThumbs": d.server.EnableThumbnails, "Theme": d.settings.Branding.Theme,
"ResizePreview": d.server.ResizePreview, "EnableThumbs": d.server.EnableThumbnails,
"EnableExec": d.server.EnableExec, "ResizePreview": d.server.ResizePreview,
"EnableExec": d.server.EnableExec,
} }
if d.settings.Branding.Files != "" { if d.settings.Branding.Files != "" {

View File

@ -2,9 +2,10 @@ package settings
// Branding contains the branding settings of the app. // Branding contains the branding settings of the app.
type Branding struct { type Branding struct {
Name string `json:"name"` Name string `json:"name"`
DisableExternal bool `json:"disableExternal"` DisableExternal bool `json:"disableExternal"`
Files string `json:"files"` DisableUsedPercentage bool `json:"disableUsedPercentage"`
Theme string `json:"theme"` Files string `json:"files"`
Color string `json:"color"` Theme string `json:"theme"`
Color string `json:"color"`
} }