From 04f391c162d9aec34bd9732a2af515b840b5e843 Mon Sep 17 00:00:00 2001 From: seebees Date: Fri, 18 Nov 2022 08:46:51 -0800 Subject: [PATCH 1/5] feat: Larger report Make the report use the entier browser. Also change the text and section columns to autoresize --- www/package-lock.json | 16 ++++++++-------- www/src/App.js | 2 +- www/src/spec.js | 5 +++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/www/package-lock.json b/www/package-lock.json index e0fdc88c..ee956c22 100644 --- a/www/package-lock.json +++ b/www/package-lock.json @@ -1,12 +1,12 @@ { "name": "duvet-report", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "duvet-report", - "version": "0.1.0", + "version": "0.2.0", "dependencies": { "@material-ui/core": "4", "@material-ui/icons": "4", @@ -4458,9 +4458,9 @@ "dev": true }, "node_modules/@types/react": { - "version": "18.0.25", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.25.tgz", - "integrity": "sha512-xD6c0KDT4m7n9uD4ZHi02lzskaiqcBxf4zi+tXZY98a04wvc0hi/TcCPC2FOESZi51Nd7tlUeOJY8RofL799/g==", + "version": "17.0.52", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.52.tgz", + "integrity": "sha512-vwk8QqVODi0VaZZpDXQCmEmiOuyjEFPY7Ttaw5vjM112LOq37yz1CDJGrRJwA1fYEq4Iitd5rnjd1yWAc/bT+A==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -21611,9 +21611,9 @@ "dev": true }, "@types/react": { - "version": "18.0.25", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.25.tgz", - "integrity": "sha512-xD6c0KDT4m7n9uD4ZHi02lzskaiqcBxf4zi+tXZY98a04wvc0hi/TcCPC2FOESZi51Nd7tlUeOJY8RofL799/g==", + "version": "17.0.52", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.52.tgz", + "integrity": "sha512-vwk8QqVODi0VaZZpDXQCmEmiOuyjEFPY7Ttaw5vjM112LOq37yz1CDJGrRJwA1fYEq4Iitd5rnjd1yWAc/bT+A==", "requires": { "@types/prop-types": "*", "@types/scheduler": "*", diff --git a/www/src/App.js b/www/src/App.js index ce2566cd..c9964efb 100644 --- a/www/src/App.js +++ b/www/src/App.js @@ -86,7 +86,7 @@ function App() { })} >
- + diff --git a/www/src/spec.js b/www/src/spec.js index 53fb82f8..e18abffc 100644 --- a/www/src/spec.js +++ b/www/src/spec.js @@ -75,6 +75,7 @@ export function Requirements({ requirements, showSection }) { if (showSection) { columns.push({ + flex: 1, // This is paired with "content" below field: "section", headerName: "Section", valueGetter(params) { @@ -104,7 +105,7 @@ export function Requirements({ requirements, showSection }) { { field: "level", headerName: "Requirement", - width: 120, + width: 150, sortComparator(v1, v2) { return LEVEL_IDS[v2] - LEVEL_IDS[v1]; }, @@ -182,7 +183,7 @@ export function Requirements({ requirements, showSection }) { field: "comment", headerName: "Text", sortable: false, - width: 850, + flex: 4, // This is paired with "section" above cellClassName: classes.text, }); From 2d867a0bd2d5c91eb9ccc59c64f16f252bb4e66e Mon Sep 17 00:00:00 2001 From: seebees Date: Fri, 18 Nov 2022 13:48:46 -0800 Subject: [PATCH 2/5] fix: Filter by section The value getter for section should return the string, not the whole row. --- www/src/spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/src/spec.js b/www/src/spec.js index e18abffc..091efea3 100644 --- a/www/src/spec.js +++ b/www/src/spec.js @@ -79,7 +79,7 @@ export function Requirements({ requirements, showSection }) { field: "section", headerName: "Section", valueGetter(params) { - return params.row; + return params.row.section.title; }, sortComparator(v1, v2) { return v1.cmp(v2); @@ -93,7 +93,7 @@ export function Requirements({ requirements, showSection }) { hash: `#A${requirement.id}`, }} > - {requirement.section.shortId} + {requirement.section.title} ); }, From bc66432b1dd10e89d5ce6696722c660eec03a42a Mon Sep 17 00:00:00 2001 From: seebees Date: Fri, 18 Nov 2022 13:56:24 -0800 Subject: [PATCH 3/5] feat: Add view of all requirements It can be useful to view all requriements across every specification. --- www/src/App.js | 24 ++++++++++++++++++++++ www/src/list.js | 21 +++++++++++++++++++ www/src/nav.js | 8 +++++++- www/src/result.js | 38 +++------------------------------- www/src/spec.js | 30 +++++++++++++++++++++++++-- www/src/stats_class.js | 46 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 129 insertions(+), 38 deletions(-) create mode 100644 www/src/list.js create mode 100644 www/src/stats_class.js diff --git a/www/src/App.js b/www/src/App.js index c9964efb..6a556b94 100644 --- a/www/src/App.js +++ b/www/src/App.js @@ -7,7 +7,9 @@ import { Nav } from "./nav"; import { Spec, Stats } from "./spec"; import { Section } from "./section"; import { Link } from "./link"; +import { List } from "./list"; import specifications from "./result"; +import { Stats as StatsClass } from "./stats_class"; import clsx from "clsx"; const drawerWidth = 400; @@ -88,6 +90,9 @@ function App() {
+ + + @@ -136,4 +141,23 @@ function SectionRoute() { return
; } +function ListRoute() { + const requirements = specifications.flatMap((spec) => spec.requirements); + const total = { + id: "AllSpecifications", + stats: specifications.reduce((total, {stats}) => { + Object.keys(stats).forEach((statName) => { + const stat = total[statName] || new StatsClass() + total[statName] = stat; + stat.onStat(stats[statName]); + }); + return total; + }, {}), + requirements, + } + specifications + .map((spec) => spec.requirements) + return ; +} + export default App; diff --git a/www/src/list.js b/www/src/list.js new file mode 100644 index 00000000..f71d7fd1 --- /dev/null +++ b/www/src/list.js @@ -0,0 +1,21 @@ +import { Requirements, Stats } from "./spec" + +export function List({spec}) { + return ( + <> +

Requirements across specifications

+ +

Stats

+ + +

Requirements

+ + + ); +} + diff --git a/www/src/nav.js b/www/src/nav.js index 05c17e23..dedc7d32 100644 --- a/www/src/nav.js +++ b/www/src/nav.js @@ -125,7 +125,13 @@ export function Nav({ open, setOpen }) { - Compliance Coverage Report + Compliance by Specification + + + + + + Compliance by Requirement diff --git a/www/src/result.js b/www/src/result.js index 4fcc2a74..d80bd955 100644 --- a/www/src/result.js +++ b/www/src/result.js @@ -1,3 +1,6 @@ + +import { Stats } from "./stats_class"; + const input = process.env.NODE_ENV === "production" ? JSON.parse(document.getElementById("result").innerHTML) @@ -91,41 +94,6 @@ input.annotations.forEach((anno, id) => { }; }); -class Stats { - constructor() { - this.total = 0; - this.complete = 0; - this.incomplete = 0; - this.citations = 0; - this.implications = 0; - this.tests = 0; - this.exceptions = 0; - this.todos = 0; - } - - onRequirement(requirement) { - this.total += 1; - - if (requirement.incomplete) this.incomplete += 1; - else if (requirement.isOk) this.complete += 1; - - if (requirement.citation) this.citations += 1; - if (requirement.implication) this.implications += 1; - if (requirement.test) this.tests += 1; - if (requirement.exception) this.exceptions += 1; - if (requirement.todo) this.todos += 1; - } - - percent(field) { - const percent = this.total ? this[field] / this.total : 0; - return Number(percent).toLocaleString(undefined, { - style: "percent", - minimumFractionDigits: 0, - maximumFractionDigits: 2, - }); - } -} - // create stats now that we've linked everything specifications.forEach((spec) => { spec.requirements.sort(sortRequirements); diff --git a/www/src/spec.js b/www/src/spec.js index 091efea3..afd12fda 100644 --- a/www/src/spec.js +++ b/www/src/spec.js @@ -68,11 +68,37 @@ const LEVEL_IDS = LEVELS.reduce((acc, level, idx) => { return acc; }, {}); -export function Requirements({ requirements, showSection }) { +export function Requirements({ requirements, showSection, showSpecification }) { const classes = useStyles(); const columns = []; + if (showSpecification) { + columns.push({ + flex: 1, // This is paired with "content" below + field: "specification", + headerName: "Specification", + valueGetter(params) { + return params.row.specification.title; + }, + sortComparator(v1, v2) { + return v1.localeCompare(v2) + }, + renderCell(params) { + const requirement = params.row; + return ( + + {requirement.specification.title} + + ); + }, + }); + } + if (showSection) { columns.push({ flex: 1, // This is paired with "content" below @@ -190,7 +216,7 @@ export function Requirements({ requirements, showSection }) { return (
Date: Mon, 21 Nov 2022 08:51:39 -0800 Subject: [PATCH 4/5] PR feedback --- www/src/App.js | 18 ++---------------- www/src/result.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/www/src/App.js b/www/src/App.js index 6a556b94..76e15e67 100644 --- a/www/src/App.js +++ b/www/src/App.js @@ -9,6 +9,7 @@ import { Section } from "./section"; import { Link } from "./link"; import { List } from "./list"; import specifications from "./result"; +import { AllSpecificationsRequirements } from "./result"; import { Stats as StatsClass } from "./stats_class"; import clsx from "clsx"; @@ -142,22 +143,7 @@ function SectionRoute() { } function ListRoute() { - const requirements = specifications.flatMap((spec) => spec.requirements); - const total = { - id: "AllSpecifications", - stats: specifications.reduce((total, {stats}) => { - Object.keys(stats).forEach((statName) => { - const stat = total[statName] || new StatsClass() - total[statName] = stat; - stat.onStat(stats[statName]); - }); - return total; - }, {}), - requirements, - } - specifications - .map((spec) => spec.requirements) - return ; + return ; } export default App; diff --git a/www/src/result.js b/www/src/result.js index d80bd955..e87d9076 100644 --- a/www/src/result.js +++ b/www/src/result.js @@ -256,3 +256,16 @@ function mapLine(line) { } export default specifications; + +export const AllSpecificationsRequirements = { + id: "AllSpecificationsRequirements", + stats: specifications.reduce((total, {stats}) => { + Object.keys(stats).forEach((statName) => { + const stat = total[statName] || new StatsClass() + total[statName] = stat; + stat.onStat(stats[statName]); + }); + return total; + }, {}), + requirements: specifications.flatMap((spec) => spec.requirements), +} From bb49df9bea79ecdb244dce875b5fae30ed22aeb8 Mon Sep 17 00:00:00 2001 From: seebees Date: Mon, 21 Nov 2022 08:52:42 -0800 Subject: [PATCH 5/5] update file name --- www/src/App.js | 2 +- www/src/result.js | 2 +- www/src/{stats_class.js => stats.js} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename www/src/{stats_class.js => stats.js} (100%) diff --git a/www/src/App.js b/www/src/App.js index 76e15e67..65186a7a 100644 --- a/www/src/App.js +++ b/www/src/App.js @@ -10,7 +10,7 @@ import { Link } from "./link"; import { List } from "./list"; import specifications from "./result"; import { AllSpecificationsRequirements } from "./result"; -import { Stats as StatsClass } from "./stats_class"; +import { Stats as StatsClass } from "./stats"; import clsx from "clsx"; const drawerWidth = 400; diff --git a/www/src/result.js b/www/src/result.js index e87d9076..a614d053 100644 --- a/www/src/result.js +++ b/www/src/result.js @@ -1,5 +1,5 @@ -import { Stats } from "./stats_class"; +import { Stats } from "./stats"; const input = process.env.NODE_ENV === "production" diff --git a/www/src/stats_class.js b/www/src/stats.js similarity index 100% rename from www/src/stats_class.js rename to www/src/stats.js