Skip to content

Commit

Permalink
[CE-30] init expressJS and add index page
Browse files Browse the repository at this point in the history
Change-Id: I35d105eaad29efd10bb90fe5fc684f998eb0d09f
Signed-off-by: lixucheng <[email protected]>
  • Loading branch information
xuchengli committed May 2, 2017
1 parent 56e13c4 commit abf6fe8
Show file tree
Hide file tree
Showing 79 changed files with 4,999 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pip-selfcheck.json

# All .idea stuff:
.idea/*
.idea/

# User-specific stuff:
.idea/workspace.xml
Expand Down Expand Up @@ -215,3 +216,4 @@ node_modules
jspm_packages
.npm
.eslintcache
!/**/lib
34 changes: 34 additions & 0 deletions user-dashboard/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Created by lixuc on 2017/5/2.
*/
var express = require("express");
var path = require("path");
var cookieParser = require("cookie-parser");
var bodyParser = require("body-parser");
var session = require("express-session");

var app = express();

app.set("views", path.join(__dirname, "views"));
app.set("view engine", "pug");

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(session({
secret: "blockchain dashboard",
resave: true,
saveUninitialized: false,
unset: "destroy",
cookie: { maxAge: 24*60*60*1000 }
}));
app.use(express.static(path.join(__dirname, "public")));
app.use("/bc/api", require("./routes/api"));
app.use("/bc", require("./routes/index"));
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.send(err.message);
});
app.listen(8080, function() {
console.log("Server started>>>");
});
31 changes: 31 additions & 0 deletions user-dashboard/modules/configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Created by lixuc on 2017/5/2.
*/
module.exports = {
cookieName: "BlockChainAccount",
SV_BaseURL: process.env.SV_BaseURL || "https://ptopenlab.com/cloudlab/api/",
RESTful_Server: process.env.RESTful_Server || "9.186.91.4:8108",
RESTful_BaseURL: "/restful/api/v2/",
PoolManager_Server: process.env.PoolManager_Server || "9.186.91.26",
PoolManager_BaseURL: "/v2/",
Log_Server: process.env.Log_Server || "9.186.91.29:8080",
Log_BaseURL: "/v1/log",
mongodb: {
ip: "127.0.0.1",
port: 27017,
name: "bc_dashboard",
auth: true,
username: "admin",
password: "passw0rd"
},
topology: {
vp0: [200, 130],
vp1: [300, -130],
vp2: [-300, -130],
vp3: [-200, 130],
vp4: [350, 30],
vp5: [-350, 30],
vp6: [50, -250],
vp7: [-50, -250]
}
};
93 changes: 93 additions & 0 deletions user-dashboard/modules/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Created by lixuc on 2017/5/2.
*/
var rp = require("request-promise");
var uuid = require("node-uuid");
var config = require("./configuration");

function user() {}
user.prototype = {
BaseURL: config.SV_BaseURL,
account: function(apikey) {
return new Promise(function(resolve, reject) {
rp({
uri: this.BaseURL + "user/account/apikey/" + apikey,
json: true
}).then(function(response) {
resolve({
success: true,
username: response.username,
apikey: response.apikey,
isActivated: response.isActivated,
balance: response.balance
});
}).catch(function(err) {
reject({
success: false,
message: err.message || "System maintenance, please try again later!"
});
});
}.bind(this));
},
validate: function(name, password) {
return new Promise(function(resolve, reject) {
rp({
method: "POST",
uri: this.BaseURL + "user/account/validate",
body: {
username: name,
passwd: password
},
json: true
}).then(function(response) {
if (response.success) {
resolve({
success: true,
apikey: response.description
});
} else {
var e = new Error(response.description);
e.status = 403;
throw e;
}
}).catch(function(err) {
reject({
success: false,
message: (err.status == 403 && err.message) || "System maintenance, please try again later!"
});
});
}.bind(this));
},
register: function(name, password) {
var apikey = uuid.v1();
return new Promise(function(resolve, reject) {
rp({
method: "POST",
uri: this.BaseURL + "user/account",
body: {
username: name,
passwd: password,
apikey: apikey
},
json: true
}).then(function(response) {
if (response.success) {
resolve({
success: true,
apikey: apikey
});
} else {
var e = new Error(response.description);
e.status = 409;
throw e;
}
}).catch(function(err) {
reject({
success: false,
message: (err.status == 409 && err.message) || "System maintenance, please try again later!"
});
});
}.bind(this));
}
};
module.exports = user;
22 changes: 22 additions & 0 deletions user-dashboard/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "bc-dashboard",
"version": "1.0.0",
"description": "It is the nodeJS version of blockchain dashboard",
"main": "app.js",
"dependencies": {
"cookie-parser": "^1.4.3",
"body-parser": "^1.17.1",
"express": "^4.15.2",
"express-session": "^1.15.2",
"pug": "^2.0.0-rc.1",
"request-promise": "^4.2.0",
"request": "^2.81.0",
"node-uuid": "^1.4.8"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "li xu cheng",
"license": "ISC"
}
2 changes: 2 additions & 0 deletions user-dashboard/public/css/addon/form-file.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions user-dashboard/public/css/addon/notify.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions user-dashboard/public/css/addon/sticky.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions user-dashboard/public/css/addon/tooltip.almost-flat.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

141 changes: 141 additions & 0 deletions user-dashboard/public/css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
@CHARSET "UTF-8";
#banner{
width:100%;
height:100%;
background-image:url(/images/banner.jpg);
background-position:center center;
background-repeat:no-repeat;
-webkit-background-size:cover;
background-size:cover;
background-color:#616161;
}
#sign{text-align:center;}
#sign a{
color:#FFFFFF;
font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;
font-size:16px;border:1px solid #FFFFFF;padding:7px 13px 7px 12px;text-decoration:none;
-webkit-transition:all 0.3s;-moz-transition:all 0.3s;-o-transition:all 0.3s;
}
#sign a:hover{background:#FB966E;color:#fff;}
#sign label{
font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;
font-size:12px;
color:#FFFFFF;
margin-right:12px;
line-height:35px;
}
.star-gray{color:#cccccc;}
.star-orange{color:#FB966E;}
.try-box{padding-top:190px;text-align:center;margin-right:auto;margin-left:auto;}
.sv-title{margin-bottom:15px;}
.sv-title p{
font-family:"HelvRegularIBM","Helvetica Neue",OpenSans,Arial,sans-serif;
color:#FFFFFF;
font-size:16px;
margin:0 auto;
letter-spacing:3px;
}
.home-title{
font-family:"Lucida Bright",Georgia,serif;
line-height:60px;
font-size:60px;
color:#FFFFFF;
letter-spacing:1px;
text-shadow:0px 0px 7px rgba(230,178,178,0.50);
text-transform:uppercase;
}
.home-title span{
font-family:"HelvRegularIBM","Helvetica Neue",Arial,sans-serif;
text-shadow:none;
letter-spacing:0px;
}
#tryBtn{
background:rgba(0,0,0,0.53);
border:2px solid #FFFFFF;
font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;
font-size:24px;
color:#FFFFFF;
letter-spacing:2.79px;
text-transform:uppercase;
padding:17px 39px 17px 53px;
-webkit-transition:all 0.3s;-moz-transition:all 0.3s;-o-transition:all 0.3s;
}
#tryBtn:hover{background:#FB966E;color:#fff;}
.intro-title{margin-top:10px;}
.intro-title h1{
font-family:"Lucida Bright",Georgia,serif;
font-size:33px;
color:#000000;
letter-spacing:-0.83px;
text-shadow:0px 0px 7px rgba(230,178,178,0.50);
text-transform:uppercase;
}
.intro-title span{font-size: 41px;}
.intro-title h2{
font-family:"Lucida Bright",Georgia,serif;
font-size:18px;
color:#000000;
letter-spacing:-0.37px;
border-top:1px solid #000000;
width:70%;
margin:0 auto;
padding-top:14px;
}
.attr{
font-family:"Lucida Bright",Georgia,serif;
color:#000000;
margin-right:10%;
margin-left:10%;
}
.attr img{
outline:1px solid #fff;
outline-offset:-10px;
width:100%;
max-width:300px;
}
.attr-title{min-height:30px;}
.attr-border{
border-bottom:1px solid #000000;
width:60%;
margin:0 auto;
padding-top:10px;
}
.attr h3{
font-family:"Lucida Bright",Georgia,serif;
color:#000000;
letter-spacing:-0.65px;
text-shadow:0px 0px 7px rgba(230,178,178,0.50);
margin:10px auto 0;
font-size:25px;
line-height:28px;
width:100%;
}
.attr p{
font-size:16px;
letter-spacing:-0.37px;
margin:20px auto;
width:100%;
}
footer{
margin-top:100px;
background-color:#000;
font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;
font-size:16px;
color:#D8D8D8;
line-height:45px;
text-align:center;
}
#urls{background-color:#FB966E;color:#fff;line-height:100px;font-size:16px;}
#urls li{margin-right:26px;}
#urls a{color:#fff;}
#urls img{height:30px;}
.sign-pop{padding:30px;text-align:left;color:#757575;}
.sign-pop legend{
font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;
font-size:30px;
letter-spacing:0.56px;
line-height:30px;
}
.sign-pop span{font-size:14px;color:#A1A1A1;letter-spacing:0.3px;}
#login-btn,#register-btn{background-color:#FB966E;}
#login-btn:disabled,#register-btn:disabled{background-color:#fafafa;}
1 change: 1 addition & 0 deletions user-dashboard/public/css/ol.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions user-dashboard/public/css/uikit.almost-flat.min.css

Large diffs are not rendered by default.

Binary file added user-dashboard/public/fonts/FontAwesome.otf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions user-dashboard/public/images/add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added user-dashboard/public/images/banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added user-dashboard/public/images/blue-points.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added user-dashboard/public/images/buy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added user-dashboard/public/images/chains.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added user-dashboard/public/images/dashboard-bgi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added user-dashboard/public/images/devops.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added user-dashboard/public/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit abf6fe8

Please sign in to comment.