Add subscription filter to crontab page

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-11-07 16:15:16 +00:00
parent ef98aa22d2
commit a05d5df470

View File

@ -270,7 +270,13 @@ const Crontab = () => {
},
{
title: intl.get('关联订阅'),
key: 'sub_id',
dataIndex: 'sub_id',
width: 185,
filters: allSubscriptions.map((sub) => ({
text: sub.name || sub.alias,
value: sub.id,
})),
render: (text, record: any) => record?.subscription?.name || '-',
},
{
@ -347,6 +353,7 @@ const Crontab = () => {
const tableRef = useRef<HTMLDivElement>(null);
const tableScrollHeight = useTableScrollHeight(tableRef);
const [activeKey, setActiveKey] = useState('');
const [allSubscriptions, setAllSubscriptions] = useState<any[]>([]);
const goToScriptManager = (record: any) => {
const result = getCommandScript(record.command);
@ -801,6 +808,7 @@ const Crontab = () => {
useEffect(() => {
getCronViews();
getAllSubscriptions();
}, []);
const viewAction = (key: string) => {
@ -886,6 +894,19 @@ const Crontab = () => {
});
};
const getAllSubscriptions = () => {
request
.get(`${config.apiPrefix}subscriptions`)
.then(({ code, data }) => {
if (code === 200) {
setAllSubscriptions(data || []);
}
})
.catch(() => {
// Silently fail if subscriptions can't be loaded
});
};
const tabClick = (key: string) => {
const view = enabledCronViews.find((x) => x.id == key);
setSelectedRowIds([]);