Пример #1
0
 public void UpdateWans(bool forceRefresh)
 {
     panel.SetActive(true);
     DestroyWans();
     // Get WANs from SteelConnect API
     _dataManager.GetWans(forceRefresh)
     .Then(wans => wans.ForEach(wan => {
         _wans.Add(wan);
     }))
     .Then(() =>
           // Get uplinks from SteelConnect API
           _dataManager.GetUplinks(forceRefresh)
           .Then(uplinks => uplinks.ForEach(uplink => {
         this.uplinks[uplink.id] = uplink;
     })))
     .Then(() => {
         // Create WAN gameObjects
         bool nameTextOnTop = true;
         foreach (Wan wan in _wans)
         {
             GameObject newWanMarkerObject = Instantiate(wanPrefab, panel.transform);
             WanMarker newWanMarker        = newWanMarkerObject.GetComponent <WanMarker>();
             newWanMarker.wan = wan;
             // Alternate WAN name Y position
             if (nameTextOnTop)
             {
                 newWanMarker.text.transform.localPosition = new Vector3(_nameTextXPosition, _nameTextOnTopYPosition, _nameTextZPosition);
             }
             nameTextOnTop = !nameTextOnTop;
             Debug.Log($"Created {wan.id}");
             // Create Uplink Marker Objects for each WAN
             foreach (string uplinkID in wan.uplinks)
             {
                 GameObject newUplinkMarkerObject = Instantiate(uplinkPrefab, newWanMarker.uplinks.transform);
                 UplinkMarker newUplinkMarker     = newUplinkMarkerObject.GetComponent <UplinkMarker>();
                 newUplinkMarker.uplink           = uplinks[uplinkID];
                 newUplinkMarker.wan = newWanMarkerObject;
                 string uplinkSiteID = newUplinkMarker.uplink.site;
                 if (_stateManager.currentSiteMarkers.ContainsKey(uplinkSiteID))
                 {
                     newUplinkMarker.site = _stateManager.currentSiteMarkers[uplinkSiteID].gameObject;
                 }
                 else
                 {
                     Debug.LogError($"Site does not exist: {uplinkSiteID}");
                 }
             }
         }
         ShowHideUplinks();
     });
 }
Пример #2
0
    public void UpdateInformation()
    {
        UplinkMarker uplinkMarker = _uplinkObject.GetComponent <UplinkMarker>();
        Uplink       uplink       = uplinkMarker.uplink;
        string       text         = $"Id: {uplink.id}\n" +
                                    $"Name: {uplink.name}\n" +
                                    $"Org: {uplink.org}\n" +
                                    $"Site: {uplink.site}\n" +
                                    $"WAN: {uplink.wan}\n" +
                                    $"Appliance: {uplink.node}";
        TextMesh textMesh = GetComponent <TextMesh>();

        textMesh.text = text;
    }
Пример #3
0
 public void OnPointerDown(PointerEventData eventData)
 {
     // Delete WAN
     if (_stateManager.currentMode == StateManagerMode.Delete)
     {
         // Confirmation panel
         _stateManager.ShowConfirm();
         _stateManager.SetDeleteConfirmText(gameObject, wan.name);
     }
     else
     {
         // Create uplink GameObject
         _currentUplinkCreation = Instantiate(uplinkPrefab, transform);
         UplinkMarker uplinkMarker = _currentUplinkCreation.GetComponent <UplinkMarker>();
         uplinkMarker.created = false;
     }
 }
Пример #4
0
 public void OnPointerUp(PointerEventData eventData)
 {
     // Create uplink if selecting site
     if (_stateManager.currentMode != StateManagerMode.Delete)
     {
         if (_stateManager.currentObjectHover && _stateManager.currentObjectHover.tag == _siteLayer)
         {
             GameObject currentSite = _stateManager.currentObjectHover;
             _uplinks.Add(_currentUplinkCreation);
             string siteId = currentSite.GetComponent <SiteMarker>().site.id;
             Debug.Log($"Creating uplink {_currentUplinkCreation} from WAN: {wan.id} to site:{siteId}");
             _uplinkCreationInProgress = _currentUplinkCreation;
             // Create uplink API call
             _steelConnect.CreateUplink(wan.id, siteId)
             .Then(response => {
                 Uplink uplinkResponse = JsonUtility.FromJson <Uplink>(response.Text);
                 Debug.Log($"Uplink created {uplinkResponse.id} from WAN: {wan.id} to site:{siteId}");
                 UplinkMarker uplinkMarker = _uplinkCreationInProgress.GetComponent <UplinkMarker>();
                 GameObject line           = _uplinkCreationInProgress.transform.Find("Line").gameObject;
                 line.GetComponent <BoxCollider>().enabled = true;
                 uplinkMarker.created     = true;
                 uplinkMarker.uplink.id   = uplinkResponse.id;
                 uplinkMarker.uplink.name = uplinkResponse.name;
                 uplinkMarker.uplink.node = uplinkResponse.node;
                 uplinkMarker.uplink.org  = uplinkResponse.org;
                 uplinkMarker.uplink.site = uplinkResponse.site;
                 uplinkMarker.uplink.wan  = uplinkResponse.wan;
                 uplinkMarker.UpdateInformation();
                 uplinkMarker.wan  = gameObject;
                 uplinkMarker.site = currentSite;
                 _uplinkCreationInProgress.transform.parent = uplinks.transform;
                 _uplinkCreationInProgress = null;
             });
         }
         else
         {
             Destroy(_currentUplinkCreation);
         }
         _currentUplinkCreation = null;
     }
 }
Пример #5
0
    private void DeleteUplink(GameObject gameObjectUplink)
    {
        UplinkMarker uplinkMarker = gameObjectUplink.GetComponent <UplinkMarker>();

        uplinkMarker.DeleteUplink();
    }