diff --git a/controller/channel-billing.go b/controller/channel-billing.go
index 55eec54a..17dd0b2f 100644
--- a/controller/channel-billing.go
+++ b/controller/channel-billing.go
@@ -296,7 +296,7 @@ func UpdateChannelBalance(c *gin.Context) {
}
func updateAllChannelsBalance() error {
- channels, err := model.GetAllChannels(0, 0, true)
+ channels, err := model.GetAllChannels(0, 0, "all")
if err != nil {
return err
}
diff --git a/controller/channel-test.go b/controller/channel-test.go
index 6fe18d6a..d00e5e5d 100644
--- a/controller/channel-test.go
+++ b/controller/channel-test.go
@@ -149,7 +149,7 @@ func TestChannel(c *gin.Context) {
var testAllChannelsLock sync.Mutex
var testAllChannelsRunning bool = false
-func testAllChannels(notify bool) error {
+func testChannels(notify bool, scope string) error {
if config.RootUserEmail == "" {
config.RootUserEmail = model.GetRootUserEmail()
}
@@ -160,7 +160,7 @@ func testAllChannels(notify bool) error {
}
testAllChannelsRunning = true
testAllChannelsLock.Unlock()
- channels, err := model.GetAllChannels(0, 0, true)
+ channels, err := model.GetAllChannels(0, 0, scope)
if err != nil {
return err
}
@@ -201,8 +201,12 @@ func testAllChannels(notify bool) error {
return nil
}
-func TestAllChannels(c *gin.Context) {
- err := testAllChannels(true)
+func TestChannels(c *gin.Context) {
+ scope := c.Query("scope")
+ if scope == "" {
+ scope = "all"
+ }
+ err := testChannels(true, scope)
if err != nil {
c.JSON(http.StatusOK, gin.H{
"success": false,
@@ -221,7 +225,7 @@ func AutomaticallyTestChannels(frequency int) {
for {
time.Sleep(time.Duration(frequency) * time.Minute)
logger.SysLog("testing all channels")
- _ = testAllChannels(false)
+ _ = testChannels(false, "all")
logger.SysLog("channel test finished")
}
}
diff --git a/controller/channel.go b/controller/channel.go
index bdfa00d9..37bfb99d 100644
--- a/controller/channel.go
+++ b/controller/channel.go
@@ -15,7 +15,7 @@ func GetAllChannels(c *gin.Context) {
if p < 0 {
p = 0
}
- channels, err := model.GetAllChannels(p*config.ItemsPerPage, config.ItemsPerPage, false)
+ channels, err := model.GetAllChannels(p*config.ItemsPerPage, config.ItemsPerPage, "limited")
if err != nil {
c.JSON(http.StatusOK, gin.H{
"success": false,
diff --git a/model/channel.go b/model/channel.go
index 19af2263..6bfeb4e4 100644
--- a/model/channel.go
+++ b/model/channel.go
@@ -32,12 +32,15 @@ type Channel struct {
Config string `json:"config"`
}
-func GetAllChannels(startIdx int, num int, selectAll bool) ([]*Channel, error) {
+func GetAllChannels(startIdx int, num int, scope string) ([]*Channel, error) {
var channels []*Channel
var err error
- if selectAll {
+ switch scope {
+ case "all":
err = DB.Order("id desc").Find(&channels).Error
- } else {
+ case "disabled":
+ err = DB.Order("id desc").Where("status = ? or status = ?", common.ChannelStatusAutoDisabled, common.ChannelStatusManuallyDisabled).Find(&channels).Error
+ default:
err = DB.Order("id desc").Limit(num).Offset(startIdx).Omit("key").Find(&channels).Error
}
return channels, err
diff --git a/router/api-router.go b/router/api-router.go
index dc1fdc6b..5b755ede 100644
--- a/router/api-router.go
+++ b/router/api-router.go
@@ -70,7 +70,7 @@ func SetApiRouter(router *gin.Engine) {
channelRoute.GET("/search", controller.SearchChannels)
channelRoute.GET("/models", controller.ListModels)
channelRoute.GET("/:id", controller.GetChannel)
- channelRoute.GET("/test", controller.TestAllChannels)
+ channelRoute.GET("/test", controller.TestChannels)
channelRoute.GET("/test/:id", controller.TestChannel)
channelRoute.GET("/update_balance", controller.UpdateAllChannelsBalance)
channelRoute.GET("/update_balance/:id", controller.UpdateChannelBalance)
diff --git a/web/default/src/components/ChannelsTable.js b/web/default/src/components/ChannelsTable.js
index 358b9262..5f837d03 100644
--- a/web/default/src/components/ChannelsTable.js
+++ b/web/default/src/components/ChannelsTable.js
@@ -240,11 +240,11 @@ const ChannelsTable = () => {
}
};
- const testAllChannels = async () => {
- const res = await API.get(`/api/channel/test`);
+ const testChannels = async (scope) => {
+ const res = await API.get(`/api/channel/test?scope=${scope}`);
const { success, message } = res.data;
if (success) {
- showInfo('已成功开始测试所有通道,请刷新页面查看结果。');
+ showInfo('已成功开始测试通道,请刷新页面查看结果。');
} else {
showError(message);
}
@@ -529,9 +529,12 @@ const ChannelsTable = () => {
-