4 * Copyright 2016 RIFT.IO Inc
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import React from 'react';
20 import LaunchpadCard from './launchpad_card/launchpadCard.jsx';
21 import Loader from 'widgets/loading-indicator/loadingIndicator.jsx';
22 import ScreenLoader from 'widgets/screen-loader/screenLoader.jsx';
23 import MPFilter from './monitoring-params-filter.jsx'
24 import NsCardPanel from './nsCardPanel/nsCardPanel.jsx';
25 import NsListPanel from './nsListPanel/nsListPanel.jsx';
26 import Crouton from 'react-crouton'
27 import AppHeader from 'widgets/header/header.jsx';
28 import './launchpad.scss';
30 import {SkyquakeRBAC, isRBACValid} from 'widgets/skyquake_rbac/skyquakeRBAC.jsx';
31 import ROLES from 'utils/roleConstants.js';
33 const PROJECT_ROLES = ROLES.PROJECT;
35 let ReactCSSTransitionGroup = require('react-addons-css-transition-group');
36 var LaunchpadFleetActions = require('./launchpadFleetActions.js');
37 var LaunchpadFleetStore = require('./launchpadFleetStore.js');
39 export default class LaunchpadApp extends React.Component {
43 this.state = LaunchpadFleetStore.getState();
44 this.state.slideno = 0;
45 this.handleUpdate = this.handleUpdate.bind(this);
49 LaunchpadFleetStore.getCatalog();
50 LaunchpadFleetStore.listen(this.handleUpdate);
52 // Can not put a dispatch here it causes errors
53 // LaunchpadFleetActions.validateReset();
54 setTimeout(function() {
55 LaunchpadFleetStore.openNSRSocket();
58 setTimeout(function() {
59 consoleo.log("launchpad.componentDidMount openNsrListSocket");
60 LaunchpadFleetStore.openNsrListSocket();
72 LaunchpadFleetActions.validateReset()
74 componentWillUnmount() {
75 LaunchpadFleetStore.closeSocket();
76 LaunchpadFleetStore.unlisten(this.handleUpdate);
79 handleOpenNsCard(nsr) {
80 LaunchpadFleetActions.openNSRCard(nsr);
83 handleCloseNsCard(id) {
84 LaunchpadFleetActions.closeNSRCard(id);
87 handleShowHideNsListPanelToggle() {
89 showNsListPanel: !this.state.showNsListPanel
94 return this.state.nsrs;
99 const hasAccess = isRBACValid(this.context.userProfile, [PROJECT_ROLES.LCM_ADMIN, PROJECT_ROLES.PROJECT_ADMIN]);
100 let mgmtDomainName = window.location.hash.split('/')[2];
102 if(!mgmtDomainName) {
103 mgmtDomainName = 'dashboard';
105 if(mgmtDomainName.toUpperCase() == 'DASHBOARD' || mgmtDomainName.toUpperCase() == 'UNDEFINED') {
108 mgmtDomainName = ' : ' + mgmtDomainName;
110 let nav = <AppHeader title={'LAUNCHPAD' + mgmtDomainName} nav={navItems} />
113 <div className="app-body">
114 <div className="lp_dashboard">
115 <NsListPanel nsrs={self.state.nsrs}
116 openedNsrIDs={self.state.openedNsrIDs}
117 isVisible={self.state.isNsListPanelVisible}
119 <NsCardPanel nsrs={self.state.nsrs}
120 openedNsrIDs={self.state.openedNsrIDs}
121 hasAccess={hasAccess} />
127 LaunchpadApp.contextTypes = {
128 router: React.PropTypes.object,
129 userProfile: React.PropTypes.object
131 LaunchpadApp.defaultProps = {
132 // name: 'Loading...',