1 |
e75db9cd
|
Jan Pašek
|
Vue.component("certificate-item",{
|
2 |
|
|
props: ["certificate"],
|
3 |
|
|
template: "<tr>"+
|
4 |
|
|
"<td class='align-middle'>{{ certificate.CN }}</td>"+
|
5 |
|
|
"<td class='align-middle'>{{ certificate.notBefore }}</td>"+
|
6 |
|
|
"<td class='align-middle'>{{ certificate.notAfter }}</td>"+
|
7 |
|
|
"<td class='align-middle'>" +
|
8 |
|
|
" <div v-if='certificate.usage.CA'>CA</div>" +
|
9 |
|
|
" <div v-if='certificate.usage.authentication'>authentication</div>" +
|
10 |
|
|
" <div v-if='certificate.usage.digitalSignature'>digital signature</div>" +
|
11 |
|
|
" <div v-if='certificate.usage.SSL'>SSL/TLS</div>" +
|
12 |
|
|
"</td>"+
|
13 |
|
|
"<td class='align-middle'><button v-on:click='onCertificateDownload()'>Download certificate</button></td>"+
|
14 |
28787717
|
Jan Pašek
|
"<td class='align-middle'><button v-on:click='onCertificateChainDownload()'>Download chain of trust</button></td>"+
|
15 |
|
|
"<td class='align-middle'><button v-on:click='onCertificateRootDownload()'>Download chain root</button></td>"+
|
16 |
e75db9cd
|
Jan Pašek
|
"</tr>",
|
17 |
|
|
methods: {
|
18 |
|
|
onCertificateDownload: function () {
|
19 |
|
|
var id = this.certificate.id;
|
20 |
28787717
|
Jan Pašek
|
axios.get(API_URL + "certificates/" + id)
|
21 |
e75db9cd
|
Jan Pašek
|
.then(function (response) {
|
22 |
|
|
if(response.data["success"]) {
|
23 |
|
|
download(id + ".crt", response.data["data"])
|
24 |
|
|
}
|
25 |
|
|
else
|
26 |
|
|
console.log("Error occurred while downloading the certificate") // TODO more action may be required
|
27 |
|
|
})
|
28 |
|
|
.catch(function (error) {
|
29 |
|
|
console.log(error);
|
30 |
|
|
});
|
31 |
28787717
|
Jan Pašek
|
},
|
32 |
|
|
onCertificateChainDownload: function () {
|
33 |
|
|
var id = this.certificate.id;
|
34 |
|
|
axios.get(API_URL + "certificates/" + id + "/chain")
|
35 |
|
|
.then(function (response) {
|
36 |
|
|
if(response.data["success"]) {
|
37 |
|
|
download(id + "_chain.crt", response.data["data"])
|
38 |
|
|
}
|
39 |
|
|
else
|
40 |
|
|
console.log("Error occurred while downloading the certificate's chain of trust") // TODO more action may be required
|
41 |
|
|
})
|
42 |
|
|
.catch(function (error) {
|
43 |
|
|
console.log(error);
|
44 |
|
|
});
|
45 |
|
|
},
|
46 |
|
|
onCertificateRootDownload: function () {
|
47 |
|
|
var id = this.certificate.id;
|
48 |
|
|
axios.get(API_URL + "certificates/" + id + "/root")
|
49 |
|
|
.then(function (response) {
|
50 |
|
|
if(response.data["success"]) {
|
51 |
|
|
download(id + "_root.crt", response.data["data"])
|
52 |
|
|
}
|
53 |
|
|
else
|
54 |
|
|
console.log("Error occurred while downloading the certificate's root CA") // TODO more action may be required
|
55 |
|
|
})
|
56 |
|
|
.catch(function (error) {
|
57 |
|
|
console.log(error);
|
58 |
|
|
});
|
59 |
e75db9cd
|
Jan Pašek
|
}
|
60 |
|
|
}
|
61 |
|
|
});
|