83de71e3c6b74004923c2a27e44dde56d13a7f8d
[osm/riftware.git] /
1 /*
2  *    Copyright 2016 RIFT.IO Inc
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16
17 /*
18  * 
19  *
20  */
21 import React from 'react';
22 import DashboardCard from '../../../components/dashboard_card/dashboard_card.jsx';
23 import ManagementDomainCardHeader from './managementDomainCardHeader.jsx';
24 import './managementDomainCard.scss'
25 function openLaunch() {
26   window.location.hash = window.location.hash + '/launch';
27 }
28
29 class ManagementDomainCard extends React.Component {
30   constructor(props) {
31     super(props);
32   }
33   componentWillReceiveProps(nextProps) {
34   }
35   shouldComponentUpdate(nextProps) {
36     return true;
37   }
38   openCreate() {
39     window.location.hash = window.location.hash + 'management-domain/create'
40   }
41   render() {
42     let html;
43      if(this.props.create){
44       html = <DashboardCard className="managementDomainCard"><div className={'managementDomainCard_create'} onClick={this.openCreate} style={{cursor:'pointer'}}><img src={require("../../../../assets/img/launchpad-add-fleet-icon.png")}/> Create Management Domain </div> </DashboardCard>;
45     } else {
46       var pools_html = null;
47       if (this.props.data.pools) {
48         pools_html = (
49           <dl>
50             <dt>VM Pool: </dt>
51             <dd>{this.props.data.pools.vm || null}</dd>
52             <dt>Network Pool: </dt>
53             <dd>{this.props.data.pools.network || null}</dd>
54             <dt>IP Address: </dt>
55             <dd>{this.props.data.launchpad.ip_address}</dd>
56           </dl>
57         )
58       } else {
59         pools_html = (
60           <dl>
61             <dt>VM Pool: </dt>
62             <dd>None</dd>
63             <dt>Network Pool: </dt>
64             <dd>None</dd>
65             <dt>IP Address: </dt>
66             <dd>{this.props.data.pools ? this.props.data.launchpad.ip_address : null}</dd>
67           </dl>
68         )
69       }
70     html = (
71       <DashboardCard className="managementDomainCard">
72         <ManagementDomainCardHeader name={this.props.data.name} isActive={this.props.isActive} style="93px" data={this.props.data}/>
73         <div className="content">
74           {pools_html}
75         </div>
76       </DashboardCard>
77     );
78 }
79     // <dt>VM Pools</dt>
80     //         <dd>{this.props.data.pools.vm}</dd>
81     //         <dt>Network Pools</dt>
82     //         <dd>{this.props.data.pools.network}</dd>
83     return html;
84   }
85 }
86 ManagementDomainCard.propTypes = {
87   nsr: React.PropTypes.object,
88   isActive: React.PropTypes.bool,
89   name: React.PropTypes.string
90  };
91 ManagementDomainCard.defaultProps = {
92   name: 'Loading...',
93   data: {},
94   isActive: false
95 };
96 export default ManagementDomainCard