Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Leveraging blockchain usage to enhance slag exchange
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HyperCOG public
Leveraging blockchain usage to enhance slag exchange
Commits
ca89295d
Commit
ca89295d
authored
3 years ago
by
Gomez Goiri, Aitor
Browse files
Options
Downloads
Patches
Plain Diff
Validating numbers received from the user
parent
efa1b351
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/README.md
+6
-2
6 additions, 2 deletions
apps/README.md
apps/cement-cli/lib.js
+11
-2
11 additions, 2 deletions
apps/cement-cli/lib.js
apps/sidenor-cli/lib.js
+7
-3
7 additions, 3 deletions
apps/sidenor-cli/lib.js
with
24 additions
and
7 deletions
apps/README.md
+
6
−
2
View file @
ca89295d
...
@@ -63,6 +63,10 @@ $ cd sidenor-cli
...
@@ -63,6 +63,10 @@ $ cd sidenor-cli
$
node index.js register
--asset-name
"Slag 1"
$
node index.js register
--asset-name
"Slag 1"
Registered asset asst_07b75e28-6685-4e18-b810-75e410dd37f2
Registered asset asst_07b75e28-6685-4e18-b810-75e410dd37f2
$
node index.js composition
? Select asset asst_a9e0bd5d-aaa2-412e-95ee-c7cff1f831dc
(
Slag 1,
type
: 10, status: slag
)
? Choose the percentage of CaO content
in
the slag
(
min: 40%, max 70%
)
: 43
$
node index.js to-cone
$
node index.js to-cone
? Select asset asst_07b75e28-6685-4e18-b810-75e410dd37f2
(
Slag 1,
type
: 10, status: slag
)
? Select asset asst_07b75e28-6685-4e18-b810-75e410dd37f2
(
Slag 1,
type
: 10, status: slag
)
Moved to cone c28bed645434c46376369bc5cc400b4c
Moved to cone c28bed645434c46376369bc5cc400b4c
...
@@ -82,9 +86,9 @@ $ node index.js to-cone
...
@@ -82,9 +86,9 @@ $ node index.js to-cone
Moved to cone 513be341a8c15c74dc06ca434b33cb36
Moved to cone 513be341a8c15c74dc06ca434b33cb36
$
node index.js to-stock
$
node index.js to-stock
? Select asset
6007feb7e2984c92d8efc1
3c
2
36
06fbb
(
undefined
,
type
: 1002, status: batched
)
? Select asset
513be341a8c15c74dc06ca434b3
3c
b
36
(
Slag batch
(
in
cone
)
,
type
: 1002, status: batched
)
? Select the stock where the cone will be merged newStock
(
New stock,
type
: 10 02, status: stocked
)
? Select the stock where the cone will be merged newStock
(
New stock,
type
: 10 02, status: stocked
)
Moved to stock
caaa642c25d96a5d8f14cf031a898fed
Moved to stock
6007feb7e2984c92d8efc13c23606fbb
$
cd
../cement-cli
$
cd
../cement-cli
$
node index.js bid
$
node index.js bid
...
...
This diff is collapsed.
Click to expand it.
apps/cement-cli/lib.js
+
11
−
2
View file @
ca89295d
...
@@ -20,7 +20,11 @@ const bidAsset = async (
...
@@ -20,7 +20,11 @@ const bidAsset = async (
type
:
"
number
"
,
type
:
"
number
"
,
name
:
"
inputQuantity
"
,
name
:
"
inputQuantity
"
,
message
:
`Choose an amount of slag to bid for (max:
${
assetToBid
.
quantity
}
${
assetToBid
.
units
}
):`
,
message
:
`Choose an amount of slag to bid for (max:
${
assetToBid
.
quantity
}
${
assetToBid
.
units
}
):`
,
default
:
Math
.
floor
(
assetToBid
.
quantity
*
0.1
)
// Default: 10%
default
:
Math
.
floor
(
assetToBid
.
quantity
*
0.1
),
// Default: 10%
validate
:
n
=>
{
if
(
n
>
0
)
return
true
return
"
Please, provide a quantity to bid for.
"
}
}
}
])
])
chosenQuantity
=
inputQuantity
chosenQuantity
=
inputQuantity
...
@@ -32,7 +36,12 @@ const bidAsset = async (
...
@@ -32,7 +36,12 @@ const bidAsset = async (
{
{
type
:
"
number
"
,
type
:
"
number
"
,
name
:
"
inputPrice
"
,
name
:
"
inputPrice
"
,
message
:
"
Provide the offered price (in €):
"
message
:
"
Provide the offered price (in €):
"
,
default
:
0
,
validate
:
n
=>
{
if
(
n
>
0
)
return
true
return
`Please, provide a price for
${
chosenQuantity
}
${
assetToBid
.
units
}
in €.`
}
}
}
])
])
chosenPrice
=
inputPrice
chosenPrice
=
inputPrice
...
...
This diff is collapsed.
Click to expand it.
apps/sidenor-cli/lib.js
+
7
−
3
View file @
ca89295d
...
@@ -15,7 +15,7 @@ const createAsset = async (apiClient, { assetName }) => {
...
@@ -15,7 +15,7 @@ const createAsset = async (apiClient, { assetName }) => {
id
:
`asst_
${
faker
.
datatype
.
uuid
()}
`
,
id
:
`asst_
${
faker
.
datatype
.
uuid
()}
`
,
type
:
TYPES
.
RESIDUO_PROCESOS_TERMICOS
,
type
:
TYPES
.
RESIDUO_PROCESOS_TERMICOS
,
units
:
"
kg
"
,
units
:
"
kg
"
,
quantity
:
faker
.
datatype
.
number
({
max
:
5000
}),
quantity
:
faker
.
datatype
.
number
({
min
:
0
,
max
:
5000
}),
fields
:
{
fields
:
{
description
:
"
Escoria
"
,
description
:
"
Escoria
"
,
name
:
assetName
,
name
:
assetName
,
...
@@ -42,11 +42,14 @@ const editComposition = async (
...
@@ -42,11 +42,14 @@ const editComposition = async (
const
{
inputCaoPercentage
}
=
await
inquirer
.
prompt
([
const
{
inputCaoPercentage
}
=
await
inquirer
.
prompt
([
{
{
type
:
"
number
"
,
type
:
"
number
"
,
name
:
"
input
Quantity
"
,
name
:
"
input
CaoPercentage
"
,
message
:
message
:
"
Choose the percentage of CaO content in the slag (min: 40%, max 70%):
"
,
"
Choose the percentage of CaO content in the slag (min: 40%, max 70%):
"
,
default
:
faker
.
datatype
.
number
({
min
:
40
,
max
:
70
}),
default
:
faker
.
datatype
.
number
({
min
:
40
,
max
:
70
}),
validate
:
n
=>
n
>=
40
&&
n
<=
70
validate
:
n
=>
{
if
(
n
>=
40
&&
n
<=
70
)
return
true
return
"
The CaO percentage must be between 40 and 70
"
}
}
}
])
])
chosenCaoPercentage
=
inputCaoPercentage
chosenCaoPercentage
=
inputCaoPercentage
...
@@ -101,6 +104,7 @@ const sendToCone = async (apiClient, { assetId: paramAssetId }) => {
...
@@ -101,6 +104,7 @@ const sendToCone = async (apiClient, { assetId: paramAssetId }) => {
units
:
"
kg
"
,
units
:
"
kg
"
,
quantity
:
newConeQuantity
,
quantity
:
newConeQuantity
,
fields
:
{
fields
:
{
name
:
"
Slag batch (in cone)
"
,
status
:
STATUSES
.
SLAG_BATCH
status
:
STATUSES
.
SLAG_BATCH
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment