summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/properties-assignment
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment')
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts69
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html9
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts17
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/services/hierarchy-nav.service.ts83
-rw-r--r--catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts (renamed from catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts)17
5 files changed, 130 insertions, 65 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts
index 1c6f51314d..203c75dd11 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts
@@ -17,70 +17,43 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
import { NgModule } from "@angular/core";
-import { PropertiesAssignmentComponent } from "./properties-assignment.page.component";
-import { HierarchyNavigationComponent } from "./../../components/hierarchy-navigtion/hierarchy-navigation.component";
-import { BrowserModule } from "@angular/platform-browser";
-import { FormsModule } from "@angular/forms";
-import { HttpModule } from "@angular/http";
-import { TabModule } from '../../shared/tabs/tabs.module';
-import { CheckboxModule} from '../../shared/checkbox/checkbox.module';
-import { PropertiesTableComponent } from '../../components/properties-table/properties-table.component';
-import { InputsTableComponent } from '../../components/inputs-table/inputs-table.component';
-import { ContentAfterLastDotPipe } from "../../pipes/contentAfterLastDot.pipe";
-import { SearchFilterPipe } from "../../pipes/searchFilter.pipe";
-import { FilterChildPropertiesPipe } from "../../pipes/filterChildProperties.pipe";
-import { DataTypeService } from './../../services/data-type.service';
-import { PropertiesService } from './../../services/properties.service';
-import { HierarchyNavService } from './../../services/hierarchy-nav.service';
-import { PropertiesUtils } from './properties.utils';
-import { DynamicElementModule } from 'app/ng2/components/dynamic-element/dynamic-element.module';
-import { DynamicPropertyComponent } from './../../components/properties-table/dynamic-property/dynamic-property.component';
-import { PopoverModule } from "../../components/popover/popover.module";
-import { ModalModule } from "../../components/modal/modal.module";
-import { FilterPropertiesAssignmentComponent } from "./../../components/filter-properties-assignment/filter-properties-assignment.component";
-import { GroupByPipe } from 'app/ng2/pipes/groupBy.pipe';
-import { KeysPipe } from 'app/ng2/pipes/keys.pipe';
-import {TooltipModule} from "../../components/tooltip/tooltip.module";
-import { ComponentModeService } from "app/ng2/services/component-mode.service"
-import {LoaderComponent} from "app/ng2/components/loader/loader.component"
+import {HierarchyNavigationComponent} from "../../components/logic/hierarchy-navigtion/hierarchy-navigation.component";
+import {HttpModule} from "@angular/http";
+import {FormsModule} from "@angular/forms";
+import {PropertyTableModule} from "../../components/logic/properties-table/property-table.module";
+import {UiElementsModule} from "../../components/ui/ui-elements.module";
+import {GlobalPipesModule} from "../../pipes/global-pipes.module";
+import {BrowserModule} from "@angular/platform-browser";
+import {FilterPropertiesAssignmentComponent} from "../../components/logic/filter-properties-assignment/filter-properties-assignment.component";
+import {InputsTableComponent} from "../../components/logic/inputs-table/inputs-table.component";
+import {PropertiesService} from "../../services/properties.service";
+import {DataTypeService} from "../../services/data-type.service";
+import {PropertiesAssignmentComponent} from "./properties-assignment.page.component";
+import {HierarchyNavService} from "./services/hierarchy-nav.service";
+import {PropertiesUtils} from "./services/properties.utils";
+import {ComponentModeService} from "../../services/component-services/component-mode.service";
@NgModule({
declarations: [
PropertiesAssignmentComponent,
- PropertiesTableComponent,
InputsTableComponent,
- ContentAfterLastDotPipe,
- GroupByPipe,
- KeysPipe,
- SearchFilterPipe,
- FilterChildPropertiesPipe,
HierarchyNavigationComponent,
- DynamicPropertyComponent,
- // PopoverContentComponent,
- // PopoverComponent,
- FilterPropertiesAssignmentComponent,
- LoaderComponent
+ FilterPropertiesAssignmentComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
- TabModule,
- CheckboxModule,
- DynamicElementModule,
- PopoverModule,
- TooltipModule,
- ModalModule
- ],
+ GlobalPipesModule,
+ PropertyTableModule,
+ UiElementsModule],
+
entryComponents: [PropertiesAssignmentComponent],
exports: [
PropertiesAssignmentComponent
- // PopoverContentComponent,
- // PopoverComponent
],
- providers: [PropertiesService, HierarchyNavService, PropertiesUtils, DataTypeService, ContentAfterLastDotPipe, GroupByPipe, KeysPipe, ComponentModeService]
+ providers: [PropertiesService, HierarchyNavService, PropertiesUtils, DataTypeService, ComponentModeService]
})
export class PropertiesAssignmentModule {
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
index be7e03dccd..beea3fe73f 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html
@@ -11,6 +11,7 @@
[propertyNameSearchText]="searchPropertyName"
[readonly]="isReadonly"
[isLoading]="loadingProperties"
+ [hasDeclareOption]="true"
(valueChanged)="propertyValueChanged($event)"
(propertySelected)="propertySelected($event)"
(selectPropertyRow)="selectPropertyRow($event)"
@@ -31,12 +32,12 @@
</tabs>
<div class="header">
<div class="search-filter-container" [class.without-filter]="isInpusTabSelected">
- <span *ngIf="displayClearSearch && !isInpusTabSelected" (click)="clickOnClearSearch()" class="clear-filter">Clear All</span>
- <input type="text" class="search-box" placeholder="Search" [(ngModel)]="searchQuery" />
- <span class="sprite search-icon"></span>
+ <span *ngIf="displayClearSearch && !isInpusTabSelected" (click)="clickOnClearSearch()" class="clear-filter" data-tests-id="clear-filter-button">Clear All</span>
+ <input type="text" class="search-box" placeholder="Search" [(ngModel)]="searchQuery" data-tests-id="search-box"/>
+ <span class="sprite search-icon" data-tests-id="search-button"></span>
<filter-properties-assignment *ngIf="!isInpusTabSelected" #advanceSearch class="advance-search" [componentType]="component.componentType" (searchProperties)="searchPropertiesInstances($event)"></filter-properties-assignment>
</div>
- <button class="tlv-btn blue declare-button" [disabled]="!checkedPropertiesCount || isReadonly" (click)="declareProperties()">Declare</button>
+ <button class="tlv-btn blue declare-button" [disabled]="!checkedPropertiesCount || isReadonly" (click)="declareProperties()" data-tests-id="declare-button">Declare</button>
</div>
</div>
<div class="right-column gray-border">
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
index 82754f13f0..9603648bd8 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
@@ -20,21 +20,22 @@
import {Component, ViewChild, ElementRef, Renderer, Inject} from "@angular/core";
import { PropertiesService } from "../../services/properties.service";
-import { HierarchyNavService } from "../../services/hierarchy-nav.service";
-import { PropertiesUtils } from './properties.utils';
import { PropertyFEModel, InstanceFePropertiesMap, InstanceBePropertiesMap, InstancePropertiesAPIMap, Component as ComponentData, FilterPropertiesAssignmentData } from "app/models";
-import { PROPERTY_TYPES, ResourceType } from "app/utils";
+import { ResourceType } from "app/utils";
import property = require("lodash/property");
import {ComponentServiceNg2} from "../../services/component-services/component.service";
import {ComponentInstanceServiceNg2} from "../../services/component-instance-services/component-instance.service"
-import { InputBEModel, InputFEModel, ComponentInstance, PropertyBEModel, DerivedPropertyType, DerivedFEProperty, ResourceInstance, SimpleFlatProperty } from "app/models";
-import {HierarchyDisplayOptions} from "../../components/hierarchy-navigtion/hierarchy-display-options"
-import {PropertyRowSelectedEvent} from "./../../components/properties-table/properties-table.component";
+import { InputBEModel, InputFEModel, ComponentInstance, PropertyBEModel, DerivedFEProperty, ResourceInstance, SimpleFlatProperty } from "app/models";
import { KeysPipe } from 'app/ng2/pipes/keys.pipe';
-import {FilterPropertiesAssignmentComponent} from "../../components/filter-properties-assignment/filter-properties-assignment.component";
-import { ComponentModeService } from "app/ng2/services/component-mode.service"
import {WorkspaceMode, EVENTS} from "../../../utils/constants";
import {EventListenerService} from "app/services/event-listener-service"
+import {HierarchyDisplayOptions} from "../../components/logic/hierarchy-navigtion/hierarchy-display-options";
+import {FilterPropertiesAssignmentComponent} from "../../components/logic/filter-properties-assignment/filter-properties-assignment.component";
+import {PropertyRowSelectedEvent} from "../../components/logic/properties-table/properties-table.component";
+import {HierarchyNavService} from "./services/hierarchy-nav.service";
+import {PropertiesUtils} from "./services/properties.utils";
+import {ComponentModeService} from "../../services/component-services/component-mode.service";
+
@Component({
templateUrl: './properties-assignment.page.component.html',
styleUrls: ['./properties-assignment.page.component.less']
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/services/hierarchy-nav.service.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/services/hierarchy-nav.service.ts
new file mode 100644
index 0000000000..016b04788e
--- /dev/null
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/services/hierarchy-nav.service.ts
@@ -0,0 +1,83 @@
+/*-
+ * ============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 { Injectable } from '@angular/core';
+import { SimpleFlatProperty, PropertyFEModel, DerivedFEProperty } from 'app/models';
+
+
+@Injectable()
+export class HierarchyNavService {
+ /**
+ * Build hirarchy structure for the tree when user selects on table row.
+ * First create Array<SimpleFlatProperty> and insert also the parent (PropertyFEModel) to this array.
+ * The Array is flat and contains SimpleFlatProperty that has parentName and uniqueId.
+ * Now we build hirarchy from this Array (that includes childrens) and return it for the tree
+ *
+ * @argument property: PropertyFEModel - property contains flattenedChildren array of DerivedFEProperty
+ * @returns Array<SimpleFlatProperty> - containing childrens Array<SimpleFlatProperty>, augmantin childrens to SimpleFlatProperty.
+ */
+ public getSimplePropertiesTree(property: PropertyFEModel, instanceName: string): Array<SimpleFlatProperty> {
+ // Build Array of SimpleFlatProperty before unflatten function
+ let flattenProperties: Array<SimpleFlatProperty> = [];
+ flattenProperties.push(this.createSimpleFlatProperty(property, instanceName)); // Push the root property
+ _.each(property.flattenedChildren, (child: DerivedFEProperty): void => {
+ if (child.isChildOfListOrMap && child.schema.property.isSimpleType) return; //do not display non-complex children of list or map
+ flattenProperties.push(this.createSimpleFlatProperty(child, instanceName));
+ });
+
+ let tree = this.unflatten(flattenProperties, '', []);
+ return tree[0].childrens; // Return the childrens without the root.
+ }
+
+ public createSimpleFlatProperty = (property: PropertyFEModel | DerivedFEProperty, instanceName:string): SimpleFlatProperty => {
+ if (property instanceof PropertyFEModel) {
+ return new SimpleFlatProperty(property.uniqueId, property.name, property.name, '', instanceName);
+ } else {
+ let propName: string = (property.isChildOfListOrMap) ? property.mapKey : property.name;
+ return new SimpleFlatProperty(property.uniqueId, property.propertiesName, propName, property.parentName, instanceName);
+ }
+
+ }
+
+ /**
+ * Unflatten Array<SimpleFlatProperty> and build hirarchy.
+ * The result will be Array<SimpleFlatProperty> that augmantin with childrens for each SimpleFlatProperty.
+ */
+ private unflatten(array: Array<SimpleFlatProperty>, parent: any, tree?: any): any {
+ tree = typeof tree !== 'undefined' ? tree : [];
+ parent = typeof parent !== 'undefined' && parent !== '' ? parent : { path: '' };
+
+ var childrens = _.filter(array, (child: SimpleFlatProperty): boolean => {
+ return child.parentName == parent.path;
+ });
+
+ if (!_.isEmpty(childrens)) {
+ if (parent.path == '') {
+ tree = childrens;
+ } else {
+ parent['childrens'] = childrens;
+ }
+ _.each(childrens, (child): void => {
+ this.unflatten(array, child);
+ });
+ }
+ return tree;
+ }
+}
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts
index d8d991d218..8f46c6f603 100644
--- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts
+++ b/catalog-ui/src/app/ng2/pages/properties-assignment/services/properties.utils.ts
@@ -19,11 +19,10 @@
*/
import { Injectable } from '@angular/core';
-import { DataTypeModel, PropertyFEModel, PropertyBEModel, InstanceBePropertiesMap, InstanceFePropertiesMap, SchemaProperty, DerivedFEProperty, DerivedFEPropertyMap, DerivedPropertyType, InputFEModel} from "app/models";
+import { DataTypeModel, PropertyFEModel, PropertyBEModel, InstanceBePropertiesMap, InstanceFePropertiesMap, DerivedFEProperty, DerivedPropertyType, InputFEModel} from "app/models";
import { DataTypeService } from "app/ng2/services/data-type.service";
import { PropertiesService } from "app/ng2/services/properties.service";
-import { PROPERTY_TYPES } from "app/utils";
-import { UUID } from "angular2-uuid";
+import { PROPERTY_TYPES, PROPERTY_DATA } from "app/utils";
@Injectable()
export class PropertiesUtils {
@@ -106,8 +105,16 @@ export class PropertiesUtils {
public initValueObjectRef = (property: PropertyFEModel): void => {
if (property.derivedDataType == DerivedPropertyType.SIMPLE || property.isDeclared) { //if property is declared, it gets a simple input instead. List and map values and pseudo-children will be handled in property component
property.valueObj = property.value || property.defaultValue;
-
- if (property.isDeclared && typeof property.valueObj == 'object') property.valueObj = JSON.stringify(property.valueObj);
+ if (property.isDeclared) {
+ if(typeof property.valueObj == 'object'){
+ property.valueObj = JSON.stringify(property.valueObj);
+ }
+ }else if(property.valueObj &&
+ property.type !== PROPERTY_TYPES.STRING &&
+ property.type !== PROPERTY_TYPES.JSON &&
+ PROPERTY_DATA.SCALAR_TYPES.indexOf(property.type) == -1){
+ property.valueObj = JSON.parse(property.valueObj);//The valueObj contains the real value ans not the value as string
+ }
} else {
if (property.derivedDataType == DerivedPropertyType.LIST) {
property.valueObj = _.merge([], JSON.parse(property.defaultValue || '[]'), JSON.parse(property.value || '[]')); //value object should be merged value and default value. Value takes higher precendence. Set valueObj to empty obj if undefined.