Skip to content

Commit

Permalink
Order by latest request
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronvb committed Jun 27, 2021
1 parent 1bbacbb commit 3474565
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions web/src/Request.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function Params(props) {
</div>
)
}

}

function QueryParams(props) {
Expand Down Expand Up @@ -89,13 +88,14 @@ function JsonParams(props) {
}

function Request(props) {
const time = new Date(props.fields.time).toLocaleString('en-US', {hour12: false}).replace(', ', ' - ')
return(
<div className="shadow bg-white rounded-md py-4 px-4 flex flex-wrap md:flex-nowrap mb-3 animate-fade-in-down">
<div className="md:w-64 md:mb-0 mb-6 flex-shrink-0 flex flex-col">
<span className="self-start inline-block py-1 px-2 rounded bg-indigo-50 text-indigo-500 text-s font-semibold tracking-widest">
{props.fields.method}
</span>
<span className="mt-1 text-gray-500 text-sm">3 minutes ago</span>
<span className="mt-1 text-gray-400 text-sm">{time}</span>
</div>
<div className="md:flex-grow">
<div className="border-b-2 mb-3 border-gray-100">
Expand Down
6 changes: 5 additions & 1 deletion web/src/Requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ function AllRequests() {
<div>Failed to load.</div>
);

return data.requests.map(({ fields, headers, param_fields }) => (
const sortedRequests = data.requests.slice().sort((a, b) =>
new Date(b.fields.time) - new Date(a.fields.time)
)

return sortedRequests.map(({ fields, headers, param_fields }) => (
<Request fields={fields} headers={headers} param_fields={param_fields}/>
));
}
Expand Down

0 comments on commit 3474565

Please sign in to comment.