1 |
dd56c333
|
Jan Pašek
|
Vue.use(VueLoading);
|
2 |
|
|
Vue.component('loading', VueLoading)
|
3 |
e75db9cd
|
Jan Pašek
|
|
4 |
dd56c333
|
Jan Pašek
|
// certificate listing app VUE instance
|
5 |
|
|
var certificateListingApp = new Vue({
|
6 |
|
|
el: "#certificateListingPage",
|
7 |
|
|
data: {
|
8 |
|
|
loading: true,
|
9 |
|
|
// list of all certificates to be displayed in the list
|
10 |
|
|
certificates: [],
|
11 |
|
|
successMessage: ''
|
12 |
|
|
},
|
13 |
37a8e8ec
|
Jan Pašek
|
mounted: async function () {
|
14 |
dd56c333
|
Jan Pašek
|
const params = window.location.search;
|
15 |
|
|
if (params !== "") {
|
16 |
|
|
const urlParams = new URLSearchParams(params);
|
17 |
|
|
if (urlParams.get("success") != null) this.successMessage = urlParams.get("success");
|
18 |
81e73700
|
Jan Pašek
|
|
19 |
dd56c333
|
Jan Pašek
|
// the following code is necessary to dismiss the alert when the page is reloaded
|
20 |
|
|
const nextURL = '/static/index.html';
|
21 |
|
|
const nextTitle = 'X.509 Certificate Management';
|
22 |
|
|
const nextState = {additionalInformation: 'Updated the URL with JS'};
|
23 |
81e73700
|
Jan Pašek
|
|
24 |
dd56c333
|
Jan Pašek
|
// This will create a new entry in the browser's history, without reloading
|
25 |
|
|
window.history.pushState(nextState, nextTitle, nextURL);
|
26 |
81e73700
|
Jan Pašek
|
|
27 |
dd56c333
|
Jan Pašek
|
// This will replace the current entry in the browser's history, without reloading
|
28 |
|
|
window.history.replaceState(nextState, nextTitle, nextURL);
|
29 |
e75db9cd
|
Jan Pašek
|
}
|
30 |
|
|
|
31 |
dd56c333
|
Jan Pašek
|
// download a list of all available certificates and display them in the table
|
32 |
37a8e8ec
|
Jan Pašek
|
try {
|
33 |
|
|
const response = await axios.get(API_URL + "certificates");
|
34 |
|
|
if (response.data["success"]) {
|
35 |
|
|
response.data["data"].forEach(item => certificateListingApp.certificates.push(item))
|
36 |
|
|
}
|
37 |
|
|
certificateListingApp.loading = false;
|
38 |
|
|
} catch (error) {
|
39 |
|
|
console.log(error);
|
40 |
|
|
certificateListingApp.loading = false;
|
41 |
|
|
}
|
42 |
dd56c333
|
Jan Pašek
|
}
|
43 |
|
|
});
|