Created loopback API function to fetch data-types from backend and
display them in data-type drop-down
Issue-ID: CCSDK-707
Change-Id: I797177b9042558c99a94df9c9dd4295c43389d29
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
searchResourceDictionaryByTags: '/resourcedictionary/search',
searchResourceDictionaryByName: '',
getSources: '/resourcedictionary/source-mapping',
searchResourceDictionaryByTags: '/resourcedictionary/search',
searchResourceDictionaryByName: '',
getSources: '/resourcedictionary/source-mapping',
- getModelType: '/resourcedictionary/model-type'
+ getModelType: '/resourcedictionary/model-type',
+ getDataType: '/resourcedictionary/model-type/by-definition/data_type'
}
\ No newline at end of file
}
\ No newline at end of file
getModelType(name) {
return this.api.get(ResourceDictionaryURLs.getModelType + '/' + name);
}
getModelType(name) {
return this.api.get(ResourceDictionaryURLs.getModelType + '/' + name);
}
+
+ getDataTypes() {
+ return this.api.get(ResourceDictionaryURLs.getDataType);
+ }
}
\ No newline at end of file
}
\ No newline at end of file
</mat-form-field>
<mat-form-field class="form-field">
<mat-select matInput placeholder="Data Type" formControlName="_type">
</mat-form-field>
<mat-form-field class="form-field">
<mat-select matInput placeholder="Data Type" formControlName="_type">
- <mat-option value="string">string</mat-option>
- <mat-option value="list">list</mat-option>
+ <!-- <mat-option value="string">string</mat-option> -->
+ <!-- <mat-option value="list">list</mat-option> -->
+ <mat-option value="string" *ngFor="let item of dataTypeList">{{item.modelName}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="form-field" >
</mat-select>
</mat-form-field>
<mat-form-field class="form-field" >
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import { IResources } from 'src/app/common/core/store/models/resources.model';
import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import { IResources } from 'src/app/common/core/store/models/resources.model';
import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model';
-import { Observable } from 'rxjs';
+import { Observable, from } from 'rxjs';
import { Store } from '@ngrx/store';
import { IAppState } from '../../../../common/core/store/state/app.state';
import { A11yModule } from '@angular/cdk/a11y';
import { Store } from '@ngrx/store';
import { IAppState } from '../../../../common/core/store/state/app.state';
import { A11yModule } from '@angular/cdk/a11y';
import { LoadResourcesSuccess } from 'src/app/common/core/store/actions/resources.action';
import { IPropertyData } from 'src/app/common/core/store/models/propertyData.model';
import { IEntrySchema } from 'src/app/common/core/store/models/entrySchema.model';
import { LoadResourcesSuccess } from 'src/app/common/core/store/actions/resources.action';
import { IPropertyData } from 'src/app/common/core/store/models/propertyData.model';
import { IEntrySchema } from 'src/app/common/core/store/models/entrySchema.model';
+import { ResourceEditService } from '../resource-edit.service';
@Component({
selector: 'app-resource-metadata',
@Component({
selector: 'app-resource-metadata',
propertyValues = [];
property = [];
@Output() resourcesData = new EventEmitter();
propertyValues = [];
property = [];
@Output() resourcesData = new EventEmitter();
+ dataTypeList: any[] = [
+ {modelName: 'String'}, {modelName: 'Boolean'}, {modelName: 'Integer'}, {modelName: 'Float'}, {modelName: 'Double'}
+ ];
- constructor(private formBuilder: FormBuilder, private store: Store<IAppState>) {
+ constructor(private formBuilder: FormBuilder,
+ private store: Store<IAppState>,
+ private resourceEditService: ResourceEditService) {
this.rdState = this.store.select('resources');
this.ResourceMetadata = this.formBuilder.group({
Resource_Name: ['', Validators.required],
this.rdState = this.store.select('resources');
this.ResourceMetadata = this.formBuilder.group({
Resource_Name: ['', Validators.required],
+ this.resourceEditService.getDataTypes()
+ .subscribe(data=>{
+ console.log(data);
+ if(data) {
+ data.forEach(element => {
+ this.dataTypeList.push(element);
+ });
+ }
+ }, (error)=>{
+ console.log("There is an error");
+ });
this.rdState.subscribe(
resourcesdata => {
var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess };
this.rdState.subscribe(
resourcesdata => {
var resourcesState: IResourcesState = { resources: resourcesdata.resources, isLoadSuccess: resourcesdata.isLoadSuccess, isSaveSuccess: resourcesdata.isSaveSuccess, isUpdateSuccess: resourcesdata.isUpdateSuccess };
async getmodelType(@param.path.string('source') source: string) {
return await this.rdservice.getModelType(source);
}
async getmodelType(@param.path.string('source') source: string) {
return await this.rdservice.getModelType(source);
}
+
+ @get('/resourcedictionary/model-type/by-definition/data_type', {
+ responses: {
+ '200': {
+ content: { 'application/json': {} },
+ },
+ },
+ })
+ async getDataTypes() {
+ return await this.rdservice.getDataTypes();
+ }
{
"template": {
"method": "GET",
{
"template": {
"method": "GET",
"functions": {
"getModelType": ["source"]
"functions": {
"getModelType": ["source"]
+ }
+ },
+ {
+ "template": {
+ "method": "GET",
+ "url": controllerApiConfig.http.url + "/model-type/by-definition/data_type",
+ "headers": {
+ "accepts": "application/json",
+ "content-type": "application/json",
+ "authorization": controllerApiConfig.http.authToken
+ },
+ "responsePath": "$.*"
+ },
+ "functions": {
+ "getDataTypes": []
+
save(resourceDictionary: JSON): Promise<JSON>;
searchbyNames(resourceDictionaryList: JSON): Promise<JSON>;
getModelType(source: string): Promise<JSON>;
save(resourceDictionary: JSON): Promise<JSON>;
searchbyNames(resourceDictionaryList: JSON): Promise<JSON>;
getModelType(source: string): Promise<JSON>;
+ getDataTypes(): Promise<JSON>;
}
export class ResourceDictionaryServiceProvider implements Provider<ResourceDictionaryService> {
}
export class ResourceDictionaryServiceProvider implements Provider<ResourceDictionaryService> {