From d4a97b193c7b68d52d40b034f33a5662f8745f69 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 23 Sep 2024 22:07:49 +0200 Subject: [PATCH 1/2] add calc --- cmd/server/server.go | 3 +- config.ini | 6 +- config/config.go | 25 ++-- frontend/js/App.vue | 2 +- frontend/js/router/index.js | 12 +- frontend/js/views/CalcView.vue | 12 +- frontend/scss/main.scss | 9 ++ web/controller/collabora/controller.go | 134 ++++++++++++++++++++ web/router/router.go | 2 + web/view/template/collabora/iframe.templ | 15 +++ web/view/template/collabora/iframe_templ.go | 62 +++++++++ 11 files changed, 255 insertions(+), 27 deletions(-) create mode 100644 web/controller/collabora/controller.go create mode 100644 web/view/template/collabora/iframe.templ create mode 100644 web/view/template/collabora/iframe_templ.go diff --git a/cmd/server/server.go b/cmd/server/server.go index a7fa942..4c8853c 100644 --- a/cmd/server/server.go +++ b/cmd/server/server.go @@ -13,6 +13,7 @@ import ( "github.com/gorilla/sessions" "github.com/labstack/echo-contrib/session" "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" "gitnet.fr/deblan/budget/config" "gitnet.fr/deblan/budget/database/manager" "gitnet.fr/deblan/budget/database/model" @@ -49,7 +50,7 @@ func main() { assetHandler := http.FileServer(rice.MustFindBox("../../web/view/static").HTTPBox()) e.GET("/static/*", echo.WrapHandler(http.StripPrefix("/static/", assetHandler))) - + e.Use(middleware.Logger()) router.RegisterControllers(e) if err := e.Start(fmt.Sprintf("%s:%d", conf.Server.Address, conf.Server.Port)); err != nil && !errors.Is(err, http.ErrServerClosed) { diff --git a/config.ini b/config.ini index a18ab45..db3fe35 100644 --- a/config.ini +++ b/config.ini @@ -1,12 +1,14 @@ [server] port = 1324 address = "0.0.0.0" +base_url = "http://10.0.0.2:1324" [security] secret = "e93865c991358ff7a14f9781fa33ba4f28c33bb8d1cf3490ce6fd68521513536" -[calc] -url = "https://deblan.cloud/index.php/apps/files/files/1402577?dir=%2FAdministratif%2FProjet+de+construction&openfile=true" +[collabora] +url = "https://loolwsd.deblan.org" +budget_file = "_data/test.ods" [log] ; level = "debug" diff --git a/config/config.go b/config/config.go index 53f1787..28c3a38 100644 --- a/config/config.go +++ b/config/config.go @@ -1,6 +1,7 @@ package config import ( + "fmt" "log" "gopkg.in/ini.v1" @@ -19,20 +20,26 @@ type security struct { } type server struct { + BaseUrl string Address string Port int } -type calc struct { - Url string +type collabora struct { + Url string + BudgetFile string +} + +func (c *collabora) HostingDiscoveryUrl() string { + return fmt.Sprintf("%s/hosting/discovery", c.Url) } type Config struct { - Database database - Log logging - Security security - Server server - Calc calc + Database database + Log logging + Security security + Server server + Collabora collabora } var config *Config @@ -57,5 +64,7 @@ func (c *Config) Load(file string) { config.Security.Secret = cfg.Section("security").Key("secret").String() config.Server.Address = cfg.Section("server").Key("address").String() config.Server.Port, _ = cfg.Section("server").Key("port").Int() - config.Calc.Url = cfg.Section("calc").Key("url").String() + config.Server.BaseUrl = cfg.Section("server").Key("base_url").String() + config.Collabora.Url = cfg.Section("collabora").Key("url").String() + config.Collabora.BudgetFile = cfg.Section("collabora").Key("budget_file").String() } diff --git a/frontend/js/App.vue b/frontend/js/App.vue index cd597a2..10331b4 100644 --- a/frontend/js/App.vue +++ b/frontend/js/App.vue @@ -13,7 +13,7 @@ import { BNavItem } from 'bootstrap-vue-next'