Skip to content

Commit

Permalink
Connected the install chaincode to the backend
Browse files Browse the repository at this point in the history
Signed-off-by: xiaor2 <xiaor2@illinois.edu>
  • Loading branch information
xiaor2 committed Apr 27, 2024
1 parent a0b64f1 commit d313b5c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/dashboard/src/pages/ChainCode/ChainCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class ChainCode extends PureComponent {
if (visible) {
this.fetchNodes();
this.setState({
chainCodeName: record.packageID,
chainCodeName: record.package_id,
});
}
this.setState({
Expand All @@ -248,6 +248,23 @@ class ChainCode extends PureComponent {
});
};

handleInstall = (values, callback) => {
const { dispatch } = this.props;
const formData = new FormData();

Object.keys(values)
.filter(key => !(key === 'description' && !values[key])) // filter out empty description
.forEach(key => {
formData.append(key, values[key]);
});

dispatch({
type: 'chainCode/installChainCode',
payload: formData,
callback,
});
};

handleUpload = (values, callback) => {
const { dispatch } = this.props;
const formData = new FormData();
Expand Down Expand Up @@ -308,6 +325,7 @@ class ChainCode extends PureComponent {
installModalVisible,
handleInstallModalVisible: this.handleInstallModalVisible,
fetchChainCodes: this.fetchChainCodes,
handleInstall: this.handleInstall,
installing,
chainCodeName,
nodes,
Expand Down
23 changes: 22 additions & 1 deletion src/dashboard/src/pages/ChainCode/forms/InstallForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import { injectIntl, useIntl } from 'umi';
import { Modal, message, Select, Form, Tag } from 'antd';
import { Modal, message, Select, Form, Tag, Input } from 'antd';
import { listNode } from '@/services/node';
import styles from '../styles.less';

Expand All @@ -17,6 +17,7 @@ const InstallForm = props => {
installing,
fetchChainCodes,
handleInstall,
chainCodeName,
} = props;

useEffect(() => {
Expand Down Expand Up @@ -101,6 +102,26 @@ const InstallForm = props => {
onCancel={() => handleInstallModalVisible(false)}
>
<Form onFinish={onFinish} form={form} preserve={false}>
<FormItem
{...formItemLayout}
label={intl.formatMessage({
id: 'app.chainCode.form.install.chainCodeName',
defaultMessage: 'Chaincode name:',
})}
name="id"
initialValue={chainCodeName}
rules={[
{
required: true,
message: intl.formatMessage({
id: 'app.chainCode.form.install.chainCodeName',
defaultMessage: 'Chaincode name:',
}),
},
]}
>
<Input disabled />
</FormItem>
<FormItem
{...formItemLayout}
label={intl.formatMessage({
Expand Down
7 changes: 7 additions & 0 deletions src/dashboard/src/services/chaincode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ export async function uploadChainCode(params) {
});
}

export async function installChainCode(params) {
return request('/api/v1/chaincodes/install', {
method: 'POST',
body: params,
});
}

// export async function listApprovedChaincode(params) {
// // const { channelName, orgName } = params;
// // return request(`/api/v1/approvedChaincodeDefinitions/${channel_name}/${org_name}`);
Expand Down

0 comments on commit d313b5c

Please sign in to comment.