Commit 581c3f32 authored by Kevin Di Lallo's avatar Kevin Di Lallo
Browse files

map state optimizations

parent 1f3cc203
Loading
Loading
Loading
Loading
+46 −59
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ import {
import {
  sboxChangeScenario,
  sboxChangeTable,
  sboxChangeMap,
  sboxChangeMapUeList,
  sboxChangeMapPoaList,
  sboxChangeMapComputeList,
@@ -134,6 +135,7 @@ const images = importAll(require.context('../../img', false, /\.(png|jpe?g|svg)$
class AppContainer extends Component {
  constructor(props) {
    super(props);

    this.creationSandboxTimer = null;
    this.sboxPageRefreshIntervalTimer = null;
    this.sandboxErrorCount = 0;
@@ -159,9 +161,7 @@ class AppContainer extends Component {
    this.meepGisAutomationApi = new meepGisEngineRestApiClient.AutomationApi();
    this.meepGeoDataApi = new meepGisEngineRestApiClient.GeospatialDataApi();
    this.meepMonEngineApi = new meepMonEngineRestApiClient.PodStatesApi();
  }

  componentWillMount() {
    // Initialize undefined states
    if (this.props.activationInProgressCount === undefined) {
      this.props.changeActivationInProgressCount(-1);
@@ -605,9 +605,10 @@ class AppContainer extends Component {
    this.props.changeActivationInProgressCount(-1);
    this.props.changeActivationInProgressScenarioName('');

    this.props.changeMapUeList([]);
    this.props.changeMapPoaList([]);
    this.props.changeMapComputeList([]);
    this.props.changeMap({ueList: [], poaList: [], computeList: []});
    // this.props.changeMapUeList([]);
    // this.props.changeMapPoaList([]);
    // this.props.changeMapComputeList([]);

    if (this.props.page !== PAGE_HOME) {
      this.setMainContent(PAGE_HOME);
@@ -817,28 +818,43 @@ class AppContainer extends Component {
   * @param {module:model/GeoDataAssetList} data The data returned by the service call.
   * @param {String} response The complete HTTP response.
   */
  getUeAssetDataCb(error, data) {
  getAssetDataCb(error, data) {
    if (error !== null) {
      return;
    }
    var ueList = data.geoDataAssets ? _.sortBy(data.geoDataAssets, ['assetName']) : [];

    // Update UE list with new location & paths (if available)
    if (this.refreshUePaths) {
      // Update UE list with latest paths
      this.props.changeMapUeList(ueList);
      this.refreshUePaths = false;
    } else {
      // Update UE list using paths from previous UE list
    var ueList = [];
    var poaList = [];
    var computeList = [];

    // Extract assets by type
    if (data.geoDataAssets) {
      _.forEach(data.geoDataAssets, asset => {
        switch (asset.assetType) {
        case 'UE':
          ueList.push(asset);
          break;
        case 'POA':
          poaList.push(asset);
          break;
        case 'COMPUTE':
          computeList.push(asset);
          break;
        default:
          break;
        }
      });
    }

    // Use previous UE paths using paths from previous UE list (if not updated)
    if (!this.refreshUePaths) {
      var prevUeList = this.props.map.ueList;
      var prevIndex = 0;
      for (var i = 0; i < ueList.length; i++) {
        var found = false;
        for (var j = prevIndex; j < prevUeList.length; j++) {
        for (var j = 0; j < prevUeList.length; j++) {
          if (ueList[i].assetName === prevUeList[j].assetName) {
            ueList[i].path = prevUeList[j].path;
            found = true;
            prevIndex = j + 1;
            break;
          }
        }
@@ -847,45 +863,21 @@ class AppContainer extends Component {
          this.uePathUpdateRequired = true;
        }
      }
      this.props.changeMapUeList(ueList);
    }
    this.refreshUePaths = false;

    // Update asset map
    var assetMap = {
      ueList: _.sortBy(ueList, ['assetName']),
      poaList: _.sortBy(poaList, ['assetName']),
      computeList: _.sortBy(computeList, ['assetName'])
    };
    this.props.changeMap(assetMap);

    // Sync UE button state with backend
    this.syncUeButtons(ueList);
  }

  /**
   * Callback function to receive the result of the getAssetData operation.
   * @callback module:api/GeospatialDataApi~getAssetDataCallback
   * @param {String} error Error message, if any.
   * @param {module:model/GeoDataAssetList} data The data returned by the service call.
   * @param {String} response The complete HTTP response.
   */
  getPoaAssetDataCb(error, data) {
    if (error !== null) {
      return;
    }

    // Update POA list
    this.props.changeMapPoaList(data.geoDataAssets ? _.sortBy(data.geoDataAssets, ['assetName']) : []);
  }

  // /**
  //  * Callback function to receive the result of the getAssetData operation.
  //  * @callback module:api/GeospatialDataApi~getAssetDataCallback
  //  * @param {String} error Error message, if any.
  //  * @param {module:model/GeoDataAssetList} data The data returned by the service call.
  //  * @param {String} response The complete HTTP response.
  //  */
  getComputeAssetDataCb(error, data) {
    if (error !== null) {
      return;
    }

    // Update Compute list
    this.props.changeMapComputeList(data.geoDataAssets ? _.sortBy(data.geoDataAssets, ['assetName']) : []);
  }

  // Refresh Map
  refreshMap() {
    // If UE cound has increased, include UE paths in the next request
@@ -893,14 +885,8 @@ class AppContainer extends Component {
      this.refreshUePaths = true;
      this.uePathUpdateRequired = false;
    }
    this.meepGeoDataApi.getAssetData({ assetType: 'UE', excludePath: !this.refreshUePaths }, (error, data) =>
      this.getUeAssetDataCb(error, data)
    );
    this.meepGeoDataApi.getAssetData({ assetType: 'POA' }, (error, data) =>
      this.getPoaAssetDataCb(error, data)
    );
    this.meepGeoDataApi.getAssetData({ assetType: 'COMPUTE' }, (error, data) =>
      this.getComputeAssetDataCb(error, data)
    this.meepGeoDataApi.getAssetData({ excludePath: !this.refreshUePaths }, (error, data) =>
      this.getAssetDataCb(error, data)
    );
  }

@@ -1282,7 +1268,7 @@ const mapStateToProps = state => {
    dialogErrorMsg: state.ui.dialogErrorMsg,
    networkFiles: state.ui.networkFiles,
    networkFileSelected: state.ui.networkFileSelected,
    apiTable: state.sbox.apiTable,
    apiTable: state.sbox.apiTable.data,
    highVelocityUeList: state.ui.highVelocityUeList,
    lowVelocityUeList: state.ui.lowVelocityUeList,
    stationaryUeList: state.ui.stationaryUeList,
@@ -1327,6 +1313,7 @@ const mapDispatchToProps = dispatch => {
    // SBOX
    changeScenario: scenario => dispatch(sboxChangeScenario(scenario)),
    changeTable: table => dispatch(sboxChangeTable(table)),
    changeMap: list => dispatch(sboxChangeMap(list)),
    changeMapUeList: list => dispatch(sboxChangeMapUeList(list)),
    changeMapPoaList: list => dispatch(sboxChangeMapPoaList(list)),
    changeMapComputeList: list => dispatch(sboxChangeMapComputeList(list)),
+1 −2
Original line number Diff line number Diff line
@@ -114,8 +114,7 @@ class ApiPane extends Component {
                    fullwidth="true"
                    outlined
                    label="MEC Application Instances"
                    defaultValue={selectedOption}
                    placeholder=" "
                    value={selectedOption}
                    options={options}
                    disabled={!configEnabled}
                    onChange={event => {
+1 −4
Original line number Diff line number Diff line
@@ -101,9 +101,6 @@ const tableColumnData = [
class ApiTable extends Component {
  constructor(props) {
    super(props);
    this.state = {
      dismissibleOpen: true
    };
    this.classes = props.classes;
  }

@@ -261,7 +258,7 @@ ApiTable.propTypes = {
const mapStateToProps = state => {
  return {
    order: state.ui.order,
    apiTable: state.sbox.apiTable,
    apiTable: state.sbox.apiTable.data,
    networkFileSelected: state.ui.networkFileSelected
  };
};
+2 −13
Original line number Diff line number Diff line
@@ -86,7 +86,6 @@ class ConfigPane extends Component {
    }
  }


  decrement(value) {
    return (value === 0) ? value : --value;
  }
@@ -134,11 +133,10 @@ class ConfigPane extends Component {
    this.props.changeAppInstancesTable(null);
    this.props.changeApiDetailedData(null);
    this.updateAutomation(false);
    this.props.changeMecApiSelected('');
  }

  setScenario(name) {

    this.props.changeMecApiSelected('');
    this.props.changeActivationInProgressCount(2);
    this.props.changeActivationInProgressScenarioName(name);
    this.props.changeNetworkFileSelected(name);
@@ -156,7 +154,7 @@ class ConfigPane extends Component {
        this.getScenario(name, true);
      }
    } else {
      //scenari termination
      //scenario termination
      this.props.activateApi.terminateScenario((error, data, response) => {
        this.terminateScenarioCb(error, data, response);
      });
@@ -228,12 +226,6 @@ class ConfigPane extends Component {
    var edgeApps = parseEdgeApps(data);
    this.updateEdgeApps(edgeApps);

    // Reset selected API when network is removed
    const configEnabled = (this.props.networkFileSelected !== DEFAULT_NO_NETWORK_FILE_SELECTED) ? true : false;
    if (!configEnabled) {
      this.props.changeMecApiSelected('');
    }

    // Get UEs info from scenario
    var ues = parseUes(data);

@@ -307,7 +299,6 @@ class ConfigPane extends Component {
  }

  updateEdgeApps(edgeApps) {
    console.log(edgeApps);
    // Set list immediately if new or empty
    if (!edgeApps || !this.props.edgeApps) {
      this.props.changeEdgeAppList(edgeApps);
@@ -333,7 +324,6 @@ class ConfigPane extends Component {
        // Set enable in progress for new edge app
        edgeApp.enableInProgressCount = EDGE_APP_ENABLE_COUNT_MAX;
      }
      console.log(edgeApp);
    }

    // Update Edge app list
@@ -722,7 +712,6 @@ const mapStateToProps = state => {
    stationaryUeList: state.ui.stationaryUeList,
    lowVelocityUeList: state.ui.lowVelocityUeList,
    highVelocityUeList: state.ui.highVelocityUeList,
    apiTable: state.sbox.apiTable,
    edgeApps: state.ui.edgeApps,
    appInstanceTable: state.sbox.appInstanceTable.data,
    scenario: state.sbox.scenario,
+5 −5
Original line number Diff line number Diff line
@@ -761,11 +761,11 @@ class MapInfo extends Component {
      existingMarker.setLatLng(latlng);

      // Refresh marker style if necessary
      var connected = this.isConnected(compute.assetName);
      if (existingMarker.options.meep.compute.connected !== connected) {
      // var connected = this.isConnected(compute.assetName);
      // if (existingMarker.options.meep.compute.connected !== connected) {
      this.setComputeMarkerStyle(existingMarker);
        existingMarker.options.meep.compute.connected = connected;
      }
      //   existingMarker.options.meep.compute.connected = connected;
      // }

      // Refresh marker position
      this.updateComputePopup(existingMarker);
Loading