Skip to content
Snippets Groups Projects
Commit efa1b351 authored by Gomez Goiri, Aitor's avatar Gomez Goiri, Aitor
Browse files

Defining CaO value in composition command

parent c75f5c15
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,7 @@ program ...@@ -27,6 +27,7 @@ program
"--asset-id [value]", "--asset-id [value]",
"Identifier of the slag whose composition has been measured" "Identifier of the slag whose composition has been measured"
) )
.option("--cao-percentage [value]", "CaO percentage in the slag")
.action(loginAndCallAfterwards(editComposition)) .action(loginAndCallAfterwards(editComposition))
program program
......
...@@ -30,10 +30,28 @@ const createAsset = async (apiClient, { assetName }) => { ...@@ -30,10 +30,28 @@ const createAsset = async (apiClient, { assetName }) => {
return newAsset.id return newAsset.id
} }
const editComposition = async (apiClient, { assetId: paramAssetId }) => { const editComposition = async (
apiClient,
{ assetId: paramAssetId, caoPercentage }
) => {
const assetId = const assetId =
paramAssetId || (await promptAssetSelection(await apiClient.richQuery())) paramAssetId || (await promptAssetSelection(await apiClient.richQuery()))
let chosenCaoPercentage = caoPercentage
if (!caoPercentage) {
const { inputCaoPercentage } = await inquirer.prompt([
{
type: "number",
name: "inputQuantity",
message:
"Choose the percentage of CaO content in the slag (min: 40%, max 70%):",
default: faker.datatype.number({ min: 40, max: 70 }),
validate: n => n >= 40 && n <= 70
}
])
chosenCaoPercentage = inputCaoPercentage
}
const previousVersion = await apiClient.getAsset(assetId) const previousVersion = await apiClient.getAsset(assetId)
await apiClient.modifyAsset({ await apiClient.modifyAsset({
...@@ -41,7 +59,7 @@ const editComposition = async (apiClient, { assetId: paramAssetId }) => { ...@@ -41,7 +59,7 @@ const editComposition = async (apiClient, { assetId: paramAssetId }) => {
id: assetId, id: assetId,
fields: { fields: {
...previousVersion.fields, ...previousVersion.fields,
composition: "comp1" composition: { cao: chosenCaoPercentage }
} }
}) })
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment