6 import React from 'react';
7 import UpTime from '../../../components/uptime/uptime.jsx';
8 import LaunchpadOperationalStatus from '../../../components/operational-status/launchpadOperationalStatus.jsx';
9 import MissionControlStore from '../../missionControlStore.js';
10 import ManagementDomainStore from '../managementDomainStore.js';
11 class ManagementDomainCardHeader extends React.Component {
15 this.state.displayStatus = false;
16 this.state.isLoading = true;
17 this.openDashboard = this.openDashboard.bind(this);
18 this.openConsole = this.openConsole.bind(this);
19 this.setStatus = this.setStatus.bind(this);
20 this.toggleStatus = this.toggleStatus.bind(this);
23 componentWillReceiveProps(nextProps) {
24 let lpState = nextProps.data.launchpad.state;
25 if(lpState == 'stopped' || lpState == 'started') {
35 deleteLaunchpad(name) {
36 if (confirm("Do you really want to delete management domain '" + name + "'?")) {
37 ManagementDomainStore.delete(name);
41 console.log('Done loading')
46 //TODO instead of calling the store method, an action should be emitted and the store should respond.
49 if(this.props.isActive) {
50 window.open('http://' + this.props.data.launchpad.ip_address + ':8000/index.html?api_server=http://localhost#/launchpad/' + this.props.data.name);
54 console.log('open console clicked');
57 console.log('setting status for ', name)
58 this.props.isActive ? MissionControlStore.stopLaunchpad(name) : MissionControlStore.startLaunchpad(name)
60 editMgmtDomain(mgmtDomainName) {
61 window.location.href = '#/management-domain/' + mgmtDomainName + '/edit'
67 let isLoading = this.state.isLoading;
68 let isActive = this.props.isActive;
69 let opStatusHack = [];
71 let currentTime = (d.getTime() / 1000);
72 let startTime = currentTime - this.props.data.launchpad["create-time"];
74 id:this.props.data.launchpad.state,
75 description:this.props.data.launchpad.state
77 console.log(this.props.data.launchpad['state-details'])
79 <header className="launchpadCard_header">
80 <div className={"launchpadCard_header-title " + (this.props.isActive ? '' : 'launchpadCard_header-title-off')}>
82 className="fleet-card-pwr-btn"
83 style={{'color':this.props.isActive?'#93cb43':'white'}}
84 onClick={this.setStatus.bind(this, this.props.name)}
85 title={this.props.isActive ? 'Turn Off' : 'Turn On'}
87 <span className="oi" data-glyph="power-standby" aria-hidden="true"></span>
89 <h3 className="managementDomainCard_header-link" onClick={this.openDashboard} style={{cursor: this.props.isActive ? 'pointer' : 'default', 'text-overflow':'ellipsis', 'max-width':'150px', 'overflow':'hidden'}}>
92 <h3 className="managementDomainCard_header-link" style={{display: this.props.isActive ? 'inherit' : 'none'}}>
93 <a onClick={this.openDashboard} title="Open Launchpad">
94 <span className="oi" data-glyph="external-link" aria-hidden="true"></span>
97 <div className="managementDomainCard_header-actions">
99 {isLoading || !isActive ? '' : 'Active' }
101 <h3 style={{display: (isLoading || !isActive) ? 'none' : 'inherit'}}>
102 <UpTime initialtime={startTime} run={true} />
104 <h3 style={{display: isLoading ? 'none' : 'inherit'}}>
106 <h3 className="launchpadCard_header-link">
107 <a onClick={this.editMgmtDomain.bind(this, this.props.name)} title="Edit">
108 <span className="oi" data-glyph="pencil" aria-hidden="true">
112 <h3 className="launchpadCard_header-link" style={{display:'none'}}>
113 <a onClick={this.openConsole} title="Open Console">
114 <span className="oi" data-glyph="monitor" aria-hidden="true">
118 <h3 className="launchpadCard_header-link" style={{display: this.props.isActive ? 'none' : 'inherit'}}>
119 <a onClick={this.deleteLaunchpad.bind(this, this.props.name)} title="Delete">
120 <span className="oi" data-glyph="trash" aria-hidden="true"></span>
125 <div className="managementDomainCard_header-status">
127 <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']} />
132 ManagementDomainCardHeader.propTypes = {
133 name: React.PropTypes.string
135 ManagementDomainCardHeader.defaultProps = {
136 name: 'Loading...Some Name',
142 // <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"]} />
145 export default ManagementDomainCardHeader;