Unverified Commit 238f8969 authored by boojack's avatar boojack Committed by GitHub

feat: add system service (#2083)

* feat: add system service

* chore: update
parent 270a5299
...@@ -82,10 +82,6 @@ func (s *APIV1Service) registerSystemRoutes(g *echo.Group) { ...@@ -82,10 +82,6 @@ func (s *APIV1Service) registerSystemRoutes(g *echo.Group) {
} }
if hostUser != nil { if hostUser != nil {
systemStatus.Host = &User{ID: hostUser.ID} systemStatus.Host = &User{ID: hostUser.ID}
// data desensitize
systemStatus.Host.OpenID = ""
systemStatus.Host.Email = ""
systemStatus.Host.AvatarURL = ""
} }
systemSettingList, err := s.Store.ListSystemSettings(ctx, &store.FindSystemSetting{}) systemSettingList, err := s.Store.ListSystemSettings(ctx, &store.FindSystemSetting{})
......
...@@ -28,8 +28,9 @@ const ( ...@@ -28,8 +28,9 @@ const (
) )
var authenticationAllowlistMethods = map[string]bool{ var authenticationAllowlistMethods = map[string]bool{
"/memos.api.v2.UserService/GetUser": true, "/memos.api.v2.SystemService/GetSystemInfo": true,
"/memos.api.v2.MemoService/ListMemos": true, "/memos.api.v2.UserService/GetUser": true,
"/memos.api.v2.MemoService/ListMemos": true,
} }
// IsAuthenticationAllowed returns whether the method is exempted from authentication. // IsAuthenticationAllowed returns whether the method is exempted from authentication.
......
package v2
import (
"context"
"os"
apiv2pb "github.com/usememos/memos/proto/gen/api/v2"
"github.com/usememos/memos/server/profile"
"github.com/usememos/memos/store"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
type SystemService struct {
apiv2pb.UnimplementedSystemServiceServer
Profile *profile.Profile
Store *store.Store
}
// NewSystemService creates a new SystemService.
func NewSystemService(profile *profile.Profile, store *store.Store) *SystemService {
return &SystemService{
Profile: profile,
Store: store,
}
}
func (s *SystemService) GetSystemInfo(ctx context.Context, _ *apiv2pb.GetSystemInfoRequest) (*apiv2pb.GetSystemInfoResponse, error) {
defaultSystemInfo := &apiv2pb.SystemInfo{}
// Get the database size if the user is a host.
userIDPtr := ctx.Value(UserIDContextKey)
if userIDPtr != nil {
userID := userIDPtr.(int32)
user, err := s.Store.GetUser(ctx, &store.FindUser{
ID: &userID,
})
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get user: %v", err)
}
if user != nil && user.Role == store.RoleHost {
fi, err := os.Stat(s.Profile.DSN)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get file info: %v", err)
}
defaultSystemInfo.DbSize = fi.Size()
}
}
response := &apiv2pb.GetSystemInfoResponse{
SystemInfo: defaultSystemInfo,
}
return response, nil
}
...@@ -29,6 +29,7 @@ func NewAPIV2Service(secret string, profile *profile.Profile, store *store.Store ...@@ -29,6 +29,7 @@ func NewAPIV2Service(secret string, profile *profile.Profile, store *store.Store
authProvider.AuthenticationInterceptor, authProvider.AuthenticationInterceptor,
), ),
) )
apiv2pb.RegisterSystemServiceServer(grpcServer, NewSystemService(profile, store))
apiv2pb.RegisterUserServiceServer(grpcServer, NewUserService(store)) apiv2pb.RegisterUserServiceServer(grpcServer, NewUserService(store))
apiv2pb.RegisterMemoServiceServer(grpcServer, NewMemoService(store)) apiv2pb.RegisterMemoServiceServer(grpcServer, NewMemoService(store))
apiv2pb.RegisterTagServiceServer(grpcServer, NewTagService(store)) apiv2pb.RegisterTagServiceServer(grpcServer, NewTagService(store))
...@@ -60,6 +61,9 @@ func (s *APIV2Service) RegisterGateway(ctx context.Context, e *echo.Echo) error ...@@ -60,6 +61,9 @@ func (s *APIV2Service) RegisterGateway(ctx context.Context, e *echo.Echo) error
} }
gwMux := grpcRuntime.NewServeMux() gwMux := grpcRuntime.NewServeMux()
if err := apiv2pb.RegisterSystemServiceHandler(context.Background(), gwMux, conn); err != nil {
return err
}
if err := apiv2pb.RegisterUserServiceHandler(context.Background(), gwMux, conn); err != nil { if err := apiv2pb.RegisterUserServiceHandler(context.Background(), gwMux, conn); err != nil {
return err return err
} }
......
syntax = "proto3";
package memos.api.v2;
import "google/api/annotations.proto";
option go_package = "gen/api/v2";
service SystemService {
rpc GetSystemInfo(GetSystemInfoRequest) returns (GetSystemInfoResponse) {
option (google.api.http) = {get: "/api/v2/system/info"};
}
}
message SystemInfo {
string version = 1;
string mode = 2;
bool allow_registration = 3;
bool disable_password_login = 4;
string additional_script = 5;
string additional_style = 6;
int64 db_size = 7;
}
message GetSystemInfoRequest {}
message GetSystemInfoResponse {
SystemInfo system_info = 1;
}
...@@ -17,6 +17,13 @@ ...@@ -17,6 +17,13 @@
- [MemoService](#memos-api-v2-MemoService) - [MemoService](#memos-api-v2-MemoService)
- [api/v2/system_service.proto](#api_v2_system_service-proto)
- [GetSystemInfoRequest](#memos-api-v2-GetSystemInfoRequest)
- [GetSystemInfoResponse](#memos-api-v2-GetSystemInfoResponse)
- [SystemInfo](#memos-api-v2-SystemInfo)
- [SystemService](#memos-api-v2-SystemService)
- [api/v2/tag_service.proto](#api_v2_tag_service-proto) - [api/v2/tag_service.proto](#api_v2_tag_service-proto)
- [ListTagsRequest](#memos-api-v2-ListTagsRequest) - [ListTagsRequest](#memos-api-v2-ListTagsRequest)
- [ListTagsResponse](#memos-api-v2-ListTagsResponse) - [ListTagsResponse](#memos-api-v2-ListTagsResponse)
...@@ -195,6 +202,78 @@ ...@@ -195,6 +202,78 @@
<a name="api_v2_system_service-proto"></a>
<p align="right"><a href="#top">Top</a></p>
## api/v2/system_service.proto
<a name="memos-api-v2-GetSystemInfoRequest"></a>
### GetSystemInfoRequest
<a name="memos-api-v2-GetSystemInfoResponse"></a>
### GetSystemInfoResponse
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| system_info | [SystemInfo](#memos-api-v2-SystemInfo) | | |
<a name="memos-api-v2-SystemInfo"></a>
### SystemInfo
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| version | [string](#string) | | |
| mode | [string](#string) | | |
| allow_registration | [bool](#bool) | | |
| disable_password_login | [bool](#bool) | | |
| additional_script | [string](#string) | | |
| additional_style | [string](#string) | | |
| db_size | [int64](#int64) | | |
<a name="memos-api-v2-SystemService"></a>
### SystemService
| Method Name | Request Type | Response Type | Description |
| ----------- | ------------ | ------------- | ------------|
| GetSystemInfo | [GetSystemInfoRequest](#memos-api-v2-GetSystemInfoRequest) | [GetSystemInfoResponse](#memos-api-v2-GetSystemInfoResponse) | |
<a name="api_v2_tag_service-proto"></a> <a name="api_v2_tag_service-proto"></a>
<p align="right"><a href="#top">Top</a></p> <p align="right"><a href="#top">Top</a></p>
......
This diff is collapsed.
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: api/v2/system_service.proto
/*
Package apiv2 is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package apiv2
import (
"context"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = metadata.Join
func request_SystemService_GetSystemInfo_0(ctx context.Context, marshaler runtime.Marshaler, client SystemServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetSystemInfoRequest
var metadata runtime.ServerMetadata
msg, err := client.GetSystemInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_SystemService_GetSystemInfo_0(ctx context.Context, marshaler runtime.Marshaler, server SystemServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetSystemInfoRequest
var metadata runtime.ServerMetadata
msg, err := server.GetSystemInfo(ctx, &protoReq)
return msg, metadata, err
}
// RegisterSystemServiceHandlerServer registers the http handlers for service SystemService to "mux".
// UnaryRPC :call SystemServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterSystemServiceHandlerFromEndpoint instead.
func RegisterSystemServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server SystemServiceServer) error {
mux.Handle("GET", pattern_SystemService_GetSystemInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v2.SystemService/GetSystemInfo", runtime.WithHTTPPathPattern("/api/v2/system/info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_SystemService_GetSystemInfo_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_SystemService_GetSystemInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterSystemServiceHandlerFromEndpoint is same as RegisterSystemServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterSystemServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.DialContext(ctx, endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterSystemServiceHandler(ctx, mux, conn)
}
// RegisterSystemServiceHandler registers the http handlers for service SystemService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterSystemServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterSystemServiceHandlerClient(ctx, mux, NewSystemServiceClient(conn))
}
// RegisterSystemServiceHandlerClient registers the http handlers for service SystemService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "SystemServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "SystemServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "SystemServiceClient" to call the correct interceptors.
func RegisterSystemServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client SystemServiceClient) error {
mux.Handle("GET", pattern_SystemService_GetSystemInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/memos.api.v2.SystemService/GetSystemInfo", runtime.WithHTTPPathPattern("/api/v2/system/info"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_SystemService_GetSystemInfo_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_SystemService_GetSystemInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_SystemService_GetSystemInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v2", "system", "info"}, ""))
)
var (
forward_SystemService_GetSystemInfo_0 = runtime.ForwardResponseMessage
)
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc (unknown)
// source: api/v2/system_service.proto
package apiv2
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
SystemService_GetSystemInfo_FullMethodName = "/memos.api.v2.SystemService/GetSystemInfo"
)
// SystemServiceClient is the client API for SystemService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type SystemServiceClient interface {
GetSystemInfo(ctx context.Context, in *GetSystemInfoRequest, opts ...grpc.CallOption) (*GetSystemInfoResponse, error)
}
type systemServiceClient struct {
cc grpc.ClientConnInterface
}
func NewSystemServiceClient(cc grpc.ClientConnInterface) SystemServiceClient {
return &systemServiceClient{cc}
}
func (c *systemServiceClient) GetSystemInfo(ctx context.Context, in *GetSystemInfoRequest, opts ...grpc.CallOption) (*GetSystemInfoResponse, error) {
out := new(GetSystemInfoResponse)
err := c.cc.Invoke(ctx, SystemService_GetSystemInfo_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// SystemServiceServer is the server API for SystemService service.
// All implementations must embed UnimplementedSystemServiceServer
// for forward compatibility
type SystemServiceServer interface {
GetSystemInfo(context.Context, *GetSystemInfoRequest) (*GetSystemInfoResponse, error)
mustEmbedUnimplementedSystemServiceServer()
}
// UnimplementedSystemServiceServer must be embedded to have forward compatible implementations.
type UnimplementedSystemServiceServer struct {
}
func (UnimplementedSystemServiceServer) GetSystemInfo(context.Context, *GetSystemInfoRequest) (*GetSystemInfoResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSystemInfo not implemented")
}
func (UnimplementedSystemServiceServer) mustEmbedUnimplementedSystemServiceServer() {}
// UnsafeSystemServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to SystemServiceServer will
// result in compilation errors.
type UnsafeSystemServiceServer interface {
mustEmbedUnimplementedSystemServiceServer()
}
func RegisterSystemServiceServer(s grpc.ServiceRegistrar, srv SystemServiceServer) {
s.RegisterService(&SystemService_ServiceDesc, srv)
}
func _SystemService_GetSystemInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetSystemInfoRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(SystemServiceServer).GetSystemInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: SystemService_GetSystemInfo_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(SystemServiceServer).GetSystemInfo(ctx, req.(*GetSystemInfoRequest))
}
return interceptor(ctx, in, info, handler)
}
// SystemService_ServiceDesc is the grpc.ServiceDesc for SystemService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var SystemService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "memos.api.v2.SystemService",
HandlerType: (*SystemServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetSystemInfo",
Handler: _SystemService_GetSystemInfo_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "api/v2/system_service.proto",
}
{
"printWidth": 140,
"useTabs": false,
"semi": true,
"singleQuote": false,
"plugins": ["@ianvs/prettier-plugin-sort-imports"],
"importOrder": ["<BUILTIN_MODULES>", "<THIRD_PARTY_MODULES>", "^@/(.*)$", "^[./]", ".less$"]
}
module.exports = {
printWidth: 140,
useTabs: false,
semi: true,
singleQuote: false,
plugins: [require.resolve("@trivago/prettier-plugin-sort-imports")],
importOrder: ["<BUILTIN_MODULES>", "<THIRD_PARTY_MODULES>", "^@/((?!less).+)", "^[./]", "^(.+).less"],
};
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
"zustand": "^4.3.6" "zustand": "^4.3.6"
}, },
"devDependencies": { "devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "^4.1.0", "@trivago/prettier-plugin-sort-imports": "^3.2.0",
"@types/lodash-es": "^4.17.5", "@types/lodash-es": "^4.17.5",
"@types/node": "^18.0.3", "@types/node": "^18.0.3",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
"eslint-plugin-react": "^7.27.1", "eslint-plugin-react": "^7.27.1",
"less": "^4.1.1", "less": "^4.1.1",
"postcss": "^8.4.21", "postcss": "^8.4.21",
"prettier": "2.5.1", "prettier": "2.6.2",
"terser": "^5.16.1", "terser": "^5.16.1",
"typescript": "^5.0.4", "typescript": "^5.0.4",
"vite": "^4.2.1" "vite": "^4.2.1"
......
This diff is collapsed.
import { ImageList, ImageListItem, useMediaQuery } from "@mui/material"; import { ImageList, ImageListItem, useMediaQuery } from "@mui/material";
import { absolutifyLink } from "@/helpers/utils"; import { absolutifyLink } from "@/helpers/utils";
import { getResourceType, getResourceUrl } from "@/utils/resource"; import { getResourceType, getResourceUrl } from "@/utils/resource";
import SquareDiv from "./kit/SquareDiv";
import MemoResource from "./MemoResource"; import MemoResource from "./MemoResource";
import showPreviewImageDialog from "./PreviewImageDialog"; import showPreviewImageDialog from "./PreviewImageDialog";
import SquareDiv from "./kit/SquareDiv";
import "@/less/memo-resources.less"; import "@/less/memo-resources.less";
interface Props { interface Props {
......
import React from "react"; import React from "react";
import { getResourceType, getResourceUrl } from "@/utils/resource"; import { getResourceType, getResourceUrl } from "@/utils/resource";
import Icon from "./Icon"; import Icon from "./Icon";
import SquareDiv from "./kit/SquareDiv";
import showPreviewImageDialog from "./PreviewImageDialog"; import showPreviewImageDialog from "./PreviewImageDialog";
import SquareDiv from "./kit/SquareDiv";
import "@/less/resource-cover.less"; import "@/less/resource-cover.less";
interface ResourceCoverProps { interface ResourceCoverProps {
......
import classNames from "classnames"; import classNames from "classnames";
import { getResourceUrl } from "@/utils/resource"; import { getResourceUrl } from "@/utils/resource";
import Icon from "./Icon"; import Icon from "./Icon";
import SquareDiv from "./kit/SquareDiv";
import showPreviewImageDialog from "./PreviewImageDialog"; import showPreviewImageDialog from "./PreviewImageDialog";
import SquareDiv from "./kit/SquareDiv";
interface Props { interface Props {
className: string; className: string;
......
...@@ -7,8 +7,8 @@ import { getResourceType, getResourceUrl } from "@/utils/resource"; ...@@ -7,8 +7,8 @@ import { getResourceType, getResourceUrl } from "@/utils/resource";
import showChangeResourceFilenameDialog from "./ChangeResourceFilenameDialog"; import showChangeResourceFilenameDialog from "./ChangeResourceFilenameDialog";
import { showCommonDialog } from "./Dialog/CommonDialog"; import { showCommonDialog } from "./Dialog/CommonDialog";
import Icon from "./Icon"; import Icon from "./Icon";
import Dropdown from "./kit/Dropdown";
import showPreviewImageDialog from "./PreviewImageDialog"; import showPreviewImageDialog from "./PreviewImageDialog";
import Dropdown from "./kit/Dropdown";
interface Props { interface Props {
resource: Resource; resource: Resource;
......
...@@ -6,8 +6,8 @@ import { useGlobalStore } from "@/store/module"; ...@@ -6,8 +6,8 @@ import { useGlobalStore } from "@/store/module";
import { useTranslate } from "@/utils/i18n"; import { useTranslate } from "@/utils/i18n";
import showCreateIdentityProviderDialog from "../CreateIdentityProviderDialog"; import showCreateIdentityProviderDialog from "../CreateIdentityProviderDialog";
import { showCommonDialog } from "../Dialog/CommonDialog"; import { showCommonDialog } from "../Dialog/CommonDialog";
import Dropdown from "../kit/Dropdown";
import LearnMore from "../LearnMore"; import LearnMore from "../LearnMore";
import Dropdown from "../kit/Dropdown";
interface State { interface State {
disablePasswordLogin: boolean; disablePasswordLogin: boolean;
......
...@@ -6,9 +6,9 @@ import { useGlobalStore } from "@/store/module"; ...@@ -6,9 +6,9 @@ import { useGlobalStore } from "@/store/module";
import { useTranslate } from "@/utils/i18n"; import { useTranslate } from "@/utils/i18n";
import showCreateStorageServiceDialog from "../CreateStorageServiceDialog"; import showCreateStorageServiceDialog from "../CreateStorageServiceDialog";
import { showCommonDialog } from "../Dialog/CommonDialog"; import { showCommonDialog } from "../Dialog/CommonDialog";
import Dropdown from "../kit/Dropdown";
import LearnMore from "../LearnMore"; import LearnMore from "../LearnMore";
import showUpdateLocalStorageDialog from "../UpdateLocalStorageDialog"; import showUpdateLocalStorageDialog from "../UpdateLocalStorageDialog";
import Dropdown from "../kit/Dropdown";
const StorageSection = () => { const StorageSection = () => {
const t = useTranslate(); const t = useTranslate();
......
...@@ -5,12 +5,12 @@ import * as api from "@/helpers/api"; ...@@ -5,12 +5,12 @@ import * as api from "@/helpers/api";
import { formatBytes } from "@/helpers/utils"; import { formatBytes } from "@/helpers/utils";
import { useGlobalStore } from "@/store/module"; import { useGlobalStore } from "@/store/module";
import { useTranslate } from "@/utils/i18n"; import { useTranslate } from "@/utils/i18n";
import { showCommonDialog } from "../Dialog/CommonDialog";
import showDisablePasswordLoginDialog from "../DisablePasswordLoginDialog";
import Icon from "../Icon"; import Icon from "../Icon";
import LearnMore from "../LearnMore"; import LearnMore from "../LearnMore";
import showUpdateCustomizedProfileDialog from "../UpdateCustomizedProfileDialog"; import showUpdateCustomizedProfileDialog from "../UpdateCustomizedProfileDialog";
import "@/less/settings/system-section.less"; import "@/less/settings/system-section.less";
import { showCommonDialog } from "../Dialog/CommonDialog";
import showDisablePasswordLoginDialog from "../DisablePasswordLoginDialog";
interface State { interface State {
dbSize: number; dbSize: number;
......
...@@ -4,8 +4,8 @@ import { useGlobalStore, useUserStore } from "@/store/module"; ...@@ -4,8 +4,8 @@ import { useGlobalStore, useUserStore } from "@/store/module";
import { useTranslate } from "@/utils/i18n"; import { useTranslate } from "@/utils/i18n";
import showAboutSiteDialog from "./AboutSiteDialog"; import showAboutSiteDialog from "./AboutSiteDialog";
import Icon from "./Icon"; import Icon from "./Icon";
import Dropdown from "./kit/Dropdown";
import UserAvatar from "./UserAvatar"; import UserAvatar from "./UserAvatar";
import Dropdown from "./kit/Dropdown";
const UserBanner = () => { const UserBanner = () => {
const t = useTranslate(); const t = useTranslate();
......
...@@ -2,13 +2,13 @@ import { CssVarsProvider } from "@mui/joy"; ...@@ -2,13 +2,13 @@ import { CssVarsProvider } from "@mui/joy";
import { createRoot } from "react-dom/client"; import { createRoot } from "react-dom/client";
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import App from "./App"; import App from "./App";
import store from "./store"; import "./css/global.css";
import theme from "./theme"; import "./css/tailwind.css";
import "./helpers/polyfill"; import "./helpers/polyfill";
import "./i18n"; import "./i18n";
import "./less/code-highlight.less"; import "./less/code-highlight.less";
import "./css/global.css"; import store from "./store";
import "./css/tailwind.css"; import theme from "./theme";
const container = document.getElementById("root"); const container = document.getElementById("root");
const root = createRoot(container as HTMLElement); const root = createRoot(container as HTMLElement);
......
...@@ -5,9 +5,9 @@ import toast from "react-hot-toast"; ...@@ -5,9 +5,9 @@ import toast from "react-hot-toast";
import DailyMemo from "@/components/DailyMemo"; import DailyMemo from "@/components/DailyMemo";
import Empty from "@/components/Empty"; import Empty from "@/components/Empty";
import Icon from "@/components/Icon"; import Icon from "@/components/Icon";
import DatePicker from "@/components/kit/DatePicker";
import MobileHeader from "@/components/MobileHeader"; import MobileHeader from "@/components/MobileHeader";
import showPreviewImageDialog from "@/components/PreviewImageDialog"; import showPreviewImageDialog from "@/components/PreviewImageDialog";
import DatePicker from "@/components/kit/DatePicker";
import { DAILY_TIMESTAMP, DEFAULT_MEMO_LIMIT } from "@/helpers/consts"; import { DAILY_TIMESTAMP, DEFAULT_MEMO_LIMIT } from "@/helpers/consts";
import { convertToMillis, getDateStampByDate, getNormalizedDateString, getTimeStampByDate, isFutureDate } from "@/helpers/datetime"; import { convertToMillis, getDateStampByDate, getNormalizedDateString, getTimeStampByDate, isFutureDate } from "@/helpers/datetime";
import useToggle from "@/hooks/useToggle"; import useToggle from "@/hooks/useToggle";
......
...@@ -5,11 +5,11 @@ import showCreateResourceDialog from "@/components/CreateResourceDialog"; ...@@ -5,11 +5,11 @@ import showCreateResourceDialog from "@/components/CreateResourceDialog";
import { showCommonDialog } from "@/components/Dialog/CommonDialog"; import { showCommonDialog } from "@/components/Dialog/CommonDialog";
import Empty from "@/components/Empty"; import Empty from "@/components/Empty";
import Icon from "@/components/Icon"; import Icon from "@/components/Icon";
import Dropdown from "@/components/kit/Dropdown";
import MobileHeader from "@/components/MobileHeader"; import MobileHeader from "@/components/MobileHeader";
import ResourceCard from "@/components/ResourceCard"; import ResourceCard from "@/components/ResourceCard";
import ResourceItem from "@/components/ResourceItem"; import ResourceItem from "@/components/ResourceItem";
import ResourceSearchBar from "@/components/ResourceSearchBar"; import ResourceSearchBar from "@/components/ResourceSearchBar";
import Dropdown from "@/components/kit/Dropdown";
import { DEFAULT_MEMO_LIMIT } from "@/helpers/consts"; import { DEFAULT_MEMO_LIMIT } from "@/helpers/consts";
import useEvent from "@/hooks/useEvent"; import useEvent from "@/hooks/useEvent";
import useLoading from "@/hooks/useLoading"; import useLoading from "@/hooks/useLoading";
......
import axios from "axios";
import * as api from "@/helpers/api"; import * as api from "@/helpers/api";
import storage from "@/helpers/storage"; import storage from "@/helpers/storage";
import i18n from "@/i18n"; import i18n from "@/i18n";
...@@ -74,6 +75,11 @@ export const useGlobalStore = () => { ...@@ -74,6 +75,11 @@ export const useGlobalStore = () => {
}, },
fetchSystemStatus: async () => { fetchSystemStatus: async () => {
const { data: systemStatus } = await api.getSystemStatus(); const { data: systemStatus } = await api.getSystemStatus();
// TODO: update this when api v2 is ready.
const {
data: { systemInfo },
} = await axios.get("/api/v2/system/info");
systemStatus.dbSize = Number(systemInfo.dbSize);
store.dispatch(setGlobalState({ systemStatus: systemStatus })); store.dispatch(setGlobalState({ systemStatus: systemStatus }));
return systemStatus; return systemStatus;
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment