Read only mode for CBA view 99/94599/2
authorEzhilarasi <ezhrajam@in.ibm.com>
Thu, 29 Aug 2019 14:42:54 +0000 (20:12 +0530)
committerEzhilarasi R <ezhrajam@in.ibm.com>
Thu, 29 Aug 2019 14:51:25 +0000 (14:51 +0000)
Change-Id: I7fa0fddf14749499692931eeb86bba705de4819f
Issue-ID: CCSDK-1275
Signed-off-by: Ezhilarasi <ezhrajam@in.ibm.com>
cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.html
cds-ui/client/src/app/feature-modules/blueprint/modify-template/editor/editor.component.ts

index 619412c..6424d3f 100644 (file)
@@ -45,12 +45,12 @@ limitations under the License.
             </mat-tree-node>
         </mat-tree>
     </div>
-    <div class="editorConatiner" [ngClass] = "{ 'apply-scrol-to-editor-container' : viewTemplateMode}">
+    <div class="editorConatiner" [ngClass]="{ 'apply-scrol-to-editor-container' : viewTemplateMode}">
         <!-- <i class="fa fa-save save-icon" style="font-size:24px" (click)="updateBlueprint()"></i>
         <ace-editor [(text)]="text" [(mode)]="mode" #editor class="aceEditor"></ace-editor> -->
         <div class="normal-editor-mode" [ngClass]="{ 'resource-mapping-mode': viewTemplateMode}">
             <i class="fa fa-save save-icon" style="font-size:24px" (click)="saveEditedChanges()"></i>
-            <ace-editor [(text)]="text" [(mode)]="mode" #editor class="aceEditor"></ace-editor>
+            <ace-editor [(text)]="text" [(mode)]="mode" [(readOnly)]="editorReadOnly" #editor class="aceEditor"></ace-editor>
         </div>
         <button *ngIf="viewTemplateMode" class="btn-active" (click)="loadConfigParams()">Load Config Parameters</button>
         <button *ngIf="viewTemplateMode" class="btn-active">Auto Map to Data dictionary</button>
index cfd83f7..08f1ca1 100644 (file)
@@ -41,6 +41,7 @@ import { EditorService } from './editor.service';
 import { SortPipe } from '../../../../common/shared/pipes/sort.pipe';
 import { NotificationHandlerService } from 'src/app/common/core/services/notification-handler.service';
 import { LoaderService } from 'src/app/common/core/services/loader.service';
+import { SelectTemplateService } from '../../select-template/select-template.service';
 
 
 interface Node {
@@ -111,7 +112,7 @@ export class EditorComponent implements OnInit {
   metadata: IMetaData;
   uploadedFileName: string;
   entryDefinition: string;
-
+  editorReadOnly: boolean = false;
   private transformer = (node: Node, level: number) => {
     return {
       expandable: !!node.children && node.children.length > 0,
@@ -129,11 +130,12 @@ export class EditorComponent implements OnInit {
   dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
   artifactName: any;
   artifactVersion: any;
+  options: string;
 
   constructor(private store: Store<IAppState>, private editorService: EditorService,
-    private alertService: NotificationHandlerService, private loader: LoaderService
-    ) 
-    {
+    private alertService: NotificationHandlerService, private loader: LoaderService,
+    private dataService: SelectTemplateService
+  ) {
     this.dataSource.data = TREE_DATA;
     this.bpState = this.store.select('blueprint');
     // this.dataSource.data = TREE_DATA;
@@ -142,6 +144,12 @@ export class EditorComponent implements OnInit {
   hasChild = (_: number, node: ExampleFlatNode) => node.expandable;
 
   ngOnInit() {
+    this.dataService.currentMessage.subscribe(
+      res => {
+        this.options = res;
+        // this.metdataFormfields(res);
+      }
+    );
     this.editorContent();
     this.dataSource.data = this.filesTree;
   }
@@ -236,6 +244,10 @@ export class EditorComponent implements OnInit {
     })
     this.fileExtension = this.selectedFile.substr(this.selectedFile.lastIndexOf('.') + 1);
     this.setEditorMode();
+    if(this.options == '3')
+    {
+      this.editorReadOnly= true;
+    }
   }
 
   getEnriched() {
@@ -258,7 +270,7 @@ export class EditorComponent implements OnInit {
                 });
               this.alertService.success('Blueprint enriched successfully');
             },
-            (error)=>{
+            (error) => {
               this.alertService.error('Enrich:' + error.message);
             });
       });
@@ -277,8 +289,8 @@ export class EditorComponent implements OnInit {
           .subscribe(
             data => {
               this.alertService.success('Success:' + JSON.stringify(data));
-            }, error=>{
-              this.alertService.error('Save -' +error.message);
+            }, error => {
+              this.alertService.error('Save -' + error.message);
             });
 
       });
@@ -295,7 +307,7 @@ export class EditorComponent implements OnInit {
         this.editorService.deployPost(formData)
           .subscribe(data => {
             this.alertService.success('Saved Successfully:' + JSON.stringify(data));
-          }, error=>{
+          }, error => {
             this.alertService.error('Deploy - ' + error.message);
           });
 
@@ -312,7 +324,7 @@ export class EditorComponent implements OnInit {
         this.editorService.publishBlueprint(formData)
           .subscribe(data => {
             this.alertService.success('Published:' + JSON.stringify(data))
-          }, error=>{
+          }, error => {
             this.alertService.error('Publish - ' + error.message);
           });
 
@@ -331,9 +343,9 @@ export class EditorComponent implements OnInit {
   download() {
     console.log(this.artifactName);
     // status = this.editorService.downloadCBA("/download-blueprint/" + this.artifactName + "/" + this.artifactVersion);
-     this.editorService.downloadCBA("/"+this.artifactName + "/" + this.artifactVersion);
+    this.editorService.downloadCBA("/" + this.artifactName + "/" + this.artifactVersion);
   }
-  
+
   setEditorMode() {
     switch (this.fileExtension) {
       case "xml":