index.html 23.2 KB
Newer Older
matthias.lang's avatar
matthias.lang committed
1
2
3
<!DOCTYPE html>
<html lang="en">
<head>
4
5
  <!-- prevent IE from falling back to IE 8 engine -->
  <meta http-equiv="x-ua-compatible" content="IE=Edge"/>
matthias.lang's avatar
matthias.lang committed
6
7
8
9

  <!-- Basic Page Needs
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <meta charset="utf-8">
10
  <title>KIT-CA Zertifikatsuche</title>
matthias.lang's avatar
matthias.lang committed
11
12
13
14
15
16
17
18
19
20
21
22
23
  <meta name="description" content="">
  <meta name="author" content="">

  <!-- Mobile Specific Metas
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <!-- FONT
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">

  <!-- CSS
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
24
25
  <link rel="stylesheet" href="css/normalize.css">
  <link rel="stylesheet" href="css/skeleton.css">
matthias.lang's avatar
matthias.lang committed
26
  <link rel="stylesheet" href="css/font-awesome.min.css">
matthias.lang's avatar
matthias.lang committed
27
28

  <style>
matthias.lang's avatar
matthias.lang committed
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
    th.active .arrow {
        opacity: 1;
    }

    .arrow {
        display: inline-block;
        vertical-align: middle;
        width: 0;
        height: 0;
        margin-left: 5px;
        opacity: 0.66;
    }

    .arrow.asc {
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-bottom: 4px solid;
    }

    .arrow.dsc {
        border-top: 4px solid;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
    }

    .good { color: green; }
    .neutral { color: orange; }
    .bad { color: red; }
    .valid { color: black; }
    .invalid { color: grey; }

    .icon {
        line-height: 1em !important;
        height: 1em;
        width: 1em;
        text-align: center;
        vertical-align: middle;
        padding: 5px;
        border-radius: 4px;
        border: 1px solid #b3e0da;
        background-color: #b3e0da;
        color: #FFF;
    }

    .icon-active {
        background-color: #009682;
        border-color: #009682;
        color: #FFF;
    }

    /* TODO: asd*/
    .fa {
        font-size: 1.33333333em;
        line-height: 0.75em;
        vertical-align: -15%;
    }
matthias.lang's avatar
matthias.lang committed
85
86
87
88
89
90
  </style>

  <!-- Favicon
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <link rel="icon" type="image/png" href="images/favicon.png">

matthias.lang's avatar
matthias.lang committed
91

92
93
94
  <script src="js/vue.js"></script>
  <script src="js/vue-resource.min.js"></script>
  <script src="js/vue-router.js"></script>
95
96


matthias.lang's avatar
matthias.lang committed
97

matthias.lang's avatar
matthias.lang committed
98
99
100
</head>
<body>

matthias.lang's avatar
matthias.lang committed
101
102


matthias.lang's avatar
matthias.lang committed
103
104
105
106
    <div class="container">

        <div class="row" style="margin-bottom: 4em; margin-top: 5%"">
            <div class="one-half column">
107
                <img src="images/KIT-CA-Logo.svg" height="60px" alt="KIT-CA Logo" />
matthias.lang's avatar
matthias.lang committed
108
109
            </div>
            <div class="one-half column" style="text-align: right">
110
                <h1>Zertifikatsuche</h1>
matthias.lang's avatar
matthias.lang committed
111
112
113
114
115
116
117
118
119
120
121
122
123
            </div>
        </div>
        <div class="row">
            <div class="u-full-width">
                <p>Bitte geben Sie den Namen oder die exakte E-Mail-Adresse aus dem Zertifikat ein, das Sie suchen.</p>
            </div>
        </div>


        <div id="ca-search">
            <form v-on:submit.prevent="search()" style="margin-bottom: 0">
                <div class="row">
                    <div class="ten columns">
matthias.lang's avatar
matthias.lang committed
124
                        <input name="q" class="u-full-width" type="text" placeholder="Name oder E-Mail-Adresse" id="query" v-model="query" autofocus>
matthias.lang's avatar
matthias.lang committed
125
126
127
128
129
130
131
132
133
134
                    </div>
                    <div class="two columns">
                        <button class="button-primary" type="submit" @click="search()" v-if="!loading" required>Suchen</button>
                        <button class="button-primary" type="button" disabled="disabled" v-if="loading">Suche...</button>
                    </div>
                </div>
            </form>

            <div class="row">
                <div class="ten columns">
135
136
137
                    <span v-for="category in filterShow" class="one-third column" v-if="!category.hideInPublicSearch || visitorLoggedIn">
                        <strong>{{ category.name }}:</strong><br/>
                        <span v-for="filter in category.filters" v-if="!filter.hideInPublicSearch || visitorLoggedIn">
matthias.lang's avatar
matthias.lang committed
138
                            <span
139
140
141
                            class="icon fa"
                            :title="filter.displayName"
                            v-bind:class="[filter.displayIcon, { 'icon-active': filter.buttonState }]"
matthias.lang's avatar
matthias.lang committed
142
143
                            v-on:click="enableFilter(filter)"
                            v-on:dblclick="enableOnlyFilter(filter, category.filters)"
144
145
146
147
148
                            style="margin: 5px"
                            >
                                <!-- <small>{{ filter.resultCount}}</small> -->
                            </span>
                        </span>
matthias.lang's avatar
matthias.lang committed
149
                    </span>
150
151
152
153
                </div>
                <div class="two columns">
                    <div class="row">
                        <div class="twelve columns" style="text-align: right;">
154
                            <span class="button" type="submit" v-if="visitorLoggedIn" required>Hallo, {{ visitorGivenName }} {{ visitorSn }}</span>
155
156
157
158
                            <a :href="'/Shibboleth.sso/Login?target=/?q=' + query"><span class="button" v-if="!visitorLoggedIn" required>Nicht eingeloggt</span></a>
                        </div>
                    </div>

matthias.lang's avatar
matthias.lang committed
159
160
161
162
163
164
165
166
167
168
                </div>

            </div>

            <div class="alert alert-danger" role="alert" v-if="error">
                <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                 &#x26A0; {{ error }}
            </div>

            <div class="row" style="margin-top: 4em">
169
                <em>Zeige {{ filteredData.length }} von {{ resultData.length }} Treffern</em>
matthias.lang's avatar
matthias.lang committed
170
171
            </div>

172
            <table class="u-full-width" v-if="filteredData.length">
matthias.lang's avatar
matthias.lang committed
173
174
                <thead>
                    <tr>
175
                        <th />
matthias.lang's avatar
matthias.lang committed
176
                        <th v-for="entry in tableHeaders"
177
                                v-if="!entry.hideInPublicSearch || visitorLoggedIn"
matthias.lang's avatar
matthias.lang committed
178
179
180
181
182
183
184
185
186
187
                                @click="sortBy(entry.field)"
                                :class="{ active: sortKey == entry.field }">
                            {{ entry.description }}
                            <span class="arrow" :class="sortOrders[entry.field] > 0 ? 'asc' : 'dsc'">
                            </span>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="entry in filteredData" style="vertical-align: top">
188
189
190
191
192
193
                        <td style="text-align: right">
                            <a :href="'https://api.ca.kit.edu/redirect/getcert/' + entry.serial">
                                <i class="fa fa-download" title="Download"></i>
                            </a>
                                <i class="fa fa-info-circle" aria-hidden="true"></i>
                        </td>
Heiko Reese's avatar
Heiko Reese committed
194
                        <td>
195
                            {{entry.cn}} <span v-if="entry.ou">({{entry.ou}})</span></b><br/>
196
                            <small>S/N: {{entry.serial}}</small>
Heiko Reese's avatar
Heiko Reese committed
197
198
199
200
                        </td>
                        <td>
                            <span v-for="email in entry.emailaddresses">{{email}} </span> <!-- TODO: -->
                        </td>
201
202
203
                        <td>
                                <span :title="entry.notafter">{{ entry.notafterduration }}</span>
                        </td>
Heiko Reese's avatar
Heiko Reese committed
204
                        <td>
205
206
207
                            <i v-if="entry.valid=='valid'"   :title="entry.valid" class="fa fa-check good"></i>
                            <i v-if="entry.valid=='expired'" :title="entry.valid" class="fa fa-times neutral"></i>
                            <i v-if="entry.valid=='revoked'" :title="entry.valid" class="fa fa-ban bad"></i>
Heiko Reese's avatar
Heiko Reese committed
208
209
                        </td>
                        <td>
210
211
212
213
214
215
                            <i v-if="entry.type=='Benutzer'"    class="fa fa-user"  :title="entry.type"></i>
                            <i v-if="entry.type=='Gruppe'"      class="fa fa-users" :title="entry.type"></i>
                            <i v-if="entry.type=='Pseudonym'"   class="fa fa-user-secret"   :title="entry.type"></i>
                            <i v-if="entry.type=='Extern'"      class="fa fa-user-plus" :title="entry.type"></i>
                            <i v-if="entry.type=='Unbekannt'"   class="fa fa-question-circle"   :title="entry.type"></i>
                            <i v-if="entry.type=='Server'"      class="fa fa-server"    :title="entry.type"></i>
Heiko Reese's avatar
Heiko Reese committed
216
                        </td>
217
                        <td v-if="visitorLoggedIn">
218
219
220
                            <i v-if="entry.public=='public'"  class="fa fa-eye" :title="entry.public"></i>
                            <i v-if="entry.public=='private'" class="fa fa-eye-slash" :title="entry.public"></i>
                            <i v-if="entry.public=='unknown'" class="fa fa-low-vision" :title="entry.public"></i>
Heiko Reese's avatar
Heiko Reese committed
221
                        </td>
matthias.lang's avatar
matthias.lang committed
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
                    </tr>
                </tbody>
            </table>


        </div>
    </div>


    <script type="text/javascript">
        var caSearch = new Vue({
            el: '#ca-search',
            data: {
                tableHeaders: [
                    {'field': 'cn',                 'description': 'Name'},
                    {'field': 'emailaddresses',     'description': 'E-Mail'},
                    {'field': 'notafterepoch',      'description': 'Ablaufdatum'},
                    {'field': 'valid',              'description': ''},
                    {'field': 'type',               'description': ''},
241
                    {'field': 'public',             'description': '', 'hideInPublicSearch': true},
matthias.lang's avatar
matthias.lang committed
242
243
244
245
246
247
248
249
                ],
                resultData: [],
                loading: false,
                error: false,
                query: '',
                sortKey: String,
                sortOrders: {},
                visitorLoggedIn: false,
250
251
252
                visitorGivenName: null,
                visitorSn: null,
                visitorMail: null,
matthias.lang's avatar
matthias.lang committed
253
254
255
256
257
258
259
260
                filterShow: {
                    'validity': {
                        'name': 'Gültigkeit',
                        'filters': {
                            'v_valid': {
                                'displayName': 'gültig',
                                'displayIcon': 'fa-check',
                                filterfunction: function(element) {return element.valid != 'valid' },
261
262
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
263
264
265
266
267
                            },
                            'v_expired': {
                                'displayName': 'abgelaufen',
                                'displayIcon': 'fa-times',
                                filterfunction: function(element) {return element.valid != 'expired' },
268
269
                                'buttonState': false,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
270
271
272
273
274
                            },
                            'v_revoked': {
                                'displayName': 'gesperrt',
                                'displayIcon': 'fa-ban',
                                filterfunction: function(element) {return element.valid != 'revoked' },
275
276
277
                                'buttonState': false,
                                'resultCount': 0
                            }
matthias.lang's avatar
matthias.lang committed
278
279
280
281
282
283
284
285
286
                        }
                    },
                    'types': {
                        'name': 'Typ',
                        'filters': {
                            't_user': {
                                'displayName': 'Nutzer',
                                'displayIcon': 'fa-user',
                                filterfunction: function(element) {return element.type != 'Benutzer' },
287
288
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
289
290
291
292
293
                            },
                            't_pseudonym': {
                                'displayName': 'PN',
                                'displayIcon': 'fa-user-secret',
                                filterfunction: function(element) {return element.type != 'Pseudonym' },
294
295
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
296
297
298
299
300
                            },
                            't_group': {
                                'displayName': 'Gruppe',
                                'displayIcon': 'fa-users',
                                filterfunction: function(element) {return element.type != 'Gruppe' },
301
302
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
303
304
305
306
307
                            },
                            't_extern': {
                                'displayName': 'Extern',
                                'displayIcon': 'fa-user-plus',
                                filterfunction: function(element) {return element.type != 'Extern' },
308
309
                                'buttonState': false,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
310
311
312
313
                            },
                            't_server': {
                                'displayName': 'Server',
                                'displayIcon': 'fa-server',
314
                                'hideInPublicSearch': true,
matthias.lang's avatar
matthias.lang committed
315
                                filterfunction: function(element) {return element.type != 'Server' },
316
317
318
319
                                'buttonState': false,
                                'resultCount': 0
                            }
                        }
matthias.lang's avatar
matthias.lang committed
320
321
                    },
                    'visibility': {
matthias.lang's avatar
matthias.lang committed
322
                        'name': 'Sichtbarkeit',
323
                        'hideInPublicSearch': true,
matthias.lang's avatar
matthias.lang committed
324
325
326
327
328
                        'filters': {
                            'vis_public': {
                                'displayName': 'öffentlich',
                                'displayIcon': 'fa-eye',
                                filterfunction: function(element) {return element.public != 'public' },
329
330
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
331
332
333
334
335
                            },
                            'vis_private': {
                                'displayName': 'nicht-öffentlich',
                                'displayIcon': 'fa-eye-slash',
                                filterfunction: function(element) {return element.public == 'public' },
336
337
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
                            }
                        }
                    }

                }


            },
            computed: {
                filteredData: function () {
                    var sortKey = this.sortKey
                    var order = this.sortOrders[sortKey] || 1
                    var data = this.resultData

                    // filter
                    for (var filterCategory in this.filterShow) {
                        for (var elem in this.filterShow[filterCategory].filters) {             // TODO: UUGLLYYYYY. Fix it.
                            var filter = this.filterShow[filterCategory].filters[elem]
                            if (filter.buttonState == false) {
                                data = data.filter(filter.filterfunction)
                            }
                        }
                    }

                    // sort
                    if (sortKey) {
                        data = data.slice().sort(function (a, b) {
                            a = a[sortKey]
                            b = b[sortKey]
                            return (a === b ? 0 : a > b ? 1 : -1) * order
                        })
                    }

                    return data
                }

            },
            methods: {
                search: function() {
                    this.error = '';
                    this.resultData = [];

                    // Let the UI know we're busy
                    this.loading = true;

383
384
385
386
387
                    if (this.visitorLoggedIn) {
                        url = location.protocol + '//' + location.host + '/search/v1/json?q=';
                    } else {
                        url = location.protocol + '//' + location.host + '/pubsearch/v1/json?q=';
                    }
matthias.lang's avatar
matthias.lang committed
388
389

                    // Query our API
390
391
392
393
394
395
                    this.$http.get(url + encodeURIComponent(this.query)).then(
                        function(response) {
                            response.body.error ? this.error = response.body.error : this.resultData = response.body.results;
                            // Let the UI know we're done
                            this.loading = false;
                            //this.query = '';
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412



                            // bin search results
                            this.resultData.forEach(
                                function(entry) {
                                    for (var filterCategory in this.filterShow) {
                                        for (var elem in this.filterShow[filterCategory].filters) {
                                            var filter = this.filterShow[filterCategory].filters[elem]
                                            if (!filter.filterfunction(entry)) {
                                                filter.resultCount++;
                                            }
                                        }
                                    }
                                }, this
                            )

413
414
                        }
                    );
matthias.lang's avatar
matthias.lang committed
415
                    // TODO: error handling
416
417


matthias.lang's avatar
matthias.lang committed
418
419
                },

420
421
422
423
424
425
426
427
                // provisorium. TODO: replace with URLSearchParams polyfill or VueRouter
                getUrlParameter: function(name) {
                    name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
                    var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
                    var results = regex.exec(location.search);
                    return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
                },

matthias.lang's avatar
matthias.lang committed
428

429
430
                getShibSessionData: function() {
                    url = location.protocol + '//' + location.host + '/Shibboleth.sso/Session';
matthias.lang's avatar
matthias.lang committed
431
432
433



434
435
436
                    // Query our API
                    this.$http.get(url).then(
                        function(response) {
437
438
                            //var res = JSON.parse(response.body); //TODO: this is only needed for local development
                            var res = response.body; //TODO
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
                            if (res.hasOwnProperty('expiration') && res.hasOwnProperty('attributes')) {
                                this.visitorLoggedIn = true;

                                res.attributes.forEach(
                                    function(item) {
                                        switch (item.name) {
                                            case 'givenName':
                                                this.visitorGivenName = item.values[0];
                                                break;
                                            case 'sn':
                                                this.visitorSn        = item.values[0];
                                                break;
                                            case 'mail':
                                                this.visitorMail      = item.values[0];
                                                break;
                                        }
                                    }, this
                                );

                                if (this.query == '') {
                                    this.query = this.visitorMail;
                                }
461
462
                                this.search();  // run search again, cause it might give different results, now that we're logged in.

463
464
465
466
467
468
                            } else {
                                this.visitorLoggedIn = false;
                            }
                        },
                        function(response) {
                            // handle error
matthias.lang's avatar
matthias.lang committed
469

470
                            console.log('error')
matthias.lang's avatar
matthias.lang committed
471
                        }
472
473
                    );
/*
matthias.lang's avatar
matthias.lang committed
474
475
476
477
478
479
480
481
                    }, response => {    // error callback
                        if (response.status == 401) {
                            this.visitorLoggedIn = false;
                            this.visitorName     = null;
                            this.visitorEmail    = null;
                        } else {
                            this.error = "Couldn't figure out whether or not you're logged in. Will assume that you're not."
                        }
482
                        */
matthias.lang's avatar
matthias.lang committed
483
484
                },

matthias.lang's avatar
matthias.lang committed
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
                enableFilter: function(filter) {
                    filter.buttonState = !filter.buttonState
                },
                disableAllFilters: function() {
                    this.setAllFilters(true)
                },
                enableAllFilters: function() {
                    this.setAllFilters(false)
                },
                enableOnlyFilter: function(filter, filters) {
                    this.setAllFilters(false, filters)
                    this.enableFilter(filter)
                },
                setAllFilters: function(state, filters) {
                    if (filters) {  // modify only the explicit set that was given
                        for (var elem in filters) {
                           filters[elem].buttonState = state
                        }
                        return
                    } else {        // modify all the filters we have
                        for (var filterCategory in this.filterShow) {
                            for (var elem in this.filterShow[filterCategory].filters) {
                                this.filterShow[filterCategory].filters[elem].buttonState = state // TODO: check type of "state"
                            }
                        }
                    }
                },

matthias.lang's avatar
matthias.lang committed
513
514
515
516
517
518
519
520
521
522
523
524
525
                sortBy: function (key) {
                    this.sortKey = key
                    this.sortOrders[key] = this.sortOrders[key] * -1
                }
            },

            created: function () {
                var sortOrders = {};
                this.tableHeaders.forEach(function (key) {
                    sortOrders[key.field] = 1;
                });
                this.sortOrders = sortOrders;

526
                this.getShibSessionData();
527
528

                if (this.getUrlParameter('filter') == 'none') {
matthias.lang's avatar
matthias.lang committed
529
                    this.disableAllFilters()
530
531
                }
                this.query = this.getUrlParameter('q')
532
                if (this.query != '') {
533
                    this.search()   // this should ideally be bound to a promise of "getShibSessionData()", so we don't have to run the search twice to avoid concurrency glitches.
534
535
                }

matthias.lang's avatar
matthias.lang committed
536
537
538
539
            }
        });

    </script>
matthias.lang's avatar
matthias.lang committed
540

Heiko Reese's avatar
Heiko Reese committed
541
</body>