aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/properties-inputs
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/models/properties-inputs')
-rw-r--r--catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts21
-rw-r--r--catalog-ui/src/app/models/properties-inputs/input-be-model.ts69
-rw-r--r--catalog-ui/src/app/models/properties-inputs/input-fe-model.ts55
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-be-model.ts42
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-declare-api-model.ts38
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-fe-map.ts20
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-fe-model.ts60
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-input-detail.ts26
-rw-r--r--catalog-ui/src/app/models/properties-inputs/simple-flat-property.ts22
9 files changed, 270 insertions, 83 deletions
diff --git a/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
index f7117e456c..8ed5c734c0 100644
--- a/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
+++ b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
import { SchemaPropertyGroupModel, SchemaProperty } from '../aschema-property';
import { DerivedPropertyType, PropertyBEModel } from '../../models';
import { PROPERTY_TYPES } from 'app/utils';
@@ -12,6 +32,7 @@ export class DerivedFEProperty extends PropertyBEModel {
isDeclared: boolean;
isSelected: boolean;
isDisabled: boolean;
+ hidden: boolean;
isChildOfListOrMap: boolean;
canBeDeclared: boolean;
mapKey: string;
diff --git a/catalog-ui/src/app/models/properties-inputs/input-be-model.ts b/catalog-ui/src/app/models/properties-inputs/input-be-model.ts
index 6d7854a6bf..f6548a352c 100644
--- a/catalog-ui/src/app/models/properties-inputs/input-be-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/input-be-model.ts
@@ -1,49 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
import {PropertyBEModel} from 'app/models';
/**
* Created by rc2122 on 6/1/2017.
*/
export class InputBEModel extends PropertyBEModel {
- properties:Array<ComponentInstanceProperty>;
- inputs:Array<ComponentInstanceInput>;
-
- constructor(input?: PropertyBEModel) {
- super(input);
- }
-
-
- public toJSON = (): any => {
- };
-
-}
-
-export class ComponentInstanceProperty extends PropertyBEModel {
- componentInstanceId:string;
- componentInstanceName:string;
+ inputPath: string;
+ inputs: Array<ComponentInstanceModel>;
+ instanceUniqueId: string;
+ ownerId: string;
+ propertyId: string;
+ properties: Array<ComponentInstanceModel>;
- constructor(property?: PropertyBEModel) {
- super(property);
+ constructor(input?: InputBEModel) {
+ super(input);
+ this.instanceUniqueId = input.instanceUniqueId;
+ this.propertyId = input.propertyId;
+ this.properties = input.properties;
+ this.inputs = input.inputs;
+ this.ownerId = input.ownerId;
+ this.inputPath = input.inputPath;
}
-
-
public toJSON = (): any => {
};
}
-export class ComponentInstanceInput extends InputBEModel {
+export interface ComponentInstanceModel extends InputBEModel {
componentInstanceId:string;
- componentInstanceName:string;
-
- constructor(property?: PropertyBEModel) {
- super(property);
- }
-
-
-
- public toJSON = (): any => {
- };
-
+ componentInstanceName: string;
}
-
diff --git a/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts b/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts
index 03c923c228..630374aac3 100644
--- a/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
import { SchemaPropertyGroupModel, SchemaProperty } from "../aschema-property";
import { PropertyBEModel } from "../../models";
import {PROPERTY_DATA} from "../../utils/constants";
@@ -5,40 +25,19 @@ import {InputBEModel} from "./input-be-model";
export class InputFEModel extends InputBEModel {
isSimpleType: boolean;
- isDataType: boolean;
- instanceName: string;
- instanceId: string;
- propertyName: string;
-
+ relatedPropertyValue: any;
+ relatedPropertyName: string;
constructor(input?: InputBEModel) {
super(input);
if (input) {
this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1;
- this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1;
-
- let propNameIndex:number = this.name.indexOf('_');
- this.instanceName = this.name.substring(0, propNameIndex);
-
- if(input.properties && input.properties.length){
- this.instanceId = input.properties[0].componentInstanceId;
- this.propertyName = input.properties[0].name;
- }else if(input.inputs && input.inputs.length){
- this.instanceId = input.inputs[0].componentInstanceId;
- this.propertyName = input.inputs[0].name;
- }else{
- if (input.inputPath) {
- this.propertyName = input.inputPath.substring(0, input.inputPath.indexOf('#'))
- } else {
- this.propertyName = this.name.substring(propNameIndex + 1);
- }
+ let relatedProperty = input.properties && input.properties[0] || input.inputs && input.inputs[0];
+ if (relatedProperty) {
+ this.relatedPropertyValue = relatedProperty.value;
+ this.relatedPropertyName = relatedProperty.name;
}
}
}
-
-
- public toJSON = (): any => {
- };
-
-}
+} \ No newline at end of file
diff --git a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
index f5cd4094f5..c46c8ad28d 100644
--- a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
@@ -1,4 +1,24 @@
-import { SchemaPropertyGroupModel, SchemaProperty } from "../aschema-property";
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+import { PropertyInputDetail, SchemaPropertyGroupModel, SchemaProperty } from "app/models";
import { PROPERTY_DATA, PROPERTY_TYPES } from 'app/utils';
export enum DerivedPropertyType {
SIMPLE,
@@ -10,8 +30,10 @@ export enum DerivedPropertyType {
export class PropertyBEModel {
defaultValue: string;
+ definition: boolean;
description: string;
fromDerived: boolean;
+ getInputValues: Array<PropertyInputDetail>
name: string;
parentUniqueId: string;
password: boolean;
@@ -20,13 +42,8 @@ export class PropertyBEModel {
type: string;
uniqueId: string;
value: string;
- definition: boolean;
- inputPath: string;
- propertiesName: string;
- ownerId: string;
- input: PropertyBEModel;
- constructor(property?: PropertyBEModel, childProperty?:PropertyBEModel) {
+ constructor(property?: PropertyBEModel) {
if (property) {
this.defaultValue = property.defaultValue;
this.description = property.description;
@@ -40,16 +57,7 @@ export class PropertyBEModel {
this.uniqueId = property.uniqueId;
this.value = property.value ? property.value : property.defaultValue;
this.definition = property.definition;
- this.ownerId = property.ownerId;
- if (property.inputPath) {
- this.inputPath = property.inputPath;
- }
- }
- if (childProperty) {
- this.input = childProperty;
- this.propertiesName = childProperty.propertiesName;
- } else {
- this.propertiesName = this.name;
+ this.getInputValues = property.getInputValues;
}
if (!this.schema || !this.schema.property) {
diff --git a/catalog-ui/src/app/models/properties-inputs/property-declare-api-model.ts b/catalog-ui/src/app/models/properties-inputs/property-declare-api-model.ts
new file mode 100644
index 0000000000..5b1c12091b
--- /dev/null
+++ b/catalog-ui/src/app/models/properties-inputs/property-declare-api-model.ts
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+'use strict';
+import { PropertyBEModel, PropertyFEModel, DerivedFEProperty } from "../../models";
+
+
+export class PropertyDeclareAPIModel extends PropertyBEModel{
+ input: PropertyBEModel;
+ propertiesName: string;
+
+
+ constructor(property: PropertyFEModel, childProperty?: DerivedFEProperty) {
+ super(property);
+ if (childProperty) {
+ this.input = childProperty;
+ this.propertiesName = childProperty.propertiesName;
+ }
+ }
+
+}
diff --git a/catalog-ui/src/app/models/properties-inputs/property-fe-map.ts b/catalog-ui/src/app/models/properties-inputs/property-fe-map.ts
index 3b267460b1..30cfcf09fd 100644
--- a/catalog-ui/src/app/models/properties-inputs/property-fe-map.ts
+++ b/catalog-ui/src/app/models/properties-inputs/property-fe-map.ts
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
'use strict';
import { PropertyBEModel, PropertyFEModel } from "../../models";
diff --git a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
index 564611c344..b35bb27b65 100644
--- a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
+++ b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
import {SchemaPropertyGroupModel, SchemaProperty} from '../aschema-property';
import { PROPERTY_DATA, PROPERTY_TYPES } from 'app/utils';
import { FilterPropertiesAssignmentData, PropertyBEModel, DerivedPropertyType, DerivedFEPropertyMap, DerivedFEProperty } from 'app/models';
@@ -6,11 +26,12 @@ import { FilterPropertiesAssignmentData, PropertyBEModel, DerivedPropertyType, D
export class PropertyFEModel extends PropertyBEModel {
expandedChildPropertyId: string;
- flattenedChildren: Array<DerivedFEProperty>; //[parentPath] : Array<DerivedFEProp>
+ flattenedChildren: Array<DerivedFEProperty>;
isDeclared: boolean;
isDisabled: boolean;
isSelected: boolean;
isSimpleType: boolean; //for convenience only - we can really just check if derivedDataType == derivedPropertyTypes.SIMPLE to know if the prop is simple
+ propertiesName: string;
uniqueId: string;
valueObj: any; //this is the only value we relate to in the html templates
derivedDataType: DerivedPropertyType;
@@ -21,6 +42,7 @@ export class PropertyFEModel extends PropertyBEModel {
this.setNonDeclared();
this.derivedDataType = this.getDerivedPropertyType();
this.flattenedChildren = [];
+ this.propertiesName = this.name;
}
@@ -29,15 +51,15 @@ export class PropertyFEModel extends PropertyBEModel {
//TODO: handle this.derivedDataType == DerivedPropertyType.MAP
if (this.derivedDataType == DerivedPropertyType.LIST && this.schema.property.type == PROPERTY_TYPES.JSON) {
try {
- return JSON.stringify(this.valueObj.map(item => JSON.parse(item)));
+ return JSON.stringify(this.valueObj.map(item => (typeof item == 'string')? JSON.parse(item) : item));
} catch (e){}
}
- return (this.derivedDataType == DerivedPropertyType.SIMPLE) ? this.valueObj : JSON.stringify(this.valueObj);
+ return (this.derivedDataType == DerivedPropertyType.SIMPLE) ? this.valueObj : JSON.stringify(this.valueObj);
}
public setNonDeclared = (childPath?: string): void => {
- if (!childPath) { //declaring a child prop
+ if (!childPath) { //un-declaring a child prop
this.isDeclared = false;
} else {
let childProp: DerivedFEProperty = this.flattenedChildren.find(child => child.propertiesName == childPath);
@@ -51,6 +73,7 @@ export class PropertyFEModel extends PropertyBEModel {
this.isDeclared = true;
} else {
let childProp: DerivedFEProperty = this.flattenedChildren.find(child => child.propertiesName == childNameToDeclare);
+ if (!childProp) { console.log("ERROR: Unabled to find child: " + childNameToDeclare, this); return; }
childProp.isSelected = false;
childProp.isDeclared = true;
}
@@ -78,4 +101,33 @@ export class PropertyFEModel extends PropertyBEModel {
// this.flattenedChildren.filter(prop => prop.parentName == item.parentName).map(prop => prop.propertiesName).indexOf(item.propertiesName)
// }
+ /* Updates parent valueObj when a child prop's value has changed */
+ public childPropUpdated = (childProp: DerivedFEProperty): void => {
+ let parentNames = this.getParentNamesArray(childProp.propertiesName, []);
+ if (parentNames.length) {
+ _.set(this.valueObj, parentNames.join('.'), childProp.valueObj);
+ }
+ };
+
+ /* Returns array of individual parents for given prop path, with list/map UUIDs replaced with index/mapkey */
+ public getParentNamesArray = (parentPropName: string, parentNames?: Array<string>): Array<string> => {
+ if (parentPropName.indexOf("#") == -1) { return parentNames; } //finished recursing parents. return
+
+ let parentProp: DerivedFEProperty = this.flattenedChildren.find(prop => prop.propertiesName === parentPropName);
+ let nameToInsert: string = parentProp.name;
+
+ if (parentProp.isChildOfListOrMap) {
+ if (parentProp.derivedDataType == DerivedPropertyType.MAP) {
+ nameToInsert = parentProp.mapKey;
+ } else { //LIST
+ let siblingProps = this.flattenedChildren.filter(prop => prop.parentName == parentProp.parentName).map(prop => prop.propertiesName);
+ nameToInsert = siblingProps.indexOf(parentProp.propertiesName).toString();
+ }
+ }
+
+ parentNames.splice(0, 0, nameToInsert); //add prop name to array
+ return this.getParentNamesArray(parentProp.parentName, parentNames); //continue recursing
+ }
+
+
}
diff --git a/catalog-ui/src/app/models/properties-inputs/property-input-detail.ts b/catalog-ui/src/app/models/properties-inputs/property-input-detail.ts
new file mode 100644
index 0000000000..8c1028c45b
--- /dev/null
+++ b/catalog-ui/src/app/models/properties-inputs/property-input-detail.ts
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+export class PropertyInputDetail {
+ inputId: string;
+ inputName: string;
+ inputPath: string;
+ list: boolean;
+}
diff --git a/catalog-ui/src/app/models/properties-inputs/simple-flat-property.ts b/catalog-ui/src/app/models/properties-inputs/simple-flat-property.ts
index d67a7d4d14..e38eeb005d 100644
--- a/catalog-ui/src/app/models/properties-inputs/simple-flat-property.ts
+++ b/catalog-ui/src/app/models/properties-inputs/simple-flat-property.ts
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
export class SimpleFlatProperty {
uniqueId: string;
path: string;
@@ -12,4 +32,4 @@ export class SimpleFlatProperty {
this.parentName = parentName;
this.instanceName = instanceName;
}
-} \ No newline at end of file
+}