summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models/properties-inputs
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
committerMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
commited64b5edff15e702493df21aa3230b81593e6133 (patch)
treea4cb01fdaccc34930a8db403a3097c0d1e40914b /catalog-ui/src/app/models/properties-inputs
parent280f8015d06af1f41a3ef12e8300801c7a5e0d54 (diff)
[SDC-29] catalog 1707 rebase commit.
Change-Id: I43c3dc5cf44abf5da817649bc738938a3e8388c1 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/src/app/models/properties-inputs')
-rw-r--r--catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts72
-rw-r--r--catalog-ui/src/app/models/properties-inputs/input-fe-model.ts32
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-be-model.ts84
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-fe-map.ts21
-rw-r--r--catalog-ui/src/app/models/properties-inputs/property-fe-model.ts132
5 files changed, 341 insertions, 0 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
new file mode 100644
index 0000000000..1d79353453
--- /dev/null
+++ b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts
@@ -0,0 +1,72 @@
+import { SchemaPropertyGroupModel, SchemaProperty } from '../aschema-property';
+import { PROPERTY_DATA, PROPERTY_TYPES} from 'app/utils';
+import { PropertyBEModel } from '../../models';
+
+export enum DerivedPropertyType {
+ SIMPLE,
+ LIST,
+ MAP,
+ COMPLEX //other datatype, list of non-simple, or map of non-simple
+}
+
+export class DerivedFEProperty extends PropertyBEModel {
+ parentName: string;
+ propertiesName: string; //"network_assignments#ipv4_subnet#use_ipv4 = parentPath + name
+ derivedDataType: DerivedPropertyType;
+ isDeclared: boolean;
+ isSelected: boolean;
+ isDisabled: boolean;
+ isChildOfListOrMap: boolean;
+
+ constructor(property: PropertyBEModel, parentName?: string)
+ constructor(name: string, parentName: string, type: string, value: string, isChildOfListOrMap?:boolean, schema?: SchemaPropertyGroupModel);
+ constructor(nameOrPropertyObj?: string | PropertyBEModel, parentName?: string, type?: string, value?: string, isChildOfListOrMap?: boolean, schema?: SchemaPropertyGroupModel) {
+
+ super(typeof nameOrPropertyObj === 'string' ? null : nameOrPropertyObj);
+
+ if (typeof nameOrPropertyObj !== 'string') { //constructor #1
+ this.parentName = parentName ? parentName : null;
+ this.propertiesName = (parentName) ? parentName + '#' + nameOrPropertyObj.name : nameOrPropertyObj.name;
+ } else { //constructor #2
+ this.name = nameOrPropertyObj;
+ this.type = type;
+ this.parentName = parentName;
+ this.propertiesName = parentName + '#' + nameOrPropertyObj;
+ this.value = value;
+ if (schema) {
+ this.schema = new SchemaPropertyGroupModel(new SchemaProperty(schema.property));
+ }
+ }
+ this.derivedDataType = this.getDerivedPropertyType();
+ this.isChildOfListOrMap = (isChildOfListOrMap) ? isChildOfListOrMap : false;
+ }
+
+ public getDerivedPropertyType = () => {
+ if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1) {
+ return DerivedPropertyType.SIMPLE;
+ } else if (this.type == PROPERTY_TYPES.LIST) {
+ return DerivedPropertyType.LIST;
+ } else if (this.type == PROPERTY_TYPES.MAP) {
+ return DerivedPropertyType.MAP;
+ } else {
+ return DerivedPropertyType.COMPLEX;
+ }
+ }
+
+}
+export class DerivedFEPropertyMap {
+ [parentPath: string]: Array<DerivedFEProperty>;
+}
+
+
+
+// isDataType: boolean;
+
+
+// canAdd: boolean;
+// canCollapse: boolean;
+// canBeDeclared: boolean;
+
+// derivedValue: string;
+// derivedValueType: string;
+// propertiesName: string; \ No newline at end of file
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
new file mode 100644
index 0000000000..1261df3d6d
--- /dev/null
+++ b/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts
@@ -0,0 +1,32 @@
+import { SchemaPropertyGroupModel, SchemaProperty } from "../aschema-property";
+import { PropertyBEModel } from "../../models";
+import {PROPERTY_DATA} from "../../utils/constants";
+
+export class InputFEModel extends PropertyBEModel {
+ isSimpleType: boolean;
+ isDataType: boolean;
+ instanceName: string;
+ propertyName: string;
+
+
+ constructor(input?: PropertyBEModel) {
+ 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.inputPath) {
+ this.propertyName = input.inputPath.substring(0, input.inputPath.indexOf('#'))
+ } else {
+ this.propertyName = this.name.substring(propNameIndex + 1);
+ }
+ }
+ }
+
+
+
+ public toJSON = (): any => {
+ };
+
+}
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
new file mode 100644
index 0000000000..a5279d0668
--- /dev/null
+++ b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts
@@ -0,0 +1,84 @@
+import { SchemaPropertyGroupModel, SchemaProperty } from "../aschema-property";
+
+export class PropertyBEModel {
+
+ defaultValue: string;
+ description: string;
+ fromDerived: boolean;
+ name: string;
+ parentUniqueId: string;
+ password: boolean;
+ required: boolean;
+ schema: SchemaPropertyGroupModel;
+ type: string;
+ uniqueId: string;
+ value: string;
+ definition: boolean;
+ inputPath: string;
+ propertiesName: string;
+ input: PropertyBEModel;
+
+ constructor(property?: PropertyBEModel, childProperty?:PropertyBEModel) {
+ if (property) {
+ this.defaultValue = property.defaultValue;
+ this.description = property.description;
+ this.fromDerived = property.fromDerived;
+ this.name = property.name;
+ this.parentUniqueId = property.parentUniqueId;
+ this.password = property.password;
+ this.required = property.required;
+ this.schema = property.schema;
+ this.type = property.type;
+ this.uniqueId = property.uniqueId;
+ this.value = property.value ? property.value : property.defaultValue;
+ this.definition = property.definition;
+ if (property.inputPath) {
+ this.inputPath = property.inputPath;
+ }
+ }
+ if (childProperty) {
+ this.input = childProperty;
+ this.propertiesName = childProperty.propertiesName;
+ }
+
+ if (!this.schema || !this.schema.property) {
+ this.schema = new SchemaPropertyGroupModel(new SchemaProperty());
+ } else { //forcing creating new object, so editing different one than the object in the table
+ this.schema = new SchemaPropertyGroupModel(new SchemaProperty(this.schema.property));
+ }
+ }
+
+
+
+ public toJSON = (): any => {
+ let temp = angular.copy(this);
+ temp.value = temp.value === "{}" || temp.value === "[]" ? undefined : temp.value;
+ temp.defaultValue = temp.defaultValue === "{}" || temp.defaultValue === "[]" ? undefined : temp.defaultValue;
+ return temp;
+ };
+
+}
+
+
+// EXTRAS FROM CONSTRUCTOR:
+// this.source = property.source;
+// this.valueUniqueUid = property.valueUniqueUid;
+// this.path = property.path;
+// this.rules = property.rules;
+// this.resourceInstanceUniqueId = property.resourceInstanceUniqueId;
+// this.readonly = property.readonly;
+// this.simpleType = property.simpleType;
+// this.componentInstanceId = property.componentInstanceId;
+// this.parentValue = property.parentValue;
+//NEW PROPERTIES MAY NEED:
+// export class PropertyFEModel extends PropertyBEModel {
+// componentInstanceId: string;
+// isAlreadySelected: boolean;
+// filterTerm: string;
+// }
+//FOR INPUTS, BE ALSO INCLUDES:
+//export class InputFEModel extends PropertyBEModel {
+// hidden: boolean;
+// label: string;
+// immutable: boolean;
+// }
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
new file mode 100644
index 0000000000..3b267460b1
--- /dev/null
+++ b/catalog-ui/src/app/models/properties-inputs/property-fe-map.ts
@@ -0,0 +1,21 @@
+'use strict';
+import { PropertyBEModel, PropertyFEModel } from "../../models";
+
+export class InstanceBePropertiesMap {
+ [instanceId: string]: Array<PropertyBEModel>;
+}
+
+export class InstanceFePropertiesMap {
+ [instanceId: string]: Array<PropertyFEModel>;
+}
+
+export class InstancePropertiesAPIMap {
+ componentInstanceProperties: InstanceBePropertiesMap;
+ componentInstanceInputsMap: InstanceBePropertiesMap;
+
+ constructor(inputsMapData: InstanceBePropertiesMap, propertiesMapData: InstanceBePropertiesMap) {
+ this.componentInstanceInputsMap = inputsMapData ? inputsMapData: new InstanceBePropertiesMap();
+ this.componentInstanceProperties = propertiesMapData ? propertiesMapData: new InstanceBePropertiesMap();
+ }
+
+}
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
new file mode 100644
index 0000000000..29f2c79225
--- /dev/null
+++ b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts
@@ -0,0 +1,132 @@
+import {SchemaPropertyGroupModel, SchemaProperty} from '../aschema-property';
+import { PROPERTY_DATA } from 'app/utils';
+import { PropertyBEModel, DerivedFEPropertyMap, DerivedFEProperty } from '../../models';
+
+
+export class PropertyFEModel extends PropertyBEModel {
+
+ //START - TO REMOVE:
+ treeNodeId: string;
+ parent: PropertyFEModel;
+
+ childrenProperties: Array<PropertyFEModel>;
+ isAllChildrenLevelsCalculated: boolean;
+ uniqueId: string;
+ valueObjectRef: any;
+ //END - TO REMOVE:
+
+ expandedChildPropertyId: string;
+ flattenedChildren: Array<DerivedFEProperty>; //[parentPath] : Array<DerivedFEProp>
+ isDataType: boolean; //aka- isComplexType. (Type is NOT: simple, list, or map)
+ isDeclared: boolean;
+ isDisabled: boolean;
+ isSelected: boolean;
+ isSimpleType: boolean;
+
+ private _derivedFromSimpleTypeName:string;
+ get derivedFromSimpleTypeName():string {
+ return this._derivedFromSimpleTypeName;
+ }
+ set derivedFromSimpleTypeName(derivedFromSimpleTypeName:string) {
+ this._derivedFromSimpleTypeName = derivedFromSimpleTypeName;
+ }
+
+ constructor(property?: PropertyBEModel);
+ constructor(name: string, type: string, treeNodeId: string, parent: PropertyFEModel, valueObjectRef: any, schema?: SchemaPropertyGroupModel);
+ constructor(nameOrPropertyObj?: string | PropertyBEModel, type?: string, treeNodeId?: string, parent?: PropertyFEModel, valueObjectRef?: any, schema?: SchemaPropertyGroupModel) {
+
+ super(typeof nameOrPropertyObj === 'string' ? null : nameOrPropertyObj);
+
+ if (typeof nameOrPropertyObj === 'string') {
+ this.name = nameOrPropertyObj;
+ this.type = type;
+ this.treeNodeId = treeNodeId;
+ this.parent = parent;
+ this.valueObjectRef = valueObjectRef;
+ this.value = this.value || this.defaultValue;
+ if(schema){
+ this.schema = new SchemaPropertyGroupModel(new SchemaProperty(schema.property));
+ }
+ }
+
+ this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1;
+ this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1;
+ this.setNonDeclared();
+ }
+
+ public convertChildToInput = (childName: string): void => {
+ //childName: "mac_count_required"
+ let childJson = this.flattenedChildren[childName].map((child) => {
+
+ });
+ };
+
+ public getChildJsonRecursive = (child: string, value?: string): void => {
+ //TODO: use array.map for the below
+ /* value += "{" + this.flattenedChildren[child].name + ":";
+ if (this.flattenedChildren[child].valueType == 'simple') {
+ value += this.flattenedChildren[child].value + '}';
+ return value;
+ } else {
+ this.flattenedChildren[child].forEach(grandChild => {
+ if (this.flattenedChildren[grandChild].valueType == 'simple') {
+ return "{" + this.flattenedChildren[grandChild].name + ':' + this.flattenedChildren[child].value.toString() + "}";
+ } else {
+ return this.getChildJsonRecursive(grandChild + '#' + this.flattenedChildren[child].name);
+ }
+ });
+ }
+
+ return "{" + this.flattenedChildren[child].name + this.flattenedChildren[child].value.toString() + "}";
+*/
+
+ };
+
+ public setNonDeclared = (childPath?: string): void => {
+ if (!childPath) { //declaring a child prop
+ this.isDeclared = false;
+ } else {
+ let childProp: DerivedFEProperty = this.flattenedChildren.find(child => child.propertiesName == childPath);
+ childProp.isDeclared = false;
+ }
+ }
+
+ public setAsDeclared = (childNameToDeclare?:string): void => {
+ if (!childNameToDeclare) { //declaring a child prop
+ this.isSelected = false;
+ this.isDeclared = true;
+ } else {
+ let childProp: DerivedFEProperty = this.flattenedChildren.find(child => child.propertiesName == childNameToDeclare);
+ childProp.isSelected = false;
+ childProp.isDeclared = true;
+ }
+ }
+
+
+
+ //For expand-collapse functionality
+ public updateExpandedChildPropertyId = (childPropertyId: string): void => {
+ if (childPropertyId.lastIndexOf('#') > -1) {
+ this.expandedChildPropertyId = (this.expandedChildPropertyId == childPropertyId) ? (childPropertyId.substring(0, childPropertyId.lastIndexOf('#'))) : childPropertyId;
+ } else {
+ this.expandedChildPropertyId = this.name;
+ }
+ //console.log("expandedChild is now " + this.expandedChildPropertyId);
+ }
+
+ public convertToServerObject: Function = (): any => { //TODO: Idan, Rachel, Nechama: Decide what we need to do here
+ // let serverObject = {};
+ // let mapData = {
+ // 'type': this.type,
+ // 'required': this.required || false,
+ // 'defaultValue': this.defaultValue != '' && this.defaultValue != '[]' && this.defaultValue != '{}' ? this.defaultValue : null,
+ // 'description': this.description,
+ // 'isPassword': this.password || false,
+ // 'schema': this.schema,
+ // 'name': this.name
+ // };
+ // serverObject[this.name] = mapData;
+
+ //return JSON.stringify(serverObject);
+ };
+}