diff --git a/net/vnstat/Makefile b/net/vnstat/Makefile
index dad521ba10..e1e9bfa962 100644
--- a/net/vnstat/Makefile
+++ b/net/vnstat/Makefile
@@ -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
diff --git a/net/vnstat/pkg-descr b/net/vnstat/pkg-descr
index dfb5cf1848..46daf455fd 100644
--- a/net/vnstat/pkg-descr
+++ b/net/vnstat/pkg-descr
@@ -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)
diff --git a/net/vnstat/src/opnsense/www/js/widgets/Metadata/Vnstat.xml b/net/vnstat/src/opnsense/www/js/widgets/Metadata/Vnstat.xml
index 038c293329..e2f03d7dc8 100644
--- a/net/vnstat/src/opnsense/www/js/widgets/Metadata/Vnstat.xml
+++ b/net/vnstat/src/opnsense/www/js/widgets/Metadata/Vnstat.xml
@@ -19,6 +19,9 @@
Excluded Interfaces
Refresh Interval (minutes)
Show Average Rate
+ Sort Order
+ Ascending
+ Descending
diff --git a/net/vnstat/src/opnsense/www/js/widgets/Vnstat.js b/net/vnstat/src/opnsense/www/js/widgets/Vnstat.js
index 5afd4c4c6d..65295a5e0b 100644
--- a/net/vnstat/src/opnsense/www/js/widgets/Vnstat.js
+++ b/net/vnstat/src/opnsense/www/js/widgets/Vnstat.js
@@ -32,6 +32,7 @@ export default class Vnstat extends BaseTableWidget {
this.configurable = true;
this.excludedInterfaces = [];
this.showAvgRate = false;
+ this.sortOrder = 'ascending';
}
getGridOptions() {
@@ -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'
}
};
}
@@ -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();
}
@@ -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;
@@ -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;