Projekt

Obecné

Profil

Stáhnout (1.8 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: 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
    });
32

    
33
    // download a list of all available certificates and display them in the table
34
    axios.get(API_URL + "certificates")
35
        .then(function (response) {
36
            if (response.data["success"]) {
37
                response.data["data"].forEach(item => certificateListingApp.certificates.push(item))
38
            }
39
            certificateListingApp.loading = false;
40
        })
41
        .catch(function (error) {
42
            console.log(error);
43
            certificateListingApp.loading = false;
44
        });
(9-9/11)