完善拉取公开仓库

This commit is contained in:
whyour
2022-05-17 00:42:18 +08:00
parent f1a51638a5
commit 4e7a5c637d
9 changed files with 75 additions and 47 deletions
+8 -25
View File
@@ -200,18 +200,9 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
},
},
render: (text: string, record: any) => {
const language = navigator.language || navigator.languages[0];
return (
<span
style={{
display: 'block',
}}
>
{record.last_running_time
? diffTime(record.last_running_time)
: '-'}
</span>
);
return record.last_running_time
? diffTime(record.last_running_time)
: '-';
},
},
{
@@ -225,19 +216,11 @@ const Crontab = ({ headerStyle, isPhone, theme }: any) => {
},
render: (text: string, record: any) => {
const language = navigator.language || navigator.languages[0];
return (
<span
style={{
display: 'block',
}}
>
{record.nextRunTime
.toLocaleString(language, {
hour12: false,
})
.replace(' 24:', ' 00:')}
</span>
);
return record.nextRunTime
.toLocaleString(language, {
hour12: false,
})
.replace(' 24:', ' 00:');
},
},
+1 -1
View File
@@ -95,7 +95,7 @@ const CronLogModal = ({
<>
{(executing || loading) && <Loading3QuartersOutlined spin />}
{!executing && !loading && <CheckCircleOutlined />}
<span style={{ marginLeft: 5 }}>-{cron && cron.name}</span>{' '}
<span style={{ marginLeft: 5 }}>{cron && cron.name}</span>
</>
);
};
+2 -2
View File
@@ -21,7 +21,7 @@ const columns = [
align: 'center' as const,
width: 50,
render: (text: string, record: any, index: number) => {
return <span style={{ cursor: 'text' }}>{index + 1} </span>;
return index + 1;
},
},
{
@@ -30,7 +30,7 @@ const columns = [
key: 'timestamp',
align: 'center' as const,
render: (text: string, record: any) => {
return <span>{new Date(record.timestamp).toLocaleString()}</span>;
return new Date(record.timestamp).toLocaleString();
},
},
{
+39 -9
View File
@@ -51,7 +51,7 @@ export enum IntervalSchedule {
'seconds' = '秒',
}
const Subscription = ({ headerStyle, isPhone, theme }: any) => {
const Subscription = ({ headerStyle, isPhone, socketMessage }: any) => {
const columns: any = [
{
title: '名称',
@@ -73,6 +73,20 @@ const Subscription = ({ headerStyle, isPhone, theme }: any) => {
compare: (a: any, b: any) => a.name.localeCompare(b.name),
multiple: 2,
},
render: (text: string, record: any) => {
return (
<Paragraph
style={{
wordBreak: 'break-all',
marginBottom: 0,
textAlign: 'left',
}}
ellipsis={{ tooltip: text, rows: 2 }}
>
{text}
</Paragraph>
);
},
},
{
title: '分支',
@@ -80,20 +94,20 @@ const Subscription = ({ headerStyle, isPhone, theme }: any) => {
key: 'branch',
width: 130,
align: 'center' as const,
render: (text: string, record: any) => {
return record.branch || '-';
},
},
{
title: '定时规则',
width: 180,
align: 'center' as const,
render: (text: string, record: any) => {
const { type, value } = record.interval_schedule;
return (
<span>
{record.schedule_type === 'interval'
? `${value}${(IntervalSchedule as any)[type]}`
: record.schedule}
</span>
);
if (record.schedule_type === 'interval') {
const { type, value } = record.interval_schedule;
return `${value}${(IntervalSchedule as any)[type]}`;
}
return record.schedule;
},
},
{
@@ -472,6 +486,22 @@ const Subscription = ({ headerStyle, isPhone, theme }: any) => {
: 'subscription';
};
useEffect(() => {
if (!socketMessage) return;
const { type, message, references } = socketMessage;
if (type === 'runSubscriptionEnd' && references.length > 0) {
const result = [...value];
for (let i = 0; i < references.length; i++) {
const index = value.findIndex((x) => x.id === references[i]);
result.splice(index, 1, {
...result[index],
status: SubscriptionStatus.idle,
});
}
setValue(result);
}
}, [socketMessage]);
useEffect(() => {
if (logSubscription) {
localStorage.setItem('logSubscription', logSubscription.id);
+2 -2
View File
@@ -68,8 +68,8 @@ const SubscriptionLogModal = ({
{(executing || loading) && <Loading3QuartersOutlined spin />}
{!executing && !loading && <CheckCircleOutlined />}
<span style={{ marginLeft: 5 }}>
-{subscription && subscription.name}
</span>{' '}
{subscription && subscription.name}
</span>
</>
);
};
+6 -3
View File
@@ -174,6 +174,9 @@ const SubscriptionModal = ({
setType((subscription && subscription.type) || 'public-repo');
setScheduleType((subscription && subscription.schedule_type) || 'crontab');
setPullType((subscription && subscription.pull_type) || 'ssh-key');
if (!subscription) {
form.resetFields();
}
}, [subscription, visible]);
return (
@@ -300,7 +303,7 @@ const SubscriptionModal = ({
{type !== 'file' && (
<>
<Form.Item
name="command"
name="whitelist"
label="白名单"
rules={[{ whitespace: true }]}
tooltip="多个关键词竖线分割,支持正则表达式"
@@ -312,7 +315,7 @@ const SubscriptionModal = ({
/>
</Form.Item>
<Form.Item
name="command"
name="blacklist"
label="黑名单"
rules={[{ whitespace: true }]}
tooltip="多个关键词竖线分割,支持正则表达式"
@@ -324,7 +327,7 @@ const SubscriptionModal = ({
/>
</Form.Item>
<Form.Item
name="command"
name="dependences"
label="依赖文件"
rules={[{ whitespace: true }]}
tooltip="多个关键词竖线分割,支持正则表达式"