/* * * 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 RecordViewStore from '../recordViewer/recordViewStore.js'; import Button from 'widgets/button/rw.button.js'; import Utils from 'utils/utils.js'; import _ from 'underscore'; import UpTime from 'widgets/uptime/uptime.jsx'; import './nsrScalingGroups.scss'; export default class NsrScalingGroups extends React.Component { constructor(props) { super(props); this.state = {}; } handleExecuteClick = (nsr_id, scaling_group_id, event) => { RecordViewStore.createScalingGroupInstance({ nsr_id: nsr_id, scaling_group_id: scaling_group_id }); } handleDeleteClick = (nsr_id, scaling_group_id, scaling_instance_index, event) => { RecordViewStore.deleteScalingGroupInstance({ nsr_id: nsr_id, scaling_group_id: scaling_group_id, scaling_instance_index: scaling_instance_index }); } createScalingGroupTable = (scalingGroupDesriptorName) => { let trows = []; this.props.data['scaling-group-record'] && this.props.data['scaling-group-record'].map((sgr, sgri) => { sgr['instance'] ? sgr['instance'].map((sgrInstance, sgrInstanceIndex) => { let id = sgrInstance['instance-id']; let sgrName = sgr['scaling-group-name-ref']; if (sgrName == scalingGroupDesriptorName) { trows.push( {sgrInstanceIndex + 1} {id} {sgrInstance['op-status']} {sgrInstance['is-default'] == 'false' ? : null} ); } }) : trows.push( No network services scaled in this group ); }); let tbody = ( {trows} ); return ( {tbody}
ID Uptime Status
); } getInstancesForScalingGroup = (scalingGroupDesriptorName) => { let count = 0; this.props.data['scaling-group-record'] && this.props.data['scaling-group-record'].map((sgr, sgri) => { sgr['instance'] && sgr['instance'].map((sgrInstance, sgrInstanceIndex) => { if (sgr['scaling-group-name-ref'] == scalingGroupDesriptorName) { count++; } }); }); return count; } render() { let scalingGroups = []; this.props.data['scaling-group-descriptor'] && this.props.data['scaling-group-descriptor'].map((sgd) => { let sgvnfs = []; let sgMaxCount = ( Max: {sgd['max-instance-count']} ); sgd['vnfd-member'] && sgd['vnfd-member'].map((vnf) => { let instanceCount = vnf['count']; sgvnfs.push( {vnf['short-name']} {instanceCount > 1 ? '(' + instanceCount + ')': ''} ); }); sgvnfs = Utils.arrayIntersperse(sgvnfs, ', '); let sgInstanceTable = this.createScalingGroupTable(sgd.name); let sgCreateInstanceButton =