From ed64b5edff15e702493df21aa3230b81593e6133 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Fri, 9 Jun 2017 03:19:04 +0300 Subject: [SDC-29] catalog 1707 rebase commit. Change-Id: I43c3dc5cf44abf5da817649bc738938a3e8388c1 Signed-off-by: Michael Lando --- .../tabs/properties/properties-view-model.ts | 92 +++++++++++++++++ .../workspace/tabs/properties/properties-view.html | 59 +++++++++++ .../workspace/tabs/properties/properties.less | 115 +++++++++++++++++++++ 3 files changed, 266 insertions(+) create mode 100644 catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts create mode 100644 catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view.html create mode 100644 catalog-ui/src/app/view-models/workspace/tabs/properties/properties.less (limited to 'catalog-ui/src/app/view-models/workspace/tabs/properties') 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; + reverse:boolean; + sortBy:string; + filteredProperties:Array; + + 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 @@ +
+
+ Total Properties: {{component.properties.length}} + + +
+
Add Property
+
+
+
+
{{header.title}} + +
+
+ +
+ +
+ +
+ There are no properties to display
+ click here to add one + +
+
+ + + +
+ {{property.type.replace("org.openecomp.datatypes.heat.","")}} +
+
+ {{property.schema.property.type.replace("org.openecomp.datatypes.heat.","")}} +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
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; + } + + + } + +} -- cgit 1.2.3-korg