Commit 98b48166 authored by Kevin Di Lallo's avatar Kevin Di Lallo
Browse files

frontend updates for multiple sandboxes & scenarios

parent f25b00b7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -173,7 +173,6 @@ func terminateScenario(sandboxName string) {
			if err == nil && chartsToDelete == 0 {
				// Remove modle & cached scenario
				ve.activeScenarioNames[sandboxName] = ""
				ve.activeModels[sandboxName] = nil
				ticker.Stop()
				return
			} else {
+53 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2019  InterDigital Communications, 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, { Component } from 'react';

import IDDialog from './id-dialog';
import { MEEP_DLG_DELETE_SANDBOX } from '../../meep-constants';

class IDDeleteSandboxDialog extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  render() {
    return (
      <IDDialog
        title={this.props.title}
        open={this.props.open}
        onClose={this.props.onClose}
        onSubmit={this.props.deleteSandbox}
        cydata={MEEP_DLG_DELETE_SANDBOX}
      >
        <span style={styles.text}>
          {
            'Are you sure you want to delete the current sandbox?'
          }
        </span>
      </IDDialog>
    );
  }
}

const styles = {
  text: {
    color: 'gray'
  }
};

export default IDDeleteSandboxDialog;
+4 −16
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ import React, { Component } from 'react';
import IDDialog from './id-dialog';
import IDSelect from '../helper-components/id-select';
import {
  SANDBOX_NAME,
  MEEP_DLG_DEPLOY_SCENARIO,
  MEEP_DLG_DEPLOY_SCENARIO_SELECT
} from '../../meep-constants';
@@ -39,19 +38,10 @@ class IDDeployScenarioDialog extends Component {
      return;
    }

    // this.props.api.activateScenario(
    //   this.state.selectedScenario,
    //   null,
    //   this.props.activateScenarioCb
    // );

    var sandboxConfig = {
      scenarioName: this.state.selectedScenario
    };
    this.props.api.createSandboxWithName(
      SANDBOX_NAME,
      sandboxConfig,
      this.props.createSandboxWithNameCb
    this.props.api.activateScenario(
      this.state.selectedScenario,
      null,
      this.props.activateScenarioCb
    );
  }

@@ -81,5 +71,3 @@ class IDDeployScenarioDialog extends Component {
}

export default IDDeployScenarioDialog;

//
+77 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2019  InterDigital Communications, 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, { Component } from 'react';
import { TextField, TextFieldHelperText } from '@rmwc/textfield';

import IDDialog from './id-dialog';
import {
  MEEP_DLG_NEW_SANDBOX,
  MEEP_DLG_NEW_SANDBOX_NAME
} from '../../meep-constants';

class IDNewSandboxDialog extends Component {
  constructor(props) {
    super(props);
    this.state = {
      sandboxName: '',
      err: null
    };
  }

  changeSandboxName(name) {
    var err = null;

    if (name) {
      if (name.length > 20) {
        err = 'Maximum 20 characters';
      } else if (!name.match(/^(([a-z0-9][-a-z0-9.]*)?[a-z0-9])+$/)) {
        err = 'Lowercase alphanumeric or \'-\'';
      }
    }

    this.setState({ sandboxName: name, err: err });
  }

  render() {
    return (
      <IDDialog
        title={this.props.title}
        open={this.props.open}
        onClose={this.props.onClose}
        onSubmit={() => {this.props.createSandbox(this.state.sandboxName);}}
        cydata={MEEP_DLG_NEW_SANDBOX}
      >
        <TextField
          outlined
          style={{ width: '100%' }}
          label={'Sandbox Name'}
          onChange={e => {
            this.changeSandboxName(e.target.value);
          }}
          value={this.state.sandboxName}
          invalid={this.state.err ? true : false}
          data-cy={MEEP_DLG_NEW_SANDBOX_NAME}
        />
        <TextFieldHelperText validationMsg={true}>
          <span>{this.state.err}</span>
        </TextFieldHelperText>
      </IDDialog>
    );
  }
}

export default IDNewSandboxDialog;
+4 −2
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import {
} from '../../state/ui';

import {
  SANDBOX_NAME,
  TYPE_EXEC,
  VIEW_NAME_NONE,
  NET_TOPOLOGY_VIEW,
@@ -130,6 +129,7 @@ const getUrl = (dashboardName, dashboardOptions) => {
};

const ViewForName = ({
  sandboxName,
  scenarioName,
  selectedSource,
  selectedDest,
@@ -163,7 +163,7 @@ const ViewForName = ({
      selectedUrl = selectedUrl.replace(passVarsStr, '');
      
      // Prepend sandbox name to scenario name and replace '-' with '_'
      var sandboxScenario = SANDBOX_NAME + '_' + scenarioName;
      var sandboxScenario = sandboxName + '_' + scenarioName;
      var scenario = sandboxScenario.replace(/-/g, '_');

      var url = new URL(selectedUrl);
@@ -303,6 +303,7 @@ class DashboardContainer extends Component {

    const view1 = (
      <ViewForName
        sandboxName={this.props.sandbox}
        scenarioName={this.props.scenarioName}
        selectedSource={selectedSource}
        selectedDest={selectedDest}
@@ -313,6 +314,7 @@ class DashboardContainer extends Component {

    const view2 = (
      <ViewForName
        sandboxName={this.props.sandbox}
        scenarioName={this.props.scenarioName}
        selectedSource={selectedSource}
        selectedDest={selectedDest}
Loading