Skip to content

Commit

Permalink
#332: added number of hosts and sorted hosts by name
Browse files Browse the repository at this point in the history
  • Loading branch information
yaxue1123 committed Jun 18, 2024
1 parent 6fa9344 commit eb840d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/components/Resource/SiteDetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ class SiteDetailPage extends React.Component {
status={data.status}
hostCount={hosts.length}
/>
<h3 className="mt-5">Host Resources</h3>
<div className="d-flex flex-row align-items-center mt-5">
<h3>
Host Resources
</h3>
<span className="badge badge-primary ml-3 mb-2">{hosts && `${hosts.length} hosts`}</span>
</div>
<Accordion.Root className="AccordionRoot" type="single" defaultValue="item-1" collapsible>
{
hosts && hosts.map((host, index) =>
Expand Down
12 changes: 9 additions & 3 deletions src/services/parser/siteLevel2Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,18 @@ export default function siteParserLevel2(data, siteName, acronymToShortName) {
})
}

hosts.sort((a, b) => {
const nameA = a.Name.toUpperCase();
const nameB = b.Name.toUpperCase();
if(nameA > nameB) { return 1; }
if(nameA < nameB) { return -1; }
return 0;
});

const parsedObj = {
"parsedSite": site,
"hosts": hosts.sort((a, b) => a.Name - b.Name)
"hosts": hosts
};

console.log(parsedObj);

return parsedObj;
}

0 comments on commit eb840d9

Please sign in to comment.