Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
14718530
Unverified
Commit
14718530
authored
Dec 07, 2022
by
Zeng1998
Committed by
GitHub
Dec 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: vacuum database in setting (#694)
* feat: vacuum database in setting * update * update * update * update
parent
f48226d4
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
65 additions
and
10 deletions
+65
-10
system.go
server/system.go
+22
-0
SystemSection.tsx
web/src/components/Settings/SystemSection.tsx
+25
-3
api.ts
web/src/helpers/api.ts
+4
-0
de.json
web/src/locales/de.json
+2
-1
en.json
web/src/locales/en.json
+2
-1
fr.json
web/src/locales/fr.json
+2
-1
nl.json
web/src/locales/nl.json
+2
-1
sv.json
web/src/locales/sv.json
+2
-1
vi.json
web/src/locales/vi.json
+2
-1
zh.json
web/src/locales/zh.json
+2
-1
No files found.
server/system.go
View file @
14718530
...
...
@@ -148,4 +148,26 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
}
return
nil
})
g
.
POST
(
"/system/vacuum"
,
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"
)
}
if
err
:=
s
.
Store
.
Vacuum
(
ctx
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to vacuum database"
)
.
SetInternal
(
err
)
}
c
.
Response
()
.
WriteHeader
(
http
.
StatusOK
)
return
nil
})
}
web/src/components/Settings/SystemSection.tsx
View file @
14718530
...
...
@@ -60,6 +60,23 @@ const SystemSection = () => {
});
};
const
handleVacuumBtnClick
=
async
()
=>
{
try
{
await
api
.
vacuumDatabase
();
const
{
data
:
status
}
=
(
await
api
.
getSystemStatus
()).
data
;
setState
({
dbSize
:
status
.
dbSize
,
allowSignUp
:
status
.
allowSignUp
,
additionalStyle
:
status
.
additionalStyle
,
additionalScript
:
status
.
additionalScript
,
});
}
catch
(
error
)
{
console
.
error
(
error
);
return
;
}
toastHelper
.
success
(
"Succeed to vacuum database"
);
};
const
handleSaveAdditionalStyle
=
async
()
=>
{
try
{
await
api
.
upsertSystemSetting
({
...
...
@@ -96,9 +113,14 @@ const SystemSection = () => {
return
(
<
div
className=
"section-container system-section-container"
>
<
p
className=
"title-text"
>
{
t
(
"common.basic"
)
}
</
p
>
<
p
className=
"text-value"
>
{
t
(
"setting.system-section.database-file-size"
)
}
:
<
span
className=
"font-mono font-medium"
>
{
formatBytes
(
state
.
dbSize
)
}
</
span
>
</
p
>
<
label
className=
"form-label"
>
<
span
className=
"normal-text"
>
{
t
(
"setting.system-section.database-file-size"
)
}
:
<
span
className=
"font-mono font-medium"
>
{
formatBytes
(
state
.
dbSize
)
}
</
span
>
</
span
>
<
Button
size=
"sm"
onClick=
{
handleVacuumBtnClick
}
>
{
t
(
"common.vacuum"
)
}
</
Button
>
</
label
>
<
p
className=
"title-text"
>
{
t
(
"sidebar.setting"
)
}
</
p
>
<
label
className=
"form-label"
>
<
span
className=
"normal-text"
>
{
t
(
"setting.system-section.allow-user-signup"
)
}
</
span
>
...
...
web/src/helpers/api.ts
View file @
14718530
...
...
@@ -14,6 +14,10 @@ export function upsertSystemSetting(systemSetting: SystemSetting) {
return
axios
.
post
<
ResponseObject
<
SystemSetting
>>
(
"/api/system/setting"
,
systemSetting
);
}
export
function
vacuumDatabase
()
{
return
axios
.
post
(
"/api/system/vacuum"
);
}
export
function
signin
(
username
:
string
,
password
:
string
)
{
return
axios
.
post
<
ResponseObject
<
User
>>
(
"/api/auth/signin"
,
{
username
,
...
...
web/src/locales/de.json
View file @
14718530
...
...
@@ -45,7 +45,8 @@
"fold"
:
"Falten"
,
"expand"
:
"Erweitern"
,
"image"
:
"Bild"
,
"link"
:
"Link"
"link"
:
"Link"
,
"vacuum"
:
"Vacuum"
},
"slogan"
:
"Eine quelloffene, selbst gehostete Sammlung an Memos zur Wissensverwaltung und Vernetzung."
,
"auth"
:
{
...
...
web/src/locales/en.json
View file @
14718530
...
...
@@ -45,7 +45,8 @@
"fold"
:
"Fold"
,
"expand"
:
"Expand"
,
"image"
:
"Image"
,
"link"
:
"Link"
"link"
:
"Link"
,
"vacuum"
:
"Vacuum"
},
"slogan"
:
"An open-source, self-hosted memo hub with knowledge management and socialization."
,
"auth"
:
{
...
...
web/src/locales/fr.json
View file @
14718530
...
...
@@ -45,7 +45,8 @@
"fold"
:
"Plier"
,
"expand"
:
"Développer"
,
"image"
:
"Image"
,
"link"
:
"Link"
"link"
:
"Link"
,
"vacuum"
:
"Vacuum"
},
"slogan"
:
"An open-source, self-hosted memo hub with knowledge management and socialization."
,
"auth"
:
{
...
...
web/src/locales/nl.json
View file @
14718530
...
...
@@ -41,7 +41,8 @@
"changed"
:
"gewijzigd"
,
"update-on"
:
"Update op"
,
"fold"
:
"Invouwen"
,
"expand"
:
"Uitklappen"
"expand"
:
"Uitklappen"
,
"vacuum"
:
"Vacuum"
},
"slogan"
:
"Een open-source, zelf-beheerd memo applicatie voor kennismanagement en collaboratie."
,
"auth"
:
{
...
...
web/src/locales/sv.json
View file @
14718530
...
...
@@ -45,7 +45,8 @@
"fold"
:
"Vik ihop"
,
"expand"
:
"Expandera"
,
"image"
:
"Bild"
,
"link"
:
"Länk"
"link"
:
"Länk"
,
"vacuum"
:
"Vacuum"
},
"slogan"
:
"En öppen källkod, self-hosted antecknings hubb med kunskapshantering och socialisering"
,
"auth"
:
{
...
...
web/src/locales/vi.json
View file @
14718530
...
...
@@ -45,7 +45,8 @@
"fold"
:
"Fold"
,
"expand"
:
"Expand"
,
"image"
:
"Image"
,
"link"
:
"Link"
"link"
:
"Link"
,
"vacuum"
:
"Vacuum"
},
"slogan"
:
"An open-source, self-hosted memo hub with knowledge management and socialization."
,
"auth"
:
{
...
...
web/src/locales/zh.json
View file @
14718530
...
...
@@ -45,7 +45,8 @@
"fold"
:
"折叠"
,
"expand"
:
"展开"
,
"image"
:
"图片"
,
"link"
:
"链接"
"link"
:
"链接"
,
"vacuum"
:
"清理"
},
"slogan"
:
"An open-source, self-hosted memo hub with knowledge management and socialization."
,
"auth"
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment