diff options
Diffstat (limited to 'cds-ui')
14 files changed, 89 insertions, 185 deletions
diff --git a/cds-ui/client/src/app/common/constants/app-constants.ts b/cds-ui/client/src/app/common/constants/app-constants.ts index bcfcc4e0c..5ebde91e3 100644 --- a/cds-ui/client/src/app/common/constants/app-constants.ts +++ b/cds-ui/client/src/app/common/constants/app-constants.ts @@ -93,6 +93,16 @@ export const GlobalContants = { } }; +export const BlueprintURLs = { + getAllBlueprints: '/controllerblueprint/all', + searchByTag: '/controllerblueprint/searchByTags/', + save: '/controllerblueprint/create-blueprint', + publish: '/controllerblueprint/publish', + enrich: '/controllerblueprint/enrich-blueprint', + download: '/controllerblueprint/download-blueprint/', + deploy:'/controllerblueprint/deploy-blueprint' +} + export const ResourceDictionaryURLs = { saveResourceDictionary: '/resourcedictionary/save', searchResourceDictionaryByTags: '/resourcedictionary/search', diff --git a/cds-ui/client/src/app/feature-modules/blueprint/blueprint.module.ts b/cds-ui/client/src/app/feature-modules/blueprint/blueprint.module.ts index 4d0781aec..27803ce56 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/blueprint.module.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/blueprint.module.ts @@ -1,7 +1,7 @@ /* ============LICENSE_START========================================== =================================================================== -Copyright (C) 2018 IBM Intellectual Property. All rights reserved. +Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved. =================================================================== Unless otherwise specified, all software contained herein is licensed @@ -30,17 +30,12 @@ import { SelectTemplateModule } from './select-template/select-template.module'; import { ModifyTemplateModule } from './modify-template/modify-template.module'; import { DeployTemplateModule } from './deploy-template/deploy-template.module'; import { TestTemplateModule } from './test-template/test-template.module'; -import { SearchEditCBAComponent } from './search-edit-cba/search-edit-cba.component'; import { AppMaterialModule } from '../../../app/common/modules/app-material.module'; import { ReactiveFormsModule } from '@angular/forms'; @NgModule({ declarations: [ - BlueprintComponent, - SearchEditCBAComponent - ], - exports:[ - SearchEditCBAComponent + BlueprintComponent ], imports: [ CommonModule, diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts index 0a3a8d2ef..7b2eaeb17 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts @@ -35,7 +35,7 @@ import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; import { IBlueprintState } from 'src/app/common/core/store/models/blueprintState.model'; import { LoadBlueprintSuccess, SetBlueprintState } from '../../../../common/core/store/actions/blueprint.action' -import { ApiService } from 'src/app/common/core/services/api.service'; + import { IMetaData } from 'src/app/common/core/store/models/metadata.model'; import { EditorService } from './editor.service'; import { SortPipe } from '../../../../common/shared/pipes/sort.pipe'; @@ -130,7 +130,7 @@ export class EditorComponent implements OnInit { artifactName: any; artifactVersion: any; - constructor(private store: Store<IAppState>, private apiservice: EditorService, + constructor(private store: Store<IAppState>, private editorService: EditorService, private alertService: NotificationHandlerService, private loader: LoaderService ) { @@ -244,7 +244,8 @@ export class EditorComponent implements OnInit { .then(blob => { const formData = new FormData(); formData.append("file", blob); - this.apiservice.enrich("/enrich-blueprint/", formData) + // this.editorService.enrich("/enrich-blueprint/", formData) + this.editorService.enrich(formData) .subscribe( (response) => { this.zipFile.files = {}; @@ -271,7 +272,8 @@ export class EditorComponent implements OnInit { .then(blob => { const formData = new FormData(); formData.append("file", blob); - this.apiservice.post("/create-blueprint/", formData) + // this.editorService.saveBlueprint("/create-blueprint/", formData) + this.editorService.saveBlueprint(formData) .subscribe( data => { this.alertService.success('Success:' + JSON.stringify(data)); @@ -289,7 +291,8 @@ export class EditorComponent implements OnInit { .then(blob => { const formData = new FormData(); formData.append("file", blob); - this.apiservice.deployPost("/deploy-blueprint/", formData) + // this.editorService.deployPost("/deploy-blueprint/", formData) + this.editorService.deployPost(formData) .subscribe(data => { this.alertService.success('Saved Successfully:' + JSON.stringify(data)); }, error=>{ @@ -305,7 +308,8 @@ export class EditorComponent implements OnInit { .then(blob => { const formData = new FormData(); formData.append("file", blob); - this.apiservice.post("/publish/", formData) + // this.editorService.post("/publish/", formData) + this.editorService.publishBlueprint(formData) .subscribe(data => { this.alertService.success('Published:' + JSON.stringify(data)) }, error=>{ @@ -326,7 +330,8 @@ export class EditorComponent implements OnInit { download() { console.log(this.artifactName); - status = this.apiservice.downloadCBA("/download-blueprint/" + this.artifactName + "/" + this.artifactVersion); + // status = this.editorService.downloadCBA("/download-blueprint/" + this.artifactName + "/" + this.artifactVersion); + status = this.editorService.downloadCBA("/"+this.artifactName + "/" + this.artifactVersion); window.alert(status); // .subscribe(response => { // console.log(response); @@ -338,14 +343,8 @@ export class EditorComponent implements OnInit { // console.log(error); // } // ); - - // this.create(); - // var zipFilename = "baseconfiguration.zip"; - // this.zipFile.generateAsync({ type: "blob" }) - // .then(blob => { - // saveAs(blob, zipFilename); - // }); } + setEditorMode() { switch (this.fileExtension) { case "xml": diff --git a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts index ec2524422..025fc95d4 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.service.ts @@ -25,19 +25,18 @@ import { HttpClient } from '@angular/common/http'; import { Observable, observable } from 'rxjs'; import { ApiService } from '../../../../common/core/services/api.service'; import { saveAs } from 'file-saver'; +import { BlueprintURLs } from '../../../../common/constants/app-constants'; @Injectable() export class EditorService { - // blueprintUrl = '../../constants/blueprint.json'; - constructor(private _http: HttpClient, private api: ApiService) { } - enrich(uri: string, body: FormData): Observable<any> { - return this.api.post(uri, body, { responseType: 'blob' }); + enrich(body: FormData): Observable<any> { + return this.api.post(BlueprintURLs.enrich, body, { responseType: 'blob' }); } - downloadCBA(uri: string): string { - this.api.get(uri, { responseType: 'blob' }) + downloadCBA(artifactDetails: string): string { + this.api.get(BlueprintURLs.download+artifactDetails, { responseType: 'blob' }) .subscribe(response => { let blob = new Blob([response], { 'type': "application/octet-stream" }); saveAs(blob, "CBA.zip"); @@ -46,13 +45,17 @@ export class EditorService { return "Download Success"; } - post(uri: string, body: any | null, options?: any): Observable<any> { + saveBlueprint(body: any | null, options?: any): Observable<any> { + + return this.api.post(BlueprintURLs.save, body, options); + } + publishBlueprint(body: any | null, options?: any): Observable<any> { - return this.api.post(uri, body, options); + return this.api.post(BlueprintURLs.publish, body, options); } - deployPost(uri: string, body: any | null, options?: any): Observable<any> { + deployPost(body: any | null, options?: any): Observable<any> { - return this.api.post(uri, body, { responseType: 'text' }); + return this.api.post(BlueprintURLs.deploy, body, { responseType: 'text' }); } }
\ No newline at end of file diff --git a/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.html b/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.html deleted file mode 100644 index 7371d2105..000000000 --- a/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.html +++ /dev/null @@ -1,16 +0,0 @@ -/* ============LICENSE_START========================================== =================================================================== Copyright (C) 2018 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============================================ */ - -<form class="search-form" [formGroup]="myControl"> - <mat-form-field class="search-full-width"> - <input #resourceSelect type="text" [(ngModel)]="searchText" placeholder="Search Resources" matInput [matAutocomplete]="auto" formControlName="search_input"> - <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.tags"> - {{option.tags}} - </mat-option> - </mat-autocomplete> --> - </mat-form-field> -</form>
\ No newline at end of file diff --git a/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.scss b/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.scss deleted file mode 100644 index e69de29bb..000000000 --- a/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.scss +++ /dev/null diff --git a/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.spec.ts b/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.spec.ts deleted file mode 100644 index 78210cf12..000000000 --- a/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { SearchEditCBAComponent } from './search-edit-cba.component'; - -describe('SearchEditCBAComponent', () => { - let component: SearchEditCBAComponent; - let fixture: ComponentFixture<SearchEditCBAComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ SearchEditCBAComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(SearchEditCBAComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.ts deleted file mode 100644 index 4253e2172..000000000 --- a/cds-ui/client/src/app/feature-modules/blueprint/search-edit-cba/search-edit-cba.component.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : CDS -* ================================================================================ -* Copyright 2019 TechMahindra -* -* Modifications Copyright (C) 2019 IBM -*================================================================================= -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file 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 { Component, OnInit, ViewChild, EventEmitter, Output } from '@angular/core'; -import {FormBuilder, FormGroup, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms'; - -import { MatAutocompleteTrigger } from '@angular/material' -@Component({ - selector: 'app-search-edit-cba', - templateUrl: './search-edit-cba.component.html', - styleUrls: ['./search-edit-cba.component.scss'] -}) -export class SearchEditCBAComponent implements OnInit { - - myControl: FormGroup; - @Output() resourcesData = new EventEmitter(); - options: any[] = []; - //['One','One1', 'Two', 'Three']; - // @ViewChild('resourceSelect') resourceSelect; - @ViewChild('resourceSelect', { read: MatAutocompleteTrigger }) resourceSelect: MatAutocompleteTrigger; - - searchText: string = ''; - constructor(private _formBuilder: FormBuilder, - ) { } - - ngOnInit() { - this.myControl = this._formBuilder.group({ - search_input: ['', Validators.required] - }); - } - 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.resourceSelect.openPanel(); - // }, error=>{ - // window.alert('error' + error); - // }) - } - -} diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html index a3c287254..ca260394b 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html @@ -21,6 +21,7 @@ limitations under the License. <form class="search-form" [formGroup]="myControl"> <mat-form-field class="search-full-width"> <input #resourceSelect type="text" [(ngModel)]="searchText" placeholder="Search Resources" matInput [matAutocomplete]="auto" formControlName="search_input"> + <!-- <input #resourceSelect type="text" [(ngModel)]="searchText" placeholder="Search Resources" formControlName="search_input"> --> <button matSuffix mat-icon-button (click)="fetchResourceByName()"> <mat-icon>search</mat-icon> </button> @@ -35,7 +36,7 @@ limitations under the License. <mat-grid-tile *ngFor="let option of options"> <mat-card class="example-card"> <mat-card-content class="card-content"> - {{option}} + {{option.blueprintModel.artifactName}} </mat-card-content> <mat-card-actions> <button mat-menu-item>Edit</button> diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts index 5ae1850cc..1c3630649 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.ts @@ -19,8 +19,8 @@ limitations under the License. ============LICENSE_END============================================ */ -import { Component, OnInit, ViewChild, EventEmitter, Output } from '@angular/core'; -import { FormBuilder, FormGroup, Validators} from '@angular/forms'; +import { Component, OnInit, ViewChild, EventEmitter, Output } from '@angular/core'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { SearchTemplateService } from '../search-template.service'; import { MatAutocompleteTrigger } from '@angular/material'; import { SearchPipe } from 'src/app/common/shared/pipes/search.pipe'; @@ -32,35 +32,36 @@ import { SearchPipe } from 'src/app/common/shared/pipes/search.pipe'; export class SearchFromDatabaseComponent implements OnInit { myControl: FormGroup; - @Output() resourcesData = new EventEmitter(); - options: any[] = []; + @Output() resourcesData = new EventEmitter(); + options: any[] = []; @ViewChild('resourceSelect', { read: MatAutocompleteTrigger }) resourceSelect: MatAutocompleteTrigger; searchText: string = ''; constructor(private _formBuilder: FormBuilder, - private existingModelService: SearchTemplateService) { } - - ngOnInit() { + private searchService: SearchTemplateService) { } + + ngOnInit() { this.myControl = this._formBuilder.group({ search_input: ['', Validators.required] }); } - selected(value){ - this.resourcesData.emit(value); - } + selected(value) { + this.resourcesData.emit(value); + } - fetchResourceByName() { - // this.existingModelService.searchByTags("/searchByTags/",this.searchText) - // .subscribe(data=>{ - // console.log(data); - // data.forEach(element => { - // this.options.push(element) - // }); - // this.resourceSelect.openPanel(); - // }, error=>{ - // window.alert('error' + error); - // }) - this.options=['test','vns','capability','hello','hi','hoi','dfagfagshdgfashdf','adsfhksd']; - } + fetchResourceByName() { + this.searchService.searchByTags(this.searchText) + .subscribe(data => { + // console.log(data); + data.forEach(element => { + this.options.push(element) + }); + // this.resourceSelect.openPanel(); + }, error => { + window.alert('error' + error); + }) + console.log(this.options) + // this.options=['test','vns','capability','hello','hi','hoi','dfagfagshdgfashdf','adsfhksd']; + } } diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.service.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.service.ts index dd17a30d2..31a839cc3 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.service.ts +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.service.ts @@ -23,6 +23,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { ApiService } from '../../../../common/core/services/api.service'; +import { BlueprintURLs } from '../../../../common/constants/app-constants'; @Injectable({ providedIn: 'root' @@ -31,7 +32,7 @@ export class SearchTemplateService { constructor(private _http: HttpClient, private api: ApiService) { } - searchByTags(uri: string, searchText: String): Observable<any>{ - return this.api.post(uri, searchText); + searchByTags(searchText: String): Observable<any>{ + return this.api.get(BlueprintURLs.searchByTag+'/'+searchText); } } diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts index 3c76b8506..3e8f4f8d6 100644 --- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts +++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-edit/sources-template/sources-template.component.ts @@ -87,6 +87,7 @@ export class SourcesTemplateComponent implements OnInit { this.resources.sources = Object.assign({},originalSources); }; + // to remove this method selected(sourceValue){ this.sourcesData= [];//this.sources[value]; this.apiService.getModelType(sourceValue.value) @@ -153,25 +154,25 @@ export class SourcesTemplateComponent implements OnInit { if (typeof (dataitem) == "object") { for (let key1 in dataitem) { if (key1 == 'properties') { - let newPropOnj = {} + let newPropObj = {}; + newPropObj["name"] = event.item.element.nativeElement.innerText; + newPropObj['data'] = {}; + let newSoruceObj = {}; for (let key2 in dataitem[key1]) { - console.log(dataitem[key1][key2]); - let varType = dataitem[key1][key2].type - // let property : varType = - newPropOnj[key2] = dataitem[key1][key2]; + newSoruceObj[key2] = '';; } + newPropObj['data']['properties'] = newSoruceObj; + this.sourcesOptions.forEach(sourcesOptionsitem => { + if (sourcesOptionsitem.name == item.name) { + sourcesOptionsitem.data = newPropObj['data']; + } + }); } } } }); - this.sourcesData = data; - this.sourcesOptions.forEach(sourcesOptionsitem => { - if (sourcesOptionsitem.name == item.name) { - sourcesOptionsitem.data = data; - } - }) - }) - } + }); + } }); } } diff --git a/cds-ui/server/src/controllers/blueprint-rest.controller.ts b/cds-ui/server/src/controllers/blueprint-rest.controller.ts index 14aba5617..c73f7a6f8 100644 --- a/cds-ui/server/src/controllers/blueprint-rest.controller.ts +++ b/cds-ui/server/src/controllers/blueprint-rest.controller.ts @@ -57,7 +57,7 @@ export class BlueprintRestController { public bpservice: BlueprintService, ) { } - @get('/blueprints', { + @get('/controllerblueprint/all', { responses: { '200': { description: 'Blueprint model instance', @@ -69,7 +69,7 @@ export class BlueprintRestController { return await this.bpservice.getAllblueprints(); } - @get('/searchByTags/{tags}', { + @get('/controllerblueprint/searchByTags/{tags}', { responses: { '200': { content: { 'application/json': {} }, @@ -80,7 +80,7 @@ export class BlueprintRestController { return await this.bpservice.getByTags(tags); } - @post('/create-blueprint') + @post('/controllerblueprint/create-blueprint') async upload( @requestBody({ description: 'multipart/form-data value.', @@ -109,7 +109,7 @@ export class BlueprintRestController { }); } - @post('/publish') + @post('/controllerblueprint/publish') async publish( @requestBody({ description: 'multipart/form-data value.', @@ -138,7 +138,7 @@ export class BlueprintRestController { }); } - @post('/enrich-blueprint') + @post('/controllerblueprint/enrich-blueprint') async enrich( @requestBody({ description: 'multipart/form-data value.', @@ -167,7 +167,7 @@ export class BlueprintRestController { }); } - @get('/download-blueprint/{name}/{version}') + @get('/controllerblueprint/download-blueprint/{name}/{version}') async download( @param.path.string('name') name: string, @param.path.string('version') version: string, @@ -191,7 +191,7 @@ export class BlueprintRestController { }) } - @post('/deploy-blueprint') + @post('/controllerblueprint/deploy-blueprint') async deploy( @requestBody({ description: 'multipart/form-data value.', diff --git a/cds-ui/server/src/controllers/index.ts b/cds-ui/server/src/controllers/index.ts index 59f635149..fd4d9c8ac 100644 --- a/cds-ui/server/src/controllers/index.ts +++ b/cds-ui/server/src/controllers/index.ts @@ -20,4 +20,5 @@ limitations under the License. */ export * from './ping.controller'; +export * from './blueprint-rest.controller'; export * from './data-dictionary.controller'; |