60313dd6c49e3852223f322d5231ed0f6d2c5817
[osm/riftware.git] /
1 /*
2  * 
3  *
4  */
5
6 import React from 'react';
7 import AppHeader from '../../components/header/header.jsx';
8 import ConfigAgentAccount from './configAgentAccount.jsx';
9 import ConfigAgentAccountStore from './configAgentAccountStore';
10 import AccountSidebar from '../account_sidebar/accountSidebar.jsx';
11
12 export default class LaunchpadConfigAgentAccount extends React.Component {
13     constructor(props) {
14         super(props);
15         this.state = ConfigAgentAccountStore.getState();
16         ConfigAgentAccountStore.getCatalog();
17         ConfigAgentAccountStore.listen(this.updateState);
18         if(this.props.edit) {
19             ConfigAgentAccountStore.getConfigAgentAccount(window.location.hash.split('/')[4])
20         } else {
21             this.state.isLoading = false;
22         }
23     }
24     updateState = (state) => {
25         this.setState(state);
26     }
27     loadComposer = () => {
28       let API_SERVER = rw.getSearchParams(window.location).api_server;
29       let auth = window.sessionStorage.getItem("auth");
30       let mgmtDomainName = window.location.hash.split('/')[2];
31         window.location.replace('//' + window.location.hostname + ':9000/index.html?api_server=' + API_SERVER + '&upload_server=' + window.location.protocol + '//' + window.location.hostname + '&clearLocalStorage' + '&mgmt_domain_name=' + mgmtDomainName + '&auth=' + auth);
32     }
33     render() {
34         let html;
35         let body;
36         let title = "Launchpad: Add Config Agent Account";
37         let mgmtDomainName = window.location.hash.split('/')[2];
38         if (this.props.edit) {
39             title = "Launchpad: Edit Config Agent Account";
40         }
41         let navItems = [{
42                 name: 'DASHBOARD',
43                 href: '#/launchpad/' + mgmtDomainName
44             },{
45                  name: 'CATALOG(' + this.state.descriptorCount + ')',
46                 'onClick': this.loadComposer
47             },
48             {
49                 name: 'Accounts'
50             }
51         ];
52         if (this.props.isDashboard) {
53             body = (<div>Edit or Create New Accounts</div>);
54         } else {
55              body = <ConfigAgentAccount {...this.props} />
56         }
57         html = (<div>
58                   <AppHeader title={title} nav={navItems} isLoading={this.state.isLoading} />
59                     <div className="flex">
60                       <AccountSidebar/>
61                       {body}
62                     </div>
63               </div>);
64         return html;
65     }
66 }