CaIon пре 2 година
родитељ
комит
e3fca11f99
2 измењених фајлова са 3 додато и 3 уклоњено
  1. 1 1
      model/token.go
  2. 2 2
      web/src/components/TokensTable.js

+ 1 - 1
model/token.go

@@ -33,7 +33,7 @@ func SearchUserTokens(userId int, keyword string, token string) (tokens []*Token
 	if token != "" {
 	if token != "" {
 		token = strings.Trim(token, "sk-")
 		token = strings.Trim(token, "sk-")
 	}
 	}
-	err = DB.Where("user_id = ?", userId).Where("name LIKE ? or key LIKE ?", keyword+"%", token+"%").Find(&tokens).Error
+	err = DB.Where("user_id = ?", userId).Where("name LIKE ?", keyword+"%").Where("key LIKE ?", token+"%").Find(&tokens).Error
 	return tokens, err
 	return tokens, err
 }
 }
 
 

+ 2 - 2
web/src/components/TokensTable.js

@@ -377,14 +377,14 @@ const TokensTable = () => {
     };
     };
 
 
     const searchTokens = async () => {
     const searchTokens = async () => {
-        if (searchKeyword === '') {
+        if (searchKeyword === '' && searchToken === '') {
             // if keyword is blank, load files instead.
             // if keyword is blank, load files instead.
             await loadTokens(0);
             await loadTokens(0);
             setActivePage(1);
             setActivePage(1);
             return;
             return;
         }
         }
         setSearching(true);
         setSearching(true);
-        const res = await API.get(`/api/token/search?keyword=${searchKeyword}`);
+        const res = await API.get(`/api/token/search?keyword=${searchKeyword}&token=${searchToken}`);
         const {success, message, data} = res.data;
         const {success, message, data} = res.data;
         if (success) {
         if (success) {
             setTokensFormat(data);
             setTokensFormat(data);