1
13693261870
2022-09-16 58d012f11dd34564d81b4eb3a6099eb689876597
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
$('#myTabs a').click(function (e) {
    e.preventDefault()
    $(this).tab('show')
})
 
var revokeDevice = function (key) {
    $.ajax({
        type: 'post',
        url: urls.revokeRecord,
        data: {"key": key},
        success: function (data, status) {
            var table = $('#trustedDevicesTable').DataTable();
            table
                .rows($("#" + key).parents('tr'))
                .remove()
                .draw();
        },
        error: function (xhr, status) {
            console.log("Could not remove record");
        }
    });
};
 
var trustedDevices = (function () {
    var getData = function () {
        $.getJSON(urls.getRecords, function (data) {
            trustedDevicesTable(data);
        });
    };
 
    var trustedDevicesTable = function (jsonData) {
        var t = $('#trustedDevicesTable').DataTable({
            "order": [[2, "desc"]],
            columnDefs: [
                {"width": "20%", "targets": 0},
                {"width": "10%", "targets": 1},
                {"width": "60%", "targets": 2},
                {"width": "10%", "targets": 3},
                {"width": "30%", "targets": 4}
            ]
        });
        for (var i = 0; i < jsonData.length; i++) {
            var rec = jsonData[i];
            t.row.add([
                rec.name,
                rec.principal,
                new Date(rec.date),
                rec.geography,
                "<button id='" + rec.key + "' class='btn btn-sm btn-danger' type='button' value='ALL' onclick='revokeDevice(\"" + rec.key + "\")'>Revoke</button>"
            ]).draw(false);
        }
    };
 
    // initialization *******
    (function init() {
        getData();
    })();
})();