var onInstanceStateChange = function(type, event) {
   if (_.undefined(event.instanceState)) {
     // Delete event
     if (_.defined($scope.outputAttributesValue[event.nodeTemplateId])) {
       delete $scope.outputAttributesValue[event.nodeTemplateId][event.instanceId];
       if (Object.keys($scope.outputAttributesValue[event.nodeTemplateId]).length === 0) {
         delete $scope.outputAttributesValue[event.nodeTemplateId];
       }
     }
   } else {
     // Add modify event
     var allAttributes = event.attributes;
     for (var attribute in allAttributes) {
       if (allAttributes.hasOwnProperty(attribute) && isOutput(event.nodeTemplateId, attribute, 'outputAttributes')) {
         if (_.undefined($scope.outputAttributesValue[event.nodeTemplateId])) {
           $scope.outputAttributesValue[event.nodeTemplateId] = {};
         }
         if (_.undefined($scope.outputAttributesValue[event.nodeTemplateId][event.instanceId])) {
           $scope.outputAttributesValue[event.nodeTemplateId][event.instanceId] = {};
         }
         // fill up OUTPUT ATTRIBUTES
         $scope.outputAttributesValue[event.nodeTemplateId][event.instanceId][attribute] = allAttributes[attribute];
       }
     }
   }
   $scope.$apply();
 };
Exemple #2
0
 FORMS.setValueForPath = function(root, value, path) {
   var objectToSet = root;
   for (var i = 0; i < path.length - 1; i++) {
     if (angular.isString(path[i])) {
       if (!objectToSet.hasOwnProperty(path[i]) || _.undefined(objectToSet[path[i]])) {
         if (angular.isNumber(path[i + 1])) {
           // The next one is array so initialize an array
           objectToSet[path[i]] = [];
         } else {
           objectToSet[path[i]] = {};
         }
       }
     } else if (angular.isNumber(path[i])) {
       if (_.undefined(objectToSet[path[i]])) {
         if (angular.isNumber(path[i + 1])) {
           // The next one is array so initialize an array
           objectToSet[path[i]] = [];
         } else {
           objectToSet[path[i]] = {};
         }
       }
     }
     objectToSet = objectToSet[path[i]];
   }
   objectToSet[path[path.length - 1]] = value;
 };
 isOutputCapabilityProperty: function(capabilityId, propertyId) {
   var scope = this.scope;
   if (_.undefined(scope.topology.topology.outputCapabilityProperties) || _.undefined(scope.topology.topology.outputCapabilityProperties[scope.selectedNodeTemplate.name]) || _.undefined(scope.topology.topology.outputCapabilityProperties[scope.selectedNodeTemplate.name][capabilityId])) {
     return false;
   }
   return scope.topology.topology.outputCapabilityProperties[scope.selectedNodeTemplate.name][capabilityId].indexOf(propertyId) >= 0;
 },
 addNodeTemplateToTree: function(tree, nodeTemplate, nodeTemplates, relationshipTypes) {
   if(_.undefined(nodeTemplate.children)) {
     nodeTemplate.children = [];
   }
   if(_.undefined(nodeTemplate.attached)) {
     nodeTemplate.attached = [];
   }
   nodeTemplate.weight = 0;
   // get relationships that we want to display as hosted on.
   var relationships = this.getHostedOnRelationships(nodeTemplate, relationshipTypes);
   if (relationships.length > 0) {
     // TODO we should not have more than a single hosted on actually. Manage if not.
     var parent = nodeTemplates[relationships[0].target];
     _.safePush(parent, 'children', nodeTemplate);
     nodeTemplate.parent = parent;
   } else {
     // Manage the attach relationship in a specific way in order to display the storage close to the compute.
     relationships = this.getAttachedToRelationships(nodeTemplate, relationshipTypes);
     if (relationships.length > 0) {
       var target = nodeTemplates[relationships[0].target];
       _.safePush(target, 'attached', nodeTemplate);
       nodeTemplate.parent = tree;
       nodeTemplate.isAttached = true;
     } else {
       // if the node is not hosted on another node just add it to the root.
       tree.children.push(nodeTemplate);
       nodeTemplate.parent = tree;
     }
   }
 },
Exemple #5
0
      link: function(scope, element) {
        FORMS.initFormScope('abstractTypeFormLabel', scope, element);
        FORMS.initComplexFormScope(scope);
        for (var discriminantProperty in scope.propertyType._implementationTypes) {
          if (scope.propertyType._implementationTypes.hasOwnProperty(discriminantProperty)) {
            var currentImplementation = scope.propertyType._implementationTypes[discriminantProperty];
            currentImplementation._id = discriminantProperty;
            // Try to get discriminant property value to guess the implementation used
            var discriminantPropertyPath = FORMS.addKeyToPath(scope.path, discriminantProperty);
            var discriminantPropertyValue = FORMS.getValueForPath(scope.rootObject, discriminantPropertyPath);
            if (_.undefined(scope.propertyType._selectedImplementation)) {
              scope.propertyType._selectedImplementation = {};
            }
            // The property value can be null, we use the presence of value even if it's null to get the implementation
            if (angular.isDefined(discriminantPropertyValue)) {
              scope.propertyType._selectedImplementation[scope.propertyName] = discriminantProperty;
            } else if (_.undefined(scope.propertyType._selectedImplementation[scope.propertyName])) {
              scope.propertyType._selectedImplementation[scope.propertyName] = currentImplementation._id;
            }
          }
        }

        scope.$watch('propertyName', function(newValue, oldValue) {
          if (newValue !== oldValue) {
            scope.propertyType._selectedImplementation[newValue] = scope.propertyType._selectedImplementation[oldValue];
            delete scope.propertyType._selectedImplementation[oldValue];
          }
        });

        element.on('$destroy', function() {
          delete scope.propertyType._selectedImplementation[scope.propertyName];
        });
      }
Exemple #6
0
 }, function success(result) {
   if (_.undefined(result.error)) {
     if (_.undefined(group.roles)) {
       group.roles = [];
     }
     group.roles.push(role);
     $rootScope.$emit('groupsChanged');
   }
 });
 $scope.filteredGroups = function(groups, user) {
   if (_.undefined(user.groups) || _.undefined(groups)) {
     return groups;
   }
   var filteredGroups = [];
   for (var int = 0; int < groups.length; int++) {
     if (!_.contains(user.groups, groups[int].name)) {
       filteredGroups.push(groups[int]);
     }
   }
   return filteredGroups;
 };
Exemple #8
0
 orchestratorsService.get({}, null, function(orchestratorResult){
   if(_.undefined(orchestratorResult.data) || _.undefined(orchestratorResult.data.data)) { return; }
   _.each(orchestratorResult.data.data, function(orchestrator){
     locationsService.get({
       orchestratorId: orchestrator.id
     }, null, function(locationResult){
       if(_.undefined(locationResult.data)) { return; }
       _.each(locationResult.data, function(location) {
         location.location.orchestratorName = orchestrator.name;
         $scope.locations.push(location.location);
       });
     });
   });
 });
Exemple #9
0
 scope.inputChanged = function(propertyDefinition, propertyValue) {
   if (_.undefined(propertyValue)) {
     FORMS.deleteValueForPath(scope.rootObject, scope.path);
     if (scope.configuration.automaticSave) {
       scope.saveAction(scope.rootObject);
     }
   } else  {
     if (_.isObject(propertyValue) || _.isArray(propertyValue)) {
       // It's an object or an array then don't try to validate constraints
       FORMS.setValueForPath(scope.rootObject, propertyValue, scope.path);
       if (scope.configuration.automaticSave) {
         scope.saveAction(scope.rootObject);
       }
     } else {
       // Only check constraint for primitive properties
       var checkPropertyRequest = {
         'definitionId': scope.propertyName,
         'propertyDefinition': propertyDefinition,
         'value': propertyValue
       };
       return propertiesServices.validConstraints({}, angular.toJson(checkPropertyRequest), function(successResult) {
         if (successResult.error === null) {
           // No error save the result
           FORMS.setValueForPath(scope.rootObject, propertyValue, scope.path);
           if (scope.configuration.automaticSave) {
             scope.saveAction(scope.rootObject);
           }
         }
       }).$promise;
     }
   }
 };
        horizontal: function(graph, nodeKey, node, x, y) {
          var instance = this;

          var successors = graph.successors(nodeKey);
          var successorCoordinates = node.successorCoordinates;
          if(_.undefined(successorCoordinates)) {
            successorCoordinates = [];
            node.successorCoordinates = successorCoordinates;
          }
          if(successors.length === 0 || successors.length === (successorCoordinates.length+1)) {
            // compute and store the node position
            var minX = x; // x should be min
            var minY = y; // y should be the middle of common group
            _.each(node.successorCoordinates, function(coordinates){
              minX = Math.min(coordinates.x, minX);
              minY = Math.min(coordinates.y, minY);
            });
            node.x = minX;
            node.y = minY;

            // compute the predecessors
            var predecessors = graph.predecessors(nodeKey);
            // compute the y locations based on the predecessor
            _.each(predecessors, function(predecessorKey) {
              var predecessor = graph.node(predecessorKey);
              var xShift = (node.width/2) + (predecessor.width/2) + instance.xPadding;
              // we should be under the target bbox
              instance.horizontal(graph, predecessorKey, predecessor, x-xShift, y);
            });
          } else {
            // store the value for later computation
            node.successorCoordinates.push({x: x, y: y});
          }
        }
      // link output properties based on values that exists in the topology's node templates.
      function refreshOutputProperties() {
        var i;
        for (var nodeId in $scope.outputProperties) {
          if ($scope.outputProperties.hasOwnProperty(nodeId)) {
            $scope.outputPropertiesValue[nodeId] = {};
            for (i = 0; i < $scope.outputProperties[nodeId].length; i++) {
              var outputPropertyName = $scope.outputProperties[nodeId][i];
              $scope.outputPropertiesValue[nodeId][outputPropertyName] = $scope.nodeTemplates[nodeId].propertiesMap[outputPropertyName].value;
            }
          }
        }

        if (!_.undefined($scope.outputCapabilityProperties)) {
          for (nodeId in $scope.outputCapabilityProperties) {
            if ($scope.outputCapabilityProperties.hasOwnProperty(nodeId)) {
              $scope.outputCapabilityPropertiesValue[nodeId] = {};
              for (var capabilityId in $scope.outputCapabilityProperties[nodeId]) {
                if ($scope.outputCapabilityProperties[nodeId].hasOwnProperty(capabilityId)) {
                  $scope.outputCapabilityPropertiesValue[nodeId][capabilityId] = {};
                  for (i = 0; i < $scope.outputCapabilityProperties[nodeId][capabilityId].length; i++) {
                    var outputCapabilityPropertyName = $scope.outputCapabilityProperties[nodeId][capabilityId][i];
                    $scope.outputCapabilityPropertiesValue[nodeId][capabilityId][outputCapabilityPropertyName] = $scope.nodeTemplates[nodeId].capabilitiesMap[capabilityId].value.propertiesMap[outputCapabilityPropertyName].value;
                  }
                }
              }
            }
          }
        }
      }
    function ($scope) {
      // do nothin if there is no resource
      if(_.undefined($scope.resource)){
        return;
      }

      $scope.searchAuthorizedEnvironmentsPerApplication = function () {
        $scope.envService.get({}, function (response) {
          $scope.authorizedEnvironmentsPerApplication = response.data;
        });
      };
      $scope.searchAuthorizedEnvironmentsPerApplication();

      $scope.onModalClose = function(result){
        $scope.envService.save(result.subjects, $scope.searchAuthorizedEnvironmentsPerApplication);
      };

      $scope.revoke = function (application) {
        // here if application has env or not then do different things
        $scope.appService.delete({
          applicationId: application.application.id
        }, $scope.searchAuthorizedEnvironmentsPerApplication);
      };

      $scope.$watch('resource.id', function(newValue, oldValue){
        if(newValue === oldValue){
          return;
        }
        $scope.searchAuthorizedEnvironmentsPerApplication();
      });
    }
Exemple #13
0
 }, angular.toJson(updateRequest), function(result) {
   globalRestErrorHandler.handle(result);
   if(_.undefined(result.error)){
     $scope.selectedService.nodeInstance.attributeValues.state = newState;
     $scope.stateDisabled = !$scope.stateDisabled;
   }
 });
Exemple #14
0
    return function(text, toReplaceString, replacementString) {
      if (_.undefined(toReplaceString)) {
        return text;
      }

      if (_.undefined(replacementString)) {
        replacementString = '';
      }

      if (_.undefined(text)) {
        return '';
      }

      var re = new RegExp(toReplaceString, 'g');
      return String(text).replace(re, replacementString);
    };
Exemple #15
0
      $scope.handleRoleSelectionForUser = function(user, role) {
        if (_.undefined($scope.cloud.userRoles)) {
          $scope.cloud.userRoles = {};
        }
        var cloudUserRoles = $scope.cloud.userRoles[user.username];
        if (!cloudUserRoles || cloudUserRoles.indexOf(role) < 0) {

          cloudServices.userRoles.addUserRole([], {
            cloudId: $scope.cloud.id,
            username: user.username,
            role: role
          }, function() {
            $scope.cloud.userRoles[user.username] = updateRoles(cloudUserRoles, role, 'add');
            if (!$scope.relatedUsers[user.username]) {
              $scope.relatedUsers[user.username] = user;
            }
          });

        } else {
          cloudServices.userRoles.removeUserRole([], {
            cloudId: $scope.cloud.id,
            username: user.username,
            role: role
          }, function() {
            $scope.cloud.userRoles[user.username] = updateRoles(cloudUserRoles, role, 'remove');
          });
        }
      };
 isOutputAttribute: function(attributeName) {
   var scope = this.scope;
   if (_.undefined(scope.topology.topology.outputAttributes)) {
     return false;
   }
   return scope.topology.topology.outputAttributes[scope.selectedNodeTemplate.name].indexOf(attributeName) >= 0;
 },
 isOutputProperty: function(propertyName) {
   var scope = this.scope;
   if (_.undefined(scope.topology.topology.outputProperties)) {
     return false;
   }
   return scope.topology.topology.outputProperties[scope.selectedNodeTemplate.name].indexOf(propertyName) >= 0;
 },
      $scope.handleEnvRoleSelectionForGroup = function(group, role) {
        if (_.undefined($scope.selectedEnvironment.groupRoles)) {
          $scope.selectedEnvironment.groupRoles = {};
        }
        var envGroupRoles = $scope.selectedEnvironment.groupRoles[group.id];
        var envId = $scope.selectedEnvironment.id;
        if (!envGroupRoles || envGroupRoles.indexOf(role) < 0) {

          applicationEnvironmentServices.groupRoles.addGroupRole([], {
            applicationEnvironmentId: envId,
            applicationId: $scope.application.id,
            groupId: group.id,
            role: role
          }, function() {
            $scope.selectedEnvironment.groupRoles[group.id] = updateRoles(envGroupRoles, role, 'add');
            if (!$scope.relatedGroups[group.id]) {
              $scope.relatedGroups[group.id] = group;
            }
          });

        } else {
          applicationEnvironmentServices.groupRoles.removeGroupRole([], {
            applicationEnvironmentId: envId,
            applicationId: $scope.application.id,
            groupId: group.id,
            role: role
          }, function() {
            $scope.selectedEnvironment.groupRoles[group.id] = updateRoles(envGroupRoles, role, 'remove');
          });
        }
      };
      $scope.handleEnvRoleSelectionForUser = function(user, role) {
        if (_.undefined($scope.selectedEnvironment.userRoles)) {
          $scope.selectedEnvironment.userRoles = {};
        }
        var envUserRoles = $scope.selectedEnvironment.userRoles[user.username];
        var envId = $scope.selectedEnvironment.id;
        if (!envUserRoles || envUserRoles.indexOf(role) < 0) {

          applicationEnvironmentServices.userRoles.addUserRole([], {
            applicationEnvironmentId: envId,
            applicationId: $scope.application.id,
            username: user.username,
            role: role
          }, function() {
            $scope.selectedEnvironment.userRoles[user.username] = updateRoles(envUserRoles, role, 'add');
            if (!$scope.relatedUsers[user.username]) {
              $scope.relatedUsers[user.username] = user;
            }
          });

        } else {
          applicationEnvironmentServices.userRoles.removeUserRole([], {
            applicationEnvironmentId: envId,
            applicationId: $scope.application.id,
            username: user.username,
            role: role
          }, function() {
            $scope.selectedEnvironment.userRoles[user.username] = updateRoles(envUserRoles, role, 'remove');
          });
        }
      };
      $scope.handleAppRoleSelectionForGroup = function(group, role) {
        if (_.undefined($scope.application.groupRoles)) {
          $scope.application.groupRoles = {};
        }
        var appGroupRoles = $scope.application.groupRoles[group.id];
        if (!appGroupRoles || appGroupRoles.indexOf(role) < 0) {
          applicationServices.groupRoles.addGroupRole([], {
            applicationId: $scope.application.id,
            groupId: group.id,
            role: role
          }, function() {
            $scope.application.groupRoles[group.id] = updateRoles(appGroupRoles, role, 'add');
            if (!$scope.relatedGroups[group.id]) {
              $scope.relatedGroups[group.id] = group;
            }
          });

        } else {
          applicationServices.groupRoles.removeGroupRole([], {
            applicationId: $scope.application.id,
            groupId: group.id,
            role: role
          }, function() {
            $scope.application.groupRoles[group.id] = updateRoles(appGroupRoles, role, 'remove');
          });
        }
      };
 _.each(searchResult.data.data, function(component){
   component.selectedVersion = component.archiveVersion;
   if(_.undefined(component.olderVersions)) {
     component.olderVersions = [];
   }
   component.olderVersions.splice(0, 0, component.archiveVersion);
 });
      $scope.handleAppRoleSelectionForUser = function(user, role) {
        if (_.undefined($scope.application.userRoles)) {
          $scope.application.userRoles = {};
        }
        var appUserRoles = $scope.application.userRoles[user.username];

        if (!appUserRoles || appUserRoles.indexOf(role) < 0) {

          applicationServices.userRoles.addUserRole([], {
            applicationId: $scope.application.id,
            username: user.username,
            role: role
          }, function() {
            $scope.application.userRoles[user.username] = updateRoles(appUserRoles, role, 'add');
            if (!$scope.relatedUsers[user.username]) {
              $scope.relatedUsers[user.username] = user;
            }
          });

        } else {
          applicationServices.userRoles.removeUserRole([], {
            applicationId: $scope.application.id,
            username: user.username,
            role: role
          }, function() {
            $scope.application.userRoles[user.username] = updateRoles(appUserRoles, role, 'remove');
          });
        }
      };
 $scope.doUploadArtifact = function(file, artifactName) {
   if (_.undefined($scope.uploads)) {
     $scope.uploads = {};
   }
   $scope.uploads[artifactName] = {
     'isUploading': true,
     'type': 'info'
   };
   $upload.upload({
     url: 'rest/topologies/' + $scope.topologyDTO.topology.id + '/inputArtifacts/' + artifactName + '/upload',
     file: file
   }).progress(function(evt) {
     $scope.uploads[artifactName].uploadProgress = parseInt(100.0 * evt.loaded / evt.total);
   }).success(function(success) {
     $scope.inputArtifacts[artifactName].artifactRef = success.data.topology.inputArtifacts[artifactName].artifactRef;
     $scope.inputArtifacts[artifactName].artifactName = success.data.topology.inputArtifacts[artifactName].artifactName;
     $scope.uploads[artifactName].isUploading = false;
     $scope.uploads[artifactName].type = 'success';
   }).error(function(data, status) {
     $scope.uploads[artifactName].type = 'error';
     $scope.uploads[artifactName].error = {};
     $scope.uploads[artifactName].error.code = status;
     $scope.uploads[artifactName].error.message = 'An Error has occurred on the server!';
   });
 };
Exemple #24
0
 }, null, function(locationResult){
   if(_.undefined(locationResult.data)) { return; }
   _.each(locationResult.data, function(location) {
     location.location.orchestratorName = orchestrator.name;
     $scope.locations.push(location.location);
   });
 });
Exemple #25
0
      $scope.handleRoleSelectionForGroup = function(group, role) {
        if (_.undefined($scope.cloud.groupRoles)) {
          $scope.cloud.groupRoles = {};
        }
        var cloudGroupRoles = $scope.cloud.groupRoles[group.id];

        if (!cloudGroupRoles || cloudGroupRoles.indexOf(role) < 0) {
          cloudServices.groupRoles.addGroupRole([], {
            cloudId: $scope.cloud.id,
            groupId: group.id,
            role: role
          }, function() {
            $scope.cloud.groupRoles[group.id] = updateRoles(cloudGroupRoles, role, 'add');
            if (!$scope.relatedGroups[group.id]) {
              $scope.relatedGroups[group.id] = group;
            }
          });

        } else {
          cloudServices.groupRoles.removeGroupRole([], {
            cloudId: $scope.cloud.id,
            groupId: group.id,
            role: role
          }, function() {
            $scope.cloud.groupRoles[group.id] = updateRoles(cloudGroupRoles, role, 'remove');
          });
        }
      };
      $scope.propertySave = function(data, unit) {
        delete $scope.unitError;
        if (_.isBoolean(data)) {
          data = data.toString();
        } else if (_.isEmpty(data)) {
          data = null;
        }

        if (!_.isEmpty(data) && _.defined($scope.definitionObject.units)) {
          if (_.undefined(unit)) {
            unit = $scope.definitionObject.uiUnit;
          }
          data += ' ' + unit;
        }
        // check constraint here
        var propertyRequest = {
          propertyName: $scope.propertyName,
          propertyDefinition: $scope.definition,
          propertyValue: data
        };

        if (_.defined($scope.definition.suggestionId) && _.defined(data) && data !== null) {
          return propertySuggestionServices.get({
            input: data,
            limit: 5,
            suggestionId: $scope.definition.suggestionId
          }).$promise.then(function(suggestionResult) {
            var promise;
            $scope.propertySuggestionData = {
              suggestions: suggestionResult.data,
              propertyValue: data
            };
            if (suggestionResult.data.indexOf(data) < 0) {
              var modalInstance = $modal.open({
                templateUrl: 'propertySuggestionModal.html',
                controller: PropertySuggestionModalCtrl,
                scope: $scope
              });
              promise = modalInstance.result.then(function(modalResult) {
                if (suggestionResult.data.indexOf(modalResult) < 0) {
                  propertySuggestionServices.add([], {
                    suggestionId: $scope.definition.suggestionId,
                    value: modalResult
                  }, null);
                }
                propertyRequest.propertyValue = modalResult;
                return callSaveService(propertyRequest);
              }, function() {
                return $translate("CANCELLED");
              });
            } else {
              promise = callSaveService(propertyRequest);
            }
            return promise;
          });
        } else {
          return callSaveService(propertyRequest);
        }
      };
 function(result) {
   if (_.undefined(result.error)) {
     scope.topology.topology.nodeTemplates[scope.selectedNodeTemplate.name].capabilitiesMap[capabilityId].value.propertiesMap[propertyName].value = { value: propertyValue, definition: false };
     if (capabilityType === 'tosca.capabilities.Scalable') {
       scope.triggerTopologyRefresh = {};
     }
   }
 },
 _.each(edges, function(edge) {
   var edgeData = graph.edge(edge.v, edge.w);
   var mergeId = graph.node(edge.w).mergeId;
   if(_.undefined(mergeId)) {
     mergeId = edge.w;
   }
   simpleGraph.setEdge(edge.v, mergeId, edgeData);
 });
Exemple #29
0
 FORMS.getValueForPath = function(root, path) {
   if (_.isEmpty(path)) {
     return root;
   }
   var objectToSet = root;
   for (var i = 0; i < path.length - 1; i++) {
     if (_.undefined(objectToSet) || !objectToSet.hasOwnProperty(path[i])) {
       return undefined;
     }
     objectToSet = objectToSet[path[i]];
   }
   if (_.undefined(objectToSet)) {
     return undefined;
   } else {
     return objectToSet[path[path.length - 1]];
   }
 };
Exemple #30
0
 FORMS.deleteValueForPath = function(root, path) {
   var objectToSet = root;
   for (var i = 0; i < path.length - 1; i++) {
     objectToSet = objectToSet[path[i]];
     if (_.undefined(objectToSet)) {
       return;
     }
   }
   if (_.undefined(objectToSet)) {
     return;
   }
   if (angular.isNumber(path[path.length - 1])) {
     objectToSet.splice(path[path.length - 1], 1);
   } else {
     delete objectToSet[path[path.length - 1]];
   }
 };