2020-11-25 21:19:07 +08:00
|
|
|
|
Tea.context(function () {
|
|
|
|
|
|
this.step = "prepare"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 准备工作
|
|
|
|
|
|
*/
|
2020-12-03 18:19:09 +08:00
|
|
|
|
this.authType = "http"
|
|
|
|
|
|
|
2020-11-25 21:19:07 +08:00
|
|
|
|
this.doPrepare = function () {
|
|
|
|
|
|
this.step = "user"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-06-24 09:58:44 +08:00
|
|
|
|
this.prepareMoreOptionsVisible = false
|
|
|
|
|
|
this.authURL = ""
|
|
|
|
|
|
this.showPrepareMoreOptionsVisible = function () {
|
|
|
|
|
|
this.prepareMoreOptionsVisible = !this.prepareMoreOptionsVisible
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-25 21:19:07 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 选择用户
|
|
|
|
|
|
*/
|
|
|
|
|
|
this.userId = 0
|
|
|
|
|
|
|
|
|
|
|
|
this.goPrepare = function () {
|
|
|
|
|
|
this.step = "prepare"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.createUser = function () {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
teaweb.popup("/servers/certs/acme/users/createPopup", {
|
2021-10-03 13:09:49 +08:00
|
|
|
|
height: "27em",
|
|
|
|
|
|
width: "44em",
|
2020-11-25 21:19:07 +08:00
|
|
|
|
callback: function (resp) {
|
|
|
|
|
|
teaweb.successToast("创建成功")
|
|
|
|
|
|
|
|
|
|
|
|
let acmeUser = resp.data.acmeUser
|
|
|
|
|
|
let description = acmeUser.description
|
|
|
|
|
|
if (description.length > 0) {
|
|
|
|
|
|
description = "(" + description + ")"
|
|
|
|
|
|
}
|
|
|
|
|
|
that.userId = acmeUser.id
|
|
|
|
|
|
that.users.unshift({
|
|
|
|
|
|
id: acmeUser.id,
|
|
|
|
|
|
description: description,
|
2021-10-03 13:09:49 +08:00
|
|
|
|
email: acmeUser.email,
|
|
|
|
|
|
providerCode: acmeUser.providerCode
|
2020-11-25 21:19:07 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-10-03 13:09:49 +08:00
|
|
|
|
this.providerCode = ""
|
|
|
|
|
|
this.changeProvider = function () {
|
|
|
|
|
|
this.userId = 0
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-25 21:19:07 +08:00
|
|
|
|
this.doUser = function () {
|
2021-10-03 13:09:49 +08:00
|
|
|
|
if (this.providerCode.length == 0) {
|
|
|
|
|
|
teaweb.warn("请选择一个证书服务商")
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2020-11-25 21:19:07 +08:00
|
|
|
|
if (this.userId == 0) {
|
|
|
|
|
|
teaweb.warn("请选择一个申请证书的用户")
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
this.step = "dns"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 设置DNS解析
|
|
|
|
|
|
*/
|
|
|
|
|
|
this.dnsProviderId = 0
|
|
|
|
|
|
this.dnsDomain = ""
|
|
|
|
|
|
this.autoRenew = true
|
|
|
|
|
|
this.domains = []
|
|
|
|
|
|
this.taskId = 0
|
|
|
|
|
|
this.isRequesting = false
|
|
|
|
|
|
|
|
|
|
|
|
this.goUser = function () {
|
|
|
|
|
|
this.step = "user"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.changeDomains = function (v) {
|
|
|
|
|
|
this.domains = v
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.doDNS = function () {
|
|
|
|
|
|
this.isRequesting = true
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
|
|
|
|
|
|
this.$post("$")
|
|
|
|
|
|
.params({
|
2020-12-03 18:19:09 +08:00
|
|
|
|
authType: this.authType,
|
2020-11-25 21:19:07 +08:00
|
|
|
|
acmeUserId: this.userId,
|
|
|
|
|
|
dnsProviderId: this.dnsProviderId,
|
|
|
|
|
|
dnsDomain: this.dnsDomain,
|
|
|
|
|
|
domains: this.domains,
|
|
|
|
|
|
autoRenew: this.autoRenew ? 1 : 0,
|
2021-06-24 09:58:44 +08:00
|
|
|
|
taskId: this.taskId,
|
|
|
|
|
|
authURL: this.authURL
|
2020-11-25 21:19:07 +08:00
|
|
|
|
})
|
|
|
|
|
|
.success(function (resp) {
|
|
|
|
|
|
this.taskId = resp.data.taskId
|
|
|
|
|
|
|
|
|
|
|
|
this.isRequesting = true
|
|
|
|
|
|
this.$post(".run")
|
2020-11-26 16:39:01 +08:00
|
|
|
|
.timeout(300)
|
2020-11-25 21:19:07 +08:00
|
|
|
|
.params({
|
|
|
|
|
|
taskId: this.taskId
|
|
|
|
|
|
})
|
|
|
|
|
|
.success(function (resp) {
|
|
|
|
|
|
that.certId = resp.data.certId
|
|
|
|
|
|
that.step = "finish"
|
|
|
|
|
|
})
|
|
|
|
|
|
.done(function () {
|
|
|
|
|
|
that.isRequesting = false
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
.done(function () {
|
|
|
|
|
|
this.isRequesting = false
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 完成
|
|
|
|
|
|
*/
|
|
|
|
|
|
this.certId = 0
|
|
|
|
|
|
|
|
|
|
|
|
this.goDNS = function () {
|
|
|
|
|
|
this.step = "dns"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.doFinish = function () {
|
|
|
|
|
|
window.location = "/servers/certs/acme"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.viewCert = function () {
|
|
|
|
|
|
teaweb.popup("/servers/certs/certPopup?certId=" + this.certId, {
|
|
|
|
|
|
height: "28em",
|
|
|
|
|
|
width: "48em"
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|