2 * Copyright 2016 RIFT.IO Inc
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 import React from 'react';
22 import UpTime from '../../../components/uptime/uptime.jsx';
23 import LaunchpadOperationalStatus from '../../../components/operational-status/launchpadOperationalStatus.jsx';
24 import MissionControlStore from '../../missionControlStore.js';
25 import ManagementDomainStore from '../managementDomainStore.js';
26 class ManagementDomainCardHeader extends React.Component {
30 this.state.displayStatus = false;
31 this.state.isLoading = true;
32 this.openDashboard = this.openDashboard.bind(this);
33 this.openConsole = this.openConsole.bind(this);
34 this.setStatus = this.setStatus.bind(this);
35 this.toggleStatus = this.toggleStatus.bind(this);
38 componentWillReceiveProps(nextProps) {
39 let lpState = nextProps.data.launchpad.state;
40 if(lpState == 'stopped' || lpState == 'started') {
50 deleteLaunchpad(name) {
51 if (confirm("Do you really want to delete management domain '" + name + "'?")) {
52 ManagementDomainStore.delete(name);
56 console.log('Done loading')
61 //TODO instead of calling the store method, an action should be emitted and the store should respond.
64 if(this.props.isActive) {
65 window.open('http://' + this.props.data.launchpad.ip_address + ':8000/index.html?api_server=http://localhost#/launchpad/' + this.props.data.name);
69 console.log('open console clicked');
72 console.log('setting status for ', name)
73 this.props.isActive ? MissionControlStore.stopLaunchpad(name) : MissionControlStore.startLaunchpad(name)
75 editMgmtDomain(mgmtDomainName) {
76 window.location.href = '#/management-domain/' + mgmtDomainName + '/edit'
82 let isLoading = this.state.isLoading;
83 let isActive = this.props.isActive;
84 let opStatusHack = [];
86 let currentTime = (d.getTime() / 1000);
87 let startTime = currentTime - this.props.data.launchpad["create-time"];
89 id:this.props.data.launchpad.state,
90 description:this.props.data.launchpad.state
92 console.log(this.props.data.launchpad['state-details'])
94 <header className="launchpadCard_header">
95 <div className={"launchpadCard_header-title " + (this.props.isActive ? '' : 'launchpadCard_header-title-off')}>
97 className="fleet-card-pwr-btn"
98 style={{'color':this.props.isActive?'#93cb43':'white'}}
99 onClick={this.setStatus.bind(this, this.props.name)}
100 title={this.props.isActive ? 'Turn Off' : 'Turn On'}
102 <span className="oi" data-glyph="power-standby" aria-hidden="true"></span>
104 <h3 className="managementDomainCard_header-link" onClick={this.openDashboard} style={{cursor: this.props.isActive ? 'pointer' : 'default', 'text-overflow':'ellipsis', 'max-width':'150px', 'overflow':'hidden'}}>
107 <h3 className="managementDomainCard_header-link" style={{display: this.props.isActive ? 'inherit' : 'none'}}>
108 <a onClick={this.openDashboard} title="Open Launchpad">
109 <span className="oi" data-glyph="external-link" aria-hidden="true"></span>
112 <div className="managementDomainCard_header-actions">
114 {isLoading || !isActive ? '' : 'Active' }
116 <h3 style={{display: (isLoading || !isActive) ? 'none' : 'inherit'}}>
117 <UpTime initialtime={startTime} run={true} />
119 <h3 style={{display: isLoading ? 'none' : 'inherit'}}>
121 <h3 className="launchpadCard_header-link">
122 <a onClick={this.editMgmtDomain.bind(this, this.props.name)} title="Edit">
123 <span className="oi" data-glyph="pencil" aria-hidden="true">
127 <h3 className="launchpadCard_header-link" style={{display:'none'}}>
128 <a onClick={this.openConsole} title="Open Console">
129 <span className="oi" data-glyph="monitor" aria-hidden="true">
133 <h3 className="launchpadCard_header-link" style={{display: this.props.isActive ? 'none' : 'inherit'}}>
134 <a onClick={this.deleteLaunchpad.bind(this, this.props.name)} title="Delete">
135 <span className="oi" data-glyph="trash" aria-hidden="true"></span>
140 <div className="managementDomainCard_header-status">
142 <LaunchpadOperationalStatus className="managementDomainCard_header-operational-status" loading={this.state.isLoading} doneLoading={this.doneLoading.bind(this)} display={this.state.displayStatus} currentStatus={this.props.data.launchpad.state} currentStatusDetails={this.props.data.launchpad['state-details']} />
147 ManagementDomainCardHeader.propTypes = {
148 name: React.PropTypes.string
150 ManagementDomainCardHeader.defaultProps = {
151 name: 'Loading...Some Name',
157 // <LaunchpadOperationalStatus className="managementDomainCard_header-operational-status" loading={isLoading} doneLoading={this.doneLoading.bind(this)} display={this.state.displayStatus} currentStatus={this.props.nsr["operational-status"]} status={this.props.nsr["rw-nsr:operational-events"]} />
160 export default ManagementDomainCardHeader;