feat: Added disableUsedPercentage feature

This commit is contained in:
Gabriel Alencar 2022-09-20 19:30:14 -03:00
parent c1e6d5869a
commit f3aa885445
10 changed files with 47 additions and 25 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,7 @@
<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 +116,7 @@ import {
version, version,
signup, signup,
disableExternal, disableExternal,
disableUsedPercentage,
noAuth, noAuth,
loginPage, loginPage,
} from "@/utils/constants"; } from "@/utils/constants";
@ -137,6 +138,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: {

View File

@ -188,6 +188,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

@ -176,6 +176,7 @@
"customStylesheet": "Estilos personalizados", "customStylesheet": "Estilos personalizados",
"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": "Desabilitar gráfico de porcentagem de disco usado",
"documentation": "documentação", "documentation": "documentação",
"examples": "Exemplos", "examples": "Exemplos",
"executeOnShell": "Execute on shell", "executeOnShell": "Execute on 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"`
} }