summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/services
diff options
context:
space:
mode:
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;
};