aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/services
diff options
context:
space:
mode:
authoraribeiro <anderson.ribeiro@est.tech>2021-07-15 09:18:37 +0100
committeraribeiro <anderson.ribeiro@est.tech>2021-08-06 17:22:20 +0100
commit47bcc63a9daff1f310125fed006f27c93656fa83 (patch)
tree3c61670b039c0e63d14880f909e6047d54776492 /catalog-ui/src/app/services
parent0ed125f98ae8ea9e80c855a640c328654660d081 (diff)
Retrieve data types based on component model
Issue-ID: SDC-3660 Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: I09c533eb39277532b29e581e4dd57e9df952e8e6
Diffstat (limited to 'catalog-ui/src/app/services')
-rw-r--r--catalog-ui/src/app/services/data-types-service.ts32
1 files changed, 24 insertions, 8 deletions
diff --git a/catalog-ui/src/app/services/data-types-service.ts b/catalog-ui/src/app/services/data-types-service.ts
index 0237b2f3de..08b49ae422 100644
--- a/catalog-ui/src/app/services/data-types-service.ts
+++ b/catalog-ui/src/app/services/data-types-service.ts
@@ -20,7 +20,15 @@
'use strict';
import { DataTypePropertyModel } from "../models/data-type-properties";
-import {ComponentInstance, InputModel, DataTypesMap, PropertyModel, InputPropertyBase, IAppConfigurtaion, SchemaProperty} from "../models";
+import {
+ ComponentInstance,
+ InputModel,
+ DataTypesMap,
+ PropertyModel,
+ InputPropertyBase,
+ IAppConfigurtaion,
+ SchemaProperty
+} from "../models";
import {PROPERTY_DATA} from "../utils/constants";
export interface IDataTypesService {
@@ -32,7 +40,7 @@ export interface IDataTypesService {
selectedInstance:ComponentInstance;
selectedComponentInputs:Array<InputModel>;
//declare methods
- initDataTypes():void;
+ fetchDataTypesByModel(modelName:string):void;
getAllDataTypes():DataTypesMap;
getFirsLevelOfDataTypeProperties(dataTypeName:string):Array<DataTypePropertyModel>;
isDataTypeForSchemaType(property:SchemaProperty):boolean;
@@ -51,9 +59,10 @@ export class DataTypesService implements IDataTypesService {
constructor(private sdcConfig:IAppConfigurtaion,
private $q:ng.IQService,
private $http:ng.IHttpService) {
-
}
+ private baseUrl = this.sdcConfig.api.root + this.sdcConfig.api.component_api_root;
+
dataTypes:DataTypesMap; //Data type map
selectedPropertiesName:string;
selectedInput:PropertyModel;
@@ -61,16 +70,23 @@ export class DataTypesService implements IDataTypesService {
selectedInstance:ComponentInstance;
selectedComponentInputs:Array<InputModel>;
- public initDataTypes = ():void => {
- this.$http({
- url: this.sdcConfig.api.root + this.sdcConfig.api.component_api_root + "dataTypes",
- method: "get"
- }).then((response:any) => {
+ public fetchDataTypesByModel = (modelName: string):void => {
+ let model;
+ if (modelName) {
+ model = {'model': modelName}
+ }
+ this.$http.get(this.baseUrl+"dataTypes", {params: model})
+ .then((response:any) => {
this.dataTypes = response.data;
delete this.dataTypes['tosca.datatypes.Root'];
});
};
+ public getAllDataTypesFromModel = (modelName: string): DataTypesMap => {
+ this.fetchDataTypesByModel(modelName);
+ return this.dataTypes;
+ }
+
public getAllDataTypes = ():DataTypesMap => {
return this.dataTypes;
};