summaryrefslogtreecommitdiffstats
path: root/cds-ui
diff options
context:
space:
mode:
Diffstat (limited to 'cds-ui')
-rw-r--r--cds-ui/client/src/app/common/core/store/models/blueprintState.model.ts1
-rw-r--r--cds-ui/client/src/app/common/core/store/reducers/blueprint.reducer.ts3
-rw-r--r--cds-ui/client/src/app/common/shared/pipes/sort.pipe.ts54
-rw-r--r--cds-ui/client/src/app/common/shared/shared.module.ts8
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts5
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts36
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts7
7 files changed, 106 insertions, 8 deletions
diff --git a/cds-ui/client/src/app/common/core/store/models/blueprintState.model.ts b/cds-ui/client/src/app/common/core/store/models/blueprintState.model.ts
index 13d7d53fe..6d3aa8c93 100644
--- a/cds-ui/client/src/app/common/core/store/models/blueprintState.model.ts
+++ b/cds-ui/client/src/app/common/core/store/models/blueprintState.model.ts
@@ -29,6 +29,7 @@ export interface IBlueprintState {
files?: any;
filesData?: any;
uploadedFileName?: string;
+ entryDefinition?: string;
isLoadSuccess?: boolean;
isUpdateSuccess?: boolean;
isSaveSuccess?: boolean;
diff --git a/cds-ui/client/src/app/common/core/store/reducers/blueprint.reducer.ts b/cds-ui/client/src/app/common/core/store/reducers/blueprint.reducer.ts
index b4347d458..da933ab5e 100644
--- a/cds-ui/client/src/app/common/core/store/reducers/blueprint.reducer.ts
+++ b/cds-ui/client/src/app/common/core/store/reducers/blueprint.reducer.ts
@@ -56,7 +56,8 @@ export function blueprintReducer(state: IBlueprintState = initialBlueprintState,
name: action.payload.name,
files: action.payload.files,
filesData: action.payload.filesData,
- uploadedFileName: action.payload.uploadedFileName
+ uploadedFileName: action.payload.uploadedFileName,
+ entryDefinition: action.payload.entryDefinition
}
default:
return state;
diff --git a/cds-ui/client/src/app/common/shared/pipes/sort.pipe.ts b/cds-ui/client/src/app/common/shared/pipes/sort.pipe.ts
new file mode 100644
index 000000000..f878a2256
--- /dev/null
+++ b/cds-ui/client/src/app/common/shared/pipes/sort.pipe.ts
@@ -0,0 +1,54 @@
+/*
+============LICENSE_START==========================================
+===================================================================
+Copyright (C) 2019 IBM Intellectual propertyNameerty. 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 { Pipe, PipeTransform } from '@angular/core';
+
+@Pipe({
+ name: 'sort',
+ pure:false,
+})
+export class SortPipe implements PipeTransform {
+
+ transform(arrayData: any[], direcion: string, propertyName?: string): any {
+ if (!arrayData) {
+ return [];
+ }
+ if (!direcion || !propertyName) {
+ return arrayData
+ }
+ if (arrayData.length > 0) {
+ const _direction = direcion === 'asc' ? -1 : 1,
+ isArray = Array.isArray(arrayData),
+ arrayDataType = typeof arrayData[0],
+ flag = isArray && arrayDataType === 'object' ? true : isArray && arrayDataType !== 'object' ? false : true;
+ arrayData.sort((a, b) => {
+ a = flag ? a[propertyName] : a;
+ b = flag ? b[propertyName] : b;
+ if (typeof a === 'string') {
+ return a.toLowerCase() > b.toLowerCase() ? -1 * _direction : 1 * _direction;
+ } else if (typeof a === 'number') {
+ return a - b > 0 ? -1 * _direction : 1 * _direction;
+ }
+ });
+ }
+ return arrayData;
+ }
+} \ No newline at end of file
diff --git a/cds-ui/client/src/app/common/shared/shared.module.ts b/cds-ui/client/src/app/common/shared/shared.module.ts
index 6ca5b13a5..b036f5967 100644
--- a/cds-ui/client/src/app/common/shared/shared.module.ts
+++ b/cds-ui/client/src/app/common/shared/shared.module.ts
@@ -29,20 +29,22 @@ import { RouterModule } from "@angular/router";
import { SearchPipe } from './pipes/search.pipe';
import { SearchDialog } from './components/search-dialog/search-dialog.component';
import { AppMaterialModule } from '../modules/app-material.module';
+import { SortPipe } from './pipes/sort.pipe';
@NgModule({
declarations: [
HomeComponent,
CBAWizardComponent,
SearchPipe,
- SearchDialog
-
+ SearchDialog,
+ SortPipe
],
exports: [
HomeComponent,
CBAWizardComponent,
SearchPipe,
- SearchDialog
+ SearchDialog,
+ SortPipe
],
imports: [
AppMaterialModule,
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 09fa00315..b982fa29f 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
@@ -38,6 +38,7 @@ import { LoadBlueprintSuccess, SetBlueprintState } from '../../../../common/core
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';
interface Node {
name: string;
@@ -390,6 +391,7 @@ export class EditorComponent implements OnInit {
newFileNode.data = '';
this.filesData.push(newFileNode);
}
+ this.filesData = new SortPipe().transform(this.filesData, 'asc', 'name');
this.arrangeTreeData(this.filesData);
}
}
@@ -431,7 +433,9 @@ export class EditorComponent implements OnInit {
if (this.validfile) {
this.fetchTOSACAMetadata();
+ this.paths = new SortPipe().transform(this.paths, 'asc', 'name');
this.filesData = this.paths;
+ this.paths = new SortPipe().transform(this.paths, 'asc', 'name');
this.tree = this.arrangeTreeData(this.paths);
} else {
alert('Please update proper file with TOSCA metadata');
@@ -505,6 +509,7 @@ export class EditorComponent implements OnInit {
i = i - 1;
}
}
+ this.filesData = new SortPipe().transform(this.filesData, 'asc', 'name');
this.arrangeTreeData(this.filesData);
}
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts
index 2327a5839..609aacae7 100644
--- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts
+++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts
@@ -23,13 +23,12 @@ import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
-import { A11yModule } from '@angular/cdk/a11y';
import { IAppState } from '../../../../common/core/store/state/app.state';
import { IBlueprintState } from 'src/app/common/core/store/models/blueprintState.model';
import { IBlueprint } from 'src/app/common/core/store/models/blueprint.model';
import { IMetaData } from '../../../../common/core/store/models/metadata.model';
-import { LoadBlueprintSuccess } from 'src/app/common/core/store/actions/blueprint.action';
+import { SetBlueprintState } from 'src/app/common/core/store/actions/blueprint.action';
@Component({
selector: 'app-metadata',
@@ -41,6 +40,13 @@ export class MetadataComponent implements OnInit {
metadata: IMetaData;
bpState: Observable<IBlueprintState>;
blueprint: IBlueprint;
+ filesTree: any = [];
+ filesData: any = [];
+ selectedFile: string;
+ zipFolder: any;
+ blueprintName: string;
+ uploadedFileName: string;
+ entryDefinition: string;
constructor(private formBuilder: FormBuilder, private store: Store<IAppState>) {
this.bpState = this.store.select('blueprint');
@@ -58,6 +64,16 @@ export class MetadataComponent implements OnInit {
this.bpState.subscribe(
blueprintdata => {
var blueprintState: IBlueprintState = { blueprint: blueprintdata.blueprint, isLoadSuccess: blueprintdata.isLoadSuccess, isSaveSuccess: blueprintdata.isSaveSuccess, isUpdateSuccess: blueprintdata.isUpdateSuccess };
+ this.blueprint = blueprintState.blueprint;
+ this.filesTree = blueprintdata.files;
+ this.filesData = blueprintdata.filesData;
+ this.blueprintName = blueprintdata.name;
+ this.uploadedFileName = blueprintdata.uploadedFileName;
+ this.entryDefinition = blueprintdata.entryDefinition;
+
+
+
+ var blueprintState: IBlueprintState = { blueprint: blueprintdata.blueprint, isLoadSuccess: blueprintdata.isLoadSuccess, isSaveSuccess: blueprintdata.isSaveSuccess, isUpdateSuccess: blueprintdata.isUpdateSuccess };
this.metadata = blueprintState.blueprint.metadata;
this.blueprint = blueprintState.blueprint;
let metadatavalues = [];
@@ -82,7 +98,21 @@ export class MetadataComponent implements OnInit {
UploadMetadata() {
this.metadata = Object.assign({}, this.CBAMetadataForm.value);
this.blueprint.metadata = this.metadata;
- this.store.dispatch(new LoadBlueprintSuccess(this.blueprint));
+
+ this.filesData.forEach((fileNode) => {
+ if (fileNode.name.includes(this.blueprintName) && fileNode.name == this.entryDefinition) {
+ fileNode.data = JSON.stringify(this.blueprint, null, "\t");
+ }
+ });
+ let blueprintState = {
+ blueprint: this.blueprint,
+ name: this.blueprintName,
+ files: this.filesTree,
+ filesData: this.filesData,
+ uploadedFileName: this.uploadedFileName,
+ entryDefinition: this.entryDefinition
+ }
+ this.store.dispatch(new SetBlueprintState(blueprintState));
}
} \ No newline at end of file
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts
index 1d0ba2c39..92003c919 100644
--- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts
+++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts
@@ -29,6 +29,7 @@ import { IBlueprintState } from '../../../../common/core/store/models/blueprintS
import { IAppState } from '../../../../common/core/store/state/app.state';
import { LoadBlueprintSuccess, SET_BLUEPRINT_STATE, SetBlueprintState } from '../../../../common/core/store/actions/blueprint.action';
import { json } from 'd3';
+import { SortPipe } from '../../../../common/shared/pipes/sort.pipe';
@Component({
selector: 'app-search-template',
@@ -53,6 +54,7 @@ export class SearchTemplateComponent implements OnInit {
private activationBlueprint: any;
private tocsaMetadaData: any;
private blueprintName: string;
+ private entryDefinition: string;
constructor(private store: Store<IAppState>) { }
@@ -79,7 +81,8 @@ export class SearchTemplateComponent implements OnInit {
name: this.blueprintName,
files: this.tree,
filesData: this.paths,
- uploadedFileName: this.uploadedFileName
+ uploadedFileName: this.uploadedFileName,
+ entryDefinition: this.entryDefinition
}
this.store.dispatch(new SetBlueprintState(blueprintState))
// this.store.dispatch(new LoadBlueprintSuccess(data));
@@ -114,6 +117,7 @@ export class SearchTemplateComponent implements OnInit {
if(this.validfile) {
this.fetchTOSACAMetadata();
+ this.paths = new SortPipe().transform(this.paths, 'asc', 'name');
this.tree = this.arrangeTreeData(this.paths);
} else {
alert('Please update proper file with TOSCA metadata');
@@ -145,6 +149,7 @@ export class SearchTemplateComponent implements OnInit {
this.activationBlueprint = path.data;
newPart.data = JSON.parse(this.activationBlueprint.toString());
console.log('newpart', newPart);
+ this.entryDefinition = path.name.trim();
}
if(newPart.name !== '') {
currentLevel.push(newPart);