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);
45 let {store, ...props} = this.props;
46 //[this.props.cloud,this.props.sdn,this.props['config-agent']]
50 data: this.props.cloud
58 data: this.props['config-agent']
61 let refreshStatus = (<div>Check All Connectivity Status</div>)
62 let cloudAccounts = (this.props.cloud.length > 0) ? this.props.cloud.map(function(account, index) {
65 if (account['connection-status']) {
66 status = account['connection-status'].status;
69 <DashboardCard key={index} className='pool-card accountSidebarCard'>
71 <Link to={'accounts/cloud/' + account.name}>
72 <div className="accountSidebarCard--content">
73 <img className="accountSidebarCard--logo" src={store.getImage(account['account-type'])} />
74 <h3 title="Edit Account">
76 <AccountConnectivityStatus status={status}/>
85 let sdnAccounts = (this.props.sdn && this.props.sdn.length > 0) ? this.props.sdn.map(function(account, index) {
87 if (account['connection-status']) {
88 status = account['connection-status'].status;
91 <DashboardCard key={index} className='pool-card accountSidebarCard'>
93 <Link to={'accounts/sdn/' + account.name} title="Edit Account">
94 <div className="accountSidebarCard--content">
95 <h3>{account.name}<AccountConnectivityStatus status={status}/></h3>
102 let configAgentAccounts = (this.props['config-agent'].length > 0) ? this.props['config-agent'].map(function(account, index) {
104 if (account['connection-status']) {
105 status = account['connection-status'].status;
108 <DashboardCard key={index} className='pool-card accountSidebarCard'>
110 <Link to={'accounts/config-agent/' + account.name} title="Edit Account">
111 <div className="accountSidebarCard--content">
112 <img className="accountSidebarCard--logo" src={store.getImage(account['account-type'])} />
113 <h3 title="Edit Account">
115 <AccountConnectivityStatus status={status}/>
124 <div className='accountSidebar'>
125 <Button className="refreshList light" onClick={this.props.store.refreshAll.bind(this, AccountData)} label={this.props.refreshingAll ? 'Checking Connectivity Status...' : refreshStatus}></Button>
126 <h1>VIM Accounts</h1>
128 <DashboardCard className="accountSidebarCard">
130 to={{pathname: '/accounts/cloud/create'}}
131 title="Create Cloud Account"
132 className={'accountSidebarCard_create'}
135 <img src={require("style/img/launchpad-add-fleet-icon.png")}/>
138 <h1>SDN Accounts</h1>
140 <DashboardCard className="accountSidebarCard">
142 to={{pathname: '/accounts/sdn/create'}}
143 title="Create Sdn Account"
144 className={'accountSidebarCard_create'}
147 <img src={require("style/img/launchpad-add-fleet-icon.png")}/>
150 <h1>Config Agent Accounts</h1>
151 {configAgentAccounts}
152 <DashboardCard className="accountSidebarCard">
154 to={{pathname: '/accounts/config-agent/create'}}
155 title="Create Config Agent Account"
156 className={'accountSidebarCard_create'}
158 Add Config Agent Account
159 <img src={require("style/img/launchpad-add-fleet-icon.png")}/>
168 AccountSidebar.defaultProps = {
175 export class AccountConnectivityStatus extends React.Component {
177 return <span className={'connectivityStatus ' + 'connectivityStatus--' + this.props.status + ' ' + this.props.className} title={this.props.status}></span>
180 AccountConnectivityStatus.defaultProps = {
184 export default SkyquakeComponent(AccountSidebar);