Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions core/app/api/v2/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,42 @@ func (b *BaseApi) GetAppstoreConfig(c *gin.Context) {
helper.SuccessWithData(c, res)
}

// @Tags System Setting
// @Summary Load dashboard memo
// @Success 200 {string} memo
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /core/settings/memo [get]
func (b *BaseApi) GetMemo(c *gin.Context) {
memo, err := settingService.GetMemo()
if err != nil {
helper.InternalServer(c, err)
return
}
helper.SuccessWithData(c, memo)
}

// @Tags System Setting
// @Summary Update dashboard memo
// @Accept json
// @Param request body dto.MemoUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /core/settings/memo [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"更新仪表盘备忘录","formatEN":"update dashboard memo"}
func (b *BaseApi) UpdateMemo(c *gin.Context) {
var req dto.MemoUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := settingService.UpdateMemo(req.Content); err != nil {
helper.InternalServer(c, err)
return
}
helper.Success(c)
}

func checkEntrancePattern(val string) bool {
if len(val) == 0 {
return true
Expand Down
4 changes: 4 additions & 0 deletions core/app/dto/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,7 @@ type PasskeyInfo struct {
CreatedAt string `json:"createdAt"`
LastUsedAt string `json:"lastUsedAt"`
}

type MemoUpdate struct {
Content string `json:"content" validate:"max=500"`
}
15 changes: 15 additions & 0 deletions core/app/service/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type ISettingService interface {
UpdateAppstoreConfig(req dto.AppstoreUpdate) error
GetAppstoreConfig() (*dto.AppstoreConfig, error)
DefaultMenu() error

GetMemo() (string, error)
UpdateMemo(content string) error
}

func NewISettingService() ISettingService {
Expand Down Expand Up @@ -781,3 +784,15 @@ func checkProxy(req dto.ProxyUpdate) error {
func (u *SettingService) DefaultMenu() error {
return settingRepo.DefaultMenu()
}

func (u *SettingService) GetMemo() (string, error) {
memo, err := settingRepo.GetValueByKey("DashboardMemo")
if err != nil {
return "", nil
}
return memo, nil
}

func (u *SettingService) UpdateMemo(content string) error {
return settingRepo.UpdateOrCreate("DashboardMemo", content)
}
3 changes: 3 additions & 0 deletions core/router/ro_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ func (s *SettingRouter) InitRouter(Router *gin.RouterGroup) {

settingRouter.POST("/apps/store/update", baseApi.UpdateAppstoreConfig)
settingRouter.GET("/apps/store/config", baseApi.GetAppstoreConfig)

settingRouter.GET("/memo", baseApi.GetMemo)
settingRouter.POST("/memo", baseApi.UpdateMemo)
}
}
8 changes: 8 additions & 0 deletions frontend/src/api/modules/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,11 @@ export const generateApiKey = () => {
export const updateApiConfig = (param: Setting.ApiConfig) => {
return http.post(`/core/settings/api/config/update`, param);
};

// memo
export const getMemo = () => {
return http.get<string>(`/core/settings/memo`);
};
export const updateMemo = (content: string) => {
return http.post(`/core/settings/memo`, { content });
};
4 changes: 4 additions & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ const message = {

networkCard: 'Network card',
disk: 'Disk',

memo: 'Memo',
memoPlaceholder: 'Click to edit memo...',
tooltipSensitiveInfo: 'Show/Hide sensitive info',
},
tabs: {
more: 'More',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/es-es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ const message = {
goInstall: 'Ir a instalar',
networkCard: 'Tarjeta de red',
disk: 'Disco',
memo: 'Memo',
memoPlaceholder: 'Haga clic para editar el memo...',
tooltipSensitiveInfo: 'Mostrar/Ocultar información sensible',
},
tabs: {
more: 'Más',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ const message = {

networkCard: 'ネットワークカード',
disk: 'ディスク',
memo: 'メモ',
memoPlaceholder: 'クリックしてメモを編集...',
tooltipSensitiveInfo: '機密情報を表示/非表示',
},
tabs: {
more: 'もっと',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ const message = {

networkCard: '네트워크 카드',
disk: '디스크',
memo: '메모',
memoPlaceholder: '클릭하여 메모를 편집...',
tooltipSensitiveInfo: '민감한 정보 표시/숨기기',
},
tabs: {
more: '더 보기',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ const message = {

networkCard: 'Kad rangkaian',
disk: 'Disk',
memo: 'Catatan',
memoPlaceholder: 'Klik untuk mengedit catatan...',
tooltipSensitiveInfo: 'Tunjuk/Sembunyikan maklumat sensitif',
},
tabs: {
more: 'Lagi',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ const message = {

networkCard: 'Placa de rede',
disk: 'Disco',
memo: 'Memo',
memoPlaceholder: 'Clique para editar o memo...',
tooltipSensitiveInfo: 'Mostrar/Ocultar informações sensíveis',
},
tabs: {
more: 'Mais',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ const message = {

networkCard: 'Интерфейс',
disk: 'Диск',
memo: 'Заметка',
memoPlaceholder: 'Нажмите, чтобы редактировать заметку...',
tooltipSensitiveInfo: 'Показать/скрыть конфиденциальную информацию',
},
tabs: {
more: 'Больше',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ const message = {

networkCard: 'Ağ kartı',
disk: 'Disk',
memo: 'Not',
memoPlaceholder: 'Notu düzenlemek için tıklayın...',
tooltipSensitiveInfo: 'Hassas bilgileri göster/gizle',
},
tabs: {
more: 'Daha Fazla',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lang/modules/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ const message = {

networkCard: '網卡',
disk: '磁碟',
memo: '備忘錄',
memoPlaceholder: '點擊編輯備忘錄內容...',
tooltipSensitiveInfo: '顯示/隱藏敏感資訊',
},
tabs: {
more: '更多',
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ const message = {

networkCard: '网卡',
disk: '磁盘',

memo: '备忘录',
memoPlaceholder: '点击编辑备忘录内容...',
tooltipSensitiveInfo: '显示/隐藏敏感信息',
},
tabs: {
more: '更多',
Expand Down
Loading
Loading