diff --git a/server/system.go b/server/system.go index b5942028..5726c91a 100644 --- a/server/system.go +++ b/server/system.go @@ -157,6 +157,21 @@ func (s *Server) registerSystemRoutes(g *echo.Group) { g.GET("/system/setting", func(c echo.Context) error { ctx := c.Request().Context() + userID, ok := c.Get(getUserIDContextKey()).(int) + if !ok { + return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session") + } + + user, err := s.Store.FindUser(ctx, &api.UserFind{ + ID: &userID, + }) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find user").SetInternal(err) + } + if user == nil || user.Role != api.Host { + return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized") + } + systemSettingList, err := s.Store.FindSystemSettingList(ctx, &api.SystemSettingFind{}) if err != nil { return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find system setting list").SetInternal(err) @@ -170,6 +185,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) { if !ok { return echo.NewHTTPError(http.StatusUnauthorized, "Missing user in session") } + user, err := s.Store.FindUser(ctx, &api.UserFind{ ID: &userID, }) @@ -179,6 +195,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) { if user == nil || user.Role != api.Host { return echo.NewHTTPError(http.StatusUnauthorized, "Unauthorized") } + if err := s.Store.Vacuum(ctx); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, "Failed to vacuum database").SetInternal(err) } diff --git a/server/version/version.go b/server/version/version.go index 2df704de..ae071390 100644 --- a/server/version/version.go +++ b/server/version/version.go @@ -9,10 +9,10 @@ import ( // Version is the service current released version. // Semantic versioning: https://semver.org/ -var Version = "0.10.3" +var Version = "0.11.0" // DevVersion is the service current development version. -var DevVersion = "0.10.3" +var DevVersion = "0.11.0" func GetCurrentVersion(mode string) string { if mode == "dev" || mode == "demo" { diff --git a/store/db/migration/prod/0.11/00__user_avatar.sql b/store/db/migration/prod/0.11/00__user_avatar.sql new file mode 100644 index 00000000..11c63e95 --- /dev/null +++ b/store/db/migration/prod/0.11/00__user_avatar.sql @@ -0,0 +1,4 @@ +ALTER TABLE + user +ADD + COLUMN avatar_url TEXT NOT NULL DEFAULT ''; \ No newline at end of file diff --git a/store/db/migration/prod/0.11/01__idp.sql b/store/db/migration/prod/0.11/01__idp.sql new file mode 100644 index 00000000..be5cf49f --- /dev/null +++ b/store/db/migration/prod/0.11/01__idp.sql @@ -0,0 +1,8 @@ +-- idp +CREATE TABLE idp ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + type TEXT NOT NULL, + identifier_filter TEXT NOT NULL DEFAULT '', + config TEXT NOT NULL DEFAULT '{}' +); \ No newline at end of file diff --git a/store/db/migration/prod/0.11/02__storage.sql b/store/db/migration/prod/0.11/02__storage.sql new file mode 100644 index 00000000..8dbf5637 --- /dev/null +++ b/store/db/migration/prod/0.11/02__storage.sql @@ -0,0 +1,7 @@ +-- storage +CREATE TABLE storage ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + type TEXT NOT NULL, + config TEXT NOT NULL DEFAULT '{}' +); \ No newline at end of file diff --git a/store/db/migration/prod/LATEST__SCHEMA.sql b/store/db/migration/prod/LATEST__SCHEMA.sql index fa10f070..b2448a1e 100644 --- a/store/db/migration/prod/LATEST__SCHEMA.sql +++ b/store/db/migration/prod/LATEST__SCHEMA.sql @@ -23,7 +23,8 @@ CREATE TABLE user ( email TEXT NOT NULL DEFAULT '', nickname TEXT NOT NULL DEFAULT '', password_hash TEXT NOT NULL, - open_id TEXT NOT NULL UNIQUE + open_id TEXT NOT NULL UNIQUE, + avatar_url TEXT NOT NULL DEFAULT '' ); -- user_setting @@ -102,4 +103,21 @@ CREATE TABLE activity ( type TEXT NOT NULL DEFAULT '', level TEXT NOT NULL CHECK (level IN ('INFO', 'WARN', 'ERROR')) DEFAULT 'INFO', payload TEXT NOT NULL DEFAULT '{}' +); + +-- storage +CREATE TABLE storage ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + type TEXT NOT NULL, + config TEXT NOT NULL DEFAULT '{}' +); + +-- idp +CREATE TABLE idp ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + type TEXT NOT NULL, + identifier_filter TEXT NOT NULL DEFAULT '', + config TEXT NOT NULL DEFAULT '{}' ); \ No newline at end of file diff --git a/web/src/components/CreateStorageServiceDialog.tsx b/web/src/components/CreateStorageServiceDialog.tsx index 6d078a55..92cd2b96 100644 --- a/web/src/components/CreateStorageServiceDialog.tsx +++ b/web/src/components/CreateStorageServiceDialog.tsx @@ -1,5 +1,4 @@ import { useEffect, useState } from "react"; -import { useTranslation } from "react-i18next"; import { Button, Input, Typography } from "@mui/joy"; import * as api from "../helpers/api"; import { generateDialog } from "./Dialog"; @@ -13,7 +12,6 @@ interface Props extends DialogProps { const CreateStorageServiceDialog: React.FC = (props: Props) => { const { destroy, storage, confirmCallback } = props; - const { t } = useTranslation(); const [basicInfo, setBasicInfo] = useState({ name: "", }); @@ -95,9 +93,18 @@ const CreateStorageServiceDialog: React.FC = (props: Props) => { return ( <> -
+

- {isCreating ? t("setting.storage-section.create-a-service") : t("setting.storage-section.update-a-service")} + {isCreating ? "Create storage" : "Update storage"} + + Learn more + +