filter by name works, removed some more code
This commit is contained in:
		| @@ -4,8 +4,7 @@ import store from '../store/modules/settings.js' | |||||||
| const TerminalEndpointUrl = 'https://metadata.service.development.therig.onlinefuelslabs.io' | const TerminalEndpointUrl = 'https://metadata.service.development.therig.onlinefuelslabs.io' | ||||||
|  |  | ||||||
| export function fetchList(query) { | export function fetchList(query) { | ||||||
|   query.platform = store.state.platform |   return axios.get(`${TerminalEndpointUrl}/terminals?platform=${store.state.platform}`) | ||||||
|   return axios.get(`${TerminalEndpointUrl}/terminals`, { params: query }) |  | ||||||
| } | } | ||||||
|  |  | ||||||
| export function fetchTerminal(id) { | export function fetchTerminal(id) { | ||||||
|   | |||||||
| @@ -2,13 +2,13 @@ | |||||||
|   <div class="app-container"> |   <div class="app-container"> | ||||||
|  |  | ||||||
|     <div class="filter-container"> |     <div class="filter-container"> | ||||||
|       <el-input v-model="listQuery.terminalName" placeholder="Account Name or Email" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" /> |       <el-input v-model="terminalName" placeholder="Terminal Name" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" /> | ||||||
|       <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter"> |       <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter"> | ||||||
|         Search |         Search | ||||||
|       </el-button> |       </el-button> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|     <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%"> |     <el-table v-loading="listLoading" :data="filteredList" border fit highlight-current-row style="width: 100%"> | ||||||
|       <el-table-column align="center" label="Name" width="200"> |       <el-table-column align="center" label="Name" width="200"> | ||||||
|         <template slot-scope="scope"> |         <template slot-scope="scope"> | ||||||
|           <span>{{ scope.row.name }}</span> |           <span>{{ scope.row.name }}</span> | ||||||
| @@ -53,36 +53,32 @@ export default { | |||||||
|   }, |   }, | ||||||
|   data() { |   data() { | ||||||
|     return { |     return { | ||||||
|       list: null, |       terminalName: '', | ||||||
|  |       originaList: null, | ||||||
|  |       filteredList: null, | ||||||
|       total: 0, |       total: 0, | ||||||
|       listLoading: true, |       listLoading: true | ||||||
|       listQuery: { |  | ||||||
|         page: 1, |  | ||||||
|         limit: 20 |  | ||||||
|       } |  | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   created() { |   created() { | ||||||
|     // Set the type for the query |     // Set the type for the query | ||||||
|     this.listQuery.type = this.$route.meta.type |  | ||||||
|     this.listQuery.platform = this.$store.state.platform |  | ||||||
|  |  | ||||||
|     this.getList() |     this.getList() | ||||||
|   }, |   }, | ||||||
|   methods: { |   methods: { | ||||||
|     getList() { |     getList() { | ||||||
|       this.listLoading = true |       this.listLoading = true | ||||||
|       fetchList(this.listQuery).then(response => { |       fetchList().then(response => { | ||||||
|         this.list = response.data.terminals |         this.originaList = response.data.terminals | ||||||
|  |         this.filteredList = this.originaList | ||||||
|         this.total = response.data.terminals.length |         this.total = response.data.terminals.length | ||||||
|         this.listLoading = false |         this.listLoading = false | ||||||
|       }) |       }) | ||||||
|     }, |     }, | ||||||
|     handleFilter() { |     handleFilter() { | ||||||
|       // const searchQuery = this.accountName.toLowerCase() |       const searchQuery = this.terminalName.toLowerCase() | ||||||
|       // this.filteredList = this.originalList.filter(function(account) { |       this.filteredList = this.originaList.filter(function(terminal) { | ||||||
|       //   return account.name.toLowerCase().includes(searchQuery) |         return terminal.name.toLowerCase().includes(searchQuery) | ||||||
|       // }) |       }) | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user