Skip to content

Commit

Permalink
Feat: add bot filter (#350)
Browse files Browse the repository at this point in the history
Signed-off-by: laixingyou <[email protected]>
  • Loading branch information
coder-sett authored May 8, 2024
1 parent 5c21ff1 commit ff69469
Show file tree
Hide file tree
Showing 18 changed files with 411 additions and 116 deletions.
2 changes: 1 addition & 1 deletion apps/web/i18n
Submodule i18n updated 2 files
+6 −1 en/analyze.json
+7 −2 zh/analyze.json
12 changes: 9 additions & 3 deletions apps/web/src/common/components/Table/Download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
apiDownloadFiles,
Status,
} from '@modules/analyze/DataView/MetricDetail/tableDownload';
import { useTranslation } from 'react-i18next';

// 对象驼峰转下划线
const objectHumpToLine = (obj) => {
Expand All @@ -27,6 +28,7 @@ const Download = ({
query: any;
fileName: string;
}) => {
const { t } = useTranslation();
const newQuery = objectHumpToLine(query);
newQuery['sort_opts'] && (newQuery['sort_opts'] = [newQuery['sort_opts']]);

Expand Down Expand Up @@ -66,9 +68,12 @@ const Download = ({
};
return (
<>
<div className="flex h-7 w-10 cursor-pointer items-center justify-center rounded-sm border border-[#3f60ef] text-xs text-[#3f60ef]">
<div className="flex h-7 cursor-pointer items-center justify-center rounded-sm border py-2 px-3 text-sm hover:text-[#3f60ef]">
{loadingDownLoad ? (
<AiOutlineLoading className="t animate-spin" />
<>
<AiOutlineLoading className="t mr-1 animate-spin" />
{t('analyze:metric_detail.download_data')}
</>
) : (
<Tooltip arrow title={fileName} placement="top">
<div
Expand All @@ -78,7 +83,8 @@ const Download = ({
await downloadFun();
}}
>
<BsDownload />
<BsDownload className="mr-1" />
{t('analyze:metric_detail.download_data')}
</div>
</Tooltip>
)}
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/modules/academe/DataUsageProcess/DataTerms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ const DataTerms = () => {
4. 如果该学术研究成果可进行工程化部署,在不侵犯知识产权的情况下,请同意
OSS Compass 享有此成果的使用权。
<br />
5. 具体细节请查看底部协议附件。
{/* 5. 具体细节请查看底部协议附件。 */}
</p>
<h3 className="my-4 text-lg font-semibold">
{/* <h3 className="my-4 text-lg font-semibold">
附:
<a
className="underline"
Expand All @@ -80,7 +80,7 @@ const DataTerms = () => {
>
OSS Compass 项目合作框架协议书.pdf
</a>
</h3>
</h3> */}
</div>
);
const enTerms = (
Expand Down Expand Up @@ -178,9 +178,9 @@ const DataTerms = () => {
engineering without infringing intellectual property rights, please
agree to OSS Compass having the right to use these results.
<br />
5. For specific details, please see the agreement below.
{/* 5. For specific details, please see the agreement below. */}
</p>
<h3 className="my-4 text-lg font-semibold">
{/* <h3 className="my-4 text-lg font-semibold">
<a
className="underline"
download
Expand All @@ -189,7 +189,7 @@ const DataTerms = () => {
>
OSS Compass Project Cooperation Framework Agreement.pdf
</a>
</h3>
</h3> */}
</div>
);
if (i18n.language === 'en') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import {
import client from '@common/gqlClient';
import { useTranslation } from 'next-i18next';
import MetricChart from '@modules/analyze/DataView/MetricDetail/MetricChart';
import { useGetEcologicalText } from './contribution';
import { useGetEcologicalText } from '../contribution';
import { gradientRamp } from '@common/options';
import PieDropDownMenu from '../PieDropDownMenu';
import PieDropDownMenu from '../../PieDropDownMenu';
import type { EChartsOption } from 'echarts';

const ContributorContribution: React.FC<{
label: string;
level: string;
beginDate: Date;
endDate: Date;
mileage: string[];
}> = ({ label, level, beginDate, endDate, mileage }) => {
commonFilterOpts: any[];
}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => {
const [orgModel, setOrgModel] = useState<boolean>(true);
const [onlyIdentity, setOnlyIdentity] = useState<boolean>(false);
const [onlyOrg, setOnlyOrg] = useState<boolean>(false);
Expand Down Expand Up @@ -59,15 +59,15 @@ const ContributorContribution: React.FC<{
level={level}
beginDate={beginDate}
endDate={endDate}
mileage={mileage}
commonFilterOpts={commonFilterOpts}
/>
) : (
<EcoContributorContribution
label={label}
level={level}
beginDate={beginDate}
endDate={endDate}
mileage={mileage}
commonFilterOpts={commonFilterOpts}
orgModel={orgModel}
onlyIdentity={onlyIdentity}
onlyOrg={onlyOrg}
Expand Down Expand Up @@ -195,7 +195,7 @@ const EcoContributorContribution: React.FC<{
level: string;
beginDate: Date;
endDate: Date;
mileage: string[];
commonFilterOpts: any[];
orgModel: boolean;
onlyIdentity: boolean;
onlyOrg: boolean;
Expand All @@ -204,7 +204,7 @@ const EcoContributorContribution: React.FC<{
level,
beginDate,
endDate,
mileage,
commonFilterOpts,
orgModel,
onlyIdentity,
onlyOrg,
Expand All @@ -216,7 +216,7 @@ const EcoContributorContribution: React.FC<{
level: level,
beginDate: beginDate,
endDate: endDate,
filterOpts: [{ type: 'mileage_type', values: mileage }],
filterOpts: commonFilterOpts,
});
const getEcologicalText = useGetEcologicalText();
const getSeries = useMemo(() => {
Expand Down Expand Up @@ -301,16 +301,16 @@ const OrgContributorContribution: React.FC<{
level: string;
beginDate: Date;
endDate: Date;
mileage: string[];
}> = ({ label, level, beginDate, endDate, mileage }) => {
commonFilterOpts: any[];
}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => {
const { t } = useTranslation();
const chartRef = useRef<HTMLDivElement>(null);
const { data, isLoading } = useOrgContributionDistributionQuery(client, {
label: label,
level: level,
beginDate: beginDate,
endDate: endDate,
filterOpts: [{ type: 'mileage_type', values: mileage }],
filterOpts: commonFilterOpts,
});
const getEcologicalText = useGetEcologicalText();
const getSeries = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ const ContributorContribution: React.FC<{
level: string;
beginDate: Date;
endDate: Date;
mileage: string[];
}> = ({ label, level, beginDate, endDate, mileage }) => {
commonFilterOpts: any[];
}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => {
const { t } = useTranslation();
const chartRef = useRef<HTMLDivElement>(null);
const { data, isLoading } = useOrgContributorsOverviewQuery(client, {
label: label,
level: level,
beginDate: beginDate,
endDate: endDate,
filterOpts: [{ type: 'mileage_type', values: mileage }],
filterOpts: commonFilterOpts,
});
const getSeries = useMemo(() => {
const legend = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ const ContributionCount: React.FC<{
level: string;
beginDate: Date;
endDate: Date;
mileage: string[];
}> = ({ label, level, beginDate, endDate, mileage }) => {
commonFilterOpts: any[];
}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => {
return (
<div className="flex h-full lg:flex-col">
<ContributorContribution
label={label}
level={level}
beginDate={beginDate}
endDate={endDate}
mileage={mileage}
commonFilterOpts={commonFilterOpts}
/>
<ContributorOrganizations
label={label}
level={level}
beginDate={beginDate}
endDate={endDate}
mileage={mileage}
commonFilterOpts={commonFilterOpts}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ const MetricTable: React.FC<{
level: string;
beginDate: Date;
endDate: Date;
mileage: string[];
}> = ({ label, level, beginDate, endDate, mileage }) => {
commonFilterOpts: any[];
}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => {
const { t } = useTranslation();
const [openConfirm, setOpenConfirm] = useState(false);
const [currentName, setCurrentName] = useState('');
Expand All @@ -68,14 +68,6 @@ const MetricTable: React.FC<{
const router = useRouter();
const { handleQueryParams } = useHandleQueryParams();

const mileageFilter = useMemo(() => {
if (mileage.length > 0) {
return { type: 'mileage_type', values: mileage };
} else {
return null;
}
}, [mileage]);

const queryFilterOpts = router.query?.filterOpts as string;
const defaultFilterOpts = queryFilterOpts ? JSON.parse(queryFilterOpts) : [];
const defaultSortOpts = router.query?.sortOpts
Expand All @@ -101,7 +93,7 @@ const MetricTable: React.FC<{
const query = {
page: tableParams.pagination.current,
per: tableParams.pagination.pageSize,
filterOpts: [...filterOpts, mileageFilter],
filterOpts: [...filterOpts, ...commonFilterOpts],
sortOpts: tableParams.sortOpts,
label,
level,
Expand Down Expand Up @@ -330,7 +322,7 @@ const MetricTable: React.FC<{
];
return (
<>
<div className="absolute right-0 top-2">
<div className="absolute right-4 top-16">
<Download
beginFun={getContributorExport}
pollingFun={getContributorPolling}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ const ContributorContributors: React.FC<{
level: string;
beginDate: Date;
endDate: Date;
mileage: string[];
}> = ({ label, level, beginDate, endDate, mileage }) => {
commonFilterOpts: any[];
}> = ({ label, level, beginDate, endDate, commonFilterOpts }) => {
const { t } = useTranslation();
const getEcologicalText = useGetEcologicalText();
const chartRef = useRef<HTMLDivElement>(null);
Expand All @@ -137,7 +137,7 @@ const ContributorContributors: React.FC<{
level: level,
beginDate: beginDate,
endDate: endDate,
filterOpts: [{ type: 'mileage_type', values: mileage }],
filterOpts: commonFilterOpts,
});

const getSeries = useMemo(() => {
Expand Down
Loading

0 comments on commit ff69469

Please sign in to comment.