Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1bb41eb
Make it clear that settings apply only to list view
cmichi Mar 19, 2019
138b4af
Add Jdenticon
cmichi Mar 21, 2019
8c26dc8
Add Grandpa consensus visualisation
cmichi Apr 3, 2019
3c830af
Remove fade-in animation
cmichi Apr 4, 2019
c570cbc
Update packages and yarn.lock
cmichi Apr 4, 2019
e4de35c
Broadcast only delta of what changed
cmichi Apr 6, 2019
1e824c7
Minor code improvements
cmichi Apr 7, 2019
a7ba531
Use NodeId instead of Address in first dimension
cmichi Apr 8, 2019
672a33f
Refactoring and improving naming
cmichi Apr 8, 2019
e4b4916
Display boxes only after size has been detected
cmichi Apr 8, 2019
b2253e0
Fix cache
cmichi Apr 8, 2019
a3e9f06
Send consensus info on first subscribe
cmichi Apr 8, 2019
4b5505b
Increase cache size
cmichi Apr 8, 2019
5c48daa
Send deltas only if block in cache
cmichi Apr 8, 2019
0623e5b
Adjust cache size
cmichi Apr 8, 2019
064506a
Make cache sizes dependent
cmichi Apr 8, 2019
bde604a
Ensure authority caches are aligned
cmichi Apr 8, 2019
5b590ba
Extract function
cmichi Apr 10, 2019
062866a
Handle restarts on authority set changes properly
cmichi Apr 10, 2019
a569f54
Fix backfill mechanism
cmichi Apr 10, 2019
003aace
Display only blocks since last authority set change
cmichi Apr 10, 2019
b3d3507
Handle authority set sent on connect
cmichi Apr 12, 2019
03b3ae4
Introduce Authority type
cmichi Apr 12, 2019
fdc86c5
Handle corner case
cmichi Apr 15, 2019
b8d689b
Display placeholder if name not yet available
cmichi Apr 15, 2019
0a0acce
Replace with camelCase
cmichi Apr 23, 2019
23c254e
Replace with correct types
cmichi May 6, 2019
44bf2a5
Replace grandpa icon
cmichi May 6, 2019
3a4ea63
Merge branch 'master' into cmichi-display-state-of-consensus
maciejhirsz May 6, 2019
3a6427a
Change consensus icon to cube (finalized block icon)
cmichi May 13, 2019
bf4d9ea
Upgrade dependencies
cmichi May 15, 2019
7040545
Implement thin backend instead of thick
cmichi May 15, 2019
ca5d29b
Cleanup and minor improvements
cmichi May 16, 2019
0bc61dc
Minor refactoring
cmichi May 16, 2019
019d1f5
Extract common code into function
cmichi May 16, 2019
ed429c6
Switch module to class
cmichi May 16, 2019
6fe140a
Remove unused code
cmichi May 16, 2019
4e73e8f
Clean markup
cmichi May 16, 2019
5e0dbdf
Remove unused code
cmichi May 16, 2019
174eba4
Revert "Upgrade dependencies"
cmichi May 19, 2019
0da0c44
Update polkadot-identicon in frontend
cmichi May 19, 2019
64d08c3
Run yarn install
cmichi May 19, 2019
acd1218
Update react-measure to 2.3.0
cmichi May 19, 2019
f198278
Improve typing by introducing partial type
cmichi May 19, 2019
5da7937
Reduce indexing operations
cmichi May 19, 2019
b02f72d
Shorten function
cmichi May 19, 2019
12fd5c9
Shorten function
cmichi May 19, 2019
770b10f
Introduce initialiseConsensusViewByRef
cmichi May 19, 2019
0bafe84
Remove dead conditional branch
cmichi May 19, 2019
bce0576
Return consensusView ref from initialiseConsensusView
cmichi May 19, 2019
44863a5
Handle consensusView ref returned from initialiseConsensusView
cmichi May 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handle corner case
In the case of only one block having been produced, two authorities,
and only one authority connected, the UI did not show up.
  • Loading branch information
cmichi committed Apr 15, 2019
commit fdc86c59f5592bc99d28a71910dfd1efafed7aa6
49 changes: 36 additions & 13 deletions packages/frontend/src/components/Consensus/Consensus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export namespace Consensus {

export interface State {
dimensions: BoundingRect;

largeBlockWithLegend: BoundingRect,
largeBlock: BoundingRect,
countBlocksInLargeRow: number,
largeRowsAddFlexClass: boolean,

smallBlock: BoundingRect,
smallBlocksRows: number,
countBlocksInSmallRow: number,
smallRowsAddFlexClass: boolean,
}
}

Expand All @@ -22,30 +32,37 @@ export class Consensus extends React.Component<Consensus.Props, {}> {
// entire area available for rendering the visualization
dimensions: { width: -1, height: -1 } as BoundingRect,

largeBlockWithLegend: { width: -1, height: -1 },
largeBlock: { width: -1, height: -1 },
largeBlockWithLegend: { width: -1, height: -1 } as BoundingRect,
largeBlock: { width: -1, height: -1 } as BoundingRect,
countBlocksInLargeRow: 2,
largeRowsAddFlexClass: false,

smallBlock: { width: -1, height: -1 },
smallBlock: { width: -1, height: -1 } as BoundingRect,
smallBlocksRows: 1,
countBlocksInSmallRow: 1,
smallRowsAddFlexClass: false,
};

public largeBlocksSizeDetected(): boolean {
return this.state.largeBlockWithLegend.width > -1 && this.state.largeBlockWithLegend.height > -1 &&
this.state.largeBlock.width > -1 && this.state.largeBlock.height > -1;
public largeBlocksSizeDetected(state: Consensus.State): boolean {
const countBlocks = Object.keys(this.props.appState.consensusInfo).length;
if (countBlocks === 1) {
return state.largeBlockWithLegend.width > -1 && state.largeBlockWithLegend.height > -1;
}

// if there is more than one block then the size of the first block (with legend)
// will be different from the succeeding blocks (without legend)
return state.largeBlockWithLegend.width > -1 && state.largeBlockWithLegend.height > -1 &&
state.largeBlock.width > -1 && state.largeBlock.height > -1;
}

public smallBlocksSizeDetected(): boolean {
return this.state.smallBlock.width > -1 && this.state.largeBlockWithLegend.height > -1;
public smallBlocksSizeDetected(state: Consensus.State): boolean {
return state.smallBlock.width > -1 && state.largeBlockWithLegend.height > -1;
}

public calculateBoxCount(wasResized: boolean) {
// if the css class for flexing has already been added we don't calculate
// any box measurements then, because the box sizes would be skewed then.
if ((wasResized || this.state.largeRowsAddFlexClass === false) && this.largeBlocksSizeDetected()) {
if ((wasResized || this.state.largeRowsAddFlexClass === false) && this.largeBlocksSizeDetected(this.state)) {
// we need to add +2 because of the last block which doesn't contain a border.
let countBlocks = (this.state.dimensions.width - this.state.largeBlockWithLegend.width + 2) /
(this.state.largeBlock.width + 2);
Expand All @@ -59,7 +76,7 @@ export class Consensus extends React.Component<Consensus.Props, {}> {
this.setState({largeRowsAddFlexClass: true, countBlocksInLargeRow: countBlocks });
}

if ((wasResized || this.state.smallRowsAddFlexClass === false) && this.smallBlocksSizeDetected()) {
if ((wasResized || this.state.smallRowsAddFlexClass === false) && this.smallBlocksSizeDetected(this.state)) {
const howManyRows = 2;

const heightLeft = this.state.dimensions.height - (this.state.largeBlock.height * howManyRows);
Expand Down Expand Up @@ -93,8 +110,14 @@ export class Consensus extends React.Component<Consensus.Props, {}> {
const windowSizeChanged = JSON.stringify(this.state.dimensions) !==
JSON.stringify(nextState.dimensions);

// size detected, but flex class has not yet been added
const largeBlocksSizeDetected = this.largeBlocksSizeDetected(nextState) === true &&
this.state.largeRowsAddFlexClass === false;
const smallBlocksSizeDetected = this.smallBlocksSizeDetected(nextState) === true &&
this.state.smallRowsAddFlexClass === false;

return authoritiesDidChange || authoritySetIdDidChange || newConsensusInfoAvailable ||
windowSizeChanged;
windowSizeChanged || largeBlocksSizeDetected || smallBlocksSizeDetected;
}

public render() {
Expand Down Expand Up @@ -147,7 +170,7 @@ export class Consensus extends React.Component<Consensus.Props, {}> {

private getLargeRow(blocks: string[], id: number) {
const largeBlockSizeChanged = (isFirstBlock: boolean, rect: BoundingRect) => {
if (this.largeBlocksSizeDetected()) {
if (this.largeBlocksSizeDetected(this.state)) {
return;
}
if (isFirstBlock) {
Expand Down Expand Up @@ -182,7 +205,7 @@ export class Consensus extends React.Component<Consensus.Props, {}> {

private getSmallRow(blocks: string[]) {
const smallBlockSizeChanged = (isFirstBlock: boolean, rect: BoundingRect) => {
if (this.smallBlocksSizeDetected()) {
if (this.smallBlocksSizeDetected(this.state)) {
return;
}
const dimensionsChanged = this.state.smallBlock.height !== rect.height &&
Expand Down