Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Close #66] Add netlify.toml config file #67

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,5 @@ screenshot
.temp

src/dashboard/dist
src/dashboard/functions
src/dashboard/lambda/mock/index.js
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ start-dashboard-dev:
make -C src/dashboard start-no-mock; \
fi

generate-mock:
make -C src/dashboard generate-mock

stop: ##@Service Stop service
if [ "$(DEPLOY_METHOD)" = "docker-compose" ]; then \
make stop-docker-compose; \
Expand Down
18 changes: 18 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[build]
functions = "src/dashboard/functions"
command = "cd src/dashboard && npm i && npm run functions:build && npm run build"
publish = "src/dashboard/dist"

[[redirects]]
from = "/api/*"
to = "/.netlify/functions/api/:splat"
status = 200
force = true
[redirects.headers]
X-From = "Netlify"
Access-Control-Allow-Origin = "*"

[[redirects]]
from = "/*"
to = "/index.html"
status = 200
5 changes: 4 additions & 1 deletion src/dashboard/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ start:

start-no-mock:
echo $(PROXY)
PROXY=$(PROXY) npm run start:no-mock
PROXY=$(PROXY) npm run start:no-mock

generate-mock:
npm run generateMock
319 changes: 0 additions & 319 deletions src/dashboard/functions/api.js

This file was deleted.

26 changes: 0 additions & 26 deletions src/dashboard/mock/_utils.js

This file was deleted.

83 changes: 52 additions & 31 deletions src/dashboard/mock/agent.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
import Mock from 'mockjs';
import faker from 'faker';
import { paginator } from './_utils';
import paginator from 'cello-paginator';

const agents = Mock.mock({
'data|11': [{
id () {
return Mock.Random.guid()
'data|11': [
{
id() {
return Mock.Random.guid();
},
name() {
return faker.company.companyName();
},
created_at: '@datetime',
ip() {
return Mock.Random.ip();
},
capacity() {
return Math.ceil(Math.random() * 10);
},
node_capacity() {
return Math.ceil(Math.random() * 10);
},
status() {
return Mock.Random.pick(['inactive', 'active']);
},
log_level() {
return Mock.Random.pick(['info', 'debug']);
},
type() {
return Mock.Random.pick(['docker', 'kubernetes']);
},
schedulable() {
return Mock.Random.pick([true, false]);
},
organization_id() {
return Mock.Random.guid();
},
image() {
return Mock.Random.pick(['financial', 'sales', 'customer', 'marketing', 'network']);
},
config_file: 'https://github.com/hyperledger/cello/archive/master.zip',
},
name () {
return faker.company.companyName();
},
created_at: '@datetime',
ip () { return Mock.Random.ip() },
capacity () { return Math.ceil(Math.random()*10) },
node_capacity () { return Math.ceil(Math.random()*10) },
status () { return Mock.Random.pick(['inactive', 'active']) },
log_level () { return Mock.Random.pick(['info', 'debug']) },
type () { return Mock.Random.pick(['docker', 'kubernetes']) },
schedulable () { return Mock.Random.pick([true, false]) },
organization_id () { return Mock.Random.guid() },
image () { return Mock.Random.pick(['financial', 'sales', 'customer', 'marketing', 'network']) },
config_file: 'https://github.com/hyperledger/cello/archive/master.zip',
}],
],
});

function getAgents(req, res) {
Expand All @@ -39,28 +59,28 @@ function createAgent(req, res) {
if (!message.capacity) {
res.send({
code: 20001,
detail: 'capacity is required'
detail: 'capacity is required',
});
}

if (!message.node_capacity) {
res.send({
code: 20001,
detail: 'node_capacity is required'
detail: 'node_capacity is required',
});
}

if (!message.type) {
res.send({
code: 20001,
detail: 'type is required'
detail: 'type is required',
});
}

if (!message.ip) {
res.send({
code: 20001,
detail: 'ip is required'
detail: 'ip is required',
});
}

Expand All @@ -79,9 +99,10 @@ function createAgent(req, res) {
schedulable: message.schedulable === 'true',
organization_id: '',
image: message.image,
config_file: req.files.length > 0 ? 'https://github.com/hyperledger/cello/archive/master.zip' : '',
config_file:
req.files.length > 0 ? 'https://github.com/hyperledger/cello/archive/master.zip' : '',
});
res.send({id});
res.send({ id });
}

function getOneAgent(req, res) {
Expand All @@ -92,8 +113,8 @@ function getOneAgent(req, res) {
} else {
res.send({
code: 20005,
detail: 'The agent not found.'
})
detail: 'The agent not found.',
});
}
}

Expand Down Expand Up @@ -151,14 +172,14 @@ function applyAgent(req, res) {
if (!message.capacity) {
res.send({
code: 20001,
detail: 'capacity is required'
detail: 'capacity is required',
});
}

if (!message.type) {
res.send({
code: 20001,
detail: 'type is required'
detail: 'type is required',
});
}

Expand All @@ -168,7 +189,7 @@ function applyAgent(req, res) {
created_at: new Date(),
ip: Mock.Random.ip(),
capacity: message.capacity,
node_capacity: Math.ceil(Math.random()*10),
node_capacity: Math.ceil(Math.random() * 10),
status: Mock.Random.pick(['inactive', 'active']),
log_level: Mock.Random.pick(['info', 'debug']),
type: message.type,
Expand All @@ -178,7 +199,7 @@ function applyAgent(req, res) {
config_file: 'https://github.com/hyperledger/cello/archive/master.zip',
});

res.send({id: Mock.Random.guid()});
res.send({ id: Mock.Random.guid() });
}

function deleteAgent(req, res) {
Expand Down
74 changes: 47 additions & 27 deletions src/dashboard/mock/node.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,51 @@
import Mock from 'mockjs';
import faker from 'faker';
import { paginator } from './_utils';
import paginator from 'cello-paginator';

const nodes = Mock.mock({
'data|11': [{
id () {
return Mock.Random.guid()
'data|11': [
{
id() {
return Mock.Random.guid();
},
name() {
return faker.company.companyName();
},
created_at: '@datetime',
type() {
return Mock.Random.pick(['ca', 'orderer', 'peer']);
},
network_type() {
return Mock.Random.pick(['fabric']);
},
network_version() {
return Mock.Random.pick(['1.4.2', '1.5']);
},
status() {
return Mock.Random.pick([
'deploying',
'running',
'stopped',
'deleting',
'error',
'deleted',
]);
},
agent_id() {
return Mock.Random.guid();
},
network_id() {
return Mock.Random.guid();
},
ca() {
return {
admin_name: Mock.mock('@name'),
admin_password: Mock.mock(/[a-z0-9]{6}/),
hosts: [faker.company.companyName(), faker.company.companyName()],
};
},
},
name () {
return faker.company.companyName();
},
created_at: '@datetime',
type () { return Mock.Random.pick(['ca', 'orderer', 'peer']) },
network_type () { return Mock.Random.pick(['fabric']) },
network_version () { return Mock.Random.pick(['1.4.2', '1.5']) },
status () { return Mock.Random.pick(['deploying', 'running', 'stopped', 'deleting', 'error', 'deleted']) },
agent_id () { return Mock.Random.guid() },
network_id () { return Mock.Random.guid() },
ca () {return {
admin_name: Mock.mock('@name'),
admin_password: Mock.mock(/[a-z0-9]{6}/),
hosts: [
faker.company.companyName(),
faker.company.companyName(),
],
}},
}],
],
});

function getNodes(req, res) {
Expand All @@ -44,25 +64,25 @@ function registerUserToNode(req, res) {
if (!message.name) {
res.send({
code: 20001,
detail: 'name is required'
detail: 'name is required',
});
}

if (!message.user_type) {
res.send({
code: 20001,
detail: 'user_type is required'
detail: 'user_type is required',
});
}

if (!message.secret) {
res.send({
code: 20001,
detail: 'secret is required'
detail: 'secret is required',
});
}

res.send({id: Mock.Random.guid()});
res.send({ id: Mock.Random.guid() });
}

function deleteNode(req, res) {
Expand Down
20 changes: 11 additions & 9 deletions src/dashboard/mock/organization.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import Mock from 'mockjs';
import faker from 'faker';
import { paginator } from './_utils';
import paginator from 'cello-paginator';

const organizations = Mock.mock({
'data|11': [{
id () {
return Mock.Random.guid()
'data|11': [
{
id() {
return Mock.Random.guid();
},
name() {
return faker.company.companyName();
},
created_at: '@datetime',
},
name () {
return faker.company.companyName();
},
created_at: '@datetime',
}],
],
});

function getOrgs(req, res) {
Expand Down
Loading