Skip to content

Commit

Permalink
[improvement-apache#11879]Keyword Search Improvement (apache#12951)
Browse files Browse the repository at this point in the history
* [improvement-apache#11879]Keyword Search Improvement

* [improvement] add a search component

* [Feature][UI] Revise the  `Search` component.

* [improvement] add search components

* [improvement] fix

* [improvement] remove unUsed

* [improvement] remove unUsed

* handle the different locales.

Co-authored-by: Jackie <‘[email protected]’>
Co-authored-by: Amy <[email protected]>
  • Loading branch information
3 people authored and shangeyao committed Dec 3, 2022
1 parent 1cb963d commit b960427
Show file tree
Hide file tree
Showing 28 changed files with 216 additions and 149 deletions.
55 changes: 55 additions & 0 deletions dolphinscheduler-ui/src/components/input-search/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { defineComponent, withKeys, PropType } from 'vue'
import { NInput } from 'naive-ui'
import { useI18n } from 'vue-i18n'

const props = {
placeholder: {
type: String as PropType<string>,
required: false
}
}

const Search = defineComponent({
name: 'Search',
emits: ['search','clear'],
props: props,
setup(props, ctx) {
const { t } = useI18n()

const onKeyDown = (ev: KeyboardEvent) => {
ctx.emit('search', (ev.target as HTMLInputElement)?.value || '')
}
const onClear = (ev: Event) => {
ctx.emit('clear', (ev.target as HTMLInputElement)?.value || '')
}
return () => (

<NInput
size='small'
clearable
placeholder = {props.placeholder?props.placeholder:t('input_search.placeholder')}
onKeydown={withKeys(onKeyDown, ['enter'])}
onClear = {onClear}
/>
)
}
})

export default Search
4 changes: 3 additions & 1 deletion dolphinscheduler-ui/src/locales/en_US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import crontab from '@/locales/en_US/crontab'
import data_quality from '@/locales/en_US/data-quality'
import datasource from '@/locales/en_US/datasource'
import home from '@/locales/en_US/home'
import input_search from '@/locales/en_US/input-search'
import login from '@/locales/en_US/login'
import menu from '@/locales/en_US/menu'
import modal from '@/locales/en_US/modal'
Expand Down Expand Up @@ -48,5 +49,6 @@ export default {
datasource,
data_quality,
crontab,
ui_setting
ui_setting,
input_search
}
20 changes: 20 additions & 0 deletions dolphinscheduler-ui/src/locales/en_US/input-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export default {
placeholder: 'Please enter keyword'
}
4 changes: 3 additions & 1 deletion dolphinscheduler-ui/src/locales/zh_CN/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import crontab from '@/locales/zh_CN/crontab'
import data_quality from '@/locales/zh_CN/data-quality'
import datasource from '@/locales/zh_CN/datasource'
import home from '@/locales/zh_CN/home'
import input_search from '@/locales/zh_CN/input-search'
import login from '@/locales/zh_CN/login'
import menu from '@/locales/zh_CN/menu'
import modal from '@/locales/zh_CN/modal'
Expand Down Expand Up @@ -48,5 +49,6 @@ export default {
datasource,
data_quality,
crontab,
ui_setting
ui_setting,
input_search
}
20 changes: 20 additions & 0 deletions dolphinscheduler-ui/src/locales/zh_CN/input-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export default {
placeholder: '请输入关键词'
}
25 changes: 10 additions & 15 deletions dolphinscheduler-ui/src/views/data-quality/rule/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,11 @@ import {
ref,
toRefs
} from 'vue'
import {
NSpace,
NInput,
NButton,
NIcon,
NDataTable,
NPagination
} from 'naive-ui'
import {NSpace, NButton, NIcon, NDataTable, NPagination} from 'naive-ui'
import { SearchOutlined } from '@vicons/antd'
import { useTable } from './use-table'
import Card from '@/components/card'
import Search from '@/components/input-search'
import RuleModal from './components/rule-modal'

const TaskResult = defineComponent({
Expand All @@ -58,7 +52,6 @@ const TaskResult = defineComponent({
}

const onSearch = () => {
variables.page = 1
requestTableData()
}

Expand Down Expand Up @@ -115,14 +108,16 @@ const TaskResult = defineComponent({
<NSpace vertical>
<Card>
<NSpace justify='end'>
<NInput
allowInput={this.trim}
v-model={[this.searchVal, 'value']}
size='small'
<Search
v-model:value={this.searchVal}
placeholder={t('data_quality.rule.name')}
clearable
onSearch={onSearch}
/>
<NButton size='small' type='primary' onClick={onSearch}>
<NButton
size='small'
type='primary'
onClick={onSearch}
>
<NIcon>
<SearchOutlined />
</NIcon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function useTable(viewRuleEntry = (unusedRuleJson: string): void => {}) {
page: ref(1),
pageSize: ref(10),
state: ref(null),
searchVal: ref(null),
searchVal: '',
totalPage: ref(1),
loadingRef: ref(false)
})
Expand Down
12 changes: 5 additions & 7 deletions dolphinscheduler-ui/src/views/data-quality/task-result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
} from 'vue'
import {
NSpace,
NInput,
NSelect,
NDatePicker,
NButton,
Expand All @@ -36,6 +35,7 @@ import { SearchOutlined } from '@vicons/antd'
import { useTable } from './use-table'
import { useI18n } from 'vue-i18n'
import Card from '@/components/card'
import Search from '@/components/input-search'

const TaskResult = defineComponent({
name: 'task-result',
Expand Down Expand Up @@ -90,12 +90,10 @@ const TaskResult = defineComponent({
<NSpace vertical>
<Card>
<NSpace justify='end'>
<NInput
allowInput={this.trim}
v-model={[this.searchVal, 'value']}
size='small'
placeholder={t('data_quality.task_result.task_name')}
clearable
<Search
v-model:value={this.searchVal}
placeholder={t('data_quality.task_result.task_name')}
onSearch={onSearch}
/>
<NSelect
v-model={[this.ruleType, 'value']}
Expand Down
11 changes: 5 additions & 6 deletions dolphinscheduler-ui/src/views/datasource/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
} from 'vue'
import {
NButton,
NInput,
NIcon,
NDataTable,
NPagination,
Expand All @@ -37,6 +36,7 @@ import { useColumns } from './use-columns'
import { useTable } from './use-table'
import { DefaultTableWidth } from '@/common/column-width-config'
import Card from '@/components/card'
import Search from '@/components/input-search'
import DetailModal from './detail'
import type { TableColumns } from './types'
import SourceModal from './source-modal'
Expand Down Expand Up @@ -143,11 +143,10 @@ const list = defineComponent({
{t('datasource.create_datasource')}
</NButton>
<NSpace justify='end' wrap={false}>
<NInput
allowInput={this.trim}
v-model={[this.searchVal, 'value']}
size='small'
placeholder={`${t('datasource.search_input_tips')}`}
<Search
v-model:value = {this.searchVal}
placeholder = {t('datasource.search_input_tips')}
onSearch={onUpdatedList}
/>
<NButton type='primary' size='small' onClick={onUpdatedList}>
<NIcon>
Expand Down
4 changes: 2 additions & 2 deletions dolphinscheduler-ui/src/views/datasource/list/use-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { reactive } from 'vue'
import {reactive, ref} from 'vue'
import {
queryDataSourceListPaging,
deleteDataSource
Expand All @@ -26,7 +26,7 @@ export function useTable() {
page: 1,
pageSize: 10,
itemCount: 0,
searchVal: '',
searchVal: ref(''),
list: [],
loading: false
})
Expand Down
15 changes: 7 additions & 8 deletions dolphinscheduler-ui/src/views/projects/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
NButton,
NDataTable,
NIcon,
NInput,
NPagination,
NSpace
} from 'naive-ui'
Expand All @@ -34,6 +33,7 @@ import {
import { useI18n } from 'vue-i18n'
import { useTable } from './use-table'
import Card from '@/components/card'
import Search from "@/components/input-search";
import ProjectModal from './components/project-modal'

const list = defineComponent({
Expand Down Expand Up @@ -121,14 +121,13 @@ const list = defineComponent({
{t('project.list.create_project')}
</NButton>
<NSpace>
<NInput
allowInput={this.trim}
size='small'
v-model={[this.searchVal, 'value']}
placeholder={t('project.list.project_tips')}
clearable
onClear={this.onClearSearch}
<Search
v-model:value = {this.searchVal}
placeholder={t('project.list.project_tips')}
onSearch={this.handleSearch}
onClear={this.onClearSearch}
/>

<NButton size='small' type='primary' onClick={this.handleSearch}>
<NIcon>
<SearchOutlined />
Expand Down
2 changes: 1 addition & 1 deletion dolphinscheduler-ui/src/views/projects/list/use-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export function useTable() {
tableData: [],
page: ref(1),
pageSize: ref(10),
searchVal: ref(null),
searchVal: ref(''),
totalPage: ref(1),
showModalRef: ref(false),
statusRef: ref(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
NButton,
NDataTable,
NIcon,
NInput,
NPagination,
NSpace,
NTooltip,
Expand All @@ -44,6 +43,7 @@ import TimingModal from './components/timing-modal'
import VersionModal from './components/version-modal'
import CopyModal from './components/copy-modal'
import type { Router } from 'vue-router'
import Search from "@/components/input-search";

export default defineComponent({
name: 'WorkflowDefinitionList',
Expand Down Expand Up @@ -177,12 +177,10 @@ export default defineComponent({
</NButton>
</NSpace>
<NSpace>
<NInput
allowInput={this.trim}
size='small'
placeholder={t('resource.function.enter_keyword_tips')}
v-model={[this.searchVal, 'value']}
clearable
<Search
placeholder = {t('resource.function.enter_keyword_tips')}
v-model:value={this.searchVal}
onSearch={this.handleSearch}
onClear={this.onClearSearch}
/>
<NButton type='primary' size='small' onClick={this.handleSearch}>
Expand Down
11 changes: 5 additions & 6 deletions dolphinscheduler-ui/src/views/resource/file/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
NButtonGroup,
NButton,
NPagination,
NInput,
NBreadcrumb,
NBreadcrumbItem
} from 'naive-ui'
Expand All @@ -52,6 +51,7 @@ import ResourceRenameModal from './rename'
import styles from './index.module.scss'
import type { ResourceFile } from '@/service/modules/resources/types'
import type { Router } from 'vue-router'
import Search from "@/components/input-search";

export default defineComponent({
name: 'File',
Expand Down Expand Up @@ -285,11 +285,10 @@ export default defineComponent({
</NButton>
</NButtonGroup>
<NSpace>
<NInput
size='small'
allowInput={this.trim}
placeholder={t('resource.file.enter_keyword_tips')}
v-model={[this.searchRef, 'value']}
<Search
placeholder = {t('resource.file.enter_keyword_tips')}
v-model:value={this.searchRef}
onSearch={handleConditions}
/>
<NButton size='small' type='primary' onClick={handleConditions}>
<NIcon>
Expand Down
Loading

0 comments on commit b960427

Please sign in to comment.