Skip to content

Commit

Permalink
feat(filter): added filters to list pages
Browse files Browse the repository at this point in the history
AB#13
  • Loading branch information
tikazyq committed Nov 2, 2022
1 parent df73775 commit b6eeedf
Show file tree
Hide file tree
Showing 30 changed files with 596 additions and 50 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crawlab-ui",
"version": "0.6.0-16",
"version": "0.6.0-17",
"private": false,
"author": {
"name": "Marvin Zhang",
Expand Down
20 changes: 20 additions & 0 deletions src/components/filter/FilterSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
{{ label }}
</label>
<el-select
class="content"
v-model="internalModelValue"
:placeholder="placeholder"
:filterable="filterable"
clearable
@clear="onClear"
@change="onChange"
Expand Down Expand Up @@ -38,6 +40,10 @@ export default defineComponent({
placeholder: {
type: String,
},
filterable: {
type: Boolean,
default: true,
},
options: {
type: Array as PropType<SelectOption[]>,
},
Expand All @@ -58,10 +64,12 @@ export default defineComponent({
});
const onChange = (value: any) => {
if (value === '') return;
emit('change', value);
};
const onClear = () => {
internalModelValue.value = undefined;
emit('change', undefined);
};
Expand Down Expand Up @@ -90,4 +98,16 @@ export default defineComponent({
</script>

<style lang="scss" scoped>
.filter-select {
display: flex;
align-items: center;
flex: 1 0 auto;
.label {
}
.content {
flex: 1 0 180px;
}
}
</style>
21 changes: 13 additions & 8 deletions src/components/nav/NavActionGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,26 @@ export default defineComponent({
@import "../../styles/variables.scss";
.nav-action-group {
height: auto;
height: fit-content;
display: flex;
align-items: center;
align-items: start;
box-sizing: border-box;
flex-wrap: wrap;
position: relative;
& + .nav-action-group {
//padding-left: 10px;
margin-left: 10px;
}
.border {
margin-left: -10px;
margin-right: 10px;
border-left: 1px solid $navActionsGroupBorderColor;
height: calc(100% - 20px);
}
.border {
position: absolute;
left: 0;
top: 10px;
margin-left: -10px;
margin-right: 10px;
border-left: 1px solid $navActionsGroupBorderColor;
height: calc(100% - 20px);
}
}
</style>
Expand Down
3 changes: 2 additions & 1 deletion src/components/nav/NavActionItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export default defineComponent({
.nav-action-item {
margin: 10px 0;
height: auto;
height: fit-content;
display: flex;
flex: 0 0 auto;
align-items: center;
color: $navActionsItemColor;
Expand Down
13 changes: 7 additions & 6 deletions src/components/nav/NavActions.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<div
ref="navActions"
:class="classes"
:style="style"
class="nav-actions"
ref="navActions"
:class="classes"
:style="style"
class="nav-actions"
>
<slot></slot>
</div>
Expand Down Expand Up @@ -33,7 +33,7 @@ export default defineComponent({
const style = computed(() => {
return {
height: height.value,
// height: height.value,
minHeight: height.value,
};
});
Expand Down Expand Up @@ -86,10 +86,11 @@ export default defineComponent({
padding: 0 10px;
min-height: 50px;
display: flex;
flex-wrap: wrap;
flex-wrap: nowrap;
height: fit-content;
border-bottom: 1px solid $infoBorderColor;
transition: all $navActionsCollapseTransitionDuration;
overflow-x: auto;
overflow-y: hidden;
box-sizing: border-box;
Expand Down
6 changes: 6 additions & 0 deletions src/components/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,19 @@ const useUser = (store: Store<RootStoreState>) => {
await ElMessage.success(t('common.message.success.save'));
};

const rolesOptions: SelectOption[] = [
{label: t('components.user.role.admin'), value: ROLE_ADMIN},
{label: t('components.user.role.normal'), value: ROLE_NORMAL},
];

return {
...useForm('user', store, useUserService(store), formComponentData),
modeOptions,
batchFormFields,
formRules,
allUserSelectOptions,
onChangePasswordFunc,
rolesOptions,
};
};

Expand Down
15 changes: 15 additions & 0 deletions src/i18n/lang/en/views/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ const nodes: LViewsNodes = {
}
}
},
navActionsExtra: {
filter: {
select: {
type: {
label: 'Node Type'
},
status: {
label: 'Status'
},
enabled: {
label: 'Enabled'
},
}
}
},
notice: {
create: {
title: 'Create Node',
Expand Down
20 changes: 20 additions & 0 deletions src/i18n/lang/en/views/schedules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ const schedules: LViewsSchedules = {
placeholder: 'Search schedules',
}
}
},
navActionsExtra: {
filter: {
select: {
spider: {
label: 'Spider',
},
mode: {
label: 'Mode',
},
enabled: {
label: 'Enabled',
}
},
search: {
cron: {
placeholder: 'Search cron expression',
}
}
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/i18n/lang/en/views/spiders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const spiders: LViewsSpiders = {
filter: {
select: {
project: {
label: 'Project'
label: 'Project',
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/lang/en/views/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,32 @@ const tasks: LViewsTasks = {
placeholder: 'Search tasks',
}
}
},
navActionsExtra: {
filter: {
select: {
node: {
label: 'Node',
},
spider: {
label: 'Spider',
},
schedule: {
label: 'Schedule',
},
priority: {
label: 'Priority',
},
status: {
label: 'Status',
}
},
search: {
cmd: {
placeholder: 'Search Execute Command',
}
}
},
}
};

Expand Down
14 changes: 14 additions & 0 deletions src/i18n/lang/en/views/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ const users: LViewsUsers = {
placeholder: 'Search users',
}
}
},
navActionsExtra: {
filter: {
select: {
role: {
label: 'Role',
}
},
search: {
email: {
placeholder: 'Search email',
}
}
}
}
};

Expand Down
15 changes: 15 additions & 0 deletions src/i18n/lang/zh/views/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ const nodes: LViewsNodes = {
}
}
},
navActionsExtra: {
filter: {
select: {
type: {
label: '节点类别'
},
status: {
label: '状态'
},
enabled: {
label: '是否启用'
},
}
}
},
notice: {
create: {
title: '创建节点',
Expand Down
20 changes: 20 additions & 0 deletions src/i18n/lang/zh/views/schedules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@ const schedules: LViewsSchedules = {
placeholder: '搜索定时任务',
}
}
},
navActionsExtra: {
filter: {
select: {
spider: {
label: '爬虫',
},
mode: {
label: '模式',
},
enabled: {
label: '是否启用',
}
},
search: {
cron: {
placeholder: '搜索 Cron 表达式',
}
}
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/i18n/lang/zh/views/spiders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const spiders: LViewsSpiders = {
filter: {
select: {
project: {
label: '项目'
label: '项目',
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/i18n/lang/zh/views/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,32 @@ const tasks: LViewsTasks = {
placeholder: '搜索任务',
}
}
},
navActionsExtra: {
filter: {
select: {
node: {
label: '节点',
},
spider: {
label: '爬虫',
},
schedule: {
label: '定时任务',
},
priority: {
label: '优先级',
},
status: {
label: '状态',
}
},
search: {
cmd: {
placeholder: '搜索执行命令',
}
}
},
}
};

Expand Down
14 changes: 14 additions & 0 deletions src/i18n/lang/zh/views/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ const users: LViewsUsers = {
placeholder: '搜索用户',
}
}
},
navActionsExtra: {
filter: {
select: {
role: {
label: '角色',
}
},
search: {
email: {
placeholder: '搜索邮箱',
}
}
}
}
};

Expand Down
1 change: 1 addition & 0 deletions src/interfaces/components/filter/FilterSelect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export declare global {
interface FilterSelectProps {
label?: string;
placeholder?: string;
filterable?: boolean;
options?: SelectOption[];
optionsRemote?: FilterSelectOptionsRemote;
}
Expand Down
Loading

0 comments on commit b6eeedf

Please sign in to comment.