summaryrefslogtreecommitdiffstats
path: root/src/components/CertificateInfoRow.vue
blob: 8a4a875c72a27c96fd38c8fecdc0372a20737375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<template>
    <div>
        <div class="d-flex flex-row align-items-center p-1 overflow-hidden">
            <div class="m-3 ps-3">
                <div class="cert-icon">
                    <font-awesome-icon icon="file" />
                    <font-awesome-icon class="award-icon" icon="award" />
                </div>
            </div>
            <div class="m-3">
                <table class="text-start">
                    <tbody>
                        <tr class="my-3">
                            <td class="px-3">{{ $t("Subject:") }}</td>
                            <td>{{ formatSubject(cert.subject) }}</td>
                        </tr>
                        <tr class="my-3">
                            <td class="px-3">{{ $t("Valid To:") }}</td>
                            <td><Datetime :value="cert.validTo" /></td>
                        </tr>
                        <tr class="my-3">
                            <td class="px-3">{{ $t("Days Remaining:") }}</td>
                            <td>{{ cert.daysRemaining }}</td>
                        </tr>
                        <tr class="my-3">
                            <td class="px-3">{{ $t("Issuer:") }}</td>
                            <td>{{ formatSubject(cert.issuer) }}</td>
                        </tr>
                        <tr class="my-3">
                            <td class="px-3">{{ $t("Fingerprint:") }}</td>
                            <td>{{ cert.fingerprint }}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="d-flex">
            <font-awesome-icon
                v-if="cert.issuerCertificate"
                class="m-2 ps-6 link-icon"
                icon="link"
            />
        </div>
        <certificate-info-row
            v-if="cert.issuerCertificate"
            :cert="cert.issuerCertificate"
        />
    </div>
</template>

<script>
import Datetime from "../components/Datetime.vue";
export default {
    name: "CertificateInfoRow",
    components: {
        Datetime,
    },
    props: {
        /** Object representing certificate */
        cert: {
            type: Object,
            required: true,
        },
    },
    methods: {
        /**
         * Format the subject of the certificate
         * @param {object} subject Object representing the certificates
         * subject
         * @returns {string} Certificate subject
         */
        formatSubject(subject) {
            if (subject.O && subject.CN && subject.C) {
                return `${subject.CN} - ${subject.O} (${subject.C})`;
            } else if (subject.O && subject.CN) {
                return `${subject.CN} - ${subject.O}`;
            } else if (subject.CN) {
                return subject.CN;
            } else {
                return "no info";
            }
        },
    },
};
</script>

<style lang="scss" scoped>
@import "../assets/vars.scss";

table {
    overflow: hidden;
}

.cert-icon {
    position: relative;
    font-size: 70px;
    color: $link-color;
    opacity: 0.5;

    .dark & {
        color: $dark-font-color;
        opacity: 0.3;
    }
}

.award-icon {
    position: absolute;
    font-size: 0.5em;
    bottom: 20%;
    left: 12%;
    color: white;

    .dark & {
        color: $dark-bg;
    }
}

.link-icon {
    font-size: 20px;
    margin-left: 50px !important;
    color: $link-color;
    opacity: 0.5;

    .dark & {
        color: $dark-font-color;
        opacity: 0.3;
    }
}
</style>