Projekt

Obecné

Profil

Stáhnout (1.69 KB) Statistiky
| Větev: | Tag: | Revize:
1
Vue.use(VueLoading);
2
Vue.component('loading', VueLoading)
3

    
4
// 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
    mounted: async 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

    
19
            // 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

    
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
        }
30

    
31
        // download a list of all available certificates and display them in the table
32
        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
    }
43
});
(9-9/11)