mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 14:08:06 +08:00
fix: remove duplicate code (#7763)
This commit is contained in:
parent
e66eb00bd0
commit
d6b21f4ab5
@ -159,7 +159,7 @@ func (u *BackupRepo) GetRecord(opts ...DBOption) (*model.BackupRecord, error) {
|
|||||||
|
|
||||||
func (u *BackupRepo) SyncAll(data []model.BackupAccount) error {
|
func (u *BackupRepo) SyncAll(data []model.BackupAccount) error {
|
||||||
tx := global.DB.Begin()
|
tx := global.DB.Begin()
|
||||||
if err := tx.Where("1 = 1").Delete(&model.BackupAccount{}).Error; err != nil {
|
if err := tx.Where("is_public = ?", 1).Delete(&model.BackupAccount{}).Error; err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -635,8 +635,7 @@ func handleAlert(stdout, clamName string, clamId uint) {
|
|||||||
lines := strings.Split(stdout, "\n")
|
lines := strings.Split(stdout, "\n")
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
if strings.HasPrefix(line, "Infected files: ") {
|
if strings.HasPrefix(line, "Infected files: ") {
|
||||||
var infectedFiles = 0
|
infectedFiles, _ := strconv.Atoi(strings.TrimPrefix(line, "Infected files: "))
|
||||||
infectedFiles, _ = strconv.Atoi(strings.TrimPrefix(line, "Infected files: "))
|
|
||||||
if infectedFiles > 0 {
|
if infectedFiles > 0 {
|
||||||
pushAlert := dto.PushAlert{
|
pushAlert := dto.PushAlert{
|
||||||
TaskName: clamName,
|
TaskName: clamName,
|
||||||
|
@ -70,11 +70,12 @@ func (u *DockerService) LoadDockerConf() *dto.DaemonJsonConf {
|
|||||||
var data dto.DaemonJsonConf
|
var data dto.DaemonJsonConf
|
||||||
data.IPTables = true
|
data.IPTables = true
|
||||||
data.Version = "-"
|
data.Version = "-"
|
||||||
if cmd.Which("docker") {
|
if !cmd.Which("docker") {
|
||||||
data.IsExist = false
|
data.IsExist = false
|
||||||
return &data
|
return &data
|
||||||
}
|
}
|
||||||
data.IsExist = true
|
data.IsExist = true
|
||||||
|
data.IsActive = true
|
||||||
client, err := docker.NewDockerClient()
|
client, err := docker.NewDockerClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
data.IsActive = false
|
data.IsActive = false
|
||||||
|
@ -21,7 +21,6 @@ func InitAgentDB() {
|
|||||||
migrations.InitImageRepo,
|
migrations.InitImageRepo,
|
||||||
migrations.InitDefaultCA,
|
migrations.InitDefaultCA,
|
||||||
migrations.InitPHPExtensions,
|
migrations.InitPHPExtensions,
|
||||||
migrations.InitNodePort,
|
|
||||||
migrations.InitBackup,
|
migrations.InitBackup,
|
||||||
})
|
})
|
||||||
if err := m.Migrate(); err != nil {
|
if err := m.Migrate(); err != nil {
|
||||||
|
@ -232,20 +232,6 @@ var AddTaskTable = &gormigrate.Migration{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var InitNodePort = &gormigrate.Migration{
|
|
||||||
ID: "20241226-init-node-port",
|
|
||||||
Migrate: func(tx *gorm.DB) error {
|
|
||||||
var itemPort model.Setting
|
|
||||||
_ = tx.Where("key = ?", "NodePort").First(&itemPort).Error
|
|
||||||
if itemPort.ID == 0 {
|
|
||||||
if err := tx.Create(&model.Setting{Key: "NodePort", Value: "9999"}).Error; err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
var InitBackup = &gormigrate.Migration{
|
var InitBackup = &gormigrate.Migration{
|
||||||
ID: "20241226-init-backup",
|
ID: "20241226-init-backup",
|
||||||
Migrate: func(tx *gorm.DB) error {
|
Migrate: func(tx *gorm.DB) error {
|
||||||
|
@ -131,9 +131,6 @@ var InitSetting = &gormigrate.Migration{
|
|||||||
if err := tx.Create(&model.Setting{Key: "SystemStatus", Value: "Free"}).Error; err != nil {
|
if err := tx.Create(&model.Setting{Key: "SystemStatus", Value: "Free"}).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := tx.Create(&model.Setting{Key: "MasterRequestAddr", Value: ""}).Error; err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := tx.Create(&model.Setting{Key: "BindAddress", Value: "0.0.0.0"}).Error; err != nil {
|
if err := tx.Create(&model.Setting{Key: "BindAddress", Value: "0.0.0.0"}).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,8 @@ export namespace Container {
|
|||||||
}
|
}
|
||||||
export interface DaemonJsonConf {
|
export interface DaemonJsonConf {
|
||||||
isSwarm: boolean;
|
isSwarm: boolean;
|
||||||
status: string;
|
isExist: boolean;
|
||||||
|
isActive: boolean;
|
||||||
version: string;
|
version: string;
|
||||||
registryMirrors: Array<string>;
|
registryMirrors: Array<string>;
|
||||||
insecureRegistries: Array<string>;
|
insecureRegistries: Array<string>;
|
||||||
|
@ -41,7 +41,7 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const statusItem = computed(() => {
|
const statusItem = computed(() => {
|
||||||
return props.status.toLowerCase() || '';
|
return props.status?.toLowerCase() || '';
|
||||||
});
|
});
|
||||||
|
|
||||||
const getType = (status: string) => {
|
const getType = (status: string) => {
|
||||||
|
@ -5,20 +5,14 @@
|
|||||||
<div class="flex w-full flex-col gap-4 md:flex-row">
|
<div class="flex w-full flex-col gap-4 md:flex-row">
|
||||||
<div class="flex flex-wrap gap-4">
|
<div class="flex flex-wrap gap-4">
|
||||||
<el-tag class="float-left" effect="dark" type="success">Docker</el-tag>
|
<el-tag class="float-left" effect="dark" type="success">Docker</el-tag>
|
||||||
<Status class="mt-0.5" :status="form.status" />
|
<Status class="mt-0.5" :status="form.isActive ? 'enable' : 'disable'" />
|
||||||
<el-tag>{{ $t('app.version') }}: {{ form.version }}</el-tag>
|
<el-tag>{{ $t('app.version') }}: {{ form.version }}</el-tag>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-0.5" v-if="form.status === 'Running'">
|
<div class="mt-0.5">
|
||||||
<el-button type="primary" @click="onOperator('stop')" link>
|
<el-button v-if="form.isActive" type="primary" @click="onOperator('stop')" link>
|
||||||
{{ $t('container.stop') }}
|
{{ $t('container.stop') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-divider direction="vertical" />
|
<el-button v-if="!form.isActive" type="primary" @click="onOperator('start')" link>
|
||||||
<el-button type="primary" @click="onOperator('restart')" link>
|
|
||||||
{{ $t('container.restart') }}
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="mt-0.5" v-if="form.status === 'Stopped'">
|
|
||||||
<el-button type="primary" @click="onOperator('start')" link>
|
|
||||||
{{ $t('container.start') }}
|
{{ $t('container.start') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-divider direction="vertical" />
|
<el-divider direction="vertical" />
|
||||||
@ -270,7 +264,8 @@ const sockPathRef = ref();
|
|||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
isSwarm: false,
|
isSwarm: false,
|
||||||
status: '',
|
isActive: false,
|
||||||
|
isExist: false,
|
||||||
version: '',
|
version: '',
|
||||||
mirrors: '',
|
mirrors: '',
|
||||||
registries: '',
|
registries: '',
|
||||||
@ -480,7 +475,8 @@ const changeMode = async () => {
|
|||||||
const search = async () => {
|
const search = async () => {
|
||||||
const res = await loadDaemonJson();
|
const res = await loadDaemonJson();
|
||||||
form.isSwarm = res.data.isSwarm;
|
form.isSwarm = res.data.isSwarm;
|
||||||
form.status = res.data.status;
|
form.isActive = res.data.isActive;
|
||||||
|
form.isExist = res.data.isExist;
|
||||||
form.version = res.data.version;
|
form.version = res.data.version;
|
||||||
form.cgroupDriver = res.data.cgroupDriver || 'cgroupfs';
|
form.cgroupDriver = res.data.cgroupDriver || 'cgroupfs';
|
||||||
form.liveRestore = res.data.liveRestore;
|
form.liveRestore = res.data.liveRestore;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user