mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-25 03:26:34 +08:00
增加批量上传证书功能
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
<menu-item :href="'/servers/certs?type=30days&keyword=' + keyword" :active="type == '30days'">30天内过期({{count30Days}})</menu-item>
|
||||
<span class="item disabled">|</span>
|
||||
<a href="" class="item" @click.prevent="uploadCert">[上传证书]</a>
|
||||
<a href="" class="item" @click.prevent="uploadBatch">[批量上传]</a>
|
||||
</second-menu>
|
||||
|
||||
<form class="ui form">
|
||||
|
||||
@@ -11,6 +11,16 @@ Tea.context(function () {
|
||||
})
|
||||
}
|
||||
|
||||
// 批量上传证书
|
||||
this.uploadBatch = function () {
|
||||
teaweb.popup("/servers/certs/uploadBatchPopup", {
|
||||
height: "30em",
|
||||
callback: function () {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 删除证书
|
||||
this.deleteCert = function (certId) {
|
||||
let that = this
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<tr>
|
||||
<td><span v-if="textMode">输入证书内容</span><span v-else>选择证书文件</span></td>
|
||||
<td>
|
||||
<input type="file" name="certFile" accept="application/x-pem-file, application/pkcs10, application/x-pkcs12, application/x-x509-user-cert, application/x-x509-ca-cert, application/pkix-cert" v-if="!textMode"/>
|
||||
<input type="file" name="certFile" accept="application/x-pem-file, application/pkcs10, application/x-pkcs12, application/x-x509-user-cert, application/x-x509-ca-cert, application/pkix-cert, .pem" v-if="!textMode"/>
|
||||
<file-textarea class="wide-code" ref="certTextField" spellcheck="false" name="certText" placeholder="-----BEGIN CERTIFICATE-----" v-if="textMode" style="font-size: 0.7em"></file-textarea>
|
||||
<p class="comment"><a href="" @click.prevent="switchTextMode">[<span v-if="!textMode">输入内容</span><span v-else>上传文件</span>]</a>。文件内容中通常含有"-----BEGIN CERTIFICATE-----"类似的信息<span v-if="textMode">,可以直接拖动证书文件到输入框,留空表示不修改</span>。</p>
|
||||
</td>
|
||||
@@ -33,7 +33,7 @@
|
||||
<tr v-show="isCA == 0">
|
||||
<td><span v-if="textMode">输入私钥内容</span><span v-else>选择私钥文件</span></td>
|
||||
<td>
|
||||
<input type="file" name="keyFile" accept="application/pkcs8" v-if="!textMode"/>
|
||||
<input type="file" name="keyFile" accept="application/pkcs8, .key" v-if="!textMode"/>
|
||||
<file-textarea class="wide-code" spellcheck="false" name="keyText" placeholder="-----BEGIN RSA PRIVATE KEY-----" v-if="textMode" style="font-size: 0.7em"></file-textarea>
|
||||
<p class="comment"><a href="" @click.prevent="switchTextMode">[<span v-if="!textMode">输入内容</span><span v-else>上传文件</span>]</a>。文件内容中通常含有"-----BEGIN RSA PRIVATE KEY-----"类似的信息<span v-if="textMode">,可以直接拖动证书文件到输入框,留空表示不修改</span>。</p>
|
||||
</td>
|
||||
|
||||
25
web/views/@default/servers/certs/uploadBatchPopup.html
Normal file
25
web/views/@default/servers/certs/uploadBatchPopup.html
Normal file
@@ -0,0 +1,25 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>批量上传证书</h3>
|
||||
|
||||
<form class="ui form" data-tea-success="successUpload" data-tea-action="$" data-tea-before="before" data-tea-done="done" data-tea-timeout="600">
|
||||
<csrf-token></csrf-token>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">选择要上传的证书和私钥文件 *</td>
|
||||
<td>
|
||||
<input type="file" name="certFiles" accept="application/x-pem-file, application/pkcs10, application/x-pkcs12, application/x-x509-user-cert, application/x-x509-ca-cert, application/pkix-cert, application/pkcs8, .key, .pem" multiple="multiple"/>
|
||||
<p class="comment">点击后在弹出的文件选择框中支持多选。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>所属用户</td>
|
||||
<td>
|
||||
<user-selector @change="changeUserId"></user-selector>
|
||||
<p class="comment">可选项,指定证书所属的用户;指定用户后,上传的证书管理员无法在管理系统查看,只能在用户系统查看。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn v-show="!isRequesting">上传</submit-btn>
|
||||
<button class="ui button disabled " type="button" v-if="isRequesting">上传中...</button>
|
||||
</form>
|
||||
30
web/views/@default/servers/certs/uploadBatchPopup.js
Normal file
30
web/views/@default/servers/certs/uploadBatchPopup.js
Normal file
@@ -0,0 +1,30 @@
|
||||
Tea.context(function () {
|
||||
this.isRequesting = false
|
||||
this.userId = 0
|
||||
|
||||
this.before = function () {
|
||||
this.isRequesting = true
|
||||
}
|
||||
|
||||
this.done = function () {
|
||||
this.isRequesting = false
|
||||
}
|
||||
|
||||
this.successUpload = function (resp) {
|
||||
if (resp.data.count > 0) {
|
||||
let msg = "html:成功上传" + resp.data.count + "个证书"
|
||||
if (this.userId > 0) {
|
||||
msg += "<br/>由于你选择了证书用户,所以只有此用户才能在用户系统中查看到这些证书。"
|
||||
}
|
||||
teaweb.success(msg, function () {
|
||||
NotifyPopup(resp)
|
||||
})
|
||||
return
|
||||
}
|
||||
NotifyPopup(resp)
|
||||
}
|
||||
|
||||
this.changeUserId = function (userId) {
|
||||
this.userId = userId
|
||||
}
|
||||
})
|
||||
@@ -24,7 +24,7 @@
|
||||
<tr>
|
||||
<td><span v-if="textMode">输入证书内容</span><span v-else>选择证书文件</span> *</td>
|
||||
<td>
|
||||
<input type="file" name="certFile" accept="application/x-pem-file, application/pkcs10, application/x-pkcs12, application/x-x509-user-cert, application/x-x509-ca-cert, application/pkix-cert" v-if="!textMode"/>
|
||||
<input type="file" name="certFile" accept="application/x-pem-file, application/pkcs10, application/x-pkcs12, application/x-x509-user-cert, application/x-x509-ca-cert, application/pkix-cert, .pem" v-if="!textMode"/>
|
||||
<file-textarea class="wide-code" ref="certTextField" spellcheck="false" name="certText" placeholder="-----BEGIN CERTIFICATE-----" v-if="textMode" style="font-size: 0.7em"></file-textarea>
|
||||
<p class="comment"><a href="" @click.prevent="switchTextMode">[<span v-if="!textMode">输入内容</span><span v-else>上传文件</span>]</a>。文件内容中通常含有"-----BEGIN CERTIFICATE-----"类似的信息<span v-if="textMode">,可以直接拖动证书文件到输入框</span>。</p>
|
||||
</td>
|
||||
@@ -32,7 +32,7 @@
|
||||
<tr v-show="isCA == 0">
|
||||
<td><span v-if="textMode">输入私钥内容</span><span v-else>选择私钥文件</span> *</td>
|
||||
<td>
|
||||
<input type="file" name="keyFile" accept="application/pkcs8" v-if="!textMode"/>
|
||||
<input type="file" name="keyFile" accept="application/pkcs8, .key" v-if="!textMode"/>
|
||||
<file-textarea class="wide-code" spellcheck="false" name="keyText" placeholder="-----BEGIN RSA PRIVATE KEY-----" v-if="textMode" style="font-size: 0.7em"></file-textarea>
|
||||
<p class="comment"><a href="" @click.prevent="switchTextMode">[<span v-if="!textMode">输入内容</span><span v-else>上传文件</span>]</a>。文件内容中通常含有"-----BEGIN RSA PRIVATE KEY-----"类似的信息<span v-if="textMode">,可以直接拖动私钥文件到输入框</span>。</p>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user