Rift.IO OSM R1 Initial Submission
[osm/UI.git] / skyquake / plugins / composer / src / src / stores / RiftHeaderStore.js
1 /*
2 *
3 * Copyright 2016 RIFT.IO Inc
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 *
17 */
18 /**
19 * Created by kkashalk on 11/10/15.
20 */
21
22 // NOTE: THIS FILE HAS BEEN DEPRECATED AND WILL BE REMOVED
23
24 'use strict';
25
26 import alt from '../alt'
27 import React from 'react'
28 import utils from '../libraries/utils'
29 import RiftHeaderActions from '../actions/RiftHeaderActions'
30 import RiftHeaderSource from '../sources/RiftHeaderSource'
31 import CatalogDataSource from '../sources/CatalogDataSource'
32 import CatalogDataSourceActions from '../actions/CatalogDataSourceActions'
33
34 class RiftHeaderStore {
35
36 constructor() {
37 let mgmt_domain_name = unescape(utils.getSearchParams(window.location).mgmt_domain_name);
38 if(mgmt_domain_name.toUpperCase() == 'DASHBOARD' || mgmt_domain_name.toUpperCase() == 'UNDEFINED') {
39 mgmt_domain_name = '';
40 } else {
41 mgmt_domain_name = ' : ' + mgmt_domain_name;
42 }
43 this.headerTitle = 'Launchpad' + mgmt_domain_name;
44 this.nsdCount = 0;
45 this.isStandAlone = false;
46 this.registerAsync(CatalogDataSource);
47 this.registerAsync(RiftHeaderSource);
48 this.bindAction(CatalogDataSourceActions.LOAD_CATALOGS_SUCCESS, this.loadCatalogsSuccess);
49 this.bindActions(RiftHeaderActions);
50 }
51 requestLaunchpadConfigSuccess(data) {
52 this.setState({
53 isStandAlone: true,
54 headerTitle: 'Launchpad'
55 });
56 }
57 loadCatalogsSuccess(data) {
58 let self = this; {}
59 let descriptorCount = 0;
60 data.data.forEach((catalog) => {
61 descriptorCount += catalog.descriptors.length;
62 });
63
64 self.setState({
65 descriptorCount: descriptorCount
66 });
67 }
68 }
69
70 export default alt.createStore(RiftHeaderStore, 'RiftHeaderStore');