mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
feat: 网站列表增加证书过期时间显示 (#5488)
Refs https://github.com/1Panel-dev/1Panel/issues/4271
This commit is contained in:
parent
c30ea553bd
commit
e32104581b
@ -2,6 +2,7 @@ package response
|
||||
|
||||
import (
|
||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type WebsiteDTO struct {
|
||||
@ -11,6 +12,24 @@ type WebsiteDTO struct {
|
||||
SitePath string `json:"sitePath"`
|
||||
AppName string `json:"appName"`
|
||||
RuntimeName string `json:"runtimeName"`
|
||||
SiteDir string `gorm:"type:varchar;" json:"siteDir"`
|
||||
}
|
||||
|
||||
type WebsiteRes struct {
|
||||
ID uint `json:"id"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Protocol string `json:"protocol"`
|
||||
PrimaryDomain string `json:"primaryDomain"`
|
||||
Type string `json:"type"`
|
||||
Alias string `json:"alias"`
|
||||
Remark string `json:"remark"`
|
||||
Status string `json:"status"`
|
||||
ExpireDate time.Time `json:"expireDate"`
|
||||
SitePath string `json:"sitePath"`
|
||||
AppName string `json:"appName"`
|
||||
RuntimeName string `json:"runtimeName"`
|
||||
SSLExpireDate time.Time `json:"sslExpireDate"`
|
||||
SSLStatus string `json:"sslStatus"`
|
||||
}
|
||||
|
||||
type WebsiteOption struct {
|
||||
|
@ -53,7 +53,7 @@ type WebsiteService struct {
|
||||
}
|
||||
|
||||
type IWebsiteService interface {
|
||||
PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteDTO, error)
|
||||
PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteRes, error)
|
||||
GetWebsites() ([]response.WebsiteDTO, error)
|
||||
CreateWebsite(create request.WebsiteCreate) error
|
||||
OpWebsite(req request.WebsiteOp) error
|
||||
@ -102,9 +102,9 @@ func NewIWebsiteService() IWebsiteService {
|
||||
return &WebsiteService{}
|
||||
}
|
||||
|
||||
func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteDTO, error) {
|
||||
func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteRes, error) {
|
||||
var (
|
||||
websiteDTOs []response.WebsiteDTO
|
||||
websiteDTOs []response.WebsiteRes
|
||||
opts []repo.DBOption
|
||||
)
|
||||
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
||||
@ -154,11 +154,22 @@ func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []respons
|
||||
runtimeName = runtime.Name
|
||||
}
|
||||
sitePath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", web.Alias)
|
||||
websiteDTOs = append(websiteDTOs, response.WebsiteDTO{
|
||||
Website: web,
|
||||
AppName: appName,
|
||||
RuntimeName: runtimeName,
|
||||
SitePath: sitePath,
|
||||
|
||||
websiteDTOs = append(websiteDTOs, response.WebsiteRes{
|
||||
ID: web.ID,
|
||||
CreatedAt: web.CreatedAt,
|
||||
Protocol: web.Protocol,
|
||||
PrimaryDomain: web.PrimaryDomain,
|
||||
Type: web.Type,
|
||||
Remark: web.Remark,
|
||||
Status: web.Status,
|
||||
Alias: web.Alias,
|
||||
AppName: appName,
|
||||
ExpireDate: web.ExpireDate,
|
||||
SSLExpireDate: web.WebsiteSSL.ExpireDate,
|
||||
SSLStatus: checkSSLStatus(web.WebsiteSSL.ExpireDate),
|
||||
RuntimeName: runtimeName,
|
||||
SitePath: sitePath,
|
||||
})
|
||||
}
|
||||
return total, websiteDTOs, nil
|
||||
|
@ -1080,3 +1080,15 @@ func ChangeHSTSConfig(enable bool, nginxInstall model.AppInstall, website model.
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkSSLStatus(expireDate time.Time) string {
|
||||
now := time.Now()
|
||||
daysUntilExpiry := int(expireDate.Sub(now).Hours() / 24)
|
||||
|
||||
if daysUntilExpiry < 0 {
|
||||
return "danger"
|
||||
} else if daysUntilExpiry <= 10 {
|
||||
return "warning"
|
||||
}
|
||||
return "success"
|
||||
}
|
||||
|
@ -32,6 +32,19 @@ export namespace Website {
|
||||
appName: string;
|
||||
runtimeName: string;
|
||||
}
|
||||
export interface WebsiteRes extends CommonModel {
|
||||
protocol: string;
|
||||
primaryDomain: string;
|
||||
type: string;
|
||||
alias: string;
|
||||
remark: string;
|
||||
status: string;
|
||||
expireDate: string;
|
||||
sitePath: string;
|
||||
appName: string;
|
||||
runtimeName: string;
|
||||
sslExpireDate: Date;
|
||||
}
|
||||
|
||||
export interface NewAppInstall {
|
||||
name: string;
|
||||
|
@ -7,7 +7,7 @@ import { deepCopy } from '@/utils/util';
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
export const SearchWebsites = (req: Website.WebSiteSearch) => {
|
||||
return http.post<ResPage<Website.WebsiteDTO>>(`/websites/search`, req);
|
||||
return http.post<ResPage<Website.WebsiteRes>>(`/websites/search`, req);
|
||||
};
|
||||
|
||||
export const ListWebsites = () => {
|
||||
|
@ -2028,6 +2028,7 @@ const message = {
|
||||
'Only supports importing local backups, importing backups from other machines may cause recovery failure',
|
||||
ipWebsiteWarn: 'Websites with IP as domain names need to be set as default sites to be accessed normally',
|
||||
hstsHelper: 'Enabling HSTS can increase website security',
|
||||
sslExpireDate: 'Certificate expiration date',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: 'Short tag support',
|
||||
|
@ -1888,6 +1888,7 @@ const message = {
|
||||
websiteBackupWarn: '僅支援導入本機備份,導入其他機器備份可能會恢復失敗',
|
||||
ipWebsiteWarn: 'IP 為網域名稱的網站,需要設定為預設網站才能正常存取',
|
||||
hstsHelper: '開啟 HSTS 可以增加網站安全性',
|
||||
sslExpireDate: '憑證過期時間',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: '短標簽支持',
|
||||
|
@ -1890,6 +1890,7 @@ const message = {
|
||||
websiteBackupWarn: '仅支持导入本机备份,导入其他机器备份可能会恢复失败',
|
||||
ipWebsiteWarn: 'IP 为域名的网站,需要设置为默认站点才能正常访问',
|
||||
hstsHelper: '开启 HSTS 可以增加网站安全性',
|
||||
sslExpireDate: '证书过期时间',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: '短标签支持',
|
||||
|
@ -319,6 +319,7 @@ const submit = async (formEl: FormInstance | undefined) => {
|
||||
const changeEnable = (enable: boolean) => {
|
||||
if (enable) {
|
||||
listSSL();
|
||||
form.hsts = true;
|
||||
}
|
||||
if (resData.value.enable && !enable) {
|
||||
ElMessageBox.confirm(i18n.global.t('website.disableHTTPSHelper'), i18n.global.t('website.disableHTTPS'), {
|
||||
|
@ -154,6 +154,13 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('website.sslExpireDate')" width="150px">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.protocol == 'HTTPS'" :type="row.sslStatus">
|
||||
{{ dateFormatSimple(row.sslExpireDate) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<fu-table-operations
|
||||
:ellipsis="10"
|
||||
width="400px"
|
||||
|
Loading…
x
Reference in New Issue
Block a user