diff options
Diffstat (limited to 'catalog-ui/src/app/view-models/workspace/tabs/properties')
3 files changed, 266 insertions, 0 deletions
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts new file mode 100644 index 0000000000..923cc58a7e --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts @@ -0,0 +1,92 @@ +'use strict'; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {PropertyModel} from "app/models"; +import {ModalsHandler} from "app/utils"; +import {COMPONENT_FIELDS} from "../../../../utils/constants"; +import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response"; +import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service"; + +interface IPropertiesViewModelScope extends IWorkspaceViewModelScope { + tableHeadersList:Array<any>; + reverse:boolean; + sortBy:string; + filteredProperties:Array<PropertyModel>; + + addOrUpdateProperty(property?:PropertyModel):void; + delete(property:PropertyModel):void; + sort(sortBy:string):void; +} + +export class PropertiesViewModel { + + static '$inject' = [ + '$scope', + '$filter', + 'ModalsHandler', + 'ComponentServiceNg2' + ]; + + + constructor(private $scope:IPropertiesViewModelScope, + private $filter:ng.IFilterService, + private ModalsHandler:ModalsHandler, + private ComponentServiceNg2:ComponentServiceNg2) { + this.initComponentProperties(); + this.$scope.updateSelectedMenuItem(); + } + + private initComponentProperties = ():void => { + + if(!this.$scope.component.properties) { + this.$scope.isLoading = true; + this.ComponentServiceNg2.getComponentProperties(this.$scope.component).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.properties = response.properties; + this.initScope(); + this.$scope.isLoading = false; + }, () => { + this.$scope.isLoading = false; + }); + } else { + this.initScope(); + } + } + + private openEditPropertyModal = (property:PropertyModel):void => { + this.ModalsHandler.openEditPropertyModal(property, this.$scope.component, this.$scope.filteredProperties, false).then(() => { + }); + }; + + private initScope = ():void => { + + //let self = this; + this.$scope.filteredProperties = this.$scope.component.properties; + this.$scope.sortBy = 'name'; + this.$scope.reverse = false; + this.$scope.setValidState(true); + this.$scope.tableHeadersList = [ + {title: 'Name', property: 'name'}, + {title: 'Type', property: 'type'}, + {title: 'Schema', property: 'schema.property.type'}, + {title: 'Description', property: 'description'}, + ]; + this.$scope.sort = (sortBy:string):void => { + this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; + this.$scope.sortBy = sortBy; + }; + + + this.$scope.addOrUpdateProperty = (property?:PropertyModel):void => { + this.openEditPropertyModal(property ? property : new PropertyModel()); + }; + + this.$scope.delete = (property:PropertyModel):void => { + + let onOk = ():void => { + this.$scope.component.deleteProperty(property.uniqueId); + }; + let title:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TITLE"); + let message:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TEXT", "{'name': '" + property.name + "'}"); + this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); + }; + } +} diff --git a/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view.html b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view.html new file mode 100644 index 0000000000..d1e0582386 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view.html @@ -0,0 +1,59 @@ +<div class="workspace-properties"> + <div id="left-top-bar"> + <span id="properties-count">Total Properties: {{component.properties.length}}</span> + <input id="search-by-name" type="search" placeholder="Search" data-ng-model-options="{debounce: 200}" data-ng-model="filterTerms"/> + <span class="sprite magnification-glass search-button"></span> + </div> + <div class="add-btn" data-tests-id="addGrey" ng-if="!isViewMode()" + data-ng-class="{'disabled': isDisableMode()}" data-ng-click="addOrUpdateProperty()">Add Property</div> + <div class="table-container-flex"> + <div class="table" data-ng-class="{'view-mode': isViewMode()}"> + <div class="head flex-container"> + <div class="table-header head-row hand flex-item" data-ng-repeat="header in tableHeadersList track by $index" data-ng-click="sort(header.property)">{{header.title}} + <span data-ng-if="sortBy === header.property" class="table-header-sort-arrow" data-ng-class="{'down': reverse, 'up':!reverse}"> </span> + </div> + <div class="table-no-text-header head-row flex-item" ng-if="!isViewMode()"><span class="delete-col-header"></span></div> + <!--div class="table-no-text-header head-row flex-item"></div--> + </div> + + <div class="body"> + <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> + <div data-ng-if="component.properties.length === 0" class="no-row-text" data-ng-class="{'disabled': isDisableMode()}"> + There are no properties to display <br> + <span ng-if="!isViewMode()"> click <a data-ng-click="addOrUpdateProperty()">here</a> to add one </span> + + </div> + <div data-ng-repeat="property in filteredProperties=(component.properties | orderBy:sortBy:reverse | filter: {filterTerm:filterTerms}) track by $index" + data-tests-id="propertyRow" data-ng-class="{'selected': property.selected}" + class="flex-container data-row"> + + <div class="table-col-general flex-item text" tooltips tooltip-content="{{property.name}}"> + <a data-tests-id="propertyName_{{property.name}}" + data-ng-click="addOrUpdateProperty(property); $event.stopPropagation();" + data-ng-class="{'disabled': isViewMode()}">{{property.name}}</a> + + </div> + + <div class="table-col-general flex-item text" + tooltips tooltip-content="{{property.type}}"> + <span data-tests-id="propertyType_{{property.name}}"> {{property.type.replace("org.openecomp.datatypes.heat.","")}}</span> + </div> + <div class="table-col-general flex-item text" + tooltips tooltip-content="{{property.schema.property.type}}"> + <span data-tests-id="propertySchema_{{property.name}}"> {{property.schema.property.type.replace("org.openecomp.datatypes.heat.","")}}</span> + </div> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{property.description}}"> + <span data-tests-id="propertyDescription_{{property.name}}" data-ng-bind="property.description"></span> + </div> + <div class="table-btn-col flex-item" ng-if="!isViewMode()"> + <button class="table-delete-btn" data-tests-id="delete_{{property.name}}" data-ng-if="property.parentUniqueId==component.uniqueId" + data-ng-click="delete(property); $event.stopPropagation();" data-ng-class="{'disabled': isViewMode()}"> </button> + </div> + </div> + </perfect-scrollbar> + </div> + + </div> + </div> + +</div> diff --git a/catalog-ui/src/app/view-models/workspace/tabs/properties/properties.less b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties.less new file mode 100644 index 0000000000..3e8d6c3fbd --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties.less @@ -0,0 +1,115 @@ +.workspace-properties { + + width: 93%; + display: inline-block; + + #left-top-bar{ + float: left; + width: 155px; + ::-webkit-input-placeholder { + font-style: italic; + } + :-moz-placeholder { + font-style: italic; + } + ::-moz-placeholder { + font-style: italic; + } + :-ms-input-placeholder { + font-style: italic; + } + + #properties-count{ + font-weight: bold; + float: left; + } + + #search-by-name{ + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; + width: 245px; + height: 32px; + line-height: 32px; + border: 1px solid @main_color_o; + text-indent: 10px; + } + + .search-button{ + .hand; + cursor: pointer; + float: right; + position: relative; + top: -22px; + right: -80px; + } + } + + .add-btn { + margin: 36px 0 0 0; + } + + .delete-col-header{ + .sprite; + .sprite.e-sdc-small-icon-delete; + } + + .w-sdc-classic-btn { + float: right; + margin-bottom: 10px; + } + + .table{ + height:490px; + margin-bottom: 0; + } + + .data-row{ + .table-delete-btn{ + display: none !important; + } + &:hover{ + .table-delete-btn{ + display: inline-block !important; + } + } + } + + .table-container-flex { + margin-top: 27px; + + .text{ + overflow: hidden; + text-overflow: ellipsis; + display: inline-block; + white-space: nowrap; + } + + .flex-item:nth-child(1) { + flex-grow: 15; + a{ + .hand + } + } + + .flex-item:nth-child(2) { + flex-grow: 6; + } + + .flex-item:nth-child(3) { + flex-grow: 6; + } + + .flex-item:nth-child(4) { + flex-grow: 20; + + } + .flex-item:nth-child(5) { + flex-grow: 3; + padding-top: 10px; + } + + + } + +} |