3 * Copyright 2016 RIFT.IO Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 import React from 'react';
19 import './accountSidebar.scss';
20 import DashboardCard from 'widgets/dashboard_card/dashboard_card.jsx';
21 import AccountStore from '../account/accountStore.js';
22 import { Link } from 'react-router';
23 import SkyquakeComponent from 'widgets/skyquake_container/skyquakeComponent.jsx';
24 import Button from 'widgets/button/rw.button'
25 class AccountSidebar extends React.Component{
28 // this.props.store = this.props.flux.props.stores.hasOwnProperty('AccountStore') ? this.props.flux.props.stores.AccountStore : this.props.flux.createStore(AccountStore);
30 // this.props = this.props.store.getState();
32 listenerHandler = (state) => {
35 componentWillMount() {
36 // this.props.store.listen(this.listenerHandler);
37 // this.props.store.openAccountsSocket();
39 componentWillUnmount() {
40 // this.props.store.closeSocket();
41 // this.props.store.unlisten(this.listenerHandler);
46 let {store, ...props} = this.props;
47 //[this.props.cloud,this.props.sdn,this.props['config-agent']]
51 data: this.props.cloud
59 data: this.props['config-agent']
62 let refreshStatus = (<div>Check All Connectivity Status</div>)
63 let cloudAccounts = (this.props.cloud.length > 0) ? this.props.cloud.map(function(account, index) {
66 if (account['connection-status']) {
67 status = account['connection-status'].status;
70 <DashboardCard key={index} className='pool-card accountSidebarCard'>
72 <Link to={'accounts/cloud/' + account.name}>
73 <div className="accountSidebarCard--content">
74 <img className="accountSidebarCard--logo" src={store.getImage(account['account-type'])} />
75 <h3 title="Edit Account">
77 <AccountConnectivityStatus status={status}/>
86 let sdnAccounts = (this.props.sdn && this.props.sdn.length > 0) ? this.props.sdn.map(function(account, index) {
88 if (account['connection-status']) {
89 status = account['connection-status'].status;
92 <DashboardCard key={index} className='pool-card accountSidebarCard'>
94 <Link to={'accounts/sdn/' + account.name} title="Edit Account">
95 <div className="accountSidebarCard--content">
96 <img className="accountSidebarCard--logo" src={store.getImage(account['account-type'])} />
97 <h3>{account.name}<AccountConnectivityStatus status={status}/></h3>
104 let configAgentAccounts = (this.props['config-agent'].length > 0) ? this.props['config-agent'].map(function(account, index) {
106 if (account['connection-status']) {
107 status = account['connection-status'].status;
110 <DashboardCard key={index} className='pool-card accountSidebarCard'>
112 <Link to={'accounts/config-agent/' + account.name} title="Edit Account">
113 <div className="accountSidebarCard--content">
114 <img className="accountSidebarCard--logo" src={store.getImage(account['account-type'])} />
115 <h3 title="Edit Account">
117 <AccountConnectivityStatus status={status}/>
126 <div className='accountSidebar'>
127 <Button className="refreshList light" onClick={this.props.store.refreshAll.bind(this, AccountData)} label={this.props.refreshingAll ? 'Checking Connectivity Status...' : refreshStatus}></Button>
130 <h1>VIM Accounts</h1>
133 !self.props.readonly ?
134 <DashboardCard className="accountSidebarCard">
136 to={{pathname: '/accounts/cloud/create'}}
137 title="Create Cloud Account"
138 className={'accountSidebarCard_create'} >
140 <img src={require("style/img/launchpad-add-fleet-icon.png")}/>
143 : <div style={{margin:'1rem'}}></div>
147 <h1>SDN Accounts</h1>
150 !self.props.readonly ?
151 <DashboardCard className="accountSidebarCard">
153 to={{pathname: '/accounts/sdn/create'}}
154 title="Create Sdn Account"
155 className={'accountSidebarCard_create'}>
157 <img src={require("style/img/launchpad-add-fleet-icon.png")}/>
161 : <div style={{margin:'1rem'}}></div>
163 <h1>Config Agent Accounts</h1>
164 {configAgentAccounts}
166 !self.props.readonly ?
167 <DashboardCard className="accountSidebarCard">
169 to={{pathname: '/accounts/config-agent/create'}}
170 title="Create Config Agent Account"
171 className={'accountSidebarCard_create'}
173 Add Config Agent Account
174 <img src={require("style/img/launchpad-add-fleet-icon.png")}/>
177 : <div style={{margin:'1rem'}}></div>
185 AccountSidebar.defaultProps = {
192 export class AccountConnectivityStatus extends React.Component {
194 return <span className={'connectivityStatus ' + 'connectivityStatus--' + this.props.status + ' ' + this.props.className} title={this.props.status}></span>
197 AccountConnectivityStatus.defaultProps = {
201 export default SkyquakeComponent(AccountSidebar);