mirror of https://github.com/openspug/spug
improve the creation of custom request
parent
0e6e618cef
commit
54d5649663
|
@ -98,6 +98,7 @@ class DeployExtend2(models.Model, ModelMixin):
|
||||||
deploy = models.OneToOneField(Deploy, primary_key=True, on_delete=models.CASCADE)
|
deploy = models.OneToOneField(Deploy, primary_key=True, on_delete=models.CASCADE)
|
||||||
server_actions = models.TextField()
|
server_actions = models.TextField()
|
||||||
host_actions = models.TextField()
|
host_actions = models.TextField()
|
||||||
|
require_upload = models.BooleanField(default=False)
|
||||||
|
|
||||||
def to_dict(self, *args, **kwargs):
|
def to_dict(self, *args, **kwargs):
|
||||||
tmp = super().to_dict(*args, **kwargs)
|
tmp = super().to_dict(*args, **kwargs)
|
||||||
|
|
|
@ -151,6 +151,7 @@ class DeployView(View):
|
||||||
return json_response(error=error)
|
return json_response(error=error)
|
||||||
if len(extend_form.server_actions) + len(extend_form.host_actions) == 0:
|
if len(extend_form.server_actions) + len(extend_form.host_actions) == 0:
|
||||||
return json_response(error='请至少设置一个执行的动作')
|
return json_response(error='请至少设置一个执行的动作')
|
||||||
|
extend_form.require_upload = any(x.get('src_mode') == '1' for x in extend_form.host_actions)
|
||||||
extend_form.server_actions = json.dumps(extend_form.server_actions)
|
extend_form.server_actions = json.dumps(extend_form.server_actions)
|
||||||
extend_form.host_actions = json.dumps(extend_form.host_actions)
|
extend_form.host_actions = json.dumps(extend_form.host_actions)
|
||||||
if form.id:
|
if form.id:
|
||||||
|
|
|
@ -69,7 +69,7 @@ export default observer(function () {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const {app_host_ids, deploy_id, type} = store.record;
|
const {app_host_ids, deploy_id, type, require_upload} = store.record;
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
visible
|
visible
|
||||||
|
@ -89,12 +89,14 @@ export default observer(function () {
|
||||||
tooltip="可以在自定义脚本中引用该变量,用于设置本次发布相关的动态变量,在脚本中通过 $SPUG_RELEASE 来使用该值。">
|
tooltip="可以在自定义脚本中引用该变量,用于设置本次发布相关的动态变量,在脚本中通过 $SPUG_RELEASE 来使用该值。">
|
||||||
<Input placeholder="请输入环境变量 SPUG_RELEASE 的值"/>
|
<Input placeholder="请输入环境变量 SPUG_RELEASE 的值"/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label="上传数据" tooltip="通过数据传输动作来使用上传的文件。" className={styles.upload}>
|
{require_upload && (
|
||||||
<Upload name="file" fileList={fileList} headers={{'X-Token': X_TOKEN}} beforeUpload={handleUpload}
|
<Form.Item required label="上传数据" tooltip="通过数据传输动作来使用上传的文件。" className={styles.upload}>
|
||||||
data={{deploy_id}} onChange={handleUploadChange}>
|
<Upload name="file" fileList={fileList} headers={{'X-Token': X_TOKEN}} beforeUpload={handleUpload}
|
||||||
{fileList.length === 0 ? <Button loading={uploading} icon={<UploadOutlined/>}>点击上传</Button> : null}
|
data={{deploy_id}} onChange={handleUploadChange}>
|
||||||
</Upload>
|
{fileList.length === 0 ? <Button loading={uploading} icon={<UploadOutlined/>}>点击上传</Button> : null}
|
||||||
</Form.Item>
|
</Upload>
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
<Form.Item required label="目标主机" tooltip="可以通过创建多个发布申请单,选择主机分批发布。">
|
<Form.Item required label="目标主机" tooltip="可以通过创建多个发布申请单,选择主机分批发布。">
|
||||||
{host_ids.length > 0 && `已选择 ${host_ids.length} 台(可选${app_host_ids.length})`}
|
{host_ids.length > 0 && `已选择 ${host_ids.length} 台(可选${app_host_ids.length})`}
|
||||||
<Button type="link" onClick={() => setVisible(true)}>选择主机</Button>
|
<Button type="link" onClick={() => setVisible(true)}>选择主机</Button>
|
||||||
|
|
|
@ -32,9 +32,9 @@ class Store {
|
||||||
if (this.f_app_id) data = data.filter(x => x.app_id === this.f_app_id)
|
if (this.f_app_id) data = data.filter(x => x.app_id === this.f_app_id)
|
||||||
if (this.f_env_id) data = data.filter(x => x.env_id === this.f_env_id)
|
if (this.f_env_id) data = data.filter(x => x.env_id === this.f_env_id)
|
||||||
if (this.f_s_date) data = data.filter(x => {
|
if (this.f_s_date) data = data.filter(x => {
|
||||||
const date = x.created_at.substr(0, 10);
|
const date = x.created_at.substr(0, 10);
|
||||||
return date >= this.f_s_date && date <= this.f_e_date
|
return date >= this.f_s_date && date <= this.f_e_date
|
||||||
})
|
})
|
||||||
if (this.f_status !== 'all') {
|
if (this.f_status !== 'all') {
|
||||||
if (this.f_status === '99') {
|
if (this.f_status === '99') {
|
||||||
data = data.filter(x => ['-1', '2'].includes(x.status))
|
data = data.filter(x => ['-1', '2'].includes(x.status))
|
||||||
|
@ -84,7 +84,8 @@ class Store {
|
||||||
};
|
};
|
||||||
|
|
||||||
confirmAdd = (deploy) => {
|
confirmAdd = (deploy) => {
|
||||||
this.record = {deploy_id: deploy.id, app_host_ids: deploy.host_ids};
|
const {id, host_ids, require_upload} = deploy;
|
||||||
|
this.record = {deploy_id: id, app_host_ids: host_ids, require_upload};
|
||||||
if (deploy.extend === '1') {
|
if (deploy.extend === '1') {
|
||||||
this.ext1Visible = true
|
this.ext1Visible = true
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue