Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 56b36ca7

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

Re #8583 - Display issued certificates

Zobrazit rozdíly:

static/certificate.html
182 182
                                </tr>
183 183
                            </thead>
184 184
                            <tbody>
185
                                <tr>
186
                                    <td>&ltsome_certificate_name&gt</td>
187
                                    <td>&lttype&gt</td>
185
                                <tr class="text-center font-italic">
186
                                    <td v-if="issuedCertificates.length == 0" colspan="2">No issued certificates</td>
188 187
                                </tr>
189
                                <tr>
190
                                    <td>&ltsome_certificate_long_name&gt</td>
191
                                    <td>&ltCA&gt</td>
188
                                <tr is="issued-by-list-item"
189
                                    v-for="certificate in issuedCertificates"
190
                                    v-bind:certificate="certificate"
191
                                    v-bind:key="certificate.id">
192 192
                                </tr>
193 193
                            </tbody>
194 194
                        </table>
static/js/certificate.js
9 9
            error: false,
10 10
            id: null,
11 11
            revocationReason: "unspecified",
12
            issuedCertificates: [],
12 13
            certificate: {
13 14
                subject: {
14 15
                    C: "",
......
120 121
                    if (response.data["success"]) {
121 122
                        // display certificate
122 123
                        certificateDetailsApp.certificate = response.data["data"];
124
                        loadIssuedCertificates();
123 125
                        certificateDetailsApp.loading = false;
124 126
                        certificateDetailsApp.error = false;
125 127
                    }
......
147 149
        certificateDetailsApp.loading = false;
148 150
        certificateDetailsApp.error = true;
149 151
    }
152

  
153
    function loadIssuedCertificates() {
154
            axios.get(API_URL+"certificates", {
155
            params: {
156
                filtering: {
157
                    issuedby: parseInt(certificateDetailsApp.id)
158
                }
159
            }
160
        })
161
        .then(function (response) {
162
            if (response.data["success"]) {
163
                response.data["data"].forEach(item => {if(item.id != certificateDetailsApp.id) certificateDetailsApp.issuedCertificates.push(item)})
164
            }
165
            else
166
            {
167
                certificateDetailsApp.issuedCertificates = [];
168
            }
169
        })
170
        .catch(function (error) {
171
            console.log(error);
172
        });
173
    }
static/js/components.js
38 38
    // Certificate authority to be represented by the option
39 39
    props: ["ca"],
40 40
    template: "<option v-bind:value='ca.id'>{{ ca.CN }}</option>"
41
});
42

  
43
// Component representing a certificate issued by displayed CA
44
Vue.component("issued-by-list-item", {
45
    props: ["certificate"],
46
    template:   "<tr class='align-middle text-center'>"+
47
                    "<td class='align-middle'><a :href='certificateURL' class='font-weight-bold'>{{ certificate.CN }}</a></td>"+
48
                    "<td class='align-middle'>" +
49
                    "   <div v-if='certificate.usage.CA'>CA</div>" +
50
                    "   <div v-if='certificate.usage.authentication'>authentication</div>" +
51
                    "   <div v-if='certificate.usage.digitalSignature'>digital signature</div>" +
52
                    "   <div v-if='certificate.usage.SSL'>SSL/TLS</div>" +
53
                    "</td>"+
54
                "</tr>",
55
    computed: {
56
        certificateURL: function () {
57
            return "/static/certificate.html?id=" + this.certificate.id;
58
        }
59
    }
41 60
});

Také k dispozici: Unified diff