/* * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import React from 'react'; import DashboardCard from 'widgets/dashboard_card/dashboard_card.jsx'; import './launchpad_card.scss'; import LaunchpadNSInfo from './launchpadNSInfo.jsx'; import LaunchpadHeader from './launchpadHeader.jsx'; import MonitoringParamsCarousel from '../monitoring_params/monitoringParamsCarousel.jsx'; import LaunchpadControls from './launchpadControls.jsx'; import NfviMetricBars from 'widgets/nfvi-metric-bars/nfviMetricBars.jsx'; import MetricBarGroup from 'widgets/metric-bars/metricBarGroup.jsx'; import LoadingIndicator from 'widgets/loading-indicator/loadingIndicator.jsx'; import RecordViewStore from '../recordViewer/recordViewStore.js'; import TreeView from 'react-treeview'; import circleXImage from '../../node_modules/open-iconic/svg/circle-x.svg'; class LaunchpadCard extends React.Component { constructor(props) { super(props); } shouldComponentUpdate(nextProps) { return true; } openLaunch = () => { this.context.router.push({pathname:'instantiate'}); } render() { let html; let metrics = ''; let monitoring_params_data; let deleting = false; let metricsAndParameters = []; let carousel = '' let closeCardAction = this.props.closeButtonAction; if(this.props.nsr && this.props.nsr.data) { metrics = this.props.nsr.data.map((info, index)=> { return () }); } // debugger if(this.props.nsr && this.props.nsr["monitoring-param"]) { monitoring_params_data = this.props.nsr["monitoring-param"]; } else { monitoring_params_data = null; } if (this.props.nsr && this.props.nsr.deleting) { deleting = true; } if(true) { // metricsAndParameters.push() if (this.props.nsr) { if (this.props.nsr["nfvi-metrics"]) { metricsAndParameters.push((
)) } if (this.props.nsr["epa-params"]) { metricsAndParameters.push(); } } carousel = ; } if(this.props.create){ html = (
Instantiate Network Service
); } else { let self = this; let closeButton = ( ); if (this.props.hasAccess) closebutton = null; html = ( { deleting ?
:
NSD: {this.props.nsr.nsd_name}
{carousel} {metricsAndParameters}
}
); } return html; } } LaunchpadCard.contextTypes = { router: React.PropTypes.object }; LaunchpadCard.propTypes = { nsr: React.PropTypes.object, isActive: React.PropTypes.bool, name: React.PropTypes.string }; LaunchpadCard.defaultProps = { name: 'Loading...', data: {}, isActive: false }; export class LpCardNfviMetrics extends React.Component { constructor(props) { super(props) } convertToArray(o){ let a = []; Object.keys(o).map(function(k){ a.push(o[k]); }); return a; } render() { let mets = this.props.data; let self = this; let html = (
NFVI-METRICS
{ (mets && mets.length > 0 ) ? mets.map(function(m,i) { return b.id})} /> }) :
NO NFVI METRICS CONFIGURED
}
) return html; } } export class EpaParams extends React.Component { constructor(props) { super(props) } render() { let metrics =[]; let epa = this.props.data; let count = 0; for(let k in epa) { let epaHTMLsub = []; let epaHTML; epaHTMLsub.push(buildParams(epa[k], count)); epaHTML = (
  • {k}

    { epaHTMLsub }
  • ); metrics.push(epaHTML); count++; } function buildParams(epa, index) { let html = []; let tCount = 0; let checkForTotal = function checkForTotal(epa, html, i) { for (let k in epa) { if("total" in epa[k]) { html.push(
    {k} : {epa[k].total} {(epa[k].total>1) ? 'vms' : 'vm'}
    ) } else { html.push(
    {k}
    ) checkForTotal(epa[k], html, tCount) } tCount++; } } checkForTotal(epa, html, index) return (
    {html}
    ); } let display = (
      {metrics}
    ) // metrics = false; if(metrics.length == 0) display =
    NO EPA PARAMS CONFIGURED
    let html = (
    EPA-PARAMS
    {display}
    ) return html; } } export class NsrPrimitiveJobList extends React.Component { constructor(props) { super(props) } render () { let tree = null; tree = this.props.jobs.sort(function(a,b){ return b['job-id'] > a['job-id']; }).map(function(job, jindex) { let nsrJobLabel = job['job-name'] ? job['job-name'] + ': ' + job['job-status'] : "NSR Job ID:" + job['job-id'] + ': ' + job['job-status'] return (

    NSR Job Name: {job['job-name']}

    NSR Job ID: {job['job-id']}

    NSR Job Status: {job['job-status']}

    {job.vnfr ? {job.vnfr.map(function(v, vindex) { return (
    VNFR ID: {v.id}
    VNFR Job Status: {v['vnf-job-status']}
    {v.primitive && v.primitive.map((p, pindex) => { return (
    Name: {p.name}
    Status: {p["execution-status"]}
    ) })}
    ) })}
    :null}
    ) }); let html = (
    JOB-LIST
    {tree}
    ); return html; } } NsrPrimitiveJobList.defaultProps = { jobs: [] } export default LaunchpadCard