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
89ef9b85
Commit
89ef9b85
authored
Dec 15, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add instance url system setting
parent
56b55ad9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
1 deletion
+48
-1
system.go
api/v1/system.go
+1
-1
system_setting.go
api/v1/system_setting.go
+3
-0
SystemSection.tsx
web/src/components/Settings/SystemSection.tsx
+44
-0
No files found.
api/v1/system.go
View file @
89ef9b85
...
@@ -104,7 +104,7 @@ func (s *APIV1Service) GetSystemStatus(c echo.Context) error {
...
@@ -104,7 +104,7 @@ func (s *APIV1Service) GetSystemStatus(c echo.Context) error {
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find system setting list"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find system setting list"
)
.
SetInternal
(
err
)
}
}
for
_
,
systemSetting
:=
range
systemSettingList
{
for
_
,
systemSetting
:=
range
systemSettingList
{
if
systemSetting
.
Name
==
SystemSettingServerIDName
.
String
()
||
systemSetting
.
Name
==
SystemSettingSecretSessionName
.
String
()
||
systemSetting
.
Name
==
SystemSettingTelegramBotTokenName
.
String
()
{
if
systemSetting
.
Name
==
SystemSettingServerIDName
.
String
()
||
systemSetting
.
Name
==
SystemSettingSecretSessionName
.
String
()
||
systemSetting
.
Name
==
SystemSettingTelegramBotTokenName
.
String
()
||
systemSetting
.
Name
==
SystemSettingInstanceURLName
.
String
()
{
continue
continue
}
}
...
...
api/v1/system_setting.go
View file @
89ef9b85
...
@@ -42,6 +42,8 @@ const (
...
@@ -42,6 +42,8 @@ const (
SystemSettingMemoDisplayWithUpdatedTsName
SystemSettingName
=
"memo-display-with-updated-ts"
SystemSettingMemoDisplayWithUpdatedTsName
SystemSettingName
=
"memo-display-with-updated-ts"
// SystemSettingAutoBackupIntervalName is the name of auto backup interval as seconds.
// SystemSettingAutoBackupIntervalName is the name of auto backup interval as seconds.
SystemSettingAutoBackupIntervalName
SystemSettingName
=
"auto-backup-interval"
SystemSettingAutoBackupIntervalName
SystemSettingName
=
"auto-backup-interval"
// SystemSettingInstanceURLName is the name of instance url setting.
SystemSettingInstanceURLName
SystemSettingName
=
"instance-url"
)
)
const
systemSettingUnmarshalError
=
`failed to unmarshal value from system setting "%v"`
const
systemSettingUnmarshalError
=
`failed to unmarshal value from system setting "%v"`
...
@@ -271,6 +273,7 @@ func (upsert UpsertSystemSettingRequest) Validate() error {
...
@@ -271,6 +273,7 @@ func (upsert UpsertSystemSettingRequest) Validate() error {
if
err
:=
json
.
Unmarshal
([]
byte
(
upsert
.
Value
),
&
value
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
upsert
.
Value
),
&
value
);
err
!=
nil
{
return
errors
.
Errorf
(
systemSettingUnmarshalError
,
settingName
)
return
errors
.
Errorf
(
systemSettingUnmarshalError
,
settingName
)
}
}
case
SystemSettingInstanceURLName
:
default
:
default
:
return
errors
.
New
(
"invalid system setting name"
)
return
errors
.
New
(
"invalid system setting name"
)
}
}
...
...
web/src/components/Settings/SystemSection.tsx
View file @
89ef9b85
...
@@ -40,6 +40,7 @@ const SystemSection = () => {
...
@@ -40,6 +40,7 @@ const SystemSection = () => {
memoDisplayWithUpdatedTs
:
systemStatus
.
memoDisplayWithUpdatedTs
,
memoDisplayWithUpdatedTs
:
systemStatus
.
memoDisplayWithUpdatedTs
,
});
});
const
[
telegramBotToken
,
setTelegramBotToken
]
=
useState
<
string
>
(
""
);
const
[
telegramBotToken
,
setTelegramBotToken
]
=
useState
<
string
>
(
""
);
const
[
instanceUrl
,
setInstanceUrl
]
=
useState
<
string
>
(
""
);
useEffect
(()
=>
{
useEffect
(()
=>
{
globalStore
.
fetchSystemStatus
();
globalStore
.
fetchSystemStatus
();
...
@@ -51,6 +52,10 @@ const SystemSection = () => {
...
@@ -51,6 +52,10 @@ const SystemSection = () => {
if
(
telegramBotSetting
)
{
if
(
telegramBotSetting
)
{
setTelegramBotToken
(
telegramBotSetting
.
value
);
setTelegramBotToken
(
telegramBotSetting
.
value
);
}
}
const
instanceUrlSetting
=
systemSettings
.
find
((
setting
)
=>
setting
.
name
===
"instance-url"
);
if
(
instanceUrlSetting
)
{
setInstanceUrl
(
instanceUrlSetting
.
value
);
}
});
});
},
[]);
},
[]);
...
@@ -117,6 +122,24 @@ const SystemSection = () => {
...
@@ -117,6 +122,24 @@ const SystemSection = () => {
toast
.
success
(
t
(
"message.succeed-vacuum-database"
));
toast
.
success
(
t
(
"message.succeed-vacuum-database"
));
};
};
const
handleInstanceUrlChanged
=
(
value
:
string
)
=>
{
setInstanceUrl
(
value
);
};
const
handleSaveInstanceUrl
=
async
()
=>
{
try
{
await
api
.
upsertSystemSetting
({
name
:
"instance-url"
,
value
:
instanceUrl
,
});
}
catch
(
error
:
any
)
{
console
.
error
(
error
);
toast
.
error
(
error
.
response
.
data
.
message
);
return
;
}
toast
.
success
(
"Instance URL updated"
);
};
const
handleTelegramBotTokenChanged
=
(
value
:
string
)
=>
{
const
handleTelegramBotTokenChanged
=
(
value
:
string
)
=>
{
setTelegramBotToken
(
value
);
setTelegramBotToken
(
value
);
};
};
...
@@ -314,6 +337,27 @@ const SystemSection = () => {
...
@@ -314,6 +337,27 @@ const SystemSection = () => {
/>
/>
</
div
>
</
div
>
<
Divider
className=
"!mt-3 !my-4"
/>
<
Divider
className=
"!mt-3 !my-4"
/>
<
div
className=
"form-label"
>
<
div
className=
"flex flex-row items-center"
>
<
div
className=
"w-auto flex items-center"
>
<
span
className=
"text-sm mr-1"
>
Instance URL
</
span
>
</
div
>
</
div
>
<
Button
variant=
"outlined"
color=
"neutral"
onClick=
{
handleSaveInstanceUrl
}
>
{
t
(
"common.save"
)
}
</
Button
>
</
div
>
<
Input
className=
"w-full"
sx=
{
{
fontFamily
:
"monospace"
,
fontSize
:
"14px"
,
}
}
placeholder=
{
"Your instance url, should be started with http:// or https://"
}
value=
{
instanceUrl
}
onChange=
{
(
event
)
=>
handleInstanceUrlChanged
(
event
.
target
.
value
)
}
/>
<
Divider
className=
"!mt-3 !my-4"
/>
<
div
className=
"form-label"
>
<
div
className=
"form-label"
>
<
div
className=
"flex flex-row items-center"
>
<
div
className=
"flex flex-row items-center"
>
<
div
className=
"w-auto flex items-center"
>
<
div
className=
"w-auto flex items-center"
>
...
...
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