From 8f30fc76e498b3c561f511e218a6d4a0b0fc6d16 Mon Sep 17 00:00:00 2001 From: pacien Date: Wed, 10 Oct 2018 16:41:04 +0200 Subject: Initial implementation --- src/Blocks.js | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/Blocks.js (limited to 'src/Blocks.js') diff --git a/src/Blocks.js b/src/Blocks.js new file mode 100644 index 0000000..48e0376 --- /dev/null +++ b/src/Blocks.js @@ -0,0 +1,99 @@ +/* + * JaCoCo Report Viewer, a web-based coverage report viewer + * Copyright (C) 2018 Pacien TRAN-GIRARD + * Adam NAILI + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import React, { Component } from 'react'; + +function renderRows(renderRowFunc, rows, inline) { + const renderedRows = rows ? rows.map(renderRowFunc) : (
  • None.
  • ); + return (); +} + +export class SessionInfo extends Component { + _renderRow(row) { + const date = new Date(parseInt(row.start)); + return (
  • {row.id}: {date.toISOString()} ({row.dump - row.start} ms)
  • ); + } + + render() { + return renderRows(row => this._renderRow(row.$), this.props.data, false); + } +} + +export class Counters extends Component { + _renderRow(row) { + const covered = parseInt(row.covered); + const totalCount = covered + parseInt(row.missed); + const wellCovered = covered === totalCount; + return (
  • {row.type}: {covered}/{totalCount}
  • ); + } + + render() { + return renderRows(row => this._renderRow(row.$), this.props.data, this.props.inlineList !== undefined); + } +} + +export class PackagesCoverage extends Component { + _renderRow(row) { + return ( +
  • + {row.$.name} + + +
  • + ) + } + + render() { + return renderRows(this._renderRow, this.props.packages, false); + } +} + +class ClassesCoverage extends Component { + _renderRow(row) { + const counters = row.counter.filter(counter => counter.$.type !== 'CLASS'); + return ( +
  • + {row.$.name} + + +
  • + ) + } + + render() { + return renderRows(this._renderRow, this.props.classes, false); + } +} + +class MethodsCoverage extends Component { + _renderRow(row) { + const counters = row.counter.filter(counter => counter.$.type !== 'METHOD'); + const method = row.$.name + ':' + row.$.line; + return ( +
  • + {method} + +
  • + ) + } + + render() { + return renderRows(this._renderRow, this.props.methods, false); + } +} -- cgit v1.2.3