mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-18 21:38:57 +08:00
feat: 创建反代网站支持直接选择应用 (#6044)
Some checks failed
sync2gitee / repo-sync (push) Failing after -7m31s
Some checks failed
sync2gitee / repo-sync (push) Failing after -7m31s
This commit is contained in:
parent
f2a2c7996f
commit
5cf174be84
4 changed files with 84 additions and 26 deletions
|
|
@ -20,6 +20,7 @@ type IAppInstallRepo interface {
|
||||||
WithDetailIdNotIn(detailIds []uint) DBOption
|
WithDetailIdNotIn(detailIds []uint) DBOption
|
||||||
WithAppId(appId uint) DBOption
|
WithAppId(appId uint) DBOption
|
||||||
WithAppIdsIn(appIds []uint) DBOption
|
WithAppIdsIn(appIds []uint) DBOption
|
||||||
|
WithAppIdsNotIn(appIds []uint) DBOption
|
||||||
WithStatus(status string) DBOption
|
WithStatus(status string) DBOption
|
||||||
WithServiceName(serviceName string) DBOption
|
WithServiceName(serviceName string) DBOption
|
||||||
WithContainerName(containerName string) DBOption
|
WithContainerName(containerName string) DBOption
|
||||||
|
|
@ -72,6 +73,12 @@ func (a *AppInstallRepo) WithAppIdsIn(appIds []uint) DBOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AppInstallRepo) WithAppIdsNotIn(appIds []uint) DBOption {
|
||||||
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
|
return g.Where("app_id not in (?)", appIds)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *AppInstallRepo) WithStatus(status string) DBOption {
|
func (a *AppInstallRepo) WithStatus(status string) DBOption {
|
||||||
return func(g *gorm.DB) *gorm.DB {
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
return g.Where("status = ?", status)
|
return g.Where("status = ?", status)
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@ func (a *AppInstallService) Page(req request.AppInstalledSearch) (int64, []respo
|
||||||
if req.Name != "" {
|
if req.Name != "" {
|
||||||
opts = append(opts, commonRepo.WithLikeName(req.Name))
|
opts = append(opts, commonRepo.WithLikeName(req.Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.Tags) != 0 {
|
if len(req.Tags) != 0 {
|
||||||
tags, err := tagRepo.GetByKeys(req.Tags)
|
tags, err := tagRepo.GetByKeys(req.Tags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -202,6 +203,18 @@ func (a *AppInstallService) SearchForWebsite(req request.AppInstalledSearch) ([]
|
||||||
opts []repo.DBOption
|
opts []repo.DBOption
|
||||||
)
|
)
|
||||||
if req.Type != "" {
|
if req.Type != "" {
|
||||||
|
if req.Type == "proxy" {
|
||||||
|
phpApps, _ := appRepo.GetBy(appRepo.WithType("php"))
|
||||||
|
var ids []uint
|
||||||
|
for _, app := range phpApps {
|
||||||
|
ids = append(ids, app.ID)
|
||||||
|
}
|
||||||
|
runtimeApps, _ := appRepo.GetBy(appRepo.WithType("runtime"))
|
||||||
|
for _, app := range runtimeApps {
|
||||||
|
ids = append(ids, app.ID)
|
||||||
|
}
|
||||||
|
opts = append(opts, appInstallRepo.WithAppIdsNotIn(ids))
|
||||||
|
} else {
|
||||||
apps, err := appRepo.GetBy(appRepo.WithType(req.Type))
|
apps, err := appRepo.GetBy(appRepo.WithType(req.Type))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -214,6 +227,7 @@ func (a *AppInstallService) SearchForWebsite(req request.AppInstalledSearch) ([]
|
||||||
opts = append(opts, appInstallRepo.WithIdNotInWebsite())
|
opts = append(opts, appInstallRepo.WithIdNotInWebsite())
|
||||||
}
|
}
|
||||||
opts = append(opts, appInstallRepo.WithAppIdsIn(ids))
|
opts = append(opts, appInstallRepo.WithAppIdsIn(ids))
|
||||||
|
}
|
||||||
installs, err = appInstallRepo.ListBy(opts...)
|
installs, err = appInstallRepo.ListBy(opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ export namespace App {
|
||||||
icon: string;
|
icon: string;
|
||||||
canUpdate: boolean;
|
canUpdate: boolean;
|
||||||
path: string;
|
path: string;
|
||||||
|
httpPort?: number;
|
||||||
app: App;
|
app: App;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,9 @@
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<el-form-item v-if="website.type === 'proxy'" :label="$t('website.proxyAddress')" prop="proxyAddress">
|
<el-row :gutter="20" v-if="website.type === 'proxy'">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item :label="$t('website.proxyAddress')" prop="proxyAddress">
|
||||||
<el-input v-model="website.proxyAddress" :placeholder="$t('website.proxyHelper')">
|
<el-input v-model="website.proxyAddress" :placeholder="$t('website.proxyHelper')">
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<el-select v-model="website.proxyProtocol" class="pre-select">
|
<el-select v-model="website.proxyProtocol" class="pre-select">
|
||||||
|
|
@ -327,6 +329,26 @@
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item :label="$t('app.app')">
|
||||||
|
<el-select
|
||||||
|
v-model="website.appInstallId"
|
||||||
|
class="p-w-200"
|
||||||
|
filterable
|
||||||
|
@change="changeInstall"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(appInstall, index) in appInstalls"
|
||||||
|
:key="index"
|
||||||
|
:label="appInstall.name"
|
||||||
|
:value="appInstall.id"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
<el-form-item :label="$t('website.remark')" prop="remark">
|
<el-form-item :label="$t('website.remark')" prop="remark">
|
||||||
<el-input type="textarea" :rows="3" clearable v-model="website.remark" />
|
<el-input type="textarea" :rows="3" clearable v-model="website.remark" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
@ -479,6 +501,10 @@ const changeType = (type: string) => {
|
||||||
case 'runtime':
|
case 'runtime':
|
||||||
getRuntimes();
|
getRuntimes();
|
||||||
break;
|
break;
|
||||||
|
case 'proxy':
|
||||||
|
website.value.proxyAddress = '';
|
||||||
|
searchAppInstalled('proxy');
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
website.value.appInstallId = undefined;
|
website.value.appInstallId = undefined;
|
||||||
break;
|
break;
|
||||||
|
|
@ -487,15 +513,25 @@ const changeType = (type: string) => {
|
||||||
versionExist.value = true;
|
versionExist.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchAppInstalled = () => {
|
const searchAppInstalled = (appType: string) => {
|
||||||
GetAppInstalled({ type: 'website', unused: true, all: true, page: 1, pageSize: 100 }).then((res) => {
|
GetAppInstalled({ type: appType, unused: true, all: true, page: 1, pageSize: 100 }).then((res) => {
|
||||||
appInstalls.value = res.data;
|
appInstalls.value = res.data;
|
||||||
if (res.data && res.data.length > 0) {
|
website.value.appInstallId = undefined;
|
||||||
|
if (appType == 'website' && res.data && res.data.length > 0) {
|
||||||
website.value.appInstallId = res.data[0].id;
|
website.value.appInstallId = res.data[0].id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const changeInstall = () => {
|
||||||
|
appInstalls.value.forEach((app) => {
|
||||||
|
if (app.id === website.value.appInstallId) {
|
||||||
|
website.value.proxyProtocol = 'http://';
|
||||||
|
website.value.proxyAddress = '127.0.0.1:' + app.httpPort;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const searchApp = () => {
|
const searchApp = () => {
|
||||||
SearchApp(appReq).then((res) => {
|
SearchApp(appReq).then((res) => {
|
||||||
apps.value = res.data.items;
|
apps.value = res.data.items;
|
||||||
|
|
@ -594,14 +630,14 @@ const acceptParams = async (installPath: string) => {
|
||||||
website.value.type = 'deployment';
|
website.value.type = 'deployment';
|
||||||
runtimeResource.value = 'appstore';
|
runtimeResource.value = 'appstore';
|
||||||
|
|
||||||
searchAppInstalled();
|
searchAppInstalled('website');
|
||||||
|
|
||||||
open.value = true;
|
open.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeAppType = (type: string) => {
|
const changeAppType = (type: string) => {
|
||||||
if (type === 'installed') {
|
if (type === 'installed') {
|
||||||
searchAppInstalled();
|
searchAppInstalled('website');
|
||||||
} else {
|
} else {
|
||||||
searchApp();
|
searchApp();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue