aboutsummaryrefslogtreecommitdiff
path: root/modern/src/main
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-08-13 07:18:59 -0700
committerAnton Tananaev <anton@traccar.org>2022-08-13 07:18:59 -0700
commita34a1be52dc6b08f6691845487a7dfc843e774e3 (patch)
treec2802d6d549d983333455b8d14421b6acc70e344 /modern/src/main
parent88eeb5ca27cd50160ef5bce24539b612afea57d5 (diff)
downloadtrackermap-web-a34a1be52dc6b08f6691845487a7dfc843e774e3.tar.gz
trackermap-web-a34a1be52dc6b08f6691845487a7dfc843e774e3.tar.bz2
trackermap-web-a34a1be52dc6b08f6691845487a7dfc843e774e3.zip
Add name sorting (fix #1015)
Diffstat (limited to 'modern/src/main')
-rw-r--r--modern/src/main/MainPage.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/modern/src/main/MainPage.js b/modern/src/main/MainPage.js
index 283c61a6..a09d9f87 100644
--- a/modern/src/main/MainPage.js
+++ b/modern/src/main/MainPage.js
@@ -199,6 +199,20 @@ const MainPage = () => {
const keyword = filterKeyword.toLowerCase();
return [device.name, device.uniqueId, device.phone, device.model, device.contact].some((s) => s && s.toLowerCase().includes(keyword));
});
+ switch (filterSort) {
+ case 'name':
+ filtered.sort((device1, device2) => device1.name.localeCompare(device2.name));
+ break;
+ case 'lastUpdate':
+ filtered.sort((device1, device2) => {
+ const time1 = device1.lastUpdate ? moment(device1.lastUpdate).valueOf() : 0;
+ const time2 = device2.lastUpdate ? moment(device2.lastUpdate).valueOf() : 0;
+ return time2 - time1;
+ });
+ break;
+ default:
+ break;
+ }
if (filterSort === 'lastUpdate') {
filtered.sort((device1, device2) => {
const time1 = device1.lastUpdate ? moment(device1.lastUpdate).valueOf() : 0;
@@ -311,6 +325,7 @@ const MainPage = () => {
displayEmpty
>
<MenuItem value="">{'\u00a0'}</MenuItem>
+ <MenuItem value="name">{t('sharedName')}</MenuItem>
<MenuItem value="lastUpdate">{t('deviceLastUpdate')}</MenuItem>
</Select>
</FormControl>