Chapter 6: Building the Buyer Services and User Experience

Introduction

In this chapter, we will create the Buyer Company view and add server-side services to support it. This runs on HyperLedger Fabric Version 1.0. The code that we will write is managed in this chapter and all the subsequent chapters in the following folder structure:

Chapter 06
↳ controller
    ↳restapi
    router.js
        ↳features
        ↳composer
            autoLoad.js
            hlcAdmin.js
            hlcClient.js
            queryBlockChain.js
            Z2B_Services.js
            Z2B_Utilities.js
        ↳ text
            multi-lingual.js
            resources.js
↳ HTML
    index.html
    admin.html
    buyer.html
    ceateConnectionProfile.html
    createMember.html
    createOrder.html
    deleteConnectionProfile.html
    getMemberSecret.html
    removeMember.html
    ↳CSS
    pageStyles.css
    ↳js
    z2b-admin.js
    z2b-buyer.js
    z2b-events.js
    z2b-initiate.js
    z2b-utilities.js
↳ network
permissions.acl
queries.qry
    ↳lib
    sample.js
    ↳models
    base.cto
    events.cto
    sample.cto

Four new files are introduced in this chapter and one existing file is updated:

Web Server Code Unique to this Chapter

  • hlcClient.js This contains all code to support the buyer interface on the server side

Defining the business network

  • network/permissions.acl This file is *updated* to allow the buyer to access Orders and to execute selected transactions. It determines precisely what transactions a member can execute and what assets a member can see. The basic rule is “If authority is not specifically granted in this file, then access is denied.”

Web Browser Code Unique to this Chapter

  • z2b-buyer.js This file contains all of the browser functional code to support the buyer user experience
  • buyer.html This contains the HTML framework for the buyer experience. Content for this framework is generated by the functions in the z2b-buyer.js file Text on this page is determined by the selected language (default is US English)
  • createOrder.html Contains the HTML framework to manage buyer order creation. Content for this framework is generated by the functions in the z2b-buyer.js file Text on this page is determined by the selected language