diff --git a/MMM-Freebox.css b/MMM-Freebox.css index 0d14bbf..244802a 100644 --- a/MMM-Freebox.css +++ b/MMM-Freebox.css @@ -19,6 +19,9 @@ #FREE_IP, #FREE_DEBIT, #FREE_BAND, +#FREE_BAND_TYPE, +#FREE_BAND_DOWN, +#FREE_BAND_UP, #FREE_CLIENT { display: flex; font-size: small; @@ -35,6 +38,10 @@ white-space: nowrap; } +#FREE_VALUE.nomargin { + margin-left: 0px; +} + #FREE_RATE { margin-left: 10px; text-align: left; @@ -223,6 +230,13 @@ background-position: 0 -1px; } +#FREE_ICON.up { + background-image: url(resources/up.png); +} + +#FREE_ICON.down { + background-image: url(resources/down.png); +} #FREE_ICON.freebox_crystal0 { background-image: url(resources/players.png); diff --git a/MMM-Freebox.js b/MMM-Freebox.js index 6aff072..5e4f9a1 100644 --- a/MMM-Freebox.js +++ b/MMM-Freebox.js @@ -34,8 +34,10 @@ Module.register("MMM-Freebox", { this.Init = false; this.Freebox = { Hidden: true, - Bandwidth: null, - Debit: null, + BandwidthDown: null, + BandwidthUp: null, + DebitDown: null, + DebitUp: null, IP: null, Degroup: false, Type: null, @@ -108,8 +110,10 @@ Module.register("MMM-Freebox", { this.Freebox.Model = payload.Model; this.Freebox.Type = payload.Type; this.Freebox.Degroup = payload.Degroup; - this.Freebox.Bandwidth = payload.Bandwidth; - this.Freebox.Debit = payload.Debit; + this.Freebox.BandwidthDown = payload.BandwidthDown; + this.Freebox.BandwidthUp = payload.BandwidthUp; + this.Freebox.DebitDown = payload.DebitDown; + this.Freebox.DebitUp = payload.DebitUp; this.Freebox.IP = payload.IP; this.Freebox.Clients = payload.Clients; this.Freebox.Ping = payload.Ping; @@ -133,11 +137,18 @@ Module.register("MMM-Freebox", { /** Bande Passante **/ var bandWidth = document.getElementById("FREE_BAND"); var bandWidthIcon = bandWidth.querySelector("#FREE_ICON"); + var bandWidthType = document.getElementById("FREE_BAND_TYPE"); + var bandWidthDown = document.getElementById("FREE_BAND_DOWN"); + var bandWidthUp = document.getElementById("FREE_BAND_UP"); - var bandWidthValue = bandWidth.querySelector("#FREE_VALUE"); + var bandWidthTypeValue = bandWidth.querySelector("#FREE_VALUE"); + var bandWidthDownValue = bandWidthDown.querySelector("#FREE_VALUE"); + var bandWidthUpValue = bandWidthUp.querySelector("#FREE_VALUE"); if (this.config.showIcon) bandWidthIcon.classList.remove("hidden"); if (this.config.showBandWidth) bandWidth.classList.remove("hidden"); - bandWidthValue.textContent = this.Freebox.Type + (this.Freebox.Degroup ? " (Dégroupé): " : ": ") + this.Freebox.Bandwidth; + bandWidthTypeValue.textContent = this.Freebox.Type + (this.Freebox.Degroup ? " (Dégroupé): " : ": "); // + this.Freebox.BandwidthDown; + bandWidthDownValue.textContent = this.Freebox.BandwidthDown; + bandWidthUpValue.textContent = this.Freebox.BandwidthUp; /** Adresse IP **/ var IP = document.getElementById("FREE_IP"); @@ -196,7 +207,7 @@ Module.register("MMM-Freebox", { /** debit client **/ var clientDebit = clientSelect.querySelector("#FREE_RATE"); if (this.config.showClientRate) clientDebit.classList.remove("hidden"); - clientDebit.textContent = client.debit; + clientDebit.textContent = client.debitDown; /** bouton **/ var clientStatus = clientSelect.querySelector("INPUT"); @@ -224,7 +235,7 @@ Module.register("MMM-Freebox", { var debitValue = debit.querySelector("#FREE_VALUE"); if (this.config.showIcon) debitIcon.classList.remove("hidden"); if (this.config.showRate) debit.classList.remove("hidden"); - debitValue.textContent = this.Freebox.Debit; + debitValue.textContent = `${this.Freebox.DebitDown} - ${this.Freebox.DebitUp}`; /** Affichage Ping en temps réél **/ var ping = document.getElementById("FREE_PING"); @@ -280,9 +291,41 @@ Module.register("MMM-Freebox", { bandWidthIcon.id= "FREE_ICON"; bandWidth.appendChild(bandWidthIcon); - var bandWidthDisplay= document.createElement("div"); - bandWidthDisplay.id = "FREE_VALUE"; - bandWidth.appendChild(bandWidthDisplay); + var bandWidthType= document.createElement("div"); + bandWidthType.id = "FREE_BAND_TYPE"; + bandWidth.appendChild(bandWidthType); + + var bandWidthTypeValue= document.createElement("div"); + bandWidthTypeValue.id = "FREE_VALUE"; + bandWidthType.appendChild(bandWidthTypeValue); + + var bandWidthDown= document.createElement("div"); + bandWidthDown.id = "FREE_BAND_DOWN"; + bandWidth.appendChild(bandWidthDown); + + var bandWidthDownIcon= document.createElement("div"); + bandWidthDownIcon.className = "down"; + bandWidthDownIcon.id = "FREE_ICON"; + bandWidthDown.appendChild(bandWidthDownIcon); + + var bandWidthDownRate= document.createElement("div"); + bandWidthDownRate.id = "FREE_VALUE"; + bandWidthDownRate.className = "nomargin"; + bandWidthDown.appendChild(bandWidthDownRate); + + var bandWidthUp= document.createElement("div"); + bandWidthUp.id = "FREE_BAND_UP"; + bandWidth.appendChild(bandWidthUp); + + var bandWidthUpIcon= document.createElement("div"); + bandWidthUpIcon.className = "up"; + bandWidthUpIcon.id = "FREE_ICON"; + bandWidthUp.appendChild(bandWidthUpIcon); + + var bandWidthUpRate= document.createElement("div"); + bandWidthUpRate.id = "FREE_VALUE"; + bandWidthUpRate.className = "nomargin"; + bandWidthUp.appendChild(bandWidthUpRate); wrapper.appendChild(bandWidth); diff --git a/node_helper.js b/node_helper.js index 5d55f37..8a41bb1 100644 --- a/node_helper.js +++ b/node_helper.js @@ -156,7 +156,8 @@ module.exports = NodeHelper.create({ ip: null, type: client.host_type, vendor: client.vendor_name, - debit: null, + debitDown: null, + debitUp:null, active: client.active, repeater: false, access_type: null, @@ -178,8 +179,10 @@ module.exports = NodeHelper.create({ device.signal_percent = this.wifiPercent(device.signal); device.signal_bar = this.wifiBar(device.signal_percent); } - if (client.access_point?.tx_rate) device.debit = this.convert(client.access_point.tx_rate*8,0,1); // Warn debit en bytes! (base 8) - else device.debit = "0 Ko/s"; + if (client.access_point?.tx_rate) device.debitDown = this.convert(client.access_point.tx_rate*8,0,1); // Warn debit en bytes! (base 8) + else device.debitDown = "0 Ko/s"; + if (client.access_point?.rx_rate) device.debitUp = this.convert(client.access_point.rx_rate*8,0,1); // Warn debit en bytes! (base 8) + else device.debitUp = "0 Ko/s"; } if (this.config.showClientRate || this.config.showClientCnxType) { @@ -191,7 +194,10 @@ module.exports = NodeHelper.create({ if (client.l2ident.id === mac) { if (client.access_point?.connectivity_type === "wifi" && client.access_point?.type === "repeater") device.repeater = true; else if (res[info.id] && res[info.id].tx_bytes_rate) { - if (this.config.showEthClientRate) device.debit = this.convert(res[info.id].tx_bytes_rate,0,1); + if (this.config.showEthClientRate) { + device.debitDown = this.convert(res[info.id].tx_bytes_rate,0,1); + device.debitUp = this.convert(res[info.id].rx_bytes_rate,0,1); + } device.access_type = "ethernet"; device.eth = info.id; } @@ -316,8 +322,10 @@ module.exports = NodeHelper.create({ }); FB("Done!"); - bandwidth = `${this.convert(cnx.data.result.bandwidth_down,1,2)} - ${this.convert(cnx.data.result.bandwidth_up,1,2)}`; - debit = `${this.convert(cnx.data.result.rate_down,0,2)} - ${this.convert(cnx.data.result.rate_up,0,2)}`; + bandwidthDown = this.convert(cnx.data.result.bandwidth_down,1,2); + bandwidthUp = this.convert(cnx.data.result.bandwidth_up,1,2); + debitUp = this.convert(cnx.data.result.rate_down,0,2); + debitDown = this.convert(cnx.data.result.rate_up,0,2); type = (cnx.data.result.media === "xdsl") ? "xDSL" : ((cnx.data.result.media === "ftth") ? "FTTH" : "Inconnu"); degroup = (cnx.data.result.type === "rfc2684") ? true : false; @@ -325,8 +333,10 @@ module.exports = NodeHelper.create({ Model: this.FreeboxVersion, Type: type, Degroup: degroup, - Bandwidth: bandwidth, - Debit: debit, + BandwidthDown: bandwidthDown, + BandwidthUp: bandwidthUp, + DebitDown: debitDown, + DebitUp: debitUp, IP: cnx.data.result.ipv4, Client: clients.data.result ? clients.data.result : [], EthCnx: clientRate && ethCnx.data.result ? ethCnx.data.result : [], diff --git a/package.json b/package.json index 8013d15..c422921 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "description": "Display Freebox informations", "main": "MMM-Freebox.js", "keywords": [ - "freebox" + "freebox", + "french" ], "scripts": { "register": "node installer/Freebox_Login.js", diff --git a/resources/down.png b/resources/down.png new file mode 100644 index 0000000..3f054c1 Binary files /dev/null and b/resources/down.png differ diff --git a/resources/up.png b/resources/up.png new file mode 100644 index 0000000..b7b5c88 Binary files /dev/null and b/resources/up.png differ