<commit_before>/**
 *
 * Created by shouhewu on 6/8/17.
 *
 */
var bcservice=require('./service/bcservice.js')

var express = require("express");
var path = require('path');
var app = express();

//app.use(express.static('source'));
//app.use('/source', express.static('source'));
app.use('/source', express.static('public'));

//app.use(express.static(path.join(__dirname, '/source')))

var query=require('./app/query.js');

//指定模板引擎
app.set("view engine", 'ejs');
//指定模板位置
app.set('views', __dirname + '/views');


// =======================   控制器绑定  ===================

/**
 *  /channels
 *  /channels/:channelName
 *  /channels/:channelName/block/:blockNum
 *  /channels/:channelName/block/:blockHash
 *  /channels/:channelName/block/:blockNum/:txHash
 *  /channels/:channelName/chaincodes
 *
 *  /orgs
 *  /orgs/peers
 *
 *
 */

//首页
app.get("/", function(req, res) {
    res.render('index.ejs', {
        name: 'tinyphp',item_index_active:'1'
    });
});


//首页
app.get("/index", function(req, res) {


    // var orgs = orgconfig.getAllOrgs();
    //
    // test();
    // console.log(util.inspect(orgs));

    //console.log(util.inspect(bcserver.getAllPeerRequest()));

    var peers = bcservice.getAllPeerRequest();

    peers.forEach((item,index)=>{

        console.log(` ${index}  ==> ${item.name}  ==> ${item.org}`);

        query.getChannels(item.name,'admin',item.org).then(response=>{

            console.log(response)

            console.log("   =======  ")

        }).catch(err=>{
            console.log(err)
        })

    })





    res.render('index.ejs', {
        name: 'tinyphp',item_index_active:'1'
    });


});



//组织列表
app.get("/orgs", function(req, res) {
    var orgs=bcservice.getAllOrgs()
    res.json(orgs)
});

app.get("/orgs/peers", function(req, res) {
    res.render('orgs.ejs', {
        name: 'tinyphp',item_index_orgs:'1'
    });
});

//channel列表
app.get("/channels", function(req, res) {
    bcservice.getAllChannels().then(channels=>{
        res.send(channels)
    }).catch(err=>{
        res.send(err)
    })
});

//channel详情
app.get("/channels/:channelName", function(req, res) {
    var channelName=req.params.channelName
    bcservice.getChainInfo(channelName).then(chainInfo=>{
        res.send(chaiinInfo)
    }).catch(err=>{
        res.send(err)
    })
});

//区块列表<commit_msg>modify1<commit_after>/**
 *
 * Created by shouhewu on 6/8/17.
 *
 */
var bcservice=require('./service/bcservice.js')

var express = require("express");
var path = require('path');
var app = express();

//app.use(express.static('source'));
//app.use('/source', express.static('source'));
app.use('/source', express.static('public'));

//app.use(express.static(path.join(__dirname, '/source')))

var query=require('./app/query.js');

//指定模板引擎
app.set("view engine", 'ejs');
//指定模板位置
app.set('views', __dirname + '/views');


// =======================   控制器绑定  ===================

/**
 *  /channels
 *  /channels/:channelName
 *  /channels/:channelName/block/:blockNum
 *  /channels/:channelName/block/:blockHash
 *  /channels/:channelName/block/:blockNum/:txHash
 *  /channels/:channelName/chaincodes
 *
 *  /orgs
 *  /orgs/peers
 *
 *
 */

//首页
app.get("/", function(req, res) {
    res.render('index.ejs', {
        name: 'tinyphp',item_index_active:'1'
    });
});


//首页
app.get("/index", function(req, res) {


    // var orgs = orgconfig.getAllOrgs();
    //
    // test();
    // console.log(util.inspect(orgs));

    //console.log(util.inspect(bcserver.getAllPeerRequest()));

    var peers = bcservice.getAllPeerRequest();

    /*peers.forEach((item,index)=>{

        console.log(` ${index}  ==> ${item.name}  ==> ${item.org}`);

        query.getChannels(item.name,'admin',item.org).then(response=>{

            console.log(response)
            console.log("   =======  ")

        }).catch(err=>{
            console.log(err)
        })

    })*/


    query.getChainInfo('peer1','mychannel','admin','org1').then(response_payloads=>{
        console.info(response_payloads.height)
    }).catch(err=>{
        console.info(err)
    })




    res.render('index.ejs', {
        name: 'tinyphp',item_index_active:'1'
    });


});



//组织列表
app.get("/orgs", function(req, res) {
    var orgs=bcservice.getAllOrgs()
    //res.json(orgs)

    res.render('orgs.ejs', {
        name: 'tinyphp',item_index_orgs:'1'
    });
});

//组织列表
app.get("/peers", function(req, res) {
    var orgs=bcservice.getAllOrgs()
    //res.json(orgs)

    res.render('peers.ejs', {
        name: 'tinyphp',item_index_peers:'1'
    });
});

//节点详情
app.get("/peer_detail", function(req, res) {
    res.render('peer_detail.ejs', {
        name: 'tinyphp',item_index_peers:'1'
    });
});

//区块详情
app.get("/block_detail", function(req, res) {
    res.render('block_detail.ejs', {
        name: 'tinyphp',item_index_peers:'1'
    });
});


//交易详情
app.get("/trans_detail", function(req, res) {
    res.render('trans_detail.ejs', {
        name: 'tinyphp',item_index_peers:'1'
    });
});



//channel列表
app.get("/channels", function(req, res) {

    res.render('channels.ejs', {
        name: 'tinyphp',item_index_channels:'1'
    });

    /*bcservice.getAllChannels().then(channels=>{
        res.send(channels)
    }).catch(err=>{
        res.send(err)
    })*/
});


//账本详情
app.get("/channel_detail", function(req, res) {
    res.render('channel_detail.ejs', {
        name: 'tinyphp',item_index_channels:'1'
    });
});

app.get("/orgs/peers", function(req, res) {
    res.render('orgs.ejs', {
        name: 'tinyphp',item_index_orgs:'1'
    });
});





//channel详情
app.get("/channels/:channelName", function(req, res) {
    var channelName=req.params.channelName
    bcservice.getChainInfo(channelName).then(chainInfo=>{
        res.send(chaiinInfo)
    }).catch(err=>{
        res.send(err)
    })
});

//区块列表
{'fraction_non_alphanumeric': 0.22492713869363964, 'fraction_numerical': 0.0041145208297617, 'mean_word_length': 2.99315537303217, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '990817', 'n_tokens_mistral': 2160, 'n_tokens_neox': 2147, 'n_words': 263}