Skip to content

Commit

Permalink
Add Deprecation Warning (#1)
Browse files Browse the repository at this point in the history
* Prepare Deprecation Warning in Infobox

* Deprecation Warning: Add Content

* Add some styling

* Deprecation: Add device list and cleanup

* Make deprecation_warning configurable

* Documentation and Deprecation Warning text improvements
  • Loading branch information
margau authored Apr 12, 2020
1 parent a900062 commit ba55e7d
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ This fork of the new meshviewer has a new installation method:
- Run `npm install`
- Run `npm run build`
- A production build will be in /build

## Configuration
The configuration documentation is nowhere near finished.

#### Deprecation Warning
The deprecation warning can be turned of with `"deprecation_enabled": false` - but we wouldn't suggest it.

You can insert your own HTML into the deprecation warning via `"deprecation_text":""`.
4 changes: 3 additions & 1 deletion config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,7 @@
"image": "https://freifunk.fail/render/dashboard-solo/db/deck?&panelId=22&from=now-7d&to=now&width=600&height=300&theme=light&_t={TIME}",
"title": "Bild der Wochenstatistik"
}
]
],
"deprecation_text": "Hier kann ein eigener Text für die Deprecation Warning (inkl. HTML) stehen!",
"deprecation_enabled": true
}
22 changes: 21 additions & 1 deletion lib/config_default.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,26 @@ define([], function () {
'opacity': 0.7,
'fillOpacity': 0.2
}
}
},
'deprecated': ['TP-Link TL-WR740N/ND v1',
'AP121', 'AP121U', 'D-Link DIR-615',
'TP-Link TL-MR13U v1', 'TP-Link TL-MR3020 v1', 'TP-Link TL-MR3040 v1', 'TP-Link TL-MR3040 v2',
'TP-Link TL-MR3220 v1', 'TP-Link TL-MR3220 v2', 'TP-Link TL-MR3420 v1', 'TP-Link TL-MR3420 v2',
'TP-Link TL-WA701N/ND v1', 'TP-Link TL-WA701N/ND v2', 'TP-Link TL-WA730RE v1', 'TP-Link TL-WA750RE v1',
'TP-Link TL-WA801N/ND v1', 'TP-Link TL-WA801N/ND v2', 'TP-Link TL-WA801N/ND v3',
'TP-Link TL-WA830RE v1', 'TP-Link TL-WA830RE v2', 'TP-Link TL-WA850RE v1', 'TP-Link TL-WA860RE v1',
'TP-Link TL-WA901N/ND v1', 'TP-Link TL-WA901N/ND v2', 'TP-Link TL-WA901N/ND v3', 'TP-Link TL-WA901N/ND v4', 'TP-Link TL-WA901N/ND v5',
'TP-Link TL-WA7210N v2', 'TP-Link TL-WA7510N v1', 'TP-Link TL-WR703N v1', 'TP-Link TL-WR710N v2',
'TP-Link TL-WR740N/ND v1', 'TP-Link TL-WR740N/ND v3', 'TP-Link TL-WR740N/ND v4', 'TP-Link TL-WR740N/ND v5',
'TP-Link TL-WR741N/ND v1', 'TP-Link TL-WR741N/ND v3', 'TP-Link TL-WR741N/ND v4', 'TP-Link TL-WR741N/ND v5',
'TP-Link TL-WR743N/ND v1', 'TP-Link TL-WR743N/ND v2',
'TP-Link TL-WR840N v2',
'TP-Link TL-WR841N/ND v3', 'TP-Link TL-WR841N/ND v5', 'TP-Link TL-WR841N/ND v7', 'TP-Link TL-WR841N/ND v8', 'TP-Link TL-WR841N/ND v9', 'TP-Link TL-WR841N/ND v10', 'TP-Link TL-WR841N/ND v11', 'TP-Link TL-WR841N/ND v12',
'TP-Link TL-WR841N/ND Mod (16M) v11', 'TP-Link TL-WR841N/ND Mod (16M) v10', 'TP-Link TL-WR841N/ND Mod (16M) v8', 'TP-Link TL-WR841N/ND Mod (16M) v9', 'TP-Link TL-WR841N/ND Mod (8M) v10',
'TP-Link TL-WR843N/ND v1',
'TP-Link TL-WR940N v1', 'TP-Link TL-WR940N v2', 'TP-Link TL-WR940N v3', 'TP-Link TL-WR940N v4', 'TP-Link TL-WR940N v5', 'TP-Link TL-WR940N v6',
'TP-Link TL-WR941N/ND v2', 'TP-Link TL-WR941N/ND v3', 'TP-Link TL-WR941N/ND v4', 'TP-Link TL-WR941N/ND v5', 'TP-Link TL-WR941N/ND v6',
'A5-V11', 'D-Link DIR-615 D1', 'D-Link DIR-615 D2', 'D-Link DIR-615 D3', 'D-Link DIR-615 D4', 'D-Link DIR-615 H1',
'VoCore 8M', 'VoCore 16M']
};
});
15 changes: 15 additions & 0 deletions lib/infobox/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'helper', 'utils/node'],
}];
var tableNeighbour = new SortTable(headings, 1, renderNeighbourRow);

// Prepare deprecation warning. At first not displayed, text follows later
var deprecation = document.createElement('div');
deprecation.setAttribute('class', 'deprecated');
deprecation.setAttribute('style', 'display: none;');
deprecation.innerHTML = '<div>' + (config.deprecation_text || _.t('deprecation')) + '</div>';

el.appendChild(header);
el.appendChild(deprecation);
el.appendChild(table);
el.appendChild(neighbours);
el.appendChild(tableNeighbour.el);
Expand All @@ -146,6 +153,14 @@ define(['sorttable', 'snabbdom', 'd3-interpolate', 'helper', 'utils/node'],
} else if (nodef['show' + row.value] !== undefined) {
field = nodef['show' + row.value](d);
}
// Check if device is in list of deprecated devices. If so, display the deprecation warning
if (config.deprecation_enabled) {
if (row.name === 'node.hardware') {
if (config.deprecated && field && config.deprecated.includes(field)) {
deprecation.setAttribute('style', 'display: block;');
}
}
}

if (field) {
if (typeof field !== 'object') {
Expand Down
3 changes: 2 additions & 1 deletion locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@
"others": "andere",
"none": "keine",
"remove": "entfernen",
"close": "schließen"
"close": "schließen",
"deprecation": "Warnung: Dieser Knoten ist veraltet, und wird demnächst nicht mehr unterstützt. Mehr Infos unter <a href='https://openwrt.org/supported_devices/432_warning'>4/32 warning</a>. <br> Wenn du der Eigentümer des Gerätes bist, bitten wir dich, das Gerät zu ersetzen, um weiterhin am Netz teilnehmen zu können."
}
3 changes: 2 additions & 1 deletion locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@
"others": "other",
"none": "none",
"remove": "remove",
"close": "close"
"close": "close",
"deprecation": "This node is deprecated, and will be out of support soon. More information under <a href='https://openwrt.org/supported_devices/432_warning'>4/32 warning</a>.<br>If you're the owner, please replace it with an modern device!"
}
21 changes: 21 additions & 0 deletions scss/modules/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,24 @@ strong {
white-space: nowrap;
width: 1px;
}

.deprecated {
padding-left: $button-distance;
padding-right: $button-distance;
div {
background: rgba(194,0,0,1);
border-radius: 5px;
font-size: 110%;
color:white;
padding: 10px;
text-align:center;
font-weight: bold;
a {
color: white;
text-decoration: underline;
}
a:hover {
text-decoration: none;
}
}
}

0 comments on commit ba55e7d

Please sign in to comment.