forked from infiniflow/ragflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add GoogleScholar infiniflow#918 (infiniflow#1818)
### What problem does this PR solve? feat: Add GoogleScholar infiniflow#918 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
- Loading branch information
Showing
10 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,8 @@ | |
} | ||
} | ||
} | ||
|
||
.uploadLimit { | ||
color: red; | ||
font-size: 12px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import TopNItem from '@/components/top-n-item'; | ||
import { useTranslate } from '@/hooks/common-hooks'; | ||
import { DatePicker, DatePickerProps, Form, Select, Switch } from 'antd'; | ||
import dayjs from 'dayjs'; | ||
import { useCallback, useMemo } from 'react'; | ||
import { IOperatorForm } from '../interface'; | ||
|
||
const YearPicker = ({ | ||
onChange, | ||
value, | ||
}: { | ||
onChange?: (val: number | undefined) => void; | ||
value?: number | undefined; | ||
}) => { | ||
const handleChange: DatePickerProps['onChange'] = useCallback( | ||
(val: any) => { | ||
const nextVal = val?.format('YYYY'); | ||
onChange?.(nextVal ? Number(nextVal) : undefined); | ||
}, | ||
[onChange], | ||
); | ||
// The year needs to be converted into a number and saved to the backend | ||
const nextValue = useMemo(() => { | ||
if (value) { | ||
return dayjs(value.toString()); | ||
} | ||
return undefined; | ||
}, [value]); | ||
|
||
return <DatePicker picker="year" onChange={handleChange} value={nextValue} />; | ||
}; | ||
|
||
const GoogleScholarForm = ({ onValuesChange, form }: IOperatorForm) => { | ||
const { t } = useTranslate('flow'); | ||
|
||
const options = useMemo(() => { | ||
return ['data', 'relevance'].map((x) => ({ | ||
value: x, | ||
label: t(x), | ||
})); | ||
}, [t]); | ||
|
||
return ( | ||
<Form | ||
name="basic" | ||
labelCol={{ span: 6 }} | ||
wrapperCol={{ span: 18 }} | ||
autoComplete="off" | ||
form={form} | ||
onValuesChange={onValuesChange} | ||
> | ||
<TopNItem initialValue={5}></TopNItem> | ||
<Form.Item | ||
label={t('sortBy')} | ||
name={'sort_by'} | ||
initialValue={'relevance'} | ||
> | ||
<Select options={options}></Select> | ||
</Form.Item> | ||
<Form.Item label={t('yearLow')} name={'year_low'}> | ||
<YearPicker /> | ||
</Form.Item> | ||
<Form.Item label={t('yearHigh')} name={'year_high'}> | ||
<YearPicker /> | ||
</Form.Item> | ||
<Form.Item | ||
label={t('patents')} | ||
name={'patents'} | ||
valuePropName="checked" | ||
initialValue={true} | ||
> | ||
<Switch></Switch> | ||
</Form.Item> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default GoogleScholarForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters