export const LoopbackConfig = {
url: "http://127.0.0.1:3000",
authtoken: "ccsdkapps"
+}
+
+export const ResourceDictionaryURLs = {
+ saveResourceDictionary: '/resourcedictionary/save',
+ searchResourceDictionaryByTags: '/resourcedictionary/search',
+ searchResourceDictionaryByName: ''
}
\ No newline at end of file
if(!searchText) return items;
searchText = searchText.toLowerCase();
return items.filter( it => {
- return it.toLowerCase().includes(searchText);
+ if(it.tags) {
+ return it.tags.toLowerCase().includes(searchText);
+ } else {
+ return items;
+ }
});
}
}
\ No newline at end of file
})
export class ExistingModelComponent implements OnInit {
- resourceName:string;
+ resource:any;
constructor(private store: Store<IAppState>) { }
selectedResource(value){
console.log(value);
- this.resourceName=value;
+ this.resource=value;
+ this.updateResourcesState();
}
getDataUsingResouceName(){
updateResourcesState() {
var me = this;
var data:IResources;
- me.store.dispatch(new LoadResourcesSuccess(data));
+ me.store.dispatch(new LoadResourcesSuccess(this.resource));
}
--- /dev/null
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved.
+===================================================================
+
+Unless otherwise specified, all software contained herein is licensed
+under the Apache License, Version 2.0 (the License);
+you may not use this software except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+============LICENSE_END============================================
+*/
+
+
+import { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+import { Observable, observable } from 'rxjs';
+import { ApiService } from '../../../../common/core/services/api.service';
+import { LoopbackConfig, ResourceDictionaryURLs } from '../../../../common/constants/app-constants';
+
+@Injectable()
+export class ExsistingModelService {
+ // blueprintUrl = '../../constants/blueprint.json';
+
+ constructor(private _http: HttpClient, private api: ApiService) {
+ }
+
+ searchByTags(tag) {
+ return this.api.get(LoopbackConfig.url+ ResourceDictionaryURLs.searchResourceDictionaryByTags + '/' + tag);
+ }
+}
\ No newline at end of file
<form class="example-form" [formGroup]="myControl">
<mat-form-field class="example-full-width">
<input type="text" [(ngModel)]="searchText" placeholder="Search Resources" matInput [matAutocomplete]="auto" formControlName="search_input">
- <button matSuffix mat-icon-button><mat-icon>search</mat-icon></button>
+ <button matSuffix mat-icon-button (click)="fetchResourceByName()"><mat-icon>search</mat-icon></button>
<mat-autocomplete #auto="matAutocomplete">
- <mat-option (click)="selected(option)" *ngFor="let option of options | search : searchText" [value]="option">
- {{option}}
+ <mat-option (click)="selected(option)" *ngFor="let option of options | search : searchText" [value]="option.tags">
+ {{option.tags}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
import { Component, OnInit, ViewChild, EventEmitter, Output } from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
+import { ExsistingModelService } from '../exsisting-model.service';
+
@Component({
selector: 'app-search-resource',
templateUrl: './search-resource.component.html',
myControl: FormGroup;
@Output() resourcesData = new EventEmitter();
- options: string[] = ['One','One1', 'Two', 'Three'];
- constructor(private _formBuilder: FormBuilder) { }
+ options: any[] = [] ;
+ // = ['One','One1', 'Two', 'Three'];
+
+ searchText: string = '';
+ constructor(private _formBuilder: FormBuilder,
+ private exsistingModelService: ExsistingModelService) { }
ngOnInit() {
this.myControl = this._formBuilder.group({
}
selected(value){
this.resourcesData.emit(value);
- }
+ }
+
+ fetchResourceByName() {
+ this.exsistingModelService.searchByTags(this.searchText)
+ .subscribe(data=>{
+ console.log(data);
+ data.forEach(element => {
+ this.options.push(element)
+ });
+ // this.options = data.
+ }, error=>{
+ window.alert('error' + error);
+ })
+ }
}
<mat-step [stepControl]="step1FormGroup">
<ng-template matStepLabel>Choose Resource file</ng-template>
<br>
- <app-resource-template-options (options)="selectedOption($event)"></app-resource-template-options>
+ <app-resource-template-options (option)="selectedOption($event)"></app-resource-template-options>
<br>
<div>
<button mat-button matStepperNext class="matStepNextBtn">Proceed</button>
</mat-step>
<mat-step [stepControl]="step2FormGroup">
<ng-template matStepLabel>Browse or Search Resources</ng-template>
- <app-upload-resource (fileData)=upload($event)></app-upload-resource><br><br>
- <app-existing-model></app-existing-model>
+ <app-upload-resource (fileData)=upload($event) *ngIf="selectedValue == 1"></app-upload-resource><br><br>
+ <app-existing-model *ngIf="selectedValue == 3"></app-existing-model>
<div>
- <button mat-button matStepperNext (click)="updateResourcesState()" class="matStepNextBtn">Upload</button>
+ <button mat-button matStepperNext (click)="updateResourcesState()" class="matStepNextBtn" *ngIf="selectedValue == 1">Upload</button>
</div><br><br>
<div *ngIf="showMsg">
<p class="success"><strong>File Upload Success!</strong> Please click Proceed to continue!</p>
import { SharedModule } from '../../../../app/common/shared/shared.module';
import { FormsModule,ReactiveFormsModule } from '@angular/forms';
+import { ExsistingModelService } from './existing-model/exsisting-model.service';
+
@NgModule({
declarations: [
MatFormFieldModule,
MatStepperModule,
MatAutocompleteModule
- ]
+ ],
+ providers: [ ExsistingModelService ]
})
export class ResourceCreationModule { }