Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from sstone1/develop
Browse files Browse the repository at this point in the history
UI fixes to connection profiles
  • Loading branch information
Simon Stone authored Jan 30, 2017
2 parents f9dda6e + f9b27d0 commit 960cefc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
14 changes: 7 additions & 7 deletions packages/composer-ui/src/app/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ export class AdminService {
})
.then(() => {
// If we're in a Docker Compose environment, check to see
// if the Hyperledger connection profile exists.
// if the Hyperledger Fabric connection profile exists.
if (DOCKER_COMPOSE) {
console.log('Docker Compose environment, checking for hyperledger connection profile');
return this.adminConnection.getProfile('hyperledger')
console.log('Docker Compose environment, checking for hlfabric connection profile');
return this.adminConnection.getProfile('hlfabric')
.catch((error) => {
// It doesn't exist, so create it.
console.log('hyperledger connection profile does not exist, creating');
return this.adminConnection.createProfile('hyperledger', {
console.log('hlfabric connection profile does not exist, creating');
return this.adminConnection.createProfile('hlfabric', {
type: 'hlf',
keyValStore: '/home/concerto/.concerto-credentials',
membershipServicesURL: 'grpc://membersrvc:7054',
Expand All @@ -127,11 +127,11 @@ export class AdminService {
invokeWaitTime: 30
})
.then(() => {
return this.walletService.getWallet('hyperledger').add('admin', 'Xurw3yU9zI0l');
return this.walletService.getWallet('hlfabric').add('admin', 'Xurw3yU9zI0l');
});
});
} else {
console.log('Not in Docker Compose environment, not checking for hyperledger connection profile');
console.log('Not in Docker Compose environment, not checking for hlfabric connection profile');
}
})
.then(() => {
Expand Down
10 changes: 5 additions & 5 deletions packages/composer-ui/src/app/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<h4>Connection profiles</h4>
<div class="row h-100 mt-2">
<div class="col-sm-4 h-100">
<div class="list-group">
<button type="button" class="list-group-item list-group-item-action" *ngFor="let connectionProfile of connectionProfiles" [class.active]="connectionProfile === currentConnectionProfile" [class.disabled]="connectionProfile.default" [disabled]="connectionProfile.default" (click)="setCurrentConnectionProfile(connectionProfile)">
<ul class="list-group">
<li class="list-group-item list-group-item-action" *ngFor="let connectionProfile of connectionProfiles" [class.active]="connectionProfile === currentConnectionProfile" [class.disabled]="connectionProfile.default" (click)="!connectionProfile.default && setCurrentConnectionProfile(connectionProfile)">
<ng-container *ngIf="connectionProfile.default">Web browser</ng-container>
<ng-container *ngIf="!connectionProfile.default">{{connectionProfile.name}}</ng-container>
<button type="button" class="btn btn-danger btn-sm float-sm-right" (click)="deleteConnectionProfile(connectionProfile)" *ngIf="!connectionProfile.default" [disabled]="(connectionProfile.name === inUseConnectionProfile)">
<span class="fa fa-trash" aria-hidden="true"></span>
</button>
</button>
</div>
</li>
</ul>
<br>
<button type="button" class="btn btn-primary" (click)="addConnectionProfileModal.show()">
<span class="fa fa-plus" aria-hidden="true"></span> Connection profile
Expand Down Expand Up @@ -56,7 +56,7 @@ <h4>Connection profiles</h4>
</div>
</div>
</div>
<div bsModal #addConnectionProfileModal="bs-modal" class="modal fade" tabindex="-1">
<div bsModal #addConnectionProfileModal="bs-modal" class="modal fade" tabindex="-1" (onShow)="onShow();">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
Expand Down
13 changes: 9 additions & 4 deletions packages/composer-ui/src/app/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export class SettingsComponent implements OnInit {
}

ngOnInit(): Promise<any> {
this.setDefaults();
this.inUseConnectionProfile = this.connectionProfileService.getCurrentConnectionProfile();
return this.updateConnectionProfiles()
.then(() => {
Expand Down Expand Up @@ -176,13 +175,19 @@ export class SettingsComponent implements OnInit {
}
return false;
});
this.setDefaults();
this.adminService.connectionProfileChanged$.next(this.addConnectionProfileName);
});
}

private setDefaults() {
this.addConnectionProfileName = 'hyperledger';
private onShow() {
let connectionProfileBase = 'hlfabric';
let connectionProfileName = connectionProfileBase;
let counter = 1;
while (this.connectionProfiles.some((cp) => { return cp.name === connectionProfileName; })) {
counter++;
connectionProfileName = connectionProfileBase + counter;
}
this.addConnectionProfileName = connectionProfileName;
this.addConnectionProfilePeerURL = 'grpc://localhost:7051';
this.addConnectionProfileMembershipServicesURL = 'grpc://localhost:7054';
this.addConnectionProfileEventHubURL = 'grpc://localhost:7053';
Expand Down

0 comments on commit 960cefc

Please sign in to comment.