diff --git a/server/src/lib/ciscoController.js b/server/src/lib/ciscoController.js index a49bc75..1ee1f86 100644 --- a/server/src/lib/ciscoController.js +++ b/server/src/lib/ciscoController.js @@ -95,6 +95,7 @@ export async function getOnlineWifiDevices() { const restructuredOnlineDevices = onlineDevices.map(client => ({ user: client.Name == 'unknown' ? null : client.Name, + identity: client.Name == 'unknown' ? null : client.Name, oui: ouiFinder(client.macaddr), mac: client.macaddr, hostname: client.HN == 'unknown' ? undefined : client.HN, diff --git a/server/src/lib/unifiController.js b/server/src/lib/unifiController.js index a181f9d..28c84f9 100644 --- a/server/src/lib/unifiController.js +++ b/server/src/lib/unifiController.js @@ -179,6 +179,7 @@ export async function getOnlineWifiDevices() { const restructuredOnlineDevices = onlineDevices[0].map(client => ({ user: client['1x_identity'] || null, + identity: client['1x_identity'] || null, oui: ouiFinder(client.mac), mac: client.mac, hostname: client.hostname, @@ -193,7 +194,7 @@ export async function getOnlineWifiDevices() { signalStrength: client.signal, frequency: null, protocol: null, - speed: client.tx_rate, + speed: Math.floor(client.tx_rate / 1000), usage: +client.tx_bytes + +client.rx_bytes })) diff --git a/server/src/typeDefs.js b/server/src/typeDefs.js index 81aa955..2681333 100644 --- a/server/src/typeDefs.js +++ b/server/src/typeDefs.js @@ -236,6 +236,11 @@ const typeDefs = gql` apName: String status: Status accessPoint: AccessPoint + signalStrength: Int + frequency: String + protocol: String + speed: Int + usage: Int } "A user that is on the Wi-Fi network reach" diff --git a/web/src/main.js b/web/src/main.js index a33e557..b878591 100755 --- a/web/src/main.js +++ b/web/src/main.js @@ -8,6 +8,7 @@ import '@mdi/font/css/materialdesignicons.css' import './scss/style.scss' import './plugins/date' +import './plugins/format-bytes' import { defaultApolloProvider } from './plugins/vue-apollo' diff --git a/web/src/plugins/format-bytes.js b/web/src/plugins/format-bytes.js new file mode 100644 index 0000000..fd5d505 --- /dev/null +++ b/web/src/plugins/format-bytes.js @@ -0,0 +1,22 @@ +import Vue from 'vue' + +function bytes(bytes, decimals, kib, maxUnit) { + console.log(bytes, decimals, kib, maxUnit) + kib = kib || false + if (bytes === 0) return '0 Bytes' + if (isNaN(parseFloat(bytes)) && !isFinite(bytes)) return '' + const k = kib ? 1024 : 1000 + const dm = + decimals != null && !isNaN(decimals) && decimals >= 0 ? decimals : 2 + const sizes = kib + ? ['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB', 'BiB'] + : ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB', 'BB'] + var i = Math.floor(Math.log(bytes) / Math.log(k)) + if (maxUnit != undefined) { + const index = sizes.indexOf(maxUnit) + if (index != -1) i = index + } + return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i] +} + +Vue.filter('bytes', bytes) diff --git a/web/src/views/AccessPoints/clients.vue b/web/src/views/AccessPoints/clients.vue index 2ca941a..ff4f67a 100644 --- a/web/src/views/AccessPoints/clients.vue +++ b/web/src/views/AccessPoints/clients.vue @@ -2,19 +2,27 @@
+ - {{ accessPoint.name || accessPoint.hostname }} - ({{ accessPoint.ip }}) - +
+ + {{ accessPoint.name || accessPoint.hostname }} + ({{ accessPoint.ip }}) + + + {{ accessPoint.local }} + +
- + mdi-close
+