aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-08-10 12:08:45 +0300
committerMichael Lando <ml636r@att.com>2017-08-10 12:08:45 +0300
commit46f9fd57f24428f6a6fd0d290b0463e188975231 (patch)
tree7805037b80cbabf61bafc719e2d63b0dfff8f751 /catalog-ui
parent7f7925e39cf2f428061d161bc4ffe67cad80c76e (diff)
[SDC] code sync
Change-Id: Ia33a7874802b8ac2f49aed9199e109ea509e950e Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui')
-rw-r--r--catalog-ui/src/app/directives/file-opener/file-opener.ts5
-rw-r--r--catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html3
-rw-r--r--catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts42
-rw-r--r--catalog-ui/src/app/services/onboarding-service.ts16
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts56
-rw-r--r--catalog-ui/src/assets/styles/global.less1
6 files changed, 93 insertions, 30 deletions
diff --git a/catalog-ui/src/app/directives/file-opener/file-opener.ts b/catalog-ui/src/app/directives/file-opener/file-opener.ts
index c09d6fc553..4abd2573bb 100644
--- a/catalog-ui/src/app/directives/file-opener/file-opener.ts
+++ b/catalog-ui/src/app/directives/file-opener/file-opener.ts
@@ -51,8 +51,9 @@ export class FileOpenerDirective implements ng.IDirective {
scope.onFileSelect = () => {
scope.onFileUpload({file: scope.importFile});
- element.html('app/directives/file-opener/file-opener.html');
- this.$compile(element.contents())(scope);
+ // fix bug 311261
+ // element.html('app/directives/file-opener/file-opener.html');
+ // this.$compile(element.contents())(scope);
};
scope.getExtensionsWithDot = ():string => {
diff --git a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html
index 57da7d90e4..3ffc9c16be 100644
--- a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html
+++ b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html
@@ -38,7 +38,7 @@
<ng-container *ngIf="!property.isDeclared">
<a *ngIf="(propType == derivedPropertyTypes.LIST || propType == derivedPropertyTypes.MAP) && !property.isChildOfListOrMap" class="property-icon add-item" (click)="createNewChildProperty();" [ngClass]="{'disabled':readonly || preventInsertItem(property)}">Add value to list</a>
<span *ngIf="property.isChildOfListOrMap" (click)="deleteItem.emit(property);" class="property-icon sprite-new delete-item-icon" [ngClass]="{'disabled':readonly}"></span>
- <span *ngIf="!isPropertyFEModel && (propType == derivedPropertyTypes.COMPLEX || ((propType == derivedPropertyTypes.LIST || propType == derivedPropertyTypes.MAP) && hasChildren()))" (click)="expandChildById(propPath)" class="property-icon sprite-new round-expand-icon" [class.open]="expandedChildId.indexOf(propPath) == 0"></span>
+ <span *ngIf="!isPropertyFEModel && (propType == derivedPropertyTypes.COMPLEX || ((propType == derivedPropertyTypes.LIST || propType == derivedPropertyTypes.MAP) && hasChildren))" (click)="expandChildById(propPath)" class="property-icon sprite-new round-expand-icon" [class.open]="expandedChildId.indexOf(propPath) == 0"></span>
</ng-container>
</div>
@@ -52,6 +52,7 @@
[expandedChildId]="expandedChildId"
[propertyNameSearchText]="propertyNameSearchText"
[readonly]="readonly"
+ [hasChildren]="getHasChildren(prop)"
(valueChanged)="childValueChanged(prop)"
(mapKeyChanged)="removeValueFromParent(prop, $event)"
(expandChild)="expandChildById($event)"
diff --git a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts
index 3982e4e8dc..9cf043098b 100644
--- a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts
+++ b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts
@@ -46,6 +46,7 @@ export class DynamicPropertyComponent {
@Input() selectedPropertyId: string;
@Input() propertyNameSearchText: string;
@Input() readonly: boolean;
+ @Input() hasChildren: boolean;
@Output() valueChanged: EventEmitter<any> = new EventEmitter<any>();
@Output() expandChild: EventEmitter<string> = new EventEmitter<string>();
@@ -83,8 +84,10 @@ export class DynamicPropertyComponent {
this.checkProperty.emit(propName);
}
- hasChildren = (): number => {
- return (this.property.valueObj && typeof this.property.valueObj == 'object') ? Object.keys(this.property.valueObj).length : 0;
+ getHasChildren = (property:DerivedFEProperty): boolean => {// enter to this function only from base property (PropertyFEModel) and check for child property if it has children
+ return _.filter((<PropertyFEModel>this.property).flattenedChildren,(prop:DerivedFEProperty)=>{
+ return _.startsWith(prop.propertiesName + '#', property.propertiesName);
+ }).length > 1;
}
createNewChildProperty = (): void => {
@@ -106,15 +109,26 @@ export class DynamicPropertyComponent {
if(!newProps[0].schema.property.isSimpleType){
- angular.forEach(newProps, (prop:DerivedFEProperty):void => { //Update parent PropertyFEModel with value for each child, including nested props
+ if ( newProps[0].mapKey ) {//prevent update the new item value on parent property valueObj and saving on BE if it is map item, it will be updated and saved only after user enter key (when it is list item- the map key is the es type)
+ this.updateMapKeyValueOnMainParent(newProps);
+ if (this.property.getParentNamesArray(newProps[0].propertiesName, []).indexOf('') === -1) {
+ this.valueChanged.emit(this.property.name);
+ }
+ }
+ }
+ }
+ }
+
+ updateMapKeyValueOnMainParent(childrenProps: Array<DerivedFEProperty>){
+ if (this.property instanceof PropertyFEModel) {
+ //Update only if all this property parents has key name
+ if (this.property.getParentNamesArray(childrenProps[0].propertiesName, []).indexOf('') === -1){
+ angular.forEach(childrenProps, (prop:DerivedFEProperty):void => { //Update parent PropertyFEModel with value for each child, including nested props
(<PropertyFEModel>this.property).childPropUpdated(prop);
},this);
//grab the cumulative value for the new item from parent PropertyFEModel and assign that value to DerivedFEProp[0] (which is the list or map parent with UUID of the set we just added)
- let parentNames = (<PropertyFEModel>this.property).getParentNamesArray(newProps[0].propertiesName, []);
- newProps[0].valueObj = _.get(this.property.valueObj, parentNames.join('.'));
- if ( newProps[0].mapKey ) {//prevent saving if it is map item, whem it is list item- the map key is the es type (it will be saved only after user enter key)
- this.valueChanged.emit(this.property.name);
- }
+ let parentNames = (<PropertyFEModel>this.property).getParentNamesArray(childrenProps[0].propertiesName, []);
+ childrenProps[0].valueObj = _.get(this.property.valueObj, parentNames.join('.'));
}
}
}
@@ -122,9 +136,9 @@ export class DynamicPropertyComponent {
childValueChanged = (property: DerivedFEProperty) => { //value of child property changed
if (this.property instanceof PropertyFEModel) { // will always be the case
- this.property.childPropUpdated(property);
- this.dataTypeService.checkForCustomBehavior(this.property);
if (this.property.getParentNamesArray(property.propertiesName, []).indexOf('') === -1) {//If one of the parents is empty key -don't save
+ this.property.childPropUpdated(property);
+ this.dataTypeService.checkForCustomBehavior(this.property);
this.valueChanged.emit(this.property.name);
}
}
@@ -156,6 +170,14 @@ export class DynamicPropertyComponent {
target.setCustomValidity('');
_.set(itemParent.valueObj, replaceKey, itemParent.valueObj[oldKey]);
item.mapKey = replaceKey;
+ //If the map key was empty its valueObj was not updated on its prent property valueObj, and now we should update it.
+ if(!oldKey && !item.schema.property.isSimpleType){
+ //Search this map item children and update these value on parent property valueOBj
+ let mapKeyFlattenChildren:Array<DerivedFEProperty> = _.filter(this.property.flattenedChildren, (prop:DerivedFEProperty) => {
+ return _.startsWith(prop.propertiesName, item.propertiesName);
+ });
+ this.updateMapKeyValueOnMainParent(mapKeyFlattenChildren);
+ }
}
}
delete itemParent.valueObj[oldKey];
diff --git a/catalog-ui/src/app/services/onboarding-service.ts b/catalog-ui/src/app/services/onboarding-service.ts
index db6c72699a..3dd7269326 100644
--- a/catalog-ui/src/app/services/onboarding-service.ts
+++ b/catalog-ui/src/app/services/onboarding-service.ts
@@ -44,11 +44,21 @@ export class OnboardingService implements IOnboardingService {
this.api = sdcConfig.api;
}
- getOnboardingComponents = ():ng.IPromise<Array<IComponent>> => {
- let defer = this.$q.defer<Array<IComponent>>();
+ getOnboardingVSPs = ():ng.IPromise<Array<ICsarComponent>> =>{
+ let defer = this.$q.defer<Array<ICsarComponent>>();
this.$http.get(this.api.GET_onboarding)
.then((response:any) => {
- let onboardingComponents:Array<ICsarComponent> = response.data.results;
+ defer.resolve(response.data.results);
+ },(response) => {
+ defer.reject(response);
+ });
+
+ return defer.promise;
+ };
+
+ getOnboardingComponents = ():ng.IPromise<Array<IComponent>> => {
+ let defer = this.$q.defer<Array<IComponent>>();
+ this.getOnboardingVSPs().then((onboardingComponents:Array<ICsarComponent>) => {
let componentsList:Array<IComponent> = new Array();
onboardingComponents.forEach((obc:ICsarComponent) => {
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
index 98539d6a3b..48fc9dbb42 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
@@ -21,9 +21,10 @@
'use strict';
import {ModalsHandler, ValidationUtils, EVENTS, CHANGE_COMPONENT_CSAR_VERSION_FLAG, ComponentType, DEFAULT_ICON,
ResourceType} from "app/utils";
-import {CacheService, EventListenerService, ProgressService} from "app/services";
-import {IAppConfigurtaion, IValidate, IMainCategory, Resource, ISubCategory,Service} from "app/models";
+import {CacheService, EventListenerService, ProgressService, OnboardingService} from "app/services";
+import {IAppConfigurtaion, IValidate, IMainCategory, Resource, ISubCategory,Service, ICsarComponent} from "app/models";
import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model";
+import {Dictionary} from "lodash";
export class Validation {
componentNameValidationPattern:RegExp;
@@ -91,7 +92,8 @@ export class GeneralViewModel {
'Sdc.Services.ProgressService',
'$interval',
'$filter',
- '$timeout'
+ '$timeout',
+ 'Sdc.Services.OnboardingService'
];
constructor(private $scope:IGeneralScope,
@@ -113,7 +115,8 @@ export class GeneralViewModel {
private progressService:ProgressService,
protected $interval:any,
private $filter:ng.IFilterService,
- private $timeout:ng.ITimeoutService) {
+ private $timeout:ng.ITimeoutService,
+ private onBoardingService:OnboardingService) {
this.initScopeValidation();
this.initScopeMethods();
@@ -135,6 +138,40 @@ export class GeneralViewModel {
this.$scope.validation.projectCodeValidationPattern = this.ProjectCodeValidationPattern;
};
+ private initImportedToscaBrowseFile = ():void =>{
+ // Init the decision if to show onboarding
+ this.$scope.isShowOnboardingSelectionBrowse = false;
+ if (this.$scope.component.isResource() &&
+ this.$scope.isEditMode() &&
+ (<Resource>this.$scope.component).resourceType == ResourceType.VF &&
+ (<Resource>this.$scope.component).csarUUID) {
+ this.$scope.isShowOnboardingSelectionBrowse = true;
+ let onboardCsarFilesMap:Dictionary<string> = this.cacheService.get('onboardCsarFilesMap');
+ // The onboardCsarFilesMap in cache contains map of [packageId]:[vsp display name for brows]
+ // if the map is empty - Do request to BE
+ if(onboardCsarFilesMap) {
+ this.$scope.importedToscaBrowseFileText = onboardCsarFilesMap[(<Resource>this.$scope.component).csarUUID];
+ }
+ if(!onboardCsarFilesMap || !this.$scope.importedToscaBrowseFileText){
+
+ let onSuccess = (vsps:Array<ICsarComponent>): void =>{
+ onboardCsarFilesMap = {};
+ _.each(vsps, (vsp:ICsarComponent)=>{
+ onboardCsarFilesMap[vsp.packageId] = vsp.vspName + " (" + vsp.version + ")";
+ });
+ this.cacheService.set('onboardCsarFilesMap', onboardCsarFilesMap);
+ this.$scope.importedToscaBrowseFileText = onboardCsarFilesMap[(<Resource>this.$scope.component).csarUUID];
+ };
+
+ let onError = (): void =>{
+ console.log("Error getting onboarding list");
+ };
+
+ this.onBoardingService.getOnboardingVSPs().then(onSuccess, onError);
+ }
+ }
+ };
+
private initScope = ():void => {
// Work around to change the csar version
@@ -142,7 +179,6 @@ export class GeneralViewModel {
(<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG);
}
- this.$scope.importedToscaBrowseFileText = this.$scope.component.name + " (" + (<Resource>this.$scope.component).csarVersion + ")";
this.$scope.importCsarProgressKey = "importCsarProgressKey";
this.$scope.browseFileLabel = this.$scope.component.isResource() && (<Resource>this.$scope.component).resourceType === ResourceType.VF ? "Upload file" : "Upload VFC";
this.$scope.progressService = this.progressService;
@@ -167,16 +203,8 @@ export class GeneralViewModel {
this.$scope.isShowFileBrowse = true;
}
}
- ;
- // Init the decision if to show onboarding
- this.$scope.isShowOnboardingSelectionBrowse = false;
- if (this.$scope.component.isResource() &&
- this.$scope.isEditMode() &&
- (<Resource>this.$scope.component).resourceType == ResourceType.VF &&
- (<Resource>this.$scope.component).csarUUID) {
- this.$scope.isShowOnboardingSelectionBrowse = true;
- }
+ this.initImportedToscaBrowseFile();
//init file extensions based on the file that was imported.
if (this.$scope.component.isResource() && (<Resource>this.$scope.component).importedFile) {
diff --git a/catalog-ui/src/assets/styles/global.less b/catalog-ui/src/assets/styles/global.less
index 9faf4aeb0e..29e244e1a0 100644
--- a/catalog-ui/src/assets/styles/global.less
+++ b/catalog-ui/src/assets/styles/global.less
@@ -7,6 +7,7 @@ body {
height: 100%;
margin: auto;
position: relative;
+ user-select: text;
}
* {