From b2d294aa3ac0484a08d1be77a42fe9db18493c05 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Tue, 17 Dec 2024 15:02:36 +0100 Subject: [PATCH] remove external filebrowser --- docker-compose.yml | 14 --------- .../pages/filebrowser/Filebrowser.js | 30 ++++--------------- public/js/service/stats.js | 1 - types/config.go | 4 --- web/setup.go | 23 -------------- web/stats.go | 6 ++-- 6 files changed, 7 insertions(+), 71 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b55ef2ca..24f82a9a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,6 @@ services: SERVER_NAME: "dev-server" DEFAULT_THEME: "darkly" ENABLE_FEATURES: "shell,luashell,minetest_config,docker,modmanagement,signup,chat,minetest_web" - FILEBROWSER_URL: "http://filebrowser/" INSTALL_MTUI_MOD: "true" MINETEST_CONFIG: "/world/minetest.conf" GEOIP_API: "https://hosting.minetest.ch/api/geoip" @@ -40,21 +39,8 @@ services: - "/var/run/docker.sock:/var/run/docker.sock:ro" working_dir: /app command: ["go", "run", "."] - - filebrowser: - image: filebrowser/filebrowser:v2.31.2 - ports: - - 8081:80 - environment: - FB_DATABASE: /database/filebrowser.db - FB_BASEURL: /filebrowser - FB_NOAUTH: "true" - volumes: - - world_dir:/srv - - filebrowser_db:/database volumes: go_cache: {} go_dir: {} world_dir: {} - filebrowser_db: {} \ No newline at end of file diff --git a/public/js/components/pages/filebrowser/Filebrowser.js b/public/js/components/pages/filebrowser/Filebrowser.js index 176bda2a..458ae294 100644 --- a/public/js/components/pages/filebrowser/Filebrowser.js +++ b/public/js/components/pages/filebrowser/Filebrowser.js @@ -16,7 +16,6 @@ import format_size from "../../../util/format_size.js"; import format_time from "../../../util/format_time.js"; import { START, FILEBROWSER } from "../../Breadcrumb.js"; import { can_edit } from "./common.js"; -import { get_filebrowser_enabled } from "../../../service/stats.js"; export default { props: ["pathMatch"], @@ -26,7 +25,7 @@ export default { data: function() { return { result: null, - mkfile_name: "", + mkdir_name: "", move_name: "", move_target: "", upload_archive_busy: false, @@ -41,14 +40,9 @@ export default { get_targz_url, get_download_url, mkdir: function() { - mkdir(this.result.dir + "/" + this.mkfile_name) + mkdir(this.result.dir + "/" + this.mkdir_name) .then(() => this.browse_dir()) - .then(() => this.mkfile_name = ""); - }, - mkfile: function() { - upload(this.result.dir + "/" + this.mkfile_name, "") - .then(() => this.browse_dir()) - .then(() => this.mkfile_name = ""); + .then(() => this.mkdir_name = ""); }, upload: function() { const files = Array.from(this.$refs.input_upload.files); @@ -115,7 +109,6 @@ export default { }); }, can_edit: can_edit, - filebrowser_enabled: get_filebrowser_enabled, is_json_profile: function(filename) { return filename.match(/^profile-.*.json$/); }, @@ -168,28 +161,15 @@ export default { }, template: /*html*/` -
-
-
- - Note: To upload larger files use the dedicated filebrowser interface and enable the maintenance mode for database files -
-
-
- - -
diff --git a/public/js/service/stats.js b/public/js/service/stats.js index 302b12e6..fadde270 100644 --- a/public/js/service/stats.js +++ b/public/js/service/stats.js @@ -19,4 +19,3 @@ export const stop_polling = () => clearInterval(handle); export const get_player_count = () => store.player_count; export const get_players = () => store.players; export const get_maintenance = () => store.maintenance; -export const get_filebrowser_enabled = () => store.filebrowser_enabled; \ No newline at end of file diff --git a/types/config.go b/types/config.go index 3bb4a62b..078c73ec 100644 --- a/types/config.go +++ b/types/config.go @@ -18,8 +18,6 @@ type Config struct { Webdev bool Servername string EnabledFeatures []string - FilebrowserURL string - FilebrowserProxyPath string InstallMtuiMod bool AutoReconfigureMods bool LogStreamURL string @@ -50,8 +48,6 @@ func NewConfig(world_dir string) *Config { Webdev: os.Getenv("WEBDEV") == "true", Servername: os.Getenv("SERVER_NAME"), EnabledFeatures: strings.Split(os.Getenv("ENABLE_FEATURES"), ","), - FilebrowserURL: os.Getenv("FILEBROWSER_URL"), - FilebrowserProxyPath: os.Getenv("FILEBROWSER_PROXY_PATH"), InstallMtuiMod: os.Getenv("INSTALL_MTUI_MOD") == "true", AutoReconfigureMods: os.Getenv("AUTORECONFIGURE_MODS") == "true", LogStreamURL: os.Getenv("LOG_STREAM_URL"), diff --git a/web/setup.go b/web/setup.go index f3e59a41..601c5e9f 100644 --- a/web/setup.go +++ b/web/setup.go @@ -1,13 +1,10 @@ package web import ( - "fmt" "mtui/app" "mtui/public" "mtui/types" "net/http" - "net/http/httputil" - "net/url" "os" "time" @@ -31,26 +28,6 @@ func Setup(a *app.App) error { return err } - if a.Config.FilebrowserURL != "" { - // enable filebrowser access with "server" priv - remote, err := url.Parse(a.Config.FilebrowserURL) - if err != nil { - return err - } - - handler := func(p *httputil.ReverseProxy) func(http.ResponseWriter, *http.Request) { - return api.SecurePriv("server", func(w http.ResponseWriter, r *http.Request, c *types.Claims) { - r.Host = remote.Host - // prepend proxy path - r.URL.Path = fmt.Sprintf("%s%s", a.Config.FilebrowserProxyPath, r.URL.Path) - p.ServeHTTP(w, r) - }) - } - - proxy := httputil.NewSingleHostReverseProxy(remote) - r.PathPrefix("/filebrowser/").HandlerFunc(handler(proxy)) - } - // always on api r.HandleFunc("/api/maintenance", api.SecurePriv(types.PRIV_SERVER, api.GetMaintenanceMode)).Methods(http.MethodGet) r.HandleFunc("/api/maintenance", api.SecurePriv(types.PRIV_SERVER, api.EnableMaintenanceMode)).Methods(http.MethodPut) diff --git a/web/stats.go b/web/stats.go index 2b40c830..7c6eae3a 100644 --- a/web/stats.go +++ b/web/stats.go @@ -30,15 +30,13 @@ func (a *Api) StatsEventListener(c chan *bridge.CommandResponse) { type StatResponse struct { *command.StatsCommand - Maintenance bool `json:"maintenance"` - FilebrowserEnabled bool `json:"filebrowser_enabled"` + Maintenance bool `json:"maintenance"` } func (a *Api) GetStats(w http.ResponseWriter, r *http.Request, claims *types.Claims) { sc := &StatResponse{ - StatsCommand: &command.StatsCommand{}, - FilebrowserEnabled: a.app.Config.FilebrowserURL != "", + StatsCommand: &command.StatsCommand{}, } sc.Maintenance = a.app.MaintenanceMode.Load()