1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

fix: 解决创建网站应用没有关联的 BUG

This commit is contained in:
zhengkunwang223 2023-02-27 17:22:14 +08:00 committed by zhengkunwang223
parent 52dd0da4f8
commit f2b0eeb1f7
13 changed files with 33 additions and 37 deletions

View File

@ -4,6 +4,7 @@ import (
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/global"
"github.com/gin-gonic/gin"
)
@ -37,10 +38,13 @@ func (b *BaseApi) SearchApp(c *gin.Context) {
// @Router /apps/sync [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFuntions":[],"formatZH":"应用商店同步","formatEN":"App store synchronization"}
func (b *BaseApi) SyncApp(c *gin.Context) {
global.LOG.Infof("sync app list start ...")
if err := appService.SyncAppList(); err != nil {
global.LOG.Errorf("sync app list error [%s]", err.Error())
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
global.LOG.Infof("sync app list success!")
helper.SuccessWithData(c, "")
}

View File

@ -16,7 +16,7 @@ type App struct {
Github string `json:"github" gorm:"type:varchar(64);not null"`
Document string `json:"document" gorm:"type:varchar(64);not null"`
Recommend int `json:"recommend" gorm:"type:Integer;not null"`
Details []AppDetail `json:"-"`
Details []AppDetail `json:"-" gorm:"-:migration"`
TagsKey []string `json:"-" gorm:"-"`
AppTags []AppTag `json:"-" `
AppTags []AppTag `json:"-" gorm:"-:migration"`
}

View File

@ -21,8 +21,8 @@ type AppInstall struct {
ServiceName string `json:"serviceName" gorm:"type:varchar(256);not null"`
HttpPort int `json:"httpPort" gorm:"type:integer;not null"`
HttpsPort int `json:"httpsPort" gorm:"type:integer;not null"`
App App `json:"app"`
Backups []AppInstallBackup `json:"backups"`
App App `json:"app" gorm:"-:migration"`
Backups []AppInstallBackup `json:"backups" gorm:"-:migration"`
}
func (i *AppInstall) GetPath() string {

View File

@ -7,5 +7,5 @@ type AppInstallBackup struct {
Param string `gorm:"type:longtext;" json:"param"`
AppDetailId uint `gorm:"type:integer;not null" json:"app_detail_id"`
AppInstallId uint `gorm:"type:integer;not null" json:"app_install_id"`
AppDetail AppDetail `json:"-"`
AppDetail AppDetail `json:"-" gorm:"-:migration"`
}

View File

@ -19,8 +19,8 @@ type Website struct {
ErrorLog bool `json:"errorLog"`
AccessLog bool `json:"accessLog"`
DefaultServer bool `json:"defaultServer"`
Domains []WebsiteDomain `json:"domains"`
WebsiteSSL WebsiteSSL `json:"webSiteSSL"`
Domains []WebsiteDomain `json:"domains" gorm:"-:migration"`
WebsiteSSL WebsiteSSL `json:"webSiteSSL" gorm:"-:migration"`
}
func (w Website) TableName() string {

View File

@ -18,8 +18,8 @@ type WebsiteSSL struct {
ExpireDate time.Time `json:"expireDate"`
StartDate time.Time `json:"startDate"`
AcmeAccount WebsiteAcmeAccount `json:"acmeAccount"`
Websites []Website `json:"websites"`
AcmeAccount WebsiteAcmeAccount `json:"acmeAccount" gorm:"-:migration"`
Websites []Website `json:"websites" gorm:"-:migration"`
}
func (w WebsiteSSL) TableName() string {

View File

@ -356,7 +356,9 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) {
if err != nil {
return nil, err
}
versionRes, err := http.Get(fmt.Sprintf("%s/%s/%s/appstore/apps.json", global.CONF.System.RepoUrl, global.CONF.System.Mode, setting.SystemVersion))
versionUrl := fmt.Sprintf("%s/%s/%s/appstore/apps.json", global.CONF.System.RepoUrl, global.CONF.System.Mode, setting.SystemVersion)
versionRes, err := http.Get(versionUrl)
global.LOG.Infof("get current version from [%s]", versionUrl)
if err != nil {
return nil, err
}
@ -384,6 +386,7 @@ func (a AppService) SyncAppList() error {
return err
}
if !updateRes.CanUpdate {
global.LOG.Infof("The latest version is [%s] The app store is already up to date", updateRes.Version)
return nil
}
if err := getAppFromRepo(updateRes.DownloadPath, updateRes.Version); err != nil {

View File

@ -143,7 +143,7 @@ func (w WebsiteService) CreateWebsite(ctx context.Context, create request.Websit
return err
}
appInstall = &install
website.AppInstallID = 0
website.AppInstallID = appInstall.ID
}
}

View File

@ -21,7 +21,9 @@ func Init() {
panic(fmt.Errorf("init db file falied, err: %v", err))
}
}
db, err := gorm.Open(sqlite.Open(fullPath), &gorm.Config{})
db, err := gorm.Open(sqlite.Open(fullPath), &gorm.Config{
DisableForeignKeyConstraintWhenMigrating: true,
})
if err != nil {
panic(err)
}

View File

@ -8,32 +8,27 @@ import (
func Up(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s up -d", filePath)
return string(stdout), err
return stdout, err
}
func Down(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s down", filePath)
return string(stdout), err
return stdout, err
}
func Stop(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s stop", filePath)
return string(stdout), err
return stdout, err
}
func Restart(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s restart", filePath)
return string(stdout), err
return stdout, err
}
func Operate(filePath, operation string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s %s", filePath, operation)
return string(stdout), err
}
func Rmf(filePath string) (string, error) {
stdout, err := cmd.Execf("docker-compose -f %s rm -f", filePath)
return string(stdout), err
return stdout, err
}
func GetComposeProject(yml []byte, env map[string]string) (*types.Project, error) {

View File

@ -1,4 +0,0 @@
@font-face {
font-family: 'pingFangSC-Regular';
src: url('./PingFang-SC-Regular.ttf');
}

View File

@ -1,12 +1,8 @@
import { createApp } from 'vue';
import App from './App.vue';
// import 'element-plus/dist/index.css';
// import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/styles/index.scss';
// import '@/styles/reset.scss';
import '@/styles/common.scss';
import '@/assets/fonts/font.scss';
import '@/assets/iconfont/iconfont.css';
import '@/assets/iconfont/iconfont.js';

View File

@ -4,44 +4,44 @@
<el-row type="flex" style="margin-left: 50px" justify="center">
<el-form-item style="width: 25%">
<template #label>
<span class="status-label">{{ $t('database.connections') }}</span>
<span class="status-label">{{ $t('nginx.connections') }}</span>
</template>
<span class="status-count">{{ data.active }}</span>
</el-form-item>
<el-form-item style="width: 25%">
<template #label>
<span class="status-label">{{ $t('database.accepts') }}</span>
<span class="status-label">{{ $t('nginx.accepts') }}</span>
</template>
<span class="status-count">{{ data.accepts }}</span>
</el-form-item>
<el-form-item style="width: 25%">
<template #label>
<span class="status-label">{{ $t('database.handled') }}</span>
<span class="status-label">{{ $t('nginx.handled') }}</span>
</template>
<span class="status-count">{{ data.handled }}</span>
</el-form-item>
<el-form-item style="width: 25%">
<template #label>
<span class="status-label">{{ $t('database.requests') }}</span>
<span class="status-label">{{ $t('nginx.requests') }}</span>
</template>
<span class="status-count">{{ data.requests }}</span>
</el-form-item>
<el-form-item style="width: 25%">
<template #label>
<span class="status-label">{{ $t('database.reading') }}</span>
<span class="status-label">{{ $t('nginx.reading') }}</span>
</template>
<span class="status-count">{{ data.reading }}</span>
</el-form-item>
<el-form-item style="width: 25%">
<template #label>
<span class="status-label">{{ $t('database.writing') }}</span>
<span class="status-label">{{ $t('nginx.writing') }}</span>
</template>
<span class="status-count">{{ data.writing }}</span>
</el-form-item>
<el-form-item style="width: 25%">
<template #label>
<span class="status-label">{{ $t('database.waiting') }}</span>
<span class="status-label">{{ $t('nginx.waiting') }}</span>
</template>
<span class="status-count">{{ data.waiting }}</span>
</el-form-item>