mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 14:47:14 +01:00
Refactored dashboard sort logic.
This commit is contained in:
parent
42e87a4691
commit
62b032ab19
8 changed files with 32 additions and 40 deletions
|
|
@ -9,3 +9,10 @@ export function chunk(arr, size) {
|
|||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
export function sortArrayByMap(arr, map = [], key) {
|
||||
if (!arr) return [];
|
||||
if (map.length === 0) return arr;
|
||||
|
||||
return map.map(id => arr.find(item => item[key] === id));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,14 +78,3 @@ export function stringToColor(str) {
|
|||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
export function orderByWebsiteMap(websites, orderMap) {
|
||||
if (!websites) return [];
|
||||
|
||||
let ordered = [...websites];
|
||||
for (let website of websites) {
|
||||
ordered[orderMap[website.website_uuid]] = website;
|
||||
}
|
||||
|
||||
return ordered;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,8 +69,6 @@ export const getItem = (key, session) => {
|
|||
return JSON.parse(value);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const removeItem = (key, session) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue