WizardSummary.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. Copyright (C) 2017 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import React, { Component, PropTypes } from 'react';
  15. import withStyles from 'isomorphic-style-loader/lib/withStyles';
  16. import s from './WizardSummary.scss';
  17. import moment from 'moment';
  18. import TextTruncate from 'react-text-truncate';
  19. import Helper from '../Helper';
  20. const title = 'Summary';
  21. class WizardSummary extends Component {
  22. static contextTypes = {
  23. onSetTitle: PropTypes.func.isRequired,
  24. };
  25. static propTypes = {
  26. setWizardState: PropTypes.func,
  27. summary: PropTypes.object,
  28. }
  29. constructor(props) {
  30. super(props)
  31. this.dateTypes = ["One time"]
  32. this.state = {
  33. valid: true,
  34. currentStep: "WizardSummary"
  35. }
  36. }
  37. componentWillMount() {
  38. this.props.setWizardState(this.state)
  39. this.context.onSetTitle(title);
  40. }
  41. renderOptionsFields() {
  42. let fields = []
  43. for (let i in this.props.summary.destination_environment) {
  44. fields.push({
  45. label: Helper.convertCloudFieldLabel(i),
  46. value: this.props.summary.destination_environment[i]
  47. })
  48. }
  49. return fields.map(field => (
  50. <div className={s.row} key={"destination_environment_" + field.label}>
  51. <span>{field.label}</span>
  52. <span>{field.value}</span>
  53. </div>
  54. ))
  55. }
  56. render() {
  57. let schedules = this.props.summary.schedules.map((item, index) => (
  58. <div className="item" key={"schedule_" + index}>
  59. <span className="cell">
  60. {this.dateTypes.indexOf(item.type) == -1 ? item.type : moment(item.date).format("MMM Do YYYY")}
  61. </span>
  62. <span className="cell">
  63. {item.type != "Execute Now" &&
  64. (item.hour.label + ":" + item.minute.label + " " + item.tod + " " + item.timezone)}
  65. </span>
  66. </div>
  67. ), this)
  68. let instances = this.props.summary.selectedInstances.map((vm, index) => (
  69. <div className="item" key={"VM_" + index}>
  70. <span className="cell">
  71. <TextTruncate line={1} text={vm.name} truncateText="..." />
  72. </span>
  73. <span className="cell">
  74. {vm.num_cpu} vCPU | {vm.memory_mb} MB RAM {vm.flavor_name && ("| " + vm.flavor_name)}
  75. </span>
  76. </div>
  77. ))
  78. let networks = this.props.summary.networks.map((network, index) => {
  79. if (network.selected || true) {
  80. return (
  81. <div className="item" key={"Network_" + index}>
  82. <span className="cell">
  83. <TextTruncate line={1} text={network.network_name} truncateText="..." />
  84. </span>
  85. <span className="cell">
  86. <div className="arrow"></div>
  87. </span>
  88. <span className="cell">
  89. <TextTruncate
  90. line={1}
  91. text={network.migrateNetwork ? network.migrateNetwork : "Create new"}
  92. truncateText="..."
  93. />
  94. </span>
  95. </div>
  96. )
  97. } else {
  98. return null
  99. }
  100. })
  101. return (
  102. <div className={s.root}>
  103. <div className={s.container}>
  104. <div className={s.columnLeft}>
  105. <div className={s.group}>
  106. <h3>
  107. Overview
  108. </h3>
  109. <div className={s.values}>
  110. <div className={s.row}>
  111. <span>Source: <br /> </span>
  112. <span>
  113. <TextTruncate line={1} text={this.props.summary.sourceCloud.credential.name} truncateText="..." />
  114. <span className={s.cloudBox}>{Helper.convertCloudLabel(this.props.summary.sourceCloud.name)}</span>
  115. </span>
  116. </div>
  117. <div className={s.row}>
  118. <span>Target:</span>
  119. <span>
  120. <TextTruncate line={1} text={this.props.summary.targetCloud.credential.name} truncateText="..." />
  121. <span className={s.cloudBox}>{Helper.convertCloudLabel(this.props.summary.targetCloud.name)}</span>
  122. </span>
  123. </div>
  124. </div>
  125. </div>
  126. <div className={s.group}>
  127. <h3>
  128. Options
  129. </h3>
  130. <div className={s.values}>
  131. <div className={s.row + " " + s.migrationType + " " + this.props.summary.migrationType}>
  132. <span>Type:</span>
  133. <span>
  134. {this.props.summary.migrationType == "replica" ? "Coriolis Replica" : "Coriolis Migration"}
  135. </span>
  136. </div>
  137. {this.renderOptionsFields()}
  138. </div>
  139. </div>
  140. <div className={s.group}>
  141. <h3>
  142. Schedule
  143. </h3>
  144. <div className={s.schedules + " items-list"}>
  145. {schedules}
  146. </div>
  147. </div>
  148. </div>
  149. <div className={s.columnRight}>
  150. <div className={s.group}>
  151. <h3>
  152. Instances
  153. </h3>
  154. <div className={s.instances + " items-list"}>
  155. {instances}
  156. </div>
  157. </div>
  158. <div className={s.group}>
  159. <h3>
  160. Networks
  161. </h3>
  162. <div className={s.networks + " items-list"}>
  163. {networks}
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. );
  170. }
  171. }
  172. export default withStyles(WizardSummary, s);