mirror of
https://github.com/jpros/tacticalrmm-web.git
synced 2026-02-16 17:20:22 +00:00
fix agent drowndown in audit manager
This commit is contained in:
31
src/utils/format.js
Normal file
31
src/utils/format.js
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
export function formatAgentOptions(data) {
|
||||
let options = []
|
||||
const agents = data.map(agent => ({
|
||||
label: agent.hostname,
|
||||
value: agent.pk,
|
||||
cat: `${agent.client} > ${agent.site}`,
|
||||
}));
|
||||
|
||||
let categories = [];
|
||||
agents.forEach(option => {
|
||||
if (!categories.includes(option.cat)) {
|
||||
categories.push(option.cat);
|
||||
}
|
||||
});
|
||||
|
||||
categories.sort().forEach(cat => {
|
||||
options.push({ category: cat });
|
||||
let tmp = []
|
||||
agents.forEach(agent => {
|
||||
if (agent.cat === cat) {
|
||||
tmp.push(agent);
|
||||
}
|
||||
});
|
||||
|
||||
const sorted = tmp.sort((a, b) => a.label.localeCompare(b.label));
|
||||
options.push(...sorted);
|
||||
});
|
||||
|
||||
return options
|
||||
}
|
||||
Reference in New Issue
Block a user