[SSL证书]选择证书表格中显示是否已经选择

This commit is contained in:
GoEdgeLab
2020-12-04 09:25:35 +08:00
parent 8112bac11f
commit 1dad8af0c3
3 changed files with 22 additions and 4 deletions

View File

@@ -2,11 +2,14 @@ package certs
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/maps"
timeutil "github.com/iwind/TeaGo/utils/time"
"strings"
"time"
)
@@ -21,9 +24,16 @@ func (this *SelectPopupAction) Init() {
func (this *SelectPopupAction) RunGet(params struct {
ViewSize string
SelectedCertIds string
}) {
// TODO 支持关键词搜索
// TODO 列出常用的证书供用户选择
// TODO 列出常用和最新的证书供用户选择
// 已经选择的证书
selectedCertIds := []string{}
if len(params.SelectedCertIds) > 0 {
selectedCertIds = strings.Split(params.SelectedCertIds, ",")
}
if len(params.ViewSize) == 0 {
params.ViewSize = "normal"
@@ -67,6 +77,7 @@ func (this *SelectPopupAction) RunGet(params struct {
"isExpired": nowTime > certConfig.TimeEndAt,
"isAvailable": nowTime <= certConfig.TimeEndAt,
"countServers": countServersResp.Count,
"isSelected": lists.ContainsString(selectedCertIds, numberutils.FormatInt64(certConfig.Id)),
})
}
this.Data["certInfos"] = certMaps

View File

@@ -95,7 +95,13 @@ Vue.component("ssl-config-box", {
// 选择证书
selectCert: function () {
let that = this
teaweb.popup("/servers/certs/selectPopup", {
let selectedCertIds = []
if (this.policy != null && this.policy.certs.length > 0) {
this.policy.certs.forEach(function (cert) {
selectedCertIds.push(cert.id.toString())
})
}
teaweb.popup("/servers/certs/selectPopup?selectedCertIds=" + selectedCertIds, {
width: "50em",
height: "30em",
callback: function (resp) {

View File

@@ -35,7 +35,8 @@
<span class="ui label green tiny basic" v-else>有效中</span>
</td>
<td>
<a href="" @click.prevent="selectCert(cert)">选择</a>
<a href="" @click.prevent="selectCert(cert)" v-if="!certInfos[index].isSelected">选择</a>
<span v-else>已选</span>
</td>
</tr>
</table>