Skip to content

Commit

Permalink
various nitpicks (hyperledger-archives#2063)
Browse files Browse the repository at this point in the history
  • Loading branch information
nklincoln authored and Simon Stone committed Sep 6, 2017
1 parent 2b40a05 commit d8aeebc
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1 class="flex">My IDs for {{businessNetworkName}}</h1>
{{identityCards.get(cardRef).getName()}}
</div>
<div class="flex" *ngIf="cardRef===currentIdentity">
In Use
IN USE
</div>
<div class="flex" *ngIf="cardRef!==currentIdentity">
<i>In my wallet</i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export class IdentityComponent implements OnInit {
let connectionProfile = this.identityCardService.getCurrentIdentityCard().getConnectionProfile();
let qpn: string = this.identityCardService.getQualifiedProfileName(connectionProfile);

ids.sort((a, b) => {
return a.name.localeCompare(b.name);
});

ids.forEach((id) => {
id.ref = this.identityCardService.getCardRefFromIdentity(id.name, this.businessNetworkName, qpn);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ <h3>Samples on npm</h3>
</div>
<div>
<section>
<h3 *ngIf="networkNameValid">{{networkName ? networkName : 'Business Network Name'}}</h3>
<h3 *ngIf="!networkNameValid" style="color:red">{{networkName ? networkName : 'Business Network Name'}}</h3>
<p>{{networkDescription ? networkDescription : 'Business network description will be previewed here when
<h3 class="network-desc" *ngIf="networkNameValid">{{networkName ? networkName : 'Business Network Name'}}</h3>
<h3 class="network-desc" *ngIf="!networkNameValid" style="color:red">{{networkName ? networkName : 'Business Network Name'}}</h3>
<p class="network-desc">{{networkDescription ? networkDescription : 'Business network description will be previewed here when
entered in the basic information section.'}}</p>
</section>
<section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ deploy-business-network {
}
}

.network-desc {
word-wrap: break-word;
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>Create ID Card</h1>
</div>-->
<div *ngIf="!useCerts" class="noCerts">
<p>An Enrollment ID and Secret must be created by someone who already has access to the Business Network you are connecting to.</p>
<form #addIdentityForm="ngForm" id="add-identity-form" (ngSubmit)="addIdentityCard()">
<form #idSecretForm="ngForm" (submit)="submitCard()" (keydown)="submitCard($event)">
<div class="option">
<label for="userId"><h3>Enrollment ID</h3></label>
<input required type="text" [(ngModel)]="userId" id="userId" name="userId" autocomplete="off">
Expand All @@ -40,7 +40,7 @@ <h1>Create ID Card</h1>
<div class="holding-div">
<div class="noCerts">
<p>The name of the Business Network to which you are going to connect should be specified when using an Enrollment ID and Secret.</p>
<form #busNetForm="ngForm" id="busNet-form">
<form #busNetForm="ngForm" (submit)="submitCard()" (keydown)="submitCard($event)">
<div class="option">
<label for="busNetName"><h3>Name of Business Network</h3></label>
<input required type="text" [(ngModel)]="busNetName" id="busNetName" name="busNetName" autocomplete="off">
Expand All @@ -53,7 +53,7 @@ <h1>Create ID Card</h1>
<button type="button" class="secondary" (click)="close();">
<span>Cancel</span>
</button>
<button type="submit" form="add-identity-form" class="primary" [disabled]="!validContents()">
<button type="button" class="primary" [disabled]="!validContents() || addInProgress" (click)="addIdentityCard();">
<div *ngIf="!addInProgress">
<span>Create</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { IdentityCardService } from '../../services/identity-card.service';
import { AlertService } from '../../basic-modals/alert.service';

describe('EditCardCredentialsComponent', () => {
let sandbox;
let component: EditCardCredentialsComponent;
let fixture: ComponentFixture<EditCardCredentialsComponent>;

Expand All @@ -37,17 +36,53 @@ describe('EditCardCredentialsComponent', () => {
})
.compileComponents();

sandbox = sinon.sandbox.create();
fixture = TestBed.createComponent(EditCardCredentialsComponent);
component = fixture.componentInstance;
});

afterEach(() => {
sandbox.restore();
it('should be created', () => {
component.should.be.ok;
});

it('should be created', () => {
expect(component).should.be.ok;
describe('#submitCard', () => {

let mockValidate;
let mockAddCard;
let event;

beforeEach(() => {
mockValidate = sinon.stub(component, 'validContents').returns(false);
mockAddCard = sinon.stub(component, 'addIdentityCard');
event = document.createEvent('Events');
event.initEvent('keydown"', true, true);
event.keyCode = 40;
});

it('should not call addCard if no event', () => {
component.submitCard(null);
mockAddCard.should.not.have.been.called;
});

it('should not call addCard if invalid key press', () => {
component.submitCard(event);
mockAddCard.should.not.have.been.called;
});

it('should not call addCard if form contents invalid', () => {
event.keyCode = 13;
component.submitCard(event);
mockValidate.should.have.been.called;
mockAddCard.should.not.have.been.called;
});

it('should call addCard if valid keypress and form contents are valid', () => {
event.keyCode = 13;
mockValidate.returns(true);
component.submitCard(event);
mockValidate.should.have.been.called;
mockAddCard.should.have.been.called;
});

});

describe('#addIdentityCard', () => {
Expand All @@ -57,6 +92,8 @@ describe('EditCardCredentialsComponent', () => {
component['userSecret'] = 'suchSecret';
component['busNetName'] = 'network';
component['connectionProfile'] = { theProfile: 'muchProfile' };
component['addInProgress'] = false;
component['useCerts'] = false;
});

it('should set busy status upon entry', fakeAsync(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AlertService } from '../../basic-modals/alert.service';
import { IdentityCardService } from '../../services/identity-card.service';

Expand Down Expand Up @@ -48,6 +49,14 @@ export class EditCardCredentialsComponent {
return true;
}

submitCard(event) {
if ( (event && event.keyCode !== 13) || !this.validContents()) {
return;
} else {
this.addIdentityCard();
}
}

addIdentityCard() {
this.addInProgress = true;
this.alertService.busyStatus$.next({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>My Wallet</h1>
<section *ngIf="!showSubScreen" class="main-view">
<div class="connection-profile" *ngFor="let connectionProfileRef of connectionProfileRefs;">
<span class="connection-profile-title">
<h2>Identities for {{this.connectionProfileRef === 'web-$default' ? 'Web Browser' : this.connectionProfileNames.get(connectionProfileRef) }}</h2>
<h2>Identity cards for {{this.connectionProfileRef === 'web-$default' ? 'Web Browser' : this.connectionProfileNames.get(connectionProfileRef) }}</h2>
<tutorial-link *ngIf="this.connectionProfileRef === 'web-$default' && idCards.size == indestructibleCards.length"></tutorial-link>
</span>
<div class="identities">
Expand Down

0 comments on commit d8aeebc

Please sign in to comment.