Revize 4a772c43
Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)
static/js/utilities.js | ||
---|---|---|
21 | 21 |
|
22 | 22 |
// Adds toDateInputValue() method to Date object |
23 | 23 |
// toDateInputValue() produces date in YYYY-MM-DD format |
24 |
Date.prototype.toDateInputValue = (function() { |
|
24 |
Date.prototype.toDateInputValue = (function () {
|
|
25 | 25 |
var local = new Date(this); |
26 | 26 |
local.setMinutes(this.getMinutes() - this.getTimezoneOffset()); |
27 |
return local.toJSON().slice(0,10); |
|
27 |
return local.toJSON().slice(0, 10);
|
|
28 | 28 |
}); |
29 | 29 |
|
30 | 30 |
/** |
31 | 31 |
* Download certificate given by id |
32 | 32 |
* @param id identifier of certificate to be downloaded |
33 | 33 |
*/ |
34 |
function onCertificateDownload(id) { |
|
35 |
axios.get(API_URL + "certificates/" + id) |
|
36 |
.then(function (response) { |
|
37 |
if (response.data["success"]) { |
|
38 |
download(id + ".pem", response.data["data"]) |
|
39 |
} else |
|
40 |
console.log("Error occurred while downloading the certificate") // TODO more action may be required |
|
41 |
}) |
|
42 |
.catch(function (error) { |
|
43 |
console.log(error); |
|
44 |
}); |
|
34 |
async function onCertificateDownload(id) { |
|
35 |
try { |
|
36 |
const response = await axios.get(API_URL + "certificates/" + id); |
|
37 |
if (response.data["success"]) { |
|
38 |
download(id + ".pem", response.data["data"]) |
|
39 |
} else |
|
40 |
console.log("Error occurred while downloading the certificate") // TODO more action may be required |
|
41 |
} catch (error) { |
|
42 |
console.log(error); |
|
43 |
} |
|
45 | 44 |
} |
46 | 45 |
|
47 | 46 |
/** |
48 | 47 |
* Download root of chain of trust excluding root of given certificate |
49 | 48 |
* @param id identifier of certificate whose chain shall be downloaded |
50 | 49 |
*/ |
51 |
function onCertificateChainDownload(id) { |
|
52 |
axios.get(API_URL + "certificates/" + id + "/chain") |
|
53 |
.then(function (response) { |
|
54 |
if(response.data["success"]) { |
|
55 |
download(id + "_chain.pem", response.data["data"]) |
|
56 |
} |
|
57 |
else |
|
58 |
console.log("Error occurred while downloading the certificate's chain of trust") // TODO more action may be required |
|
59 |
}) |
|
60 |
.catch(function (error) { |
|
61 |
console.log(error); |
|
62 |
}); |
|
50 |
async function onCertificateChainDownload(id) { |
|
51 |
try { |
|
52 |
const response = await axios.get(API_URL + "certificates/" + id + "/chain"); |
|
53 |
if (response.data["success"]) { |
|
54 |
download(id + "_chain.pem", response.data["data"]) |
|
55 |
} else |
|
56 |
console.log("Error occurred while downloading the certificate's chain of trust") // TODO more action may be required |
|
57 |
} catch (error) { |
|
58 |
console.log(error); |
|
59 |
} |
|
63 | 60 |
} |
64 | 61 |
|
65 | 62 |
/** |
66 | 63 |
* Download root of chain of trust corresponding to the given certificate |
67 | 64 |
* @param id identifier of certificate whose root shall be downloaded |
68 | 65 |
*/ |
69 |
function onCertificateRootDownload(id) { |
|
70 |
axios.get(API_URL + "certificates/" + id + "/root") |
|
71 |
.then(function (response) { |
|
72 |
if(response.data["success"]) { |
|
73 |
download(id + "_root.pem", response.data["data"]) |
|
74 |
} |
|
75 |
else |
|
76 |
console.log("Error occurred while downloading the certificate's root CA") // TODO more action may be required |
|
77 |
}) |
|
78 |
.catch(function (error) { |
|
79 |
console.log(error); |
|
80 |
}); |
|
66 |
async function onCertificateRootDownload(id) { |
|
67 |
try { |
|
68 |
const response = await axios.get(API_URL + "certificates/" + id + "/root"); |
|
69 |
if (response.data["success"]) { |
|
70 |
download(id + "_root.pem", response.data["data"]) |
|
71 |
} else |
|
72 |
console.log("Error occurred while downloading the certificate's root CA") // TODO more action may be required |
|
73 |
} catch (error) { |
|
74 |
console.log(error); |
|
75 |
} |
|
81 | 76 |
} |
82 | 77 |
|
83 | 78 |
/** |
84 | 79 |
* Download public key associated with the selected certificate |
85 | 80 |
* @param id identifier of certificate whose pub. key shall be downloaded |
86 | 81 |
*/ |
87 |
function onPublicKeyDownload(id) { |
|
88 |
axios.get(API_URL + "certificates/" + id + "/publickey") |
|
89 |
.then(function (response) { |
|
90 |
if (response.data["success"]) { |
|
91 |
download(id + "_public_key.pem", response.data["data"]) |
|
92 |
} else |
|
93 |
console.log("Error occurred while downloading the certificate's public key") // TODO more action may be required |
|
94 |
}) |
|
95 |
.catch(function (error) { |
|
96 |
console.log(error); |
|
97 |
}); |
|
82 |
async function onPublicKeyDownload(id) { |
|
83 |
try { |
|
84 |
const response = await axios.get(API_URL + "certificates/" + id + "/publickey"); |
|
85 |
if (response.data["success"]) { |
|
86 |
download(id + "_public_key.pem", response.data["data"]) |
|
87 |
} else |
|
88 |
console.log("Error occurred while downloading the certificate's public key") // TODO more action may be required |
|
89 |
} catch (error) { |
|
90 |
console.log(error); |
|
91 |
} |
|
98 | 92 |
} |
99 | 93 |
|
100 | 94 |
/** |
101 | 95 |
* Download public key associated with the selected certificate |
102 | 96 |
* @param id identifier of certificate whose pub. key shall be downloaded |
103 | 97 |
*/ |
104 |
function onPrivateKeyDownload(id) { |
|
105 |
axios.get(API_URL + "certificates/" + id + "/privatekey") |
|
106 |
.then(function (response) { |
|
107 |
if (response.data["success"]) { |
|
108 |
download(id + "_private_key.pem", response.data["data"]) |
|
109 |
} else |
|
110 |
console.log("Error occurred while downloading the certificate's private key") // TODO more action may be required |
|
111 |
}) |
|
112 |
.catch(function (error) { |
|
113 |
console.log(error); |
|
114 |
}); |
|
98 |
async function onPrivateKeyDownload(id) { |
|
99 |
try { |
|
100 |
const response = await axios.get(API_URL + "certificates/" + id + "/privatekey"); |
|
101 |
if (response.data["success"]) { |
|
102 |
download(id + "_private_key.pem", response.data["data"]) |
|
103 |
} else |
|
104 |
console.log("Error occurred while downloading the certificate's private key") // TODO more action may be required |
|
105 |
} catch (error) { |
|
106 |
console.log(error); |
|
107 |
} |
|
115 | 108 |
} |
Také k dispozici: Unified diff
Re #8583 - certificate.js and utilities.js using await