Projekt

Obecné

Profil

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