Skip to content

Commit

Permalink
Merge pull request hyperledger-archives#455 from samjsmith/master
Browse files Browse the repository at this point in the history
Nitpicking items
  • Loading branch information
samjsmith authored Mar 14, 2017
2 parents 9117a67 + 7102ff6 commit 52b0e26
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h3>Connection Profiles are not available in Web Playground</h3>
<p>
It is not possible to add Connection Profiles in the Web Playground version of Fabric Composer.
If you like what you see, you can install a a local version of Fabric Composer.
The local version offers the same UI, or a CLI experience, and can be used to deploy Business Network Definitions to real Hyperleder Fabrics.
The local version offers the same UI, or a CLI experience, and can be used to deploy Business Network Definitions to running Hyperledger Fabric instances.
</p>
<p>And of course it's still 100% open source</p>
<p><a href="http://fabric-composer.org/">Learn more in the docs</a></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ <h3 *ngIf="file.readme">About</h3>
<div class="actions">
<div>
<button type="button" class="action" (click)="openImportModal()">
<svg class="ibm-icon" aria-hidden="true">
<svg class="nav-icon" aria-hidden="true">
<use xlink:href="#icon-download_32"></use>
</svg>
Import/Replace
</button>
</div>
<div>
<button type="button" class="action" (click)="openExportModal()">
<svg class="ibm-icon" aria-hidden="true">
<use xlink:href="#icon-upload_24"></use>
<svg class="nav-icon" aria-hidden="true">
<use xlink:href="#icon-upload_32"></use>
</svg>
Export
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ app-editor {
}
}

svg.nav-icon {
width: 32px;
height: 16px;
}


.main-view {
.business-network-details {
display: flex;
Expand Down
73 changes: 40 additions & 33 deletions packages/composer-playground/src/app/editor/editor.component.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import {NgbModal} from '@ng-bootstrap/ng-bootstrap';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';

import {ImportComponent} from '../import/import.component';
import {ExportComponent} from '../export/export.component';
import {AddFileComponent} from '../add-file/add-file.component';

import { ImportComponent } from '../import/import.component';
import { ExportComponent } from '../export/export.component';
import { AddFileComponent } from '../add-file/add-file.component';

import { AdminService } from '../services/admin.service';
import { ClientService } from '../services/client.service';
import { InitializationService } from '../initialization.service';
import { SampleBusinessNetworkService } from '../services/samplebusinessnetwork.service';
import { AlertService } from '../services/alert.service';

import {AclFile, BusinessNetworkDefinition, ModelFile} from 'composer-common';
import { AclFile, BusinessNetworkDefinition, ModelFile } from 'composer-common';

import {saveAs} from 'file-saver';
import { saveAs } from 'file-saver';

import 'codemirror/mode/javascript/javascript';
import 'codemirror/addon/fold/foldcode';
Expand Down Expand Up @@ -87,12 +88,12 @@ export class EditorComponent implements OnInit {
private exportedData;

constructor(private adminService: AdminService,
private clientService: ClientService,
private initializationService: InitializationService,
private modalService: NgbModal,
private route: ActivatedRoute,
private sampleBusinessNetworkService: SampleBusinessNetworkService,
private alertService: AlertService) {
private clientService: ClientService,
private initializationService: InitializationService,
private modalService: NgbModal,
private route: ActivatedRoute,
private sampleBusinessNetworkService: SampleBusinessNetworkService,
private alertService: AlertService) {

}

Expand Down Expand Up @@ -270,31 +271,40 @@ export class EditorComponent implements OnInit {
}

private updateFiles() {
let newFiles = [];
let businessNetworkDefinition = this.businessNetworkDefinition;

// deal with model files
let modelManager = businessNetworkDefinition.getModelManager();
let modelFiles = modelManager.getModelFiles();
let newFiles = [];

let newModelFiles = [];
modelFiles.forEach((modelFile) => {
newFiles.push({
newModelFiles.push({
model: true,
id: modelFile.getNamespace(),
displayID: 'lib/' + modelFile.getNamespace() + '.cto'
});
});
modelFiles.sort((a, b) => {
return a.displayID.localeCompare(b.displayID);
});
newFiles.push.apply(newFiles, newModelFiles);

// deal with script files
let scriptManager = businessNetworkDefinition.getScriptManager();
let scriptFiles = scriptManager.getScripts();
let newScriptFiles = [];
scriptFiles.forEach((scriptFile) => {
newFiles.push({
newScriptFiles.push({
script: true,
id: scriptFile.getIdentifier(),
displayID: scriptFile.getIdentifier()
});
});
newFiles.sort((a, b) => {
scriptFiles.sort((a, b) => {
return a.displayID.localeCompare(b.displayID);
});
newFiles.push.apply(newFiles, newScriptFiles);

let aclManager = businessNetworkDefinition.getAclManager();
let aclFile = aclManager.getAclFile();
Expand All @@ -307,11 +317,11 @@ export class EditorComponent implements OnInit {
}

let readme = businessNetworkDefinition.getMetadata().getREADME();
if(readme) {
if (readme) {
//add it first so it appears at the top of the list
newFiles.unshift({
readme: true,
id : 'readme',
id: 'readme',
displayID: 'README.md'
})
}
Expand Down Expand Up @@ -429,18 +439,15 @@ export class EditorComponent implements OnInit {

}
}, (reason) => {
// if no reason then we hit cancel
if (reason) {
this.alertService.errorStatus$.next(reason);
}
// do nothing - modal has been dismissed
});
}

private openExportModal() {
return this.businessNetworkDefinition.toArchive().then((exportedData) => {
let file = new File([exportedData],
this.deployedPackageName + '.bna',
{type: 'application/octet-stream'});
{ type: 'application/octet-stream' });
saveAs(file);

this.modalService.open(ExportComponent);
Expand All @@ -461,7 +468,7 @@ export class EditorComponent implements OnInit {
}
}
}).catch(() => {
}); // Ignore this, only there to prevent crash when closed
}); // Ignore this, only there to prevent crash when closed
}

private deploy(): Promise<any> {
Expand Down Expand Up @@ -529,10 +536,10 @@ export class EditorComponent implements OnInit {
let packageJson = this.businessNetworkDefinition.getMetadata().getREADME();

this.savedFiles = {
modelFiles : modelFiles,
scriptFiles : scriptFiles,
aclFile : aclFile,
readme : readme
modelFiles: modelFiles,
scriptFiles: scriptFiles,
aclFile: aclFile,
readme: readme
};
}

Expand Down Expand Up @@ -603,8 +610,8 @@ export class EditorComponent implements OnInit {
this.editingPackage = true;
}

private stopEditing(){
if(this.editingPackage){
private stopEditing() {
if (this.editingPackage) {
this.editActive = false;
this.editingPackage = false;
this.setCurrentFile(this.previousFile);
Expand Down

0 comments on commit 52b0e26

Please sign in to comment.