aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/shared/services/mapping-editor.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/shared/services/mapping-editor.service.ts')
-rw-r--r--src/app/shared/services/mapping-editor.service.ts57
1 files changed, 36 insertions, 21 deletions
diff --git a/src/app/shared/services/mapping-editor.service.ts b/src/app/shared/services/mapping-editor.service.ts
index b9e2b53..cb47687 100644
--- a/src/app/shared/services/mapping-editor.service.ts
+++ b/src/app/shared/services/mapping-editor.service.ts
@@ -68,11 +68,11 @@ export class MappingEditorService {
public latestAction: any;
public selectedWord: any;
identifier: any;
+ private selectedVNFCType;
private _navItem = {};
private _observer: Observer<any>;
private referenceList = [];
- newObject: any;
-
+ newObject: any
constructor() {
this.navChange$ = new Observable(observer =>
this._observer = observer).share();
@@ -106,12 +106,20 @@ export class MappingEditorService {
}
selectedObj(data) {
this.newObject = data;
+
}
-
saveLatestIdentifier(identifier) {
this.identifier = identifier;
}
+ setSelectedVNFCType(vnfcType) {
+ this.selectedVNFCType = vnfcType;
+ }
+
+ getSelectedVNFCType() {
+ return this.selectedVNFCType;
+ }
+
public getParamContent() {
return this.paramContent;
}
@@ -129,15 +137,15 @@ export class MappingEditorService {
}
- public initialise(editor: any, editorContent: string, modal: any): void {
+ public initialise(editor: any, editorContent: string): void {
this.editor = editor;
this.editor.session = editor.session;
this.editor.selection.session.$backMarkers = {};
this.editorContent = editorContent;
this.editor.$blockScrolling = Infinity;
this.editor.$blockSelectEnabled = false;
- this.initialiseCommands(modal);
- this.editor.setValue(this.editorContent);
+ //this.initialiseCommands(modal);
+ //this.editor.setValue(this.editorContent);
this.refreshEditor();
}
@@ -198,7 +206,7 @@ export class MappingEditorService {
for (var prop in paramJson) {
let value: string = paramJson[prop];
if (value) {
- var occurances = this.editor.findAll(value, {regExp: false});
+ var occurances = this.editor.findAll(value, { regExp: false });
var ranges = this.editor.getSelection().getAllRanges();
if (ranges && occurances && occurances > 0) {
@@ -261,8 +269,8 @@ export class MappingEditorService {
selectedRange.start.column = selectedRange.start.column - 1;
selectedRange.end.column = selectedRange.end.column + 1;
if ((this.editor.session.getTextRange(selectedRange).startsWith(' ')
- || this.editor.session.getTextRange(selectedRange).startsWith('"')
- || this.editor.session.getTextRange(selectedRange).startsWith('>'))
+ || this.editor.session.getTextRange(selectedRange).startsWith('"')
+ || this.editor.session.getTextRange(selectedRange).startsWith('>'))
&& (this.editor.session.getTextRange(selectedRange).endsWith(' ')
|| this.editor.session.getTextRange(selectedRange).endsWith('"')
|| this.editor.session.getTextRange(selectedRange).endsWith(',')
@@ -313,7 +321,7 @@ export class MappingEditorService {
}
public autoAnnotateTemplateForParam(): void {
- var occurances = this.editor.findAll(this.T_KEY_EXPRESSION, {regExp: true});
+ var occurances = this.editor.findAll(this.T_KEY_EXPRESSION, { regExp: true });
var ranges = this.editor.getSelection().getAllRanges();
if (ranges) {
for (var r = 0; r < ranges.length; r++) {
@@ -362,19 +370,25 @@ export class MappingEditorService {
}
replaceNamesWithBlankValues() {
- var occurances = this.editor.findAll(this.SYNC_T_KEY_EXPRESSION, {regExp: true});
+ var occurances = this.editor.findAll(this.SYNC_T_KEY_EXPRESSION, { regExp: true });
var ranges = this.editor.getSelection().getAllRanges();
if (occurances > 0) {
if (ranges) {
for (var r = 0; r < ranges.length; r++) {
let selectedRange: any = ranges[r];
+ // console.log("Selected range == " + selectedRange)
let selectedWord: string = this.editor.session.getTextRange(selectedRange);
let specialKeys = (selectedWord.substring(2, selectedWord.length - 1)).match(this.checkSpecialCharsReg);
- if (selectedWord && this.checkAppliedForNamesOnly(selectedRange) && !specialKeys) {
+ // console.log("Selected word == " + selectedWord.length)
+ //if (!selectedWord.startsWith('<') || !selectedWord.startsWith('{')) {
+ if (specialKeys && specialKeys.length) {
+ }
+
+ else if (selectedWord && this.checkAppliedForNamesOnly(selectedRange) && !specialKeys && this.checkComments(selectedRange)) {
let replaceWord: any = this.KEY_START + '' + this.KEY_MID + selectedWord.substring(2, selectedWord.length - 1) + this.KEY_END;
this.editor.session.replace(selectedRange, replaceWord);
}
-
+ // }
}
}
}
@@ -388,7 +402,8 @@ export class MappingEditorService {
this.hasErrorCode = false;
for (var r = 0; r < ranges.length; r++) {
let keyValue: string = this.editor.session.getTextRange(ranges[r]);
- if (keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) {
+ //console.log("keyValues==="+keyValue)
+ if (this.checkComments(ranges[r]) && keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) {
let key: string = keyValue.substring(keyValue.indexOf(this.KEY_MID) + this.KEY_MID_LENGTH, keyValue.indexOf(this.KEY_END));
let value: string = keyValue.substring(this.KEY_START_LENGTH, keyValue.indexOf(this.KEY_MID));
let specialKeys = key.match(this.checkSpecialCharsReg);
@@ -398,7 +413,7 @@ export class MappingEditorService {
if (this.fromScreen === 'TemplateScreen') {
if (key) {
paramJson[key] = value;
- var obj: any = {'paramName': '', 'paramValue': ''};
+ var obj: any = { 'paramName': '', 'paramValue': '' };
obj.paramName = key;
obj.paramValue = value;
paramData.push(obj);
@@ -408,7 +423,7 @@ export class MappingEditorService {
else if (this.fromScreen === 'MappingScreen') {
if (key) {
paramJson[key] = value;
- var obj: any = {'paramName': '', 'paramValue': ''};
+ var obj: any = { 'paramName': '', 'paramValue': '' };
obj.paramName = key;
obj.paramValue = value;
@@ -449,13 +464,13 @@ export class MappingEditorService {
public refreshMarker(): void {
if (this.editor) {
this.hasErrorCode = false;
- var occurances = this.editor.findAll(this.KEY_EXPRESSION, {regExp: true});
+ var occurances = this.editor.findAll(this.KEY_EXPRESSION, { regExp: true });
var ranges = this.editor.getSelection().getAllRanges();
var keysList = [];
// Populate missing keys
for (var r = 0; r < ranges.length; r++) {
let keyValue: string = this.editor.session.getTextRange(ranges[r]);
- if (keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) {
+ if (this.checkComments(ranges[r]) && keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) {
let key: string = keyValue.substring(keyValue.indexOf(this.KEY_MID) + this.KEY_MID_LENGTH, keyValue.indexOf(this.KEY_END));
let value: string = keyValue.substring(this.KEY_START_LENGTH, keyValue.indexOf(this.KEY_MID));
let specialKeys = key.match(this.checkSpecialCharsReg);
@@ -508,7 +523,7 @@ export class MappingEditorService {
public generateTemplate(templateEditor: any): void {
if (templateEditor) {
templateEditor.setValue(this.editor.getValue());
- var occurances = templateEditor.findAll(this.KEY_EXPRESSION, {regExp: true});
+ var occurances = templateEditor.findAll(this.KEY_EXPRESSION, { regExp: true });
var ranges = templateEditor.getSelection().getAllRanges();
if (ranges) {
for (var r = 0; r < ranges.length; r++) {
@@ -532,7 +547,7 @@ export class MappingEditorService {
public generateParams(paramsEditor: any, paramsKeyValueEditor: any): JSON {
if (paramsEditor && paramsKeyValueEditor) {
- var occurances = this.editor.findAll(this.KEY_EXPRESSION, {regExp: true});
+ var occurances = this.editor.findAll(this.KEY_EXPRESSION, { regExp: true });
var ranges = this.editor.getSelection().getAllRanges();
if (ranges) {
let paramsJSON: JSON = JSON.parse('{}');
@@ -593,4 +608,4 @@ export class MappingEditorService {
}
-}
+} \ No newline at end of file