|  | 
|  | 1 | + | 
|  | 2 | +<!-- Copyright IBM Corp, All Rights Reserved. | 
|  | 3 | +
 | 
|  | 4 | +SPDX-License-Identifier: Apache-2.0 | 
|  | 5 | +--> | 
|  | 6 | +<template> | 
|  | 7 | +  <Modal | 
|  | 8 | +    v-model="visible" | 
|  | 9 | +    title="Create a cluster" | 
|  | 10 | +    ok-text="OK" | 
|  | 11 | +    cancel-text="Cancel"> | 
|  | 12 | +    <Form ref="clusterForm" :model="formItem" :rules="ruleValidate" :label-width="80"> | 
|  | 13 | +      <FormItem label="Name" prop="name" :label-width="100"> | 
|  | 14 | +        <Input type="text" v-model="formItem.name" placeholder="Input chain name" /> | 
|  | 15 | +      </FormItem> | 
|  | 16 | +      <FormItem label="Host" prop="host_id" :label-width="100"> | 
|  | 17 | +        <Select v-model="formItem.host_id" placeholder="Select a host"> | 
|  | 18 | +          <Option v-for="host in hosts" :value="host.id">{{host.name}}</Option> | 
|  | 19 | +        </Select> | 
|  | 20 | +      </FormItem> | 
|  | 21 | +      <FormItem label="Network Type" :label-width="100"> | 
|  | 22 | +        <Select v-model="formItem.network_type"> | 
|  | 23 | +          <Option value="fabric-1.0">fabric-1.0</Option> | 
|  | 24 | +        </Select> | 
|  | 25 | +      </FormItem> | 
|  | 26 | +      <FormItem label="Chain Size" :label-width="100"> | 
|  | 27 | +        <Select v-model="formItem.size"> | 
|  | 28 | +          <Option :value="4">4</Option> | 
|  | 29 | +        </Select> | 
|  | 30 | +      </FormItem> | 
|  | 31 | +      <FormItem label="Consensus Plugin" :label-width="100"> | 
|  | 32 | +        <Select v-model="formItem.consensus_plugin" placeholder="Select consensus plugin"> | 
|  | 33 | +          <Option value="solo">SOLO</Option> | 
|  | 34 | +          <Option value="kafka">KAFKA</Option> | 
|  | 35 | +        </Select> | 
|  | 36 | +      </FormItem> | 
|  | 37 | +      <FormItem v-if="formItem.consensus_plugin === 'kafka'" label="Consensus Mode" :label-width="100"> | 
|  | 38 | +        <Select v-model="formItem.consensus_mode" placeholder="Select consensus mode"> | 
|  | 39 | +          <Option value="batch">BATCH</Option> | 
|  | 40 | +        </Select> | 
|  | 41 | +      </FormItem> | 
|  | 42 | +    </Form> | 
|  | 43 | +    <div slot="footer"> | 
|  | 44 | +      <Button type="text" @click="onCancel">Cancel</Button> | 
|  | 45 | +      <Button type="primary" :loading="submitting" @click="submitForm">Ok</Button> | 
|  | 46 | +    </div> | 
|  | 47 | +    </Modal> | 
|  | 48 | +</template> | 
|  | 49 | + | 
|  | 50 | +<script> | 
|  | 51 | +  export default { | 
|  | 52 | +    props: ['visible', 'onCancel', 'submitting', 'formItem', 'onOk', 'hosts', 'onSubmit'], | 
|  | 53 | +    data () { | 
|  | 54 | +      return { | 
|  | 55 | +        ruleValidate: { | 
|  | 56 | +          name: [ | 
|  | 57 | +            { required: true, message: 'Please input Cluster name', trigger: 'blur' } | 
|  | 58 | +          ], | 
|  | 59 | +          host_id: [ | 
|  | 60 | +            { required: true, message: 'Please Select a host', trigger: 'blur' } | 
|  | 61 | +          ] | 
|  | 62 | +        } | 
|  | 63 | +      } | 
|  | 64 | +    }, | 
|  | 65 | +    methods: { | 
|  | 66 | +      submitForm () { | 
|  | 67 | +        this.$refs['clusterForm'].validate((valid) => { | 
|  | 68 | +          if (valid) { | 
|  | 69 | +            this.onSubmit() | 
|  | 70 | +          } | 
|  | 71 | +        }) | 
|  | 72 | +      } | 
|  | 73 | +    } | 
|  | 74 | +  } | 
|  | 75 | +</script> | 
|  | 76 | + | 
|  | 77 | +<style> | 
|  | 78 | +</style> | 
0 commit comments