Skip to content

Commit

Permalink
[CE-365] Use eggjs framework rewrite user dashboard
Browse files Browse the repository at this point in the history
Initial back service for user dashboard,
currently only can login, and see empty dashboard page.
Removed old unused code in user dashboard.

Change-Id: Ia32a1915e3d9ea2db5b8092129cf45d2e7bc114f
Signed-off-by: Haitao Yue <hightall@me.com>
  • Loading branch information
hightall committed May 21, 2018
1 parent 03fb3d0 commit b92de40
Show file tree
Hide file tree
Showing 589 changed files with 4,102 additions and 28,713 deletions.
3 changes: 1 addition & 2 deletions .makerc/user-dashboard
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# SPDX-License-Identifier: Apache-2.0
# web site url for user active link
export ROOT_URL?=
WEBROOT=$(subst $(SLASH),$(REPLACE_SLASH),$(ROOT_URL))
export USER_DASHBOARD_WEBROOT?=/
9 changes: 8 additions & 1 deletion docker-compose-check-js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ services:
check-js:
build:
context: $ROOT_PATH/src/static
dockerfile: $ROOT_PATH/src/static/Dockerfile-check-js
dockerfile: Dockerfile-check-js
volumes:
- ./src/static:/var/www
command: bash -c "ln -sf /node_modules /var/www/dashboard/node_modules && cd /var/www/dashboard && npm run lint && rm -rf node_modules"

check-user-dashboard:
build:
context: $ROOT_PATH/user-dashboard
dockerfile: Dockerfile-check-js
volumes:
- ./user-dashboard/src:/var/www
10 changes: 4 additions & 6 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,21 @@ services:
ports:
- "8081:8080"
environment:
- SV_BaseURL=http://operator-dashboard:8080/api/
- RESTful_Server=operator-dashboard:8080
- RESTful_BaseURL=/api/
- RESTFUL_SERVER=operator-dashboard:8080
- DEBUG=node:*
- DEV=$DEV
- LOG_LEVEL=$LOG_LEVEL
- ENABLE_EMAIL_ACTIVE=$ENABLE_EMAIL_ACTIVE
- SMTP_SERVER=$SMTP_SERVER
- SMTP_PORT=$SMTP_PORT
- SMTP_AUTH_USERNAME=$SMTP_AUTH_USERNAME
- SMTP_AUTH_PASSWORD=$SMTP_AUTH_PASSWORD
- FROM_EMAIL=$FROM_EMAIL
- WEBROOT=$WEBROOT
- WEBROOT=$USER_DASHBOARD_WEBROOT
- FABRIC_CFG_PATH=/etc/hyperledger/fabric
volumes:
- ./user-dashboard:/usr/app/src
- ./user-dashboard/src:/var/www
- /opt/cello/baas:/opt/data
command: bash -c "cd /usr/app/src && [ "$DEV" = True ] && npm run dev || npm start"

# cello engine service
engine:
Expand Down
1 change: 1 addition & 0 deletions docker/baseimage/Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ COPY src /app
RUN cd /app/ && \
pip install -r requirements.txt && \
rm -rf /tmp/cello
WORKDIR /app
50 changes: 14 additions & 36 deletions docker/user-dashboard/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,42 +1,20 @@
FROM node:8.9 as build_login
MAINTAINER haitao yue "hightall@me.com"
COPY . /tmp/cello
RUN cp -r /tmp/cello/user-dashboard/js /app
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
RUN cd /app && npm install --loglevel http && npm run build

FROM node:8.9 as build_home
MAINTAINER haitao yue "hightall@me.com"
COPY . /tmp/cello
RUN cp -r /tmp/cello/user-dashboard/js /app
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
RUN cd /app/home && npm install --loglevel http && npm run build

FROM node:8.9 as build_dashboard
MAINTAINER haitao yue "hightall@me.com"
COPY . /tmp/cello
RUN cp -r /tmp/cello/user-dashboard/js /app
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
RUN cd /app/dashboard && npm install --loglevel http && npm run build

# Copyright IBM Corp, All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
FROM node:8.9
MAINTAINER haitao yue "hightall@me.com"
RUN npm install -g requirejs
COPY . /tmp/cello
COPY user-dashboard/package.json /
COPY user-dashboard/yarn.lock /
RUN cd / && yarn install -g --verbose
COPY user-dashboard/src/package.json /
RUN cd / && yarn install -g
ENV PATH ${PATH}:/node_modules/.bin
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
WORKDIR /usr/app/src
COPY user-dashboard/src /var/www
RUN cd /var/www && ln -sf /node_modules . && npm run build
WORKDIR /var/www
EXPOSE 8080

ENV FABRIC_VERSION 1.0.5
RUN cd /tmp && ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}') && echo $ARCH &&wget -c https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${FABRIC_VERSION}/hyperledger-fabric-${ARCH}-${FABRIC_VERSION}.tar.gz && tar -zxvf hyperledger-fabric-${ARCH}-${FABRIC_VERSION}.tar.gz && mv bin/configtxgen /usr/local/bin/configtxgen
RUN mkdir -p /etc/hyperledger
RUN cp -r /tmp/cello/user-dashboard/fabric/fabric /etc/hyperledger/fabric
COPY user-dashboard/fabric/fabric /etc/hyperledger/fabric
ENV FABRIC_CFG_PATH /etc/hyperledger/fabric
EXPOSE 8080
CMD ["npm", "start"]

CMD ln -sf /node_modules . && npm run start
46 changes: 10 additions & 36 deletions dockerhub/latest/user-dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,20 @@
#
# SPDX-License-Identifier: Apache-2.0
#
FROM node:8.9 as build_login
MAINTAINER haitao yue "hightall@me.com"
RUN cd /tmp && git clone https://github.com/hyperledger/cello.git
RUN cp -r /tmp/cello/user-dashboard/js /app
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
RUN cd /app && npm install --loglevel http && npm run build

FROM node:8.9 as build_home
MAINTAINER haitao yue "hightall@me.com"
RUN cd /tmp && git clone https://github.com/hyperledger/cello.git
RUN cp -r /tmp/cello/user-dashboard/js /app
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
RUN cd /app/home && npm install --loglevel http && npm run build

FROM node:8.9 as build_dashboard
MAINTAINER haitao yue "hightall@me.com"
RUN cd /tmp && git clone https://github.com/hyperledger/cello.git
RUN cp -r /tmp/cello/user-dashboard/js /app
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
RUN cd /app/dashboard && npm install --loglevel http && npm run build

FROM node:8.9
MAINTAINER haitao yue "hightall@me.com"
RUN npm install -g requirejs
RUN cd /tmp && git clone https://github.com/hyperledger/cello.git
RUN cp /tmp/cello/user-dashboard && cp package.json yarn.lock / && cd / && yarn install -g --verbose
RUN cd /tmp/cello/user-dashboard/src && cp package.json yarn.lock / && cd / && yarn install -g --verbose
ENV PATH ${PATH}:/node_modules/.bin
RUN mkdir -p /usr/app
RUN cp -r /tmp/cello/user-dashboard /usr/app/src
WORKDIR /usr/app/src
RUN mkdir -p /var/www
RUN cp -r /tmp/cello/user-dashboard/src /var/www
RUN cd /var/www && ln -sf /node_modules . && npm run build
WORKDIR /var/www
EXPOSE 8080

ENV FABRIC_VERSION 1.0.5
RUN cd /tmp && ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}') && echo $ARCH &&wget -c https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${FABRIC_VERSION}/hyperledger-fabric-${ARCH}-${FABRIC_VERSION}.tar.gz && tar -zxvf hyperledger-fabric-${ARCH}-${FABRIC_VERSION}.tar.gz && mv bin/configtxgen /usr/local/bin/configtxgen
RUN mkdir -p /etc/hyperledger
RUN cp -r /tmp/cello/user-dashboard/fabric/fabric /etc/hyperledger/fabric
COPY --from=build_login /usr/app/src/src/public/js/dist /usr/app/src/src/public/js/dist
COPY --from=build_home /usr/app/src/src/public/js/dist /usr/app/src/src/public/js/dist
COPY --from=build_dashboard /usr/app/src/src/public/js/dist /usr/app/src/src/public/js/dist
COPY user-dashboard/fabric/fabric /etc/hyperledger/fabric
ENV FABRIC_CFG_PATH /etc/hyperledger/fabric
EXPOSE 8080
CMD ["npm", "start"]

CMD ln -sf /node_modules . && npm run start
2 changes: 1 addition & 1 deletion env.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ SMTP_PORT=$SMTP_PORT
SMTP_AUTH_USERNAME=$SMTP_AUTH_USERNAME
SMTP_AUTH_PASSWORD=$SMTP_AUTH_PASSWORD
FROM_EMAIL=$FROM_EMAIL
WEBROOT=$ROOT_URL
USER_DASHBOARD_WEBROOT=$USER_DASHBOARD_WEBROOT
THEME=$THEME
3 changes: 3 additions & 0 deletions src/modules/user/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
login_fields = {
"success": fields.Boolean,
"id": fields.String,
"role": fields.Integer,
"next": fields.String,
"error": fields.String
}
Expand Down Expand Up @@ -57,8 +58,10 @@ def post(self, **kwargs):
data = {
"success": True,
"id": user_id,
"role": user.user_role,
"next": url_for('bp_index.show')
}

return data, 200
else:
data = {
Expand Down
2 changes: 2 additions & 0 deletions src/modules/user/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def is_admin(self):
"""
return self.isAdmin

@property
def user_role(self):
"""
Get user role
Expand Down Expand Up @@ -92,6 +93,7 @@ def get_by_username(self, username):
self.isAdmin = db_user.isAdmin
self.balance = db_user.balance
self.dbUser = db_user
self.role = db_user.role
return self
else:
return None
Expand Down
6 changes: 0 additions & 6 deletions user-dashboard/.babelrc

This file was deleted.

17 changes: 6 additions & 11 deletions user-dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,16 @@
#
FROM node:8.9
MAINTAINER haitao yue "hightall@me.com"
RUN npm install -g requirejs
COPY package.json /
COPY src/package.json /
RUN cd / && yarn install -g
RUN yarn add nodemon -g
ENV PATH ${PATH}:/node_modules/.bin
RUN mkdir -p /usr/app/src
#COPY . /usr/app/src
WORKDIR /usr/app/src
COPY src /var/www
WORKDIR /var/www
EXPOSE 7001

ENV FABRIC_VERSION 1.0.5
RUN cd /tmp && ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}') && echo $ARCH &&wget -c https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${FABRIC_VERSION}/hyperledger-fabric-${ARCH}-${FABRIC_VERSION}.tar.gz && tar -zxvf hyperledger-fabric-${ARCH}-${FABRIC_VERSION}.tar.gz && mv bin/configtxgen /usr/local/bin/configtxgen
COPY fabric/fabric /etc/hyperledger/fabric
ENV FABRIC_CFG_PATH /etc/hyperledger/fabric
#RUN mv /usr/app/src/js /reactjs && \
# cd /reactjs && npm install && npm run build && rm -rf node_modules && \
# cd /reactjs/home && npm install && npm run build && rm -rf node_modules && \
# cd /usr/app/src && npm install && npm run build && npm cache clean --force
EXPOSE 8080

CMD ["npm", "start"]
10 changes: 10 additions & 0 deletions user-dashboard/Dockerfile-check-js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# Copyright IBM Corp, All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
FROM node:8.11
MAINTAINER haitao yue "hightall@me.com"
COPY src/package.json /
RUN cd / && npm install --only=dev
CMD bash -c "ln -sf /node_modules /var/www/node_modules && cd /var/www && npm run lint && npm run lint:ui && rm -rf node_modules"
37 changes: 4 additions & 33 deletions user-dashboard/docker-compose-files/docker-compose-build-js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,8 @@

version: '2'
services:
build-login:
build:
context: $ROOT_PATH/user-dashboard/js
image: build-login
build-dashboard-js:
image: hyperledger/cello-user-dashboard
volumes:
- $ROOT_PATH/user-dashboard/js:/app
- $ROOT_PATH/user-dashboard:/usr/app/src
command: bash -c "cd /app && mv /node_modules . && npm run build && rm -rf node_modules"

build-home:
build:
context: $ROOT_PATH/user-dashboard/js/home
image: build-home
volumes:
- $ROOT_PATH/user-dashboard/js:/app
- $ROOT_PATH/user-dashboard:/usr/app/src
command: bash -c "cd /app/home && mv /node_modules . && npm run build && rm -rf node_modules"

build-dashboard:
build:
context: $ROOT_PATH/user-dashboard/js/dashboard
image: build-dashboard
volumes:
- $ROOT_PATH/user-dashboard/js:/app
- $ROOT_PATH/user-dashboard:/usr/app/src
command: bash -c "cd /app/dashboard && mv /node_modules . && npm run build && rm -rf node_modules"

build-web-service:
build:
context: $ROOT_PATH/user-dashboard
image: cello-user-dashboard
volumes:
- $ROOT_PATH/user-dashboard:/usr/app/src
command: bash -c "cd /usr/app/src && mv /node_modules . && npm run build && rm -rf node_modules"
- $ROOT_PATH/user-dashboard/src:/var/www
command: bash -c "ln -sf /node_modules . && npm run build"
10 changes: 0 additions & 10 deletions user-dashboard/js/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions user-dashboard/js/dashboard/.editorconfig

This file was deleted.

2 changes: 0 additions & 2 deletions user-dashboard/js/dashboard/.eslintignore

This file was deleted.

53 changes: 0 additions & 53 deletions user-dashboard/js/dashboard/.eslintrc

This file was deleted.

Loading

0 comments on commit b92de40

Please sign in to comment.