[Core] Add version for source (#407)

This commit is contained in:
qianmoQ 2023-08-07 21:47:07 +08:00 committed by GitHub
commit aa84547f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 88 additions and 12 deletions

View File

@ -0,0 +1,7 @@
USE `datacap`;
ALTER TABLE `source`
ADD COLUMN `version` VARCHAR(255) DEFAULT NULL,
ADD COLUMN `available` BOOLEAN DEFAULT TRUE,
ADD COLUMN `message` TEXT DEFAULT NULL,
ADD COLUMN `update_time` DATETIME DEFAULT NULL;

View File

@ -15,5 +15,6 @@ public class SourceBody
private Long id; private Long id;
private String type; private String type;
private String name; private String name;
private String version;
private IConfigure configure; private IConfigure configure;
} }

View File

@ -12,10 +12,14 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
@ -38,6 +42,7 @@ import java.util.Map;
@Entity @Entity
@Table(name = "source") @Table(name = "source")
@JsonIgnoreProperties(value = {"configure", "pluginAudits"}) @JsonIgnoreProperties(value = {"configure", "pluginAudits"})
@EntityListeners(AuditingEntityListener.class)
@org.hibernate.annotations.Table(appliesTo = "source", comment = "The storage is used to query the data connection source") @org.hibernate.annotations.Table(appliesTo = "source", comment = "The storage is used to query the data connection source")
@SuppressFBWarnings(value = {"EI_EXPOSE_REP"}, @SuppressFBWarnings(value = {"EI_EXPOSE_REP"},
justification = "I prefer to suppress these FindBugs warnings") justification = "I prefer to suppress these FindBugs warnings")
@ -82,9 +87,6 @@ public class SourceEntity
@Column(name = "_database") @Column(name = "_database")
private String database; private String database;
@Column(name = "create_time", columnDefinition = "datetime default CURRENT_TIMESTAMP()")
private Timestamp createTime;
// Add from 1.1.0.20221115 // Add from 1.1.0.20221115
@Column(name = "_ssl", columnDefinition = "boolean default false") @Column(name = "_ssl", columnDefinition = "boolean default false")
private Boolean ssl; private Boolean ssl;
@ -102,15 +104,32 @@ public class SourceEntity
@JsonProperty(value = "configure") @JsonProperty(value = "configure")
private String configure; private String configure;
@Column(name = "used_config")
private boolean usedConfig;
@Column(name = "version")
private String version;
@Column(name = "available")
private Boolean available;
@Column(name = "message")
private String message;
@Column(name = "create_time")
@CreatedDate
private Timestamp createTime;
@Column(name = "update_time")
@LastModifiedDate
private Timestamp updateTime;
@Transient @Transient
private Map<String, Object> configures; private Map<String, Object> configures;
@Transient @Transient
private IConfigure schema; private IConfigure schema;
@Column(name = "used_config")
private boolean usedConfig;
@ManyToOne @ManyToOne
@JoinColumn(name = "user_id") @JoinColumn(name = "user_id")
@JsonIncludeProperties(value = {"id", "username"}) @JsonIncludeProperties(value = {"id", "username"})

View File

@ -249,7 +249,13 @@ public class SourceServiceImpl
if (ObjectUtils.isNotEmpty(configure.getId()) && configure.getId() > 0) { if (ObjectUtils.isNotEmpty(configure.getId()) && configure.getId() > 0) {
source.setId(configure.getId()); source.setId(configure.getId());
} }
if (StringUtils.isNotEmpty(configure.getVersion())) {
source.setVersion(configure.getVersion());
source.setAvailable(true);
}
else {
source.setAvailable(false);
}
this.sourceRepository.save(source); this.sourceRepository.save(source);
// Copy file to local data // Copy file to local data
if (source.isUsedConfig()) { if (source.isUsedConfig()) {

View File

@ -125,4 +125,6 @@ export default {
seconds: 'Seconds', seconds: 'Seconds',
avatar: 'Avatar', avatar: 'Avatar',
text: 'Text', text: 'Text',
version: 'Version',
available: 'Available',
} }

View File

@ -124,5 +124,7 @@ export default {
timeout: '超时时间', timeout: '超时时间',
seconds: '秒', seconds: '秒',
avatar: '头像', avatar: '头像',
text: '文本' text: '文本',
version: '版本',
available: '可用',
} }

View File

@ -14,5 +14,6 @@ export interface SourceModel
createTime?: number; createTime?: number;
ssl?: boolean; ssl?: boolean;
configures: {}; configures: {};
file?: [] file?: [];
version?: string;
} }

View File

@ -19,8 +19,24 @@
<template #host="{ row }"> <template #host="{ row }">
<Ellipsis :text="row.host" :length="8" tooltip transfer/> <Ellipsis :text="row.host" :length="8" tooltip transfer/>
</template> </template>
<template #version="{ row }">
<Tag v-if="row.version"
color="primary">
{{ row.version }}
</Tag>
</template>
<template #available="{ row }">
<Button :type="row.available ? 'success' : 'error'"
:icon="row.available ? 'md-checkmark-circle' : 'md-close-circle'"
shape="circle"
size="small">
</Button>
</template>
<template #public="{ row }"> <template #public="{ row }">
<Switch v-model="row.public" :disabled="currentUserId !== row.user.id" @on-change="handlerShared(row.public, row.id)"/> <Switch v-model="row.public"
:disabled="currentUserId !== row.user.id"
@on-change="handlerShared(row.public, row.id)">
</Switch>
</template> </template>
<template #action="{ row }"> <template #action="{ row }">
<Space> <Space>

View File

@ -15,8 +15,10 @@
<Col :span="6"> <Col :span="6">
<Card :bordered="false" dis-hover> <Card :bordered="false" dis-hover>
<div style="text-align:center"> <div style="text-align:center">
<Progress :percent="testInfo.percent" :status="(testInfo.connected && testInfo.successful) ? 'success' : 'wrong'"> <Progress :percent="testInfo.percent"
:status="(testInfo.connected && testInfo.successful) ? 'success' : 'wrong'">
</Progress> </Progress>
{{ formState.version }}
</div> </div>
</Card> </Card>
</Col> </Col>
@ -241,7 +243,8 @@ export default defineComponent({
id: this.id, id: this.id,
type: type, type: type,
name: name, name: name,
configure: this.applyPlugin configure: this.applyPlugin,
version: this.formState.version
}; };
SourceV2Service.saveAndUpdate(configure, this.isUpdate) SourceV2Service.saveAndUpdate(configure, this.isUpdate)
.then((response) => { .then((response) => {
@ -277,6 +280,7 @@ export default defineComponent({
this.$Message.success("Test successful"); this.$Message.success("Test successful");
this.testInfo.connected = true; this.testInfo.connected = true;
this.testInfo.successful = true; this.testInfo.successful = true;
this.formState.version = response.data?.columns[0]?.version;
} }
else { else {
this.$Message.error(response.message); this.$Message.error(response.message);

View File

@ -52,12 +52,30 @@ const createHeaders = (i18n: any) => {
slot: 'public', slot: 'public',
key: 'public' key: 'public'
}, },
{
title: i18n.t('common.version'),
slot: 'version',
align: 'center'
},
{
title: i18n.t('common.available'),
key: 'available',
slot: 'available',
ellipsis: true,
align: 'center'
},
{ {
title: i18n.t('common.createTime'), title: i18n.t('common.createTime'),
key: 'createTime', key: 'createTime',
ellipsis: true, ellipsis: true,
tooltip: true tooltip: true
}, },
{
title: i18n.t('common.updateTime'),
key: 'updateTime',
ellipsis: true,
tooltip: true
},
{ {
title: i18n.t('common.action'), title: i18n.t('common.action'),
slot: 'action', slot: 'action',