Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion net/vnstat/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PLUGIN_NAME= vnstat
PLUGIN_VERSION= 1.4
PLUGIN_VERSION= 1.5
PLUGIN_COMMENT= Network traffic monitor
PLUGIN_DEPENDS= vnstat
PLUGIN_MAINTAINER= m.muenz@gmail.com
Expand Down
4 changes: 4 additions & 0 deletions net/vnstat/pkg-descr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ ensures light use of system resources.
Plugin Changelog
================

1.5

* Add Sort Option to dashboard widget options (contributed by Greg Pfountz)

1.4

* Add Month Rotate option to UI (contributed by Greg Pfountz)
Expand Down
3 changes: 3 additions & 0 deletions net/vnstat/src/opnsense/www/js/widgets/Metadata/Vnstat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<excluded_interfaces>Excluded Interfaces</excluded_interfaces>
<refresh_interval>Refresh Interval (minutes)</refresh_interval>
<show_avg_rate>Show Average Rate</show_avg_rate>
<sort_order>Sort Order</sort_order>
<sort_ascending>Ascending</sort_ascending>
<sort_descending>Descending</sort_descending>
</translations>
</vnstat>
</metadata>
17 changes: 16 additions & 1 deletion net/vnstat/src/opnsense/www/js/widgets/Vnstat.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default class Vnstat extends BaseTableWidget {
this.configurable = true;
this.excludedInterfaces = [];
this.showAvgRate = false;
this.sortOrder = 'ascending';
}

getGridOptions() {
Expand Down Expand Up @@ -75,6 +76,16 @@ export default class Vnstat extends BaseTableWidget {
{ value: 'yes', label: 'Yes' },
],
default: 'no'
},
sort_order: {
id: 'vnstat-sort-order',
title: this.translations.sort_order,
type: 'select',
options: [
{ value: 'ascending', label: this.translations.sort_ascending },
{ value: 'descending', label: this.translations.sort_descending },
],
default: 'ascending'
}
};
}
Expand All @@ -84,6 +95,7 @@ export default class Vnstat extends BaseTableWidget {
this.excludedInterfaces = config.excluded_interfaces ?? [];
this.tickTimeout = Number(config.refresh_interval) || 300;
this.showAvgRate = config.show_avg_rate === 'yes';
this.sortOrder = config.sort_order === 'descending' ? 'descending' : 'ascending';
await this._populateInterfaceDropdown();
await this._fetchAndUpdateTable();
}
Expand Down Expand Up @@ -116,6 +128,7 @@ export default class Vnstat extends BaseTableWidget {
this.excludedInterfaces = config.excluded_interfaces ?? [];
this.tickTimeout = Number(config.refresh_interval) || 300;
this.showAvgRate = config.show_avg_rate === 'yes';
this.sortOrder = config.sort_order === 'descending' ? 'descending' : 'ascending';

$(document).on('change.vnstat-widget', '#vnstat-period-select', async (e) => {
this.currentPeriod = e.target.value;
Expand Down Expand Up @@ -214,7 +227,9 @@ export default class Vnstat extends BaseTableWidget {
if (limits[this.currentPeriod]) {
entries = entries.slice(0, limits[this.currentPeriod]);
}
entries.reverse();
if (this.sortOrder === 'ascending') {
entries.reverse();
}

for (const entry of entries) {
const totalBytes = entry.rx + entry.tx;
Expand Down