summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-noddos/luasrc/view/noddos/clients.htm
blob: 4caf3e04e41dcbd9cc80003cf0dd87aeb29dfec1 (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
<%#
 Copyright (C) 2017 Steven Hessing <steven.hessing@gmail.com>
  This is free software, licensed under the GNU General Public License v3.
 /usr/lib/lua/luci/view/clients.htm
-%>

<%-

    require "nixio.fs"
    require "os"

    local last_modified = "<boottime>"
    local style = true
    local v
    local devdump

    if nixio.fs.access("/var/lib/noddos/DeviceDump.json") then
        last_modified = os.date("%c", nixio.fs.stat("/var/lib/noddos/DeviceDump.json")['mtime'])
        io.input("/var/lib/noddos/DeviceDump.json")
        t = io.read("*all")
        devdump = luci.jsonc.parse(t)
        io.input("/var/lib/noddos/DeviceProfiles.json")
        t = io.read("*all")
        temp = luci.jsonc.parse(t)
        devicevalues = {}
        for i, v in ipairs(temp) do
            devicevalues[v.DeviceProfileUuid] = v
        end
    end
-%>

<%+header%>

<div class="cbi-map" id="cbi-network">
    <h2 name="content"><%:Clients%></h2>
    <div class="cbi-map-descr"><%:The following clients have been discovered on the network. The last discovery was completed at %><%=last_modified%></div>

    <fieldset class="cbi-section">
        <legend><%:Recognized Clients%></legend>
        <div class="cbi-section-node">
            <div class="table cbi-section-table">
                <div class="tr cbi-section-table-titles">
                    <div class="th cbi-section-table-cell"><%:Hostname%></div>
                    <div class="th cbi-section-table-cell"><%:IPv4%></div>
                    <div class="th cbi-section-table-cell"><%:MAC%></div>
                    <div class="th cbi-section-table-cell"><%:Manufacturer%></div>
                    <div class="th cbi-section-table-cell"><%:Model%></div>
                    <div class="th cbi-section-table-cell"><%:Class%></div>
                </div>

                <%
                    for i,v in ipairs(devdump) do
                        if v.DeviceProfileUuid ~= "" then
                %>
                <div class="tr cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
                    <div class="td cbi-value-field"><%=v.Hostname%></div>
                    <div class="td cbi-value-field"><%=v.Ipv4Address%></div>
                    <div class="td cbi-value-field"><a href="/cgi-bin/clientdetails?mac=<%=v.MacAddress%>"><%=v.MacAddress%></a></div>
                    <div class="td cbi-value-field"><%=devicevalues[v.DeviceProfileUuid].Manufacturer%></div>
                    <div class="td cbi-value-field"><%=devicevalues[v.DeviceProfileUuid].Model%></div>
                    <div class="td cbi-value-field"><%=devicevalues[v.DeviceProfileUuid].ThingClass%></div>
                </div>
                <%
                            style=false
                        end
                    end
                %>
            </div>
        </div>
    </fieldset>
    <br />
    <fieldset class="cbi-section">
        <legend><%:Unrecognized Clients%></legend>
        <div class="cbi-section-node">
            <div class="table cbi-section-table">
                <div class="tr cbi-section-table-titles">
                    <div class="th cbi-section-table-cell"><%:Hostname%></div>
                    <div class="th cbi-section-table-cell"><%:IPv4%></div>
                    <div class="th cbi-section-table-cell"><%:MAC%></div>
                    <div class="th cbi-section-table-cell"><%:Manufacturer%></div>
                    <div class="th cbi-section-table-cell"><%:Model%></div>
                    <div class="th cbi-section-table-cell"><%:DhcpVendor%></div>
                    <div class="th cbi-section-table-cell"><%:DhcpHostname%></div>
                </div>

                <%
                    for i,v in ipairs(devdump) do
                        if v.DeviceProfileUuid == "" then
                %>
                <div class="tr cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
                    <div class="td cbi-value-field"><%=v.Hostname%></div>
                    <div class="td cbi-value-field"><%=v.Ipv4Address%></div>
                    <div class="td cbi-value-field"><a href="/cgi-bin/clientdetails?mac=<%=v.MacAddress%>"><%=v.MacAddress%></a></div>
                    <div class="td cbi-value-field"><%=v.SsdpManufacturer%></div>
                    <div class="td cbi-value-field"><%=v.SsdpModelName%></div>
                    <div class="td cbi-value-field"><%=v.DhcpVendor1%></div>
                    <div class="td cbi-value-field"><%=v.DhcpHostname%></div>
                </div>
                <%
                            style=false
                        end
                    end
                %>
            </div>
        </div>
    </fieldset>

</div>

<%+footer%>