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