Skip to content

Commit

Permalink
[CE-117] Add chain background service
Browse files Browse the repository at this point in the history
Support chain background service in user dashboard
Add user reset password service
Add jwt in cookies for user dashboard login

Change-Id: Ibb0ae045953d91e31d5ebfcc871c8bd96238a0f1
Signed-off-by: Haitao Yue <[email protected]>
  • Loading branch information
hightall committed Dec 17, 2017
1 parent d0e3d8d commit 5cc1d4c
Show file tree
Hide file tree
Showing 21 changed files with 1,822 additions and 463 deletions.
30 changes: 12 additions & 18 deletions user-dashboard/src/models/chain.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@

/* Copyright IBM Corp, All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
import jsonfile from 'jsonfile'
import rimraf from 'rimraf'
import sleep from 'sleep-promise';
import config from '../config'
import util from 'util'
const hfc = require('fabric-client');
const shell = require('shelljs');
const mongoose = require('mongoose');
const fs = require('fs-extra');
Expand Down Expand Up @@ -57,9 +61,10 @@ chainSchema.post('save', function(doc, next) {
template.keyValueStore = `${chainRootDir}/client-kvs`
template.CC_SRC_PATH = chainRootDir
const txDir = `${chainRootDir}/tx`
const libDir = `${chainRootDir}/lib`
fs.ensureDirSync(libDir)
shell.cp('-R', '/usr/app/src/src/config-template/cc_code/src', template.CC_SRC_PATH);
shell.cp('/usr/app/src/src/modules/helper.js', chainRootDir)
shell.cp('-R', '/usr/app/src/src/modules/fabric', chainRootDir)
shell.cp('-R', `/usr/app/src/src/modules/${type}/*`, libDir)

fs.ensureDirSync(template.keyValueStore)
fs.ensureDirSync(txDir)
Expand Down Expand Up @@ -122,30 +127,19 @@ function initialFabric (doc) {
if (shell.exec(`configtxgen -profile TwoOrgsChannel -channelID ${channelName} -outputCreateChannelTx ${channelConfigPath}/${channelName}.tx`).code !== 0) {
return
}
hfc.addConfigFile(`${chainRootDir}/network-config.json`);
const helper = require(`${chainRootDir}/helper.js`)
const helper = require(`${chainRootDir}/lib/helper.js`)
helper.initialize(doc._template)
const channels = require(`${chainRootDir}/fabric/create-channel.js`);
const channels = require(`${chainRootDir}/lib/create-channel.js`);
channels.initialize(doc._template)
const chaincodeVersion = "v0"
const chaincodePath = "github.com/example_cc"
const chaincodeName = `${clusterId}-${id}`
function asyncInstallChainCode(arr) {
return arr.reduce((promise, orgName) => {
return promise.then((result) => {
return new Promise((resolve, reject) => {
const join = require(`${chainRootDir}/fabric/join-channel.js`);
const join = require(`${chainRootDir}/lib/join-channel.js`);
join.initialize(doc._template)
join.joinChannel(channelName, peerNames, username, orgName)
.then(function(message) {
resolve()
// helper.setupChaincodeDeploy()
// const install = require(`${chainRootDir}/fabric/install-chaincode.js`);
// install.initialize(keyValueStore)
// install.installChaincode(peerNames, chaincodeName, chaincodePath, chaincodeVersion, username, orgName)
// .then(function(message) {
// resolve()
// });
});
})
})
Expand Down Expand Up @@ -195,4 +189,4 @@ chainSchema.post('remove', function(doc) {

const model = mongoose.model('chain', chainSchema);

module.exports = model;
module.exports = model;
5 changes: 5 additions & 0 deletions user-dashboard/src/models/chainCode.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

/* Copyright IBM Corp, All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
const mongoose = require('mongoose');
import rimraf from 'rimraf'
const log4js = require('log4js');
Expand Down
5 changes: 5 additions & 0 deletions user-dashboard/src/models/user.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

/* Copyright IBM Corp, All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
const mongoose = require('mongoose');
const log4js = require('log4js');
const logger = log4js.getLogger(__filename.slice(__dirname.length + 1));
Expand Down
Loading

0 comments on commit 5cc1d4c

Please sign in to comment.