aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties
diff options
context:
space:
mode:
authorfranciscovila <javier.paradela.vila@est.tech>2022-11-24 10:29:04 +0000
committerMichael Morris <michael.morris@est.tech>2023-01-26 23:32:10 +0000
commit701e441228724c5b701d94cc3f1e520ce656398a (patch)
tree5900482086d86f8b8e465e6d4b57db4bd7a94184 /catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties
parent1bbecd7edbdd907a53812d303d378236d23d071e (diff)
Import data type in UI
Develop all necessary changes in the UI to allow importing a data type from a yaml file Issue-ID: SDC-4279 Signed-off-by: franciscovila <javier.paradela.vila@est.tech> Change-Id: Id413386fad8b362e8c4a1d25c859a22178189074
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties')
-rw-r--r--catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.spec.ts30
-rw-r--r--catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.ts38
2 files changed, 55 insertions, 13 deletions
diff --git a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.spec.ts b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.spec.ts
index e6e9c12d14..f89be56359 100644
--- a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.spec.ts
+++ b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.spec.ts
@@ -31,6 +31,10 @@ import {DataTypeModel} from "../../../../models/data-types";
import {Component, ViewChild} from "@angular/core";
import {PropertyBEModel} from "../../../../models/properties-inputs/property-be-model";
import {ModalService} from "../../../services/modal.service";
+import {IScope} from "../../../../../typings/angularjs/angular";
+import {IWorkspaceViewModelScope} from "../../../../view-models/workspace/workspace-view-model";
+import {States} from "../../../../utils/constants";
+import {SdcUiServices} from "onap-ui-angular/dist";
describe('TypeWorkspacePropertiesComponent', () => {
const messages = require("../../../../../assets/languages/en_US.json");
@@ -54,6 +58,28 @@ describe('TypeWorkspacePropertiesComponent', () => {
return messages[translateKey];
})
};
+ let importedFileMock: File = null;
+ let stateParamsMock: Partial<ng.ui.IStateParamsService> = {
+ 'importedFile': importedFileMock
+ };
+ let resolveMock = {"$stateParams": stateParamsMock};
+ let parentScopeMock: Partial<IScope> = {
+ '$resolve': resolveMock
+ };
+ let scopeMock_: Partial<IWorkspaceViewModelScope> = {
+ '$parent': parentScopeMock,
+ 'current': {
+ 'name': States.TYPE_WORKSPACE
+ }
+ }
+ let stateMock: Partial<ng.ui.IStateService> = {
+ 'current': {
+ 'name': States.TYPE_WORKSPACE
+ }
+ };
+
+ let modalServiceSdcUIMock: Partial<SdcUiServices.ModalService>;
+ let modalServiceMock: Partial<ModalService>;
beforeEach(async(() => {
TestBed.configureTestingModule({
@@ -65,6 +91,10 @@ describe('TypeWorkspacePropertiesComponent', () => {
providers: [
{provide: DataTypeService, useValue: dataTypeServiceMock},
{provide: TranslateService, useValue: translateServiceMock},
+ {provide: SdcUiServices.ModalService, useValue: modalServiceSdcUIMock},
+ {provide: ModalService, useValue: modalServiceMock},
+ {provide: "$scope", useValue: scopeMock_},
+ {provide: '$state', useValue: stateMock},
{provide: ModalService, useValue: modalService}
]
})
diff --git a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.ts b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.ts
index f53ad5b376..bcc5fe9c28 100644
--- a/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.ts
+++ b/catalog-ui/src/app/ng2/pages/type-workspace/type-workspace-properties/type-workspace-properties.component.ts
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-import {Component, Input, OnInit} from '@angular/core';
+import {Component, Inject, Input, OnInit} from '@angular/core';
import {DataTypeModel} from "../../../../models/data-types";
import {DataTypeService} from "../../../services/data-type.service";
import {PropertyBEModel} from "../../../../models/properties-inputs/property-be-model";
@@ -30,6 +30,8 @@ import {ModalModel} from "../../../../models/modal";
import {ButtonModel} from "../../../../models/button";
import {TranslateService} from "../../../shared/translator/translate.service";
import {AddPropertyComponent, PropertyValidationEvent} from "./add-property/add-property.component";
+import {IWorkspaceViewModelScope} from "../../../../view-models/workspace/workspace-view-model";
+import {SdcUiServices} from "onap-ui-angular/dist";
@Component({
selector: 'app-type-workspace-properties',
@@ -40,6 +42,8 @@ export class TypeWorkspacePropertiesComponent implements OnInit {
@Input() isViewOnly = true;
@Input() dataType: DataTypeModel = new DataTypeModel();
+ importedFile: File;
+ derivedFromName: string;
properties: Array<PropertyBEModel> = [];
filteredProperties: Array<PropertyBEModel> = [];
tableHeadersList: Array<TableHeader> = [];
@@ -48,7 +52,12 @@ export class TypeWorkspacePropertiesComponent implements OnInit {
tableFilterTerm: string = undefined;
tableSearchTermUpdate = new Subject<string>();
- constructor(private dataTypeService: DataTypeService, private modalService: ModalService, private translateService: TranslateService) {
+ constructor(@Inject('$scope') private $scope: IWorkspaceViewModelScope,
+ @Inject('$state') private $state: ng.ui.IStateService,
+ protected dataTypeService: DataTypeService,
+ private modalServiceSdcUI: SdcUiServices.ModalService,
+ private modalService: ModalService,
+ private translateService: TranslateService) {
}
ngOnInit(): void {
@@ -70,22 +79,12 @@ export class TypeWorkspacePropertiesComponent implements OnInit {
{title: 'Required', property: 'required'},
{title: 'Description', property: 'description'},
];
-
this.tableSortBy = this.tableHeadersList[0].property;
}
private initProperties(): void {
this.dataTypeService.findAllProperties(this.dataType.uniqueId).subscribe(properties => {
- this.properties = properties.map(value => {
- const property = new PropertyBEModel(value);
- if (property.defaultValue) {
- property.defaultValue = JSON.parse(property.defaultValue);
- }
-
- return property;
- });
- this.filteredProperties = Array.from(this.properties);
- this.sort();
+ this.showPropertiesMap(properties);
});
}
@@ -188,6 +187,19 @@ export class TypeWorkspacePropertiesComponent implements OnInit {
onRowClick(property: PropertyBEModel) {
this.openAddPropertyModal(property, true);
}
+
+ private showPropertiesMap(properties: Array<PropertyBEModel>): void {
+ this.properties = properties.map(value => {
+ const property = new PropertyBEModel(value);
+ if (property.defaultValue) {
+ property.defaultValue = JSON.parse(property.defaultValue);
+ }
+
+ return property;
+ });
+ this.filteredProperties = Array.from(this.properties);
+ this.sort();
+ }
}
interface TableHeader {