Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHamidreza Ghavami <70919649+hamid-gh98@users.noreply.github.com>2023-05-12 18:02:04 +0300
committerHamidreza Ghavami <70919649+hamid-gh98@users.noreply.github.com>2023-05-12 21:15:25 +0300
commit95e006963c92ef53f92d6f10ee829f63406d211c (patch)
treee2d213afb0368e9c46cbc9847e96bc66e195e506 /web/controller
parent65588a44922ea062cc438c43957f131ba54a1404 (diff)
add searchDatafiles route
Diffstat (limited to 'web/controller')
-rw-r--r--web/controller/index.go1
-rw-r--r--web/controller/setting.go18
2 files changed, 18 insertions, 1 deletions
diff --git a/web/controller/index.go b/web/controller/index.go
index 802f3f7d..5b97a7cc 100644
--- a/web/controller/index.go
+++ b/web/controller/index.go
@@ -101,5 +101,4 @@ func (a *IndexController) getSecretStatus(c *gin.Context) {
if err == nil {
jsonObj(c, status, nil)
}
-
}
diff --git a/web/controller/setting.go b/web/controller/setting.go
index bd9c2a5f..248f3ee5 100644
--- a/web/controller/setting.go
+++ b/web/controller/setting.go
@@ -3,6 +3,7 @@ package controller
import (
"errors"
"time"
+ "x-ui/util/common"
"x-ui/web/entity"
"x-ui/web/service"
"x-ui/web/session"
@@ -44,6 +45,7 @@ func (a *SettingController) initRouter(g *gin.RouterGroup) {
g.GET("/getDefaultJsonConfig", a.getDefaultJsonConfig)
g.POST("/updateUserSecret", a.updateSecret)
g.POST("/getUserSecret", a.getUserSecret)
+ g.GET("/searchDatafiles", a.searchDatafiles)
}
func (a *SettingController) getAllSetting(c *gin.Context) {
@@ -149,6 +151,7 @@ func (a *SettingController) updateSecret(c *gin.Context) {
}
jsonMsg(c, I18n(c, "pages.settings.toasts.modifyUser"), err)
}
+
func (a *SettingController) getUserSecret(c *gin.Context) {
loginUser := session.GetLoginUser(c)
user := a.userService.GetUserSecret(loginUser.Id)
@@ -156,3 +159,18 @@ func (a *SettingController) getUserSecret(c *gin.Context) {
jsonObj(c, user, nil)
}
}
+
+func (a *SettingController) searchDatafiles(c *gin.Context) {
+ searchString := c.Query("query")
+ if searchString == "" {
+ err := common.NewError("data query parameter is empty")
+ jsonMsg(c, "Invalid query:", err)
+ return
+ }
+ found, err := a.settingService.SearchDatafiles(searchString)
+ if err != nil {
+ jsonMsg(c, "Something went wrong!", err)
+ return
+ }
+ jsonObj(c, found, nil)
+}