summaryrefslogtreecommitdiffstats
path: root/catalog-ui
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2021-08-16 17:08:17 +0100
committerMichael Morris <michael.morris@est.tech>2021-08-20 11:21:08 +0000
commit502c354da7b9f649d3b9e6a00c159a2ad53e7b1f (patch)
tree8a49353909674455a107f459b9ba6440637f093c /catalog-ui
parentb886cdecf766a51f8c74953d2f0b8187b9e32cab (diff)
Select a Model when Importing a VSP
Change-Id: I7537af4c7279636de7e450ec398210ace376eade Issue-ID: SDC-3670 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-ui')
-rw-r--r--catalog-ui/src/app/models/component-metadata.ts2
-rw-r--r--catalog-ui/src/app/models/components/resource.ts3
-rw-r--r--catalog-ui/src/app/models/csar-component.ts2
-rw-r--r--catalog-ui/src/app/ng2/services/onboarding.service.ts2
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts62
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html22
-rw-r--r--catalog-ui/src/app/view-models/workspace/workspace-view-model.ts5
7 files changed, 75 insertions, 23 deletions
diff --git a/catalog-ui/src/app/models/component-metadata.ts b/catalog-ui/src/app/models/component-metadata.ts
index 1cbecda2b3..351ae4a79b 100644
--- a/catalog-ui/src/app/models/component-metadata.ts
+++ b/catalog-ui/src/app/models/component-metadata.ts
@@ -126,6 +126,7 @@ export class ComponentMetadata implements IComponentMetadata {
public resourceType: string;
public csarUUID: string;
public csarVersion: string;
+ public csarVersionId: string;
public derivedList: string[];
public vendorName: string;
public vendorRelease: string;
@@ -134,6 +135,7 @@ export class ComponentMetadata implements IComponentMetadata {
public csarPackageType: string;
public packageId: string;
public iconSprite: string;
+ public models: string[];
// Service only
public serviceFunction: string;
diff --git a/catalog-ui/src/app/models/components/resource.ts b/catalog-ui/src/app/models/components/resource.ts
index 733f2ff9d1..267a8b4bd6 100644
--- a/catalog-ui/src/app/models/components/resource.ts
+++ b/catalog-ui/src/app/models/components/resource.ts
@@ -47,6 +47,7 @@ export class Resource extends Component {
// Onboarding parameters
public csarUUID:string;
public csarVersion:string;
+ public csarVersionId: string;
public csarPackageType:string;
public packageId:string;
@@ -61,6 +62,7 @@ export class Resource extends Component {
this.resourceType = component.resourceType;
this.csarUUID = component.csarUUID;
this.csarVersion = component.csarVersion;
+ this.csarVersionId = component.csarVersionId;
this.resourceVendorModelNumber = component.resourceVendorModelNumber;
this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version + ' ' + this.resourceType;
if (component.categories && component.categories[0] && component.categories[0].subcategories && component.categories[0].subcategories[0]) {
@@ -82,6 +84,7 @@ export class Resource extends Component {
this.resourceType = componentMetadata.resourceType;
this.csarUUID = componentMetadata.csarUUID;
this.csarVersion = componentMetadata.csarVersion;
+ this.csarVersionId = componentMetadata.csarVersionId;
this.derivedFrom = componentMetadata.derivedFrom;
this.resourceVendorModelNumber = componentMetadata.resourceVendorModelNumber;
this.setComponentDisplayData();
diff --git a/catalog-ui/src/app/models/csar-component.ts b/catalog-ui/src/app/models/csar-component.ts
index cb89f0ba5e..e388550ccb 100644
--- a/catalog-ui/src/app/models/csar-component.ts
+++ b/catalog-ui/src/app/models/csar-component.ts
@@ -25,6 +25,7 @@ export interface ICsarComponent {
description:string;
vspName:string;
version:string;
+ versionId:string;
packageId:string;
category:string;
subCategory:string
@@ -32,5 +33,6 @@ export interface ICsarComponent {
packageType:string;
resourceType:string;
vendorRelease:string;
+ models: Array<string>;
}
diff --git a/catalog-ui/src/app/ng2/services/onboarding.service.ts b/catalog-ui/src/app/ng2/services/onboarding.service.ts
index 51a7fc4c7f..638603f94a 100644
--- a/catalog-ui/src/app/ng2/services/onboarding.service.ts
+++ b/catalog-ui/src/app/ng2/services/onboarding.service.ts
@@ -112,6 +112,7 @@ export class OnboardingService {
newMetadata.csarUUID = csar.packageId;
newMetadata.csarPackageType = csar.packageType;
newMetadata.csarVersion = csar.version;
+ newMetadata.csarVersionId = csar.versionId;
newMetadata.packageId = csar.packageId;
newMetadata.description = csar.description;
newMetadata.selectedCategory = selectedCategory && selectedSubCategory ? selectedCategory.name + "_#_" + selectedSubCategory.name : '';
@@ -121,6 +122,7 @@ export class OnboardingService {
newMetadata.tags = [];
newMetadata.icon = DEFAULT_ICON;
newMetadata.iconSprite = "sprite-resource-icons";
+ newMetadata.models = csar.models;
return newMetadata;
};
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
index c78852de4c..c319b806c0 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
@@ -81,6 +81,7 @@ export interface IGeneralScope extends IWorkspaceViewModelScope {
componentModel:componentModel;
instantiationTypes:Array<instantiationType>;
isHiddenCategorySelected: boolean;
+ isModelRequired: boolean;
save():Promise<any>;
revert():void;
@@ -102,6 +103,7 @@ export interface IGeneralScope extends IWorkspaceViewModelScope {
updateIcon():void;
possibleToUpdateIcon():boolean;
initModel():void;
+ isVspImport(): boolean;
}
// tslint:disable-next-line:max-classes-per-file
@@ -465,12 +467,48 @@ export class GeneralViewModel {
};
this.$scope.initModel = ():void => {
- this.$scope.models = new Array();
+ this.$scope.isModelRequired = false;
+ this.$scope.models = [{id: '', name: 'SDC AID'}];
+ if (this.$scope.isCreateMode() && this.$scope.isVspImport()) {
+ if (this.$scope.component.componentMetadata.models) {
+ this.$scope.isModelRequired = true;
+ const modelOptions = this.$scope.component.componentMetadata.models.map(value => {
+ return {id: value, name: value};
+ });
+ if (modelOptions.length == 1) {
+ this.$scope.models = modelOptions;
+ this.$scope.component.model = modelOptions[0].id;
+ } else {
+ this.$scope.models = [{id: '', name: 'Select'}, ...modelOptions];
+ }
+ }
+ return;
+ }
+
this.modelService.getModels().subscribe((modelsFound: Model[]) => {
- modelsFound.forEach(model => {this.$scope.models.push(model.name)});})
- this.$scope.models.filter(model => model.name === this.$scope.component).model;
+ modelsFound.forEach(model => {this.$scope.models.push({id: model.name, name: model.name})});
+ });
+
+ this.$scope.models.sort(function (model1, model2) {
+ if (model1.id > model2.id) {
+ return 1;
+ }
+ if (model1.id < model2.id) {
+ return -1;
+ }
+ return 0;
+ });
};
+ this.$scope.isVspImport = (): boolean => {
+ if (!this.$scope.component || !this.$scope.component.isResource()) {
+ return false;
+ }
+
+ const resource = <Resource>this.$scope.component;
+ return resource.isCsarComponent();
+ }
+
this.$scope.initEnvironmentContext = ():void => {
if (this.$scope.componentType === ComponentType.SERVICE) {
this.$scope.environmentContextObj = this.cacheService.get('UIConfiguration').environmentContext;
@@ -725,15 +763,15 @@ export class GeneralViewModel {
this.$scope.onModelChange = (): void => {
if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component && this.$scope.component.categories) {
- let modelName = this.$scope.component.model ? this.$scope.component.model : null;
- this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => {
- this.$scope.baseTypes = []
- this.$scope.baseTypeVersions = []
- data.forEach(baseType => this.$scope.baseTypes.push(baseType.toscaResourceName));
- data[0].versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
- this.$scope.component.derivedFromGenericType = data[0].toscaResourceName;
- this.$scope.component.derivedFromGenericVersion = data[0].versions[0];
- })
+ let modelName = this.$scope.component.model ? this.$scope.component.model : null;
+ this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => {
+ this.$scope.baseTypes = []
+ this.$scope.baseTypeVersions = []
+ data.forEach(baseType => this.$scope.baseTypes.push(baseType.toscaResourceName));
+ data[0].versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
+ this.$scope.component.derivedFromGenericType = data[0].toscaResourceName;
+ this.$scope.component.derivedFromGenericVersion = data[0].versions[0];
+ });
}
};
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
index fa4af6d6f5..f9854e2256 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html
@@ -611,17 +611,17 @@
<!--------------------- Model -------------------->
<div class="i-sdc-form-item">
- <label class="i-sdc-form-label">Model</label>
- <select class="i-sdc-form-select"
- name="modelName"
- data-ng-class="{'view-mode': isViewMode()}"
- data-ng-disabled="component.isCsarComponent() || !isCreateMode()"
- data-ng-model="component.model"
- data-ng-change="onModelChange()"
- data-tests-id="modelName">
- <option value="">SDC AID</option>
- <option ng-repeat="model in models | orderBy:[name]">{{model}}</option>
- </select>
+ <label class="i-sdc-form-label required">Model</label>
+ <select class="i-sdc-form-select"
+ name="modelName"
+ data-ng-class="{'view-mode': isViewMode()}"
+ data-ng-disabled="!isCreateMode()"
+ data-ng-model="component.model"
+ data-ng-change="onModelChange()"
+ data-tests-id="modelName"
+ ng-required="isModelRequired">
+ <option ng-repeat="model in models" value="{{model.id}}">{{model.name}}</option>
+ </select>
</div>
<!--------------------- Model -------------------->
diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
index e132d53eaf..411ef10639 100644
--- a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
@@ -55,6 +55,10 @@ import { IDependenciesServerResponse } from '../../ng2/services/responses/depend
import { WorkspaceNg1BridgeService } from '../../ng2/pages/workspace/workspace-ng1-bridge-service';
import { WorkspaceService } from '../../ng2/pages/workspace/workspace.service';
+interface ModelSelectOption {
+ id: string;
+ name: string;
+}
export interface IWorkspaceViewModelScope extends ng.IScope {
@@ -92,6 +96,7 @@ export interface IWorkspaceViewModelScope extends ng.IScope {
unsavedChangesCallback: Function;
unsavedFile: boolean;
hasNoDependencies: boolean;
+ models: Array<ModelSelectOption>;
startProgress(message: string): void;