Projekt

Obecné

Profil

Stáhnout (1.74 KB) Statistiky
| Větev: | Tag: | Revize:
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
    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 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
        axios.get(API_URL + "certificates")
33
            .then(function (response) {
34
                if (response.data["success"]) {
35
                    response.data["data"].forEach(item => certificateListingApp.certificates.push(item))
36
                }
37
                certificateListingApp.loading = false;
38
            })
39
            .catch(function (error) {
40
                console.log(error);
41
                certificateListingApp.loading = false;
42
            });
43
    }
44
});