Skip to content

Commit

Permalink
feature: navigation between services and tests. Fixes #285 (#286)
Browse files Browse the repository at this point in the history
* feature: navigation between services and tests. Fixes #285

* autocomplete service name and support fuzzy search
  • Loading branch information
kezhenxu94 authored and nzomkxia committed Feb 12, 2019
1 parent 87669fd commit af0a20f
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 7 deletions.
11 changes: 11 additions & 0 deletions dubbo-admin-ui/src/components/ServiceSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@
<td>{{props.item.version}}</td>
<td>{{props.item.appName}}</td>
<td class="text-xs-center px-0" nowrap>
<v-btn
small
color='primary'
@click="toTestService(props.item)"
>
{{$t('test')}}
</v-btn>
<v-btn
small
color='primary'
Expand Down Expand Up @@ -276,6 +283,10 @@
this.$router.push({path: 'service', query: {filter: filter, pattern: pattern}})
}
})
},
toTestService (item) {
const service = item.service
this.$router.push(`/test/?service=${service}`)
}
},
mounted: function () {
Expand Down
58 changes: 53 additions & 5 deletions dubbo-admin-ui/src/components/test/ServiceTest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,24 @@
<breadcrumb title="serviceTest" :items="breads"></breadcrumb>
</v-flex>
<v-flex xs12>
<search v-model="filter" label="Search by service name" :submit="search"></search>
<v-autocomplete
flat
hide-no-data
v-model="service"
:loading="loading"
:search-input.sync="filter"
:hint="$t('testModule.searchServiceHint')"
:items="services"
item-value="service"
item-text="service"
:label="$t('placeholders.searchService')"
persistent-hint
@keyup.enter="search"
clearable
></v-autocomplete>
</v-flex>
<v-flex xs12>
<h3>Methods</h3>
<h3>{{$t('methods')}}</h3>
</v-flex>
<v-flex xs12>
<v-data-table :headers="headers" :items="methods" hide-actions class="elevation-1">
Expand All @@ -40,7 +54,7 @@
>
<v-icon>edit</v-icon>
</v-btn>
<span>Try it</span>
<span>{{$t('test')}}</span>
</v-tooltip>
</td>
</template>
Expand Down Expand Up @@ -68,13 +82,16 @@
breads: [
{
text: 'serviceSearch',
href: ''
href: '/test'
}
],
headers: [
],
service: null,
methods: []
methods: [],
services: [],
searchKey: this.$route.query['service'] || '*',
loading: false
}
},
methods: {
Expand Down Expand Up @@ -138,6 +155,26 @@
this.showSnackbar('error', error.response.data.message)
})
},
searchServices () {
let filter = this.filter || ''
if (!filter.startsWith('*')) {
filter = '*' + filter
}
if (!filter.endsWith('*')) {
filter += '*'
}
const pattern = 'service'
this.loading = true
this.$axios.get('/service', {
params: {
pattern, filter
}
}).then(response => {
this.services = response.data
}).finally(() => {
this.loading = false
})
},
getHref (application, service, method) {
return `/#/testMethod?application=${application}&service=${service}&method=${method}`
}
Expand All @@ -150,10 +187,21 @@
watch: {
area () {
this.setHeaders()
},
filter () {
this.searchServices()
},
searchKey () {
this.search()
}
},
created () {
this.search()
}
}
</script>
<style>
.v-breadcrumbs {
padding-left: 0;
}
</style>
10 changes: 9 additions & 1 deletion dubbo-admin-ui/src/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,13 @@ export default {
success: 'SUCCESS',
fail: 'FAIL',
detail: 'Detail',
more: 'More'
more: 'More',
test: 'Test',
placeholders: {
searchService: 'Search by service name'
},
methods: 'Methods',
testModule: {
searchServiceHint: 'Service ID, org.apache.dubbo.demo.api.DemoService, * for fuzzy search, press Enter to search'
}
}
10 changes: 9 additions & 1 deletion dubbo-admin-ui/src/lang/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,13 @@ export default {
success: ' 成功',
fail: '失败',
detail: '详情',
more: '更多'
more: '更多',
test: '测试',
placeholders: {
searchService: '通过服务名搜索服务'
},
methods: '方法列表',
testModule: {
searchServiceHint: '服务ID, org.apache.dubbo.demo.api.DemoService, 使用 * 进行模糊查找, 按回车键查询'
}
}

0 comments on commit af0a20f

Please sign in to comment.