Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 5885e489

Přidáno uživatelem Jan Pašek před asi 4 roky(ů)

Re #8583 - Loading screen and error reaction in certificate.html

Zobrazit rozdíly:

static/js/certificate.js
1
    Vue.use(VueLoading);
2
    Vue.component('loading', VueLoading)
3

  
1 4

  
2 5
    var certificateDetailsApp = new Vue({
3 6
        el: "#certificate-detailed-view-content",
4 7
        data: {
8
            loading: true,
9
            error: false,
5 10
            id: null,
6 11
            certificate: {
7 12
                subject: {
......
74 79
    // get details of the selected certificate
75 80
    const params = window.location.search;
76 81
    if (params !== "") {
82
        // get requested ID
77 83
        const urlParams = new URLSearchParams(params);
78 84
        if (urlParams.get("id") != null) {
79 85
            const id = urlParams.get("id");
80 86
            certificateDetailsApp.id = id;
87
            // query certificate detailes
81 88
            axios.get(API_URL + "certificates/"+id+"/details")
82 89
                .then(function (response) {
83
                    if (response.data["success"])
90
                    if (response.data["success"]) {
91
                        // display certificate
84 92
                        certificateDetailsApp.certificate = response.data["data"];
93
                        certificateDetailsApp.loading = false;
94
                        certificateDetailsApp.error = false;
95
                    }
96
                    else {
97
                        // certificate does not exists
98
                        console.error("Required certificate does not exists");
99
                        certificateDetailsApp.loading = false;
100
                        certificateDetailsApp.error = true;
101
                    }
85 102
                })
86 103
                .catch(function (error) {
87
                    alert("There should be some error reaction");
88
                    // TODO error reaction -> display fault window
104
                    // server error
105
                    console.error(error);
106
                    certificateDetailsApp.loading = false;
107
                    certificateDetailsApp.error = true;
89 108
                });
90 109
        } else {
91
            alert("There should be some error reaction");
92
            // TODO error reaction -> display fault window
110
            // id was not provided as a URL parameter
111
            console.error("URL does not contain 'id' parameter")
112
            certificateDetailsApp.loading = false;
113
            certificateDetailsApp.error = true;
93 114
        }
94 115
    } else {
95
        alert("There should be some error reaction");
96
        // TODO error reaction -> display fault window
97
    }
116
        console.error("URL does not contain 'id' parameter")
117
        certificateDetailsApp.loading = false;
118
        certificateDetailsApp.error = true;
119
    }

Také k dispozici: Unified diff