Revize 4a772c43
Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)
static/js/certificate.js | ||
---|---|---|
52 | 52 |
}, |
53 | 53 |
watch: {}, |
54 | 54 |
methods: { |
55 |
onCertificateDownload: function () { |
|
56 |
onCertificateDownload(this.id); |
|
55 |
onCertificateDownload: async function () {
|
|
56 |
await onCertificateDownload(this.id);
|
|
57 | 57 |
}, |
58 |
onRootDownload: function () { |
|
59 |
onCertificateRootDownload(this.id); |
|
58 |
onRootDownload: async function () {
|
|
59 |
await onCertificateRootDownload(this.id);
|
|
60 | 60 |
}, |
61 |
onChainDownload: function () { |
|
62 |
onCertificateChainDownload(this.id); |
|
61 |
onChainDownload: async function () {
|
|
62 |
await onCertificateChainDownload(this.id);
|
|
63 | 63 |
}, |
64 |
onPublicKeyDownload: function () { |
|
65 |
onPublicKeyDownload(this.id); |
|
64 |
onPublicKeyDownload: async function () {
|
|
65 |
await onPublicKeyDownload(this.id);
|
|
66 | 66 |
}, |
67 |
onPrivateKeyDownload: function () { |
|
68 |
onPrivateKeyDownload(this.id); |
|
67 |
onPrivateKeyDownload: async function () {
|
|
68 |
await onPrivateKeyDownload(this.id);
|
|
69 | 69 |
}, |
70 |
onRevoke: function () { |
|
70 |
onRevoke: async function () {
|
|
71 | 71 |
document.body.scrollTop = 0; |
72 | 72 |
document.documentElement.scrollTop = 0; |
73 |
axios.patch(API_URL + "certificates/" + this.id, { |
|
74 |
status: "revoked", |
|
75 |
reason: this.revocationReason |
|
76 |
}) |
|
77 |
.then(function (response) { |
|
78 |
if (response.data["success"]) { |
|
79 |
certificateDetailsApp.successMessage = "Certificate revocation successful."; |
|
80 |
} else { |
|
81 |
certificateDetailsApp.errorMessage = "Certificate cannot be revoked - " + response.data["data"] + "!"; |
|
82 |
} |
|
83 |
}) |
|
84 |
.catch(function (error) { |
|
85 |
certificateDetailsApp.errorMessage = "An error occurred while revoking certificate"; |
|
73 |
try { |
|
74 |
const response = await axios.patch(API_URL + "certificates/" + this.id, { |
|
75 |
status: "revoked", |
|
76 |
reason: this.revocationReason |
|
86 | 77 |
}); |
78 |
if (response.data["success"]) { |
|
79 |
certificateDetailsApp.successMessage = "Certificate revocation successful."; |
|
80 |
} else { |
|
81 |
certificateDetailsApp.errorMessage = "Certificate cannot be revoked - " + response.data["data"] + "!"; |
|
82 |
} |
|
83 |
} catch (error) { |
|
84 |
certificateDetailsApp.errorMessage = "An error occurred while revoking certificate"; |
|
85 |
} |
|
87 | 86 |
}, |
88 |
onDelete: function () { |
|
87 |
onDelete: async function () {
|
|
89 | 88 |
document.body.scrollTop = 0; |
90 | 89 |
document.documentElement.scrollTop = 0; |
91 |
axios.delete(API_URL + "certificates/" + this.id) |
|
92 |
.then(function (response) { |
|
93 |
if (response.data["success"]) { |
|
94 |
window.location.href = "/static/index.html?success=Certificate+successfully+deleted"; |
|
95 |
} else { |
|
96 |
certificateDetailsApp.errorMessage = "Certificate cannot be deleted - " + response.data["data"] + "!"; |
|
97 |
} |
|
98 |
}) |
|
99 |
.catch(function (error) { |
|
100 |
certificateDetailsApp.errorMessage = "An error occurred while deleting certificate"; |
|
101 |
}); |
|
102 |
}, |
|
103 |
loadIssuedCertificates: function () { |
|
104 |
|
|
90 |
try { |
|
91 |
const response = await axios.delete(API_URL + "certificates/" + this.id); |
|
92 |
if (response.data["success"]) { |
|
93 |
window.location.href = "/static/index.html?success=Certificate+successfully+deleted"; |
|
94 |
} else { |
|
95 |
certificateDetailsApp.errorMessage = "Certificate cannot be deleted - " + response.data["data"] + "!"; |
|
96 |
} |
|
97 |
} catch (error) { |
|
98 |
certificateDetailsApp.errorMessage = "An error occurred while deleting certificate"; |
|
99 |
} |
|
105 | 100 |
} |
106 | 101 |
}, |
107 |
mounted: function () { |
|
102 |
mounted: async function () {
|
|
108 | 103 |
// get details of the selected certificate |
109 | 104 |
const params = window.location.search; |
110 | 105 |
if (params !== "") { |
... | ... | |
113 | 108 |
if (urlParams.get("id") != null) { |
114 | 109 |
const id = urlParams.get("id"); |
115 | 110 |
this.id = id; |
111 |
var loadedDetails = false; |
|
116 | 112 |
// query certificate details |
117 |
axios.get(API_URL + "certificates/" + id + "/details") |
|
118 |
.then(function (response) { |
|
119 |
if (response.data["success"]) { |
|
120 |
// display certificate |
|
121 |
certificateDetailsApp.certificate = response.data["data"]; |
|
122 |
axios.get(API_URL + "certificates", { |
|
123 |
params: { |
|
124 |
filtering: { |
|
125 |
issuedby: parseInt(certificateDetailsApp.id) |
|
126 |
} |
|
127 |
} |
|
128 |
}) |
|
129 |
.then(function (response) { |
|
130 |
if (response.data["success"]) { |
|
131 |
response.data["data"].forEach(item => { |
|
132 |
if (item.id != certificateDetailsApp.id) certificateDetailsApp.issuedCertificates.push(item) |
|
133 |
}) |
|
134 |
} else { |
|
135 |
certificateDetailsApp.issuedCertificates = []; |
|
136 |
} |
|
137 |
}) |
|
138 |
.catch(function (error) { |
|
139 |
console.log(error); |
|
140 |
}); |
|
141 |
certificateDetailsApp.loading = false; |
|
142 |
certificateDetailsApp.error = false; |
|
143 |
} else { |
|
144 |
// certificate does not exists |
|
145 |
console.error("Required certificate does not exists"); |
|
146 |
certificateDetailsApp.loading = false; |
|
147 |
certificateDetailsApp.error = true; |
|
148 |
} |
|
149 |
}) |
|
150 |
.catch(function (error) { |
|
151 |
// server error |
|
152 |
console.error(error); |
|
113 |
try { |
|
114 |
const response = await axios.get(API_URL + "certificates/" + id + "/details"); |
|
115 |
if (response.data["success"]) { |
|
116 |
// display certificate |
|
117 |
certificateDetailsApp.certificate = response.data["data"]; |
|
118 |
loadedDetails = true; |
|
119 |
} else { |
|
120 |
// certificate does not exists |
|
121 |
console.error("Required certificate does not exists"); |
|
153 | 122 |
certificateDetailsApp.loading = false; |
154 | 123 |
certificateDetailsApp.error = true; |
155 |
}); |
|
124 |
} |
|
125 |
} catch (error) { |
|
126 |
console.error(error); |
|
127 |
certificateDetailsApp.loading = false; |
|
128 |
certificateDetailsApp.error = true; |
|
129 |
} |
|
156 | 130 |
} else { |
157 | 131 |
// id was not provided as a URL parameter |
158 | 132 |
console.error("URL does not contain 'id' parameter") |
... | ... | |
164 | 138 |
certificateDetailsApp.loading = false; |
165 | 139 |
certificateDetailsApp.error = true; |
166 | 140 |
} |
141 |
|
|
142 |
if (!loadedDetails) return; |
|
143 |
try { |
|
144 |
const response = await axios.get(API_URL + "certificates", { |
|
145 |
params: { |
|
146 |
filtering: { |
|
147 |
issuedby: parseInt(certificateDetailsApp.id) |
|
148 |
} |
|
149 |
} |
|
150 |
}); |
|
151 |
if (response.data["success"]) { |
|
152 |
response.data["data"].forEach(item => { |
|
153 |
if (item.id != certificateDetailsApp.id) certificateDetailsApp.issuedCertificates.push(item) |
|
154 |
}) |
|
155 |
} else { |
|
156 |
certificateDetailsApp.issuedCertificates = []; |
|
157 |
} |
|
158 |
} catch (error) { |
|
159 |
console.log(error); |
|
160 |
} |
|
161 |
this.loading = false; |
|
162 |
this.error = false; |
|
167 | 163 |
} |
168 | 164 |
}); |
169 | 165 |
|
Také k dispozici: Unified diff
Re #8583 - certificate.js and utilities.js using await