mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-01 03:24:14 +08:00
feat: merge ai from dev (#7986)
This commit is contained in:
parent
90eca45347
commit
ec746c021a
@ -41,4 +41,5 @@ type OllamaBindDomainRes struct {
|
|||||||
AllowIPs []string `json:"allowIPs"`
|
AllowIPs []string `json:"allowIPs"`
|
||||||
WebsiteID uint `json:"websiteID"`
|
WebsiteID uint `json:"websiteID"`
|
||||||
ConnUrl string `json:"connUrl"`
|
ConnUrl string `json:"connUrl"`
|
||||||
|
AcmeAccountID uint `json:"acmeAccountID"`
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func (u *AIToolService) Search(req dto.SearchWithPage) (int64, []dto.OllamaModel
|
|||||||
}
|
}
|
||||||
dtoLists = append(dtoLists, item)
|
dtoLists = append(dtoLists, item)
|
||||||
}
|
}
|
||||||
return int64(total), dtoLists, err
|
return total, dtoLists, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *AIToolService) LoadDetail(name string) (string, error) {
|
func (u *AIToolService) LoadDetail(name string) (string, error) {
|
||||||
@ -244,14 +244,18 @@ func (u *AIToolService) BindDomain(req dto.OllamaBindDomain) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
createWebsiteReq := request.WebsiteCreate{
|
createWebsiteReq := request.WebsiteCreate{
|
||||||
Domains: []request.WebsiteDomain{{Domain: req.Domain}},
|
Domains: []request.WebsiteDomain{{Domain: req.Domain, Port: 80}},
|
||||||
Alias: strings.ToLower(req.Domain),
|
Alias: strings.ToLower(req.Domain),
|
||||||
Type: constant.Deployment,
|
Type: constant.Deployment,
|
||||||
AppType: constant.InstalledApp,
|
AppType: constant.InstalledApp,
|
||||||
AppInstallID: req.AppInstallID,
|
AppInstallID: req.AppInstallID,
|
||||||
}
|
}
|
||||||
|
if req.SSLID > 0 {
|
||||||
|
createWebsiteReq.WebsiteSSLID = req.SSLID
|
||||||
|
createWebsiteReq.EnableSSL = true
|
||||||
|
}
|
||||||
websiteService := NewIWebsiteService()
|
websiteService := NewIWebsiteService()
|
||||||
if err := websiteService.CreateWebsite(createWebsiteReq); err != nil {
|
if err = websiteService.CreateWebsite(createWebsiteReq); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
website, err := websiteRepo.GetFirst(websiteRepo.WithAlias(strings.ToLower(req.Domain)))
|
website, err := websiteRepo.GetFirst(websiteRepo.WithAlias(strings.ToLower(req.Domain)))
|
||||||
@ -263,18 +267,6 @@ func (u *AIToolService) BindDomain(req dto.OllamaBindDomain) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.SSLID > 0 {
|
|
||||||
sslReq := request.WebsiteHTTPSOp{
|
|
||||||
WebsiteID: website.ID,
|
|
||||||
Enable: true,
|
|
||||||
Type: "existed",
|
|
||||||
WebsiteSSLID: req.SSLID,
|
|
||||||
HttpConfig: "HTTPSOnly",
|
|
||||||
}
|
|
||||||
if _, err = websiteService.OpWebsiteHTTPS(context.Background(), sslReq); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err = ConfigAIProxy(website); err != nil {
|
if err = ConfigAIProxy(website); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -295,6 +287,8 @@ func (u *AIToolService) GetBindDomain(req dto.OllamaBindDomainReq) (*dto.OllamaB
|
|||||||
res.Domain = website.PrimaryDomain
|
res.Domain = website.PrimaryDomain
|
||||||
if website.WebsiteSSLID > 0 {
|
if website.WebsiteSSLID > 0 {
|
||||||
res.SSLID = website.WebsiteSSLID
|
res.SSLID = website.WebsiteSSLID
|
||||||
|
ssl, _ := websiteSSLRepo.GetFirst(repo.WithByID(website.WebsiteSSLID))
|
||||||
|
res.AcmeAccountID = ssl.AcmeAccountID
|
||||||
}
|
}
|
||||||
res.ConnUrl = fmt.Sprintf("%s://%s", strings.ToLower(website.Protocol), website.PrimaryDomain)
|
res.ConnUrl = fmt.Sprintf("%s://%s", strings.ToLower(website.Protocol), website.PrimaryDomain)
|
||||||
res.AllowIPs = GetAllowIps(website)
|
res.AllowIPs = GetAllowIps(website)
|
||||||
|
@ -107,5 +107,6 @@ export namespace AI {
|
|||||||
allowIPs: string[];
|
allowIPs: string[];
|
||||||
websiteID?: number;
|
websiteID?: number;
|
||||||
connUrl: string;
|
connUrl: string;
|
||||||
|
acmeAccountID: number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,15 @@ let refresh = ref(1);
|
|||||||
const httpPort = ref(0);
|
const httpPort = ref(0);
|
||||||
const httpsPort = ref(0);
|
const httpsPort = ref(0);
|
||||||
|
|
||||||
const em = defineEmits(['setting', 'isExist', 'before', 'after', 'update:loading', 'update:maskShow']);
|
const em = defineEmits([
|
||||||
|
'setting',
|
||||||
|
'isExist',
|
||||||
|
'before',
|
||||||
|
'after',
|
||||||
|
'update:loading',
|
||||||
|
'update:maskShow',
|
||||||
|
'update:appInstallID',
|
||||||
|
]);
|
||||||
const setting = () => {
|
const setting = () => {
|
||||||
em('setting', false);
|
em('setting', false);
|
||||||
};
|
};
|
||||||
@ -128,6 +136,7 @@ const onCheck = async (key: any, name: any) => {
|
|||||||
em('isExist', res.data);
|
em('isExist', res.data);
|
||||||
em('update:maskShow', res.data.status !== 'Running');
|
em('update:maskShow', res.data.status !== 'Running');
|
||||||
operateReq.installId = res.data.appInstallId;
|
operateReq.installId = res.data.appInstallId;
|
||||||
|
em('update:appInstallID', res.data.appInstallId);
|
||||||
httpPort.value = res.data.httpPort;
|
httpPort.value = res.data.httpPort;
|
||||||
httpsPort.value = res.data.httpsPort;
|
httpsPort.value = res.data.httpsPort;
|
||||||
refresh.value++;
|
refresh.value++;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<DrawerPro v-model="open" :title="$t('aiTools.proxy.proxy')" :back="handleClose" size="large">
|
<DrawerPro v-model="open" :header="$t('aiTools.proxy.proxy')" :back="handleClose" size="large">
|
||||||
<div v-loading="loading">
|
<div v-loading="loading">
|
||||||
<el-form ref="formRef" label-position="top" @submit.prevent :model="req" :rules="rules">
|
<el-form ref="formRef" label-position="top" @submit.prevent :model="req" :rules="rules">
|
||||||
<el-row type="flex" justify="center">
|
|
||||||
<el-col :span="22">
|
|
||||||
<el-alert class="common-prompt" :closable="false" type="warning">
|
<el-alert class="common-prompt" :closable="false" type="warning">
|
||||||
<template #default>
|
<template #default>
|
||||||
<ul>
|
<ul>
|
||||||
@ -20,12 +18,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<span class="input-help">
|
<span class="input-help">
|
||||||
{{ $t('aiTools.proxy.proxyHelper6') }}
|
{{ $t('aiTools.proxy.proxyHelper6') }}
|
||||||
<el-link
|
<el-link class="pageRoute" icon="Position" @click="toWebsite(req.websiteID)" type="primary">
|
||||||
class="pageRoute"
|
|
||||||
icon="Position"
|
|
||||||
@click="toWebsite(req.websiteID)"
|
|
||||||
type="primary"
|
|
||||||
>
|
|
||||||
{{ $t('firewall.quickJump') }}
|
{{ $t('firewall.quickJump') }}
|
||||||
</el-link>
|
</el-link>
|
||||||
</span>
|
</span>
|
||||||
@ -47,16 +40,8 @@
|
|||||||
{{ $t('website.enable') + ' ' + 'HTTPS' }}
|
{{ $t('website.enable') + ' ' + 'HTTPS' }}
|
||||||
</el-checkbox>
|
</el-checkbox>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item :label="$t('website.acmeAccountManage')" prop="acmeAccountID" v-if="req.enableSSL">
|
||||||
:label="$t('website.acmeAccountManage')"
|
<el-select v-model="req.acmeAccountID" :placeholder="$t('website.selectAcme')" @change="loadSSL">
|
||||||
prop="acmeAccountID"
|
|
||||||
v-if="req.enableSSL"
|
|
||||||
>
|
|
||||||
<el-select
|
|
||||||
v-model="req.acmeAccountID"
|
|
||||||
:placeholder="$t('website.selectAcme')"
|
|
||||||
@change="listSSL"
|
|
||||||
>
|
|
||||||
<el-option :key="0" :label="$t('website.imported')" :value="0"></el-option>
|
<el-option :key="0" :label="$t('website.imported')" :value="0"></el-option>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(acme, index) in acmeAccounts"
|
v-for="(acme, index) in acmeAccounts"
|
||||||
@ -91,8 +76,6 @@
|
|||||||
{{ $t('firewall.quickJump') }}
|
{{ $t('firewall.quickJump') }}
|
||||||
</el-link>
|
</el-link>
|
||||||
</el-alert>
|
</el-alert>
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@ -134,6 +117,9 @@ const req = ref({
|
|||||||
appInstallID: 0,
|
appInstallID: 0,
|
||||||
websiteID: 0,
|
websiteID: 0,
|
||||||
});
|
});
|
||||||
|
const sslReq = reactive({
|
||||||
|
acmeAccountID: '',
|
||||||
|
});
|
||||||
const rules = reactive<FormRules>({
|
const rules = reactive<FormRules>({
|
||||||
domain: [Rules.domainWithPort],
|
domain: [Rules.domainWithPort],
|
||||||
sslID: [Rules.requiredSelectBusiness],
|
sslID: [Rules.requiredSelectBusiness],
|
||||||
@ -167,9 +153,7 @@ const changeSSL = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadSSL = () => {
|
const loadSSL = () => {
|
||||||
const sslReq = {
|
sslReq.acmeAccountID = String(req.value.acmeAccountID);
|
||||||
acmeAccountID: String(req.value.acmeAccountID),
|
|
||||||
};
|
|
||||||
listSSL(sslReq).then((res) => {
|
listSSL(sslReq).then((res) => {
|
||||||
ssls.value = res.data || [];
|
ssls.value = res.data || [];
|
||||||
if (ssls.value.length > 0) {
|
if (ssls.value.length > 0) {
|
||||||
@ -193,9 +177,6 @@ const loadSSL = () => {
|
|||||||
const listAcmeAccount = () => {
|
const listAcmeAccount = () => {
|
||||||
searchAcmeAccount({ page: 1, pageSize: 100 }).then((res) => {
|
searchAcmeAccount({ page: 1, pageSize: 100 }).then((res) => {
|
||||||
acmeAccounts.value = res.data.items || [];
|
acmeAccounts.value = res.data.items || [];
|
||||||
if (acmeAccounts.value.length > 0) {
|
|
||||||
req.value.acmeAccountID = acmeAccounts.value[0].id;
|
|
||||||
}
|
|
||||||
loadSSL();
|
loadSSL();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -229,6 +210,7 @@ const search = async (appInstallID: number) => {
|
|||||||
if (res.data.sslID > 0) {
|
if (res.data.sslID > 0) {
|
||||||
req.value.enableSSL = true;
|
req.value.enableSSL = true;
|
||||||
req.value.sslID = res.data.sslID;
|
req.value.sslID = res.data.sslID;
|
||||||
|
req.value.acmeAccountID = res.data.acmeAccountID;
|
||||||
listAcmeAccount();
|
listAcmeAccount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user