-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: sample query sample body (#775)
* fix display of non-json bodies * fix sample query conditions * abstract group generation function * reuse group generation function * remove unused functions * show history items information
- Loading branch information
Showing
8 changed files
with
407 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export function generateGroupsFromList(list: any[], property: string) { | ||
const map = new Map(); | ||
const groups: any[] = []; | ||
|
||
let isCollapsed = false; | ||
let previousCount = 0; | ||
let count = 0; | ||
|
||
if (!list || list.length === 0 || list.some(e => !e[property])) { | ||
return groups; | ||
} | ||
|
||
for (const listItem of list) { | ||
if (!map.has(listItem[property])) { | ||
map.set(listItem[property], true); | ||
count = list.filter(item => item[property] === listItem[property]).length; | ||
if (groups.length > 0) { | ||
isCollapsed = true; | ||
} | ||
groups.push({ | ||
name: listItem[property], | ||
key: listItem[property], | ||
startIndex: previousCount, | ||
isCollapsed, | ||
count, | ||
}); | ||
previousCount += count; | ||
} | ||
} | ||
|
||
return groups; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.