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 {
|
||||
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()
|
||||
return err
|
||||
}
|
||||
|
@ -635,8 +635,7 @@ func handleAlert(stdout, clamName string, clamId uint) {
|
||||
lines := strings.Split(stdout, "\n")
|
||||
for _, line := range lines {
|
||||
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 {
|
||||
pushAlert := dto.PushAlert{
|
||||
TaskName: clamName,
|
||||
|
@ -70,11 +70,12 @@ func (u *DockerService) LoadDockerConf() *dto.DaemonJsonConf {
|
||||
var data dto.DaemonJsonConf
|
||||
data.IPTables = true
|
||||
data.Version = "-"
|
||||
if cmd.Which("docker") {
|
||||
if !cmd.Which("docker") {
|
||||
data.IsExist = false
|
||||
return &data
|
||||
}
|
||||
data.IsExist = true
|
||||
data.IsActive = true
|
||||
client, err := docker.NewDockerClient()
|
||||
if err != nil {
|
||||
data.IsActive = false
|
||||
|
@ -21,7 +21,6 @@ func InitAgentDB() {
|
||||
migrations.InitImageRepo,
|
||||
migrations.InitDefaultCA,
|
||||
migrations.InitPHPExtensions,
|
||||
migrations.InitNodePort,
|
||||
migrations.InitBackup,
|
||||
})
|
||||
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{
|
||||
ID: "20241226-init-backup",
|
||||
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 {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
@ -330,7 +330,8 @@ export namespace Container {
|
||||
}
|
||||
export interface DaemonJsonConf {
|
||||
isSwarm: boolean;
|
||||
status: string;
|
||||
isExist: boolean;
|
||||
isActive: boolean;
|
||||
version: string;
|
||||
registryMirrors: Array<string>;
|
||||
insecureRegistries: Array<string>;
|
||||
|
@ -41,7 +41,7 @@ const props = defineProps({
|
||||
});
|
||||
|
||||
const statusItem = computed(() => {
|
||||
return props.status.toLowerCase() || '';
|
||||
return props.status?.toLowerCase() || '';
|
||||
});
|
||||
|
||||
const getType = (status: string) => {
|
||||
|
@ -5,20 +5,14 @@
|
||||
<div class="flex w-full flex-col gap-4 md:flex-row">
|
||||
<div class="flex flex-wrap gap-4">
|
||||
<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>
|
||||
</div>
|
||||
<div class="mt-0.5" v-if="form.status === 'Running'">
|
||||
<el-button type="primary" @click="onOperator('stop')" link>
|
||||
<div class="mt-0.5">
|
||||
<el-button v-if="form.isActive" type="primary" @click="onOperator('stop')" link>
|
||||
{{ $t('container.stop') }}
|
||||
</el-button>
|
||||
<el-divider direction="vertical" />
|
||||
<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>
|
||||
<el-button v-if="!form.isActive" type="primary" @click="onOperator('start')" link>
|
||||
{{ $t('container.start') }}
|
||||
</el-button>
|
||||
<el-divider direction="vertical" />
|
||||
@ -270,7 +264,8 @@ const sockPathRef = ref();
|
||||
|
||||
const form = reactive({
|
||||
isSwarm: false,
|
||||
status: '',
|
||||
isActive: false,
|
||||
isExist: false,
|
||||
version: '',
|
||||
mirrors: '',
|
||||
registries: '',
|
||||
@ -480,7 +475,8 @@ const changeMode = async () => {
|
||||
const search = async () => {
|
||||
const res = await loadDaemonJson();
|
||||
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.cgroupDriver = res.data.cgroupDriver || 'cgroupfs';
|
||||
form.liveRestore = res.data.liveRestore;
|
||||
|
Loading…
x
Reference in New Issue
Block a user