Commit 80acfbe9 authored by Yann Garcia's avatar Yann Garcia
Browse files

Add error message when the Network Emulated stack is not accessible

parent 583323e8
Loading
Loading
Loading
Loading
+2 −2
Changes for js-apps/frontend/package-lock.json: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
{
  "name": "mec-sandbox",
  "name": "edgenative-connector-frontend",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "mec-sandbox",
      "name": "edgenative-connector-frontend",
      "version": "1.0.0",
      "license": "ISC",
      "dependencies": {
+2 −0
Changes for js-apps/frontend/src/js/app-constants.js: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -66,6 +66,8 @@ export const DIALOG_VERSION = 'DIALOG_VERSION';

// Alert Types
export const ALERT_DEGRADED_NETWORK = 'ALERT_DEGRADED_NETWORK';
export const ALERT_NEM_NOT_RUNNING = 'ALERT_NEM_NOT_RUNNING';
export const MSG_NEM_NOT_RUNNING = 'The Network Emulation stack is not running';

// Trivia
export const NO_SCENARIO_NAME = 'NO_SCENARIO_NAME_12Q(*&HGHG___--9098';
+14 −1
Changes for js-apps/frontend/src/js/containers/sandbox/configuration-pane.js: 14 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import {
  DEFAULT_NO_NETWORK_FILE_SELECTED,
  NO_SCENARIO_NAME,
  ALERT_DEGRADED_NETWORK,
  ALERT_NEM_NOT_RUNNING,
  MSG_NEM_NOT_RUNNING,
  DIALOG_CONFIRM_DELETE_APP,
  DIALOG_CREATE_NEW_APP,
  MAX_NB_USER_APPS,
@@ -499,6 +501,11 @@ class ConfigPane extends Component {
              }}
              value={this.props.networkFileSelected}
            />
            {this.props.currentAlert === ALERT_NEM_NOT_RUNNING &&
              <Typography use="subtitle2" style={styles.nemErrorText}>
                {MSG_NEM_NOT_RUNNING}
              </Typography>
            }
          </GridCell>
        </Grid>

@@ -690,7 +697,7 @@ class ConfigPane extends Component {
          </Grid>
        }

        <div hidden={!this.props.currentAlert} style={{ width: '100%', borderTop: '2px solid #e4e4e4', marginTop: 30, marginBottom: 10}} />
        <div hidden={this.props.currentAlert !== ALERT_DEGRADED_NETWORK} style={{ width: '100%', borderTop: '2px solid #e4e4e4', marginTop: 30, marginBottom: 10}} />

        <div hidden={(this.props.currentAlert !== ALERT_DEGRADED_NETWORK)}>
          <Grid>
@@ -751,6 +758,12 @@ const styles = {
  },
  select: {
    width: '100%'
  },
  nemErrorText: {
    color: 'red',
    fontWeight: 'bold',
    display: 'block',
    marginTop: 10
  }
};

+18 −4
Changes for js-apps/frontend/src/js/containers/sandbox/sandbox-page-container.js: 18 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -15,13 +15,17 @@ import DetailedDataDialog from '../../components/dialogs/detailed-data-dialog';

import {
  uiChangeCurrentDialog,
  uiChangeCurrentAlert,
  uiSandboxChangeNetworkFilesList
} from '../../state/ui';

import { StatusCodes } from 'http-status-codes';

import {
  PAGE_SANDBOX,
  DEFAULT_NO_NETWORK_FILE_SELECTED,
  DIALOG_DETAILED_DATA
  DIALOG_DETAILED_DATA,
  ALERT_NEM_NOT_RUNNING
} from '../../app-constants';


@@ -47,18 +51,26 @@ class SandboxPageContainer extends Component {
   * @param {module:model/ScenarioList} data The data returned by the service call.
   * @param {String} response The complete HTTP response.
   */
  getScenarioListLoadCb(error, data /*, response*/) {
  getScenarioListLoadCb(error, data, response) {
    if (error !== null) {
      // TODO: consider showgina an alert
      const status = (error && error.status) || (response && response.status);
      if (status === StatusCodes.BAD_GATEWAY ||
          status === StatusCodes.GATEWAY_TIMEOUT ||
          status === StatusCodes.REQUEST_TIMEOUT ||
          status === 0) {
        this.props.changeCurrentAlert(ALERT_NEM_NOT_RUNNING);
      }
      return;
    }
    if (this.props.currentAlert === ALERT_NEM_NOT_RUNNING) {
      this.props.changeCurrentAlert(null);
    }
    if (!data.scenarios) {
      return;
    }
    let files = _.map(data.scenarios, 'name');
    files.unshift(DEFAULT_NO_NETWORK_FILE_SELECTED);
    this.props.changeNetworkFilesList(files);

  }

  updateNetworkFileList() {
@@ -185,6 +197,7 @@ const mapStateToProps = state => {
  return {
    page: state.ui.page,
    currentDialog: state.ui.currentDialog,
    currentAlert: state.ui.currentAlert,
    detailedData: state.ui.detailedData
  };
};
@@ -192,6 +205,7 @@ const mapStateToProps = state => {
const mapDispatchToProps = dispatch => {
  return {
    changeCurrentDialog: type => dispatch(uiChangeCurrentDialog(type)),
    changeCurrentAlert: alert => dispatch(uiChangeCurrentAlert(alert)),
    changeNetworkFilesList: list => dispatch(uiSandboxChangeNetworkFilesList(list))
  };
};