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 RecordViewActions from './recordViewActions.js';
21 import LoadingIndicator from 'widgets/loading-indicator/loadingIndicator.jsx';
22 import DashboardCard from 'widgets/dashboard_card/dashboard_card.jsx';
23 import Utils from 'utils/utils.js';
25 import './recordNavigator.scss';
27 export default class RecordNavigator extends React.Component{
31 handleImageError = (e) => {
32 console.log('Bad logo path, using default');
33 e.target.src = require('style/img/catalog-default.svg');
36 getDescriptorTypeFromRecordType = (recordType) => {
37 if (recordType == 'nsr') {
39 } else if (recordType == 'vnfr') {
47 let navClass = 'catalogItems';
51 let className = this.props.isLoading ? 'loading' : '';
54 this.props.nav.map(function(n, k) {
55 let itemClassName = navClass + '_item';
56 let catalog_name = (n.type == 'nsr' ? <span>({n.nsd_name})</span> : '');
57 let scalingGroupClass = '';
58 let scalingGroupTitleClass = '';
59 let scalingGroupTitle = '';
61 if (n.scalingGroupName) {
62 scalingGroupClass = navClass + ' -is-scaled';
63 scalingGroupTitleClass = scalingGroupClass + '_title';
64 scalingGroupTitle = n.scalingGroupName + '_' + n.scalingGroupInstanceId;
65 n.vnfr && n.vnfr.map((vnfr, vnfrIndex) => {
66 let iClassName = itemClassName;
67 if(vnfr.id == self.props.activeNavID) {
68 iClassName += ' -is-selected';
71 <div key={'id' + k + '-' + vnfr.id} onClick={self.props.loadRecord.bind(self,vnfr)} className={iClassName}>
73 onError={self.handleImageError}
74 src={Utils.cleanImageDataURI(vnfr.logo, self.getDescriptorTypeFromRecordType(vnfr.type), vnfr.logoId)}
76 <section id={vnfr.id}>
77 <h1 title={vnfr.name}>{vnfr.name}</h1>
84 if(n.id == self.props.activeNavID) {
85 itemClassName += ' -is-selected';
88 <div key={'id' + k + '-' + n.id} onClick={self.props.loadRecord.bind(self,n)} className={itemClassName}>
90 onError={self.handleImageError}
91 src={Utils.cleanImageDataURI(n.logo, self.getDescriptorTypeFromRecordType(n.type), n.logoId)}
94 <h1 title={n.name}>{n.name}</h1>
101 <li className={scalingGroupClass} key={"scalingGroupTile-" + k}>
102 <div className={scalingGroupTitleClass}>
109 if(this.props.isLoading) {
110 html = <DashboardCard className="loading" showHeader={true} title="Loading..."><LoadingIndicator size={10} show={true} /></DashboardCard>
113 <DashboardCard showHeader={true} title="Select Record" className={"recordNavigator" + className}>
114 <ul className="catalogItems">
125 RecordNavigator.defaultProps = {