Merge "added navbar in source-view component"
[ccsdk/cds.git] / cds-ui / designer-client / src / app / modules / feature-modules / packages / package-creation / template-mapping / templ-mapp-creation / templ-mapp-creation.component.html
index 10f1db6..e1b0f83 100644 (file)
@@ -1,24 +1,41 @@
-<h6 class="create-title">CREATE</h6>
+<div class="row template-mapping-action">
+    <div class="col">
+        <h6 [hidden]="edit" class="create-title">Create Template</h6>
+        <button (click)="openListView()" [hidden]="!edit" class="btn btn-outline-secondary"><i
+                class="fa fa-chevron-left mr-2"></i>Template List</button>
+    </div>
+    <div class="col text-right">
+
+        <button data-toggle="modal" [hidden]="!edit" data-target="#templateDeletionModal2"
+            class="btn btn-outline-danger" title="Delete Template">Delete</button>
+
+
+        <button (click)="cancel()" [hidden]="fileName?.length <=0 || edit"
+            class="btn btn-outline-secondary">Clear</button>
+        <button (click)="saveToStore()" [disabled]="fileName?.length <=0" class="btn btn-primary">Finish</button>
+    </div>
+</div>
 <div class="card creat-card">
     <div class="single-line-model">
         <label class="label-name">Name
             <span _ngcontent-uew-c3="">*</span>
         </label>
-        
+
         <div class="label-input">
-            <input type="input" placeholder="Topology name.vLB.CDS">
+            <input type="input" [disabled]="edit" [(ngModel)]="fileName" placeholder="Template name" name="templateName"
+                autofocus [autofocus]="true">
         </div>
     </div>
 </div>
 
 <div class="template-mapping-accordion">
-    <div id="accordion">
+    <div class="accordion" id="accordion">
         <div class="card">
             <div class="card-header" id="headingOne">
                 <h5 class="mb-0 d-flex justify-content-between">
                     <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true"
                         aria-controls="collapseOne">
-                        1. Create Template
+                        1. Template <span class="accordian-title">{{currentTemplate?.fileName?.split('/')[1]}}</span>
                     </button>
 
                 </h5>
                     <div class="single-line">
                         <label class="label-name">Template Type</label>
                         <div class="label-input">
-                            <label name="trst">
-                                <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value=Velcoity>
-                
+                            <label name="trst" (click)="allowedExt=['.vtl']">
+                                <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
+                                    name="exampleRadios" id="exampleRadios1" value=Velcoity>
                                 <span>
                                     Velcoity
                                 </span>
                             </label>
-                            <label name="trst">
-                                <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value=Velcoity>
-                
+                            <label name="trst" (click)="allowedExt=['.j2','.jinja2']">
+                                <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
+                                    name="exampleRadios" id="exampleRadios1" value=Jinja>
+
                                 <span>
                                     Jinja
                                 </span>
                             </label>
-                            <label name="trst">
-                                <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value=Velcoity>
-                
+                            <label name="trst" (click)="allowedExt=['.kt']">
+                                <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
+                                    name="exampleRadios" id="exampleRadios1" value=Kotlin>
+
                                 <span>
                                     Kotlin
                                 </span>
                             </label>
                         </div>
                     </div>
-                    <div class="create-template-import">Use the editor to add parameters or you can also <a href="#" data-toggle="modal" data-target="#exampleModal">Import File</a></div>
-                    <div class="editor-container">
-                        <app-dsl-definitions-tab></app-dsl-definitions-tab>
+                    <div class="create-template-import">Use the editor to add parameters or you can also
+                        <a href="#" data-toggle="modal" (click)="allowedExt=[getFileExtension()]"
+                            data-target="#templateModal"><b>Import
+                                File</b></a></div>
+                    <div class="editor-container mb-4">
+                        <app-source-editor [lang]="'velocity'" (textChange)="textChanges($event,templateInfo.fileName)"
+                            [(text)]="templateFileContent"></app-source-editor>
                     </div>
                 </div>
             </div>
                 <h5 class="mb-0">
                     <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo"
                         aria-expanded="false" aria-controls="collapseTwo">
-                        2. Manage Mapping
+                        2. Manage Mapping <span
+                            class="accordian-title">{{currentMapping?.fileName?.split('/')[1]}}</span>
                     </button>
                 </h5>
             </div>
             <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
                 <div class="card-body">
-                    <h6 class="text-center">Select a source to load config parameters</h6>
+                    <p class="text-center"><b>Select a source to load config parameters</b></p>
                     <div class="text-center">
-                        <a href="#" class="mapping-source-load">
-                            <i class="icon-current-template"></i>
-                        <br/>
+                        <button [disabled]="!(variables?.length>0 && templateFileContent?.trim()?.length > 0)"
+                            (click)="getMappingTableFromTemplate($event)" class="mapping-source-load" [ngClass]="variables?.length>0 && templateFileContent?.trim()?.length > 0
+                            ?'hover-enable':'hover-disable'">
+                            <i class="icon-use-attributes"></i>
+                            <br />
                             <span>Use Current Template Instance</span>
-                        </a>
-                        <a href="#" data-toggle="modal" data-target="#exampleModal" class="mapping-source-load">
-                            <i class="icon-Upload-attribute"></i>
-                        <br/>
-                            <div>Upload attribute list</div>
+                        </button>
+                        <a href="#" (click)="allowedExt=['.csv']" data-toggle="modal" data-target="#templateModal"
+                            class="mapping-source-load">
+                            <i class="icon-upload-attributes"></i>
+                            <br />
+                            <div>Upload Attributes List</div>
                             <div class="source-load-note">(Should be comma delimited file)</div>
                         </a>
                         <!-- <a href="#" class="mapping-source-load">
                     </div>
 
                     <div class="table-container">
-                        
+
 
                     </div>
                 </div>
+                <div id="mapping-table" [hidden]="resourceDictionaryRes?.length == 0" class="mapping-table mx-4 my-2">
+                    <table datatable [dtOptions]="initDtOptions" [dtTrigger]="dtTrigger" class="row-border hover">
+                        <thead>
+                            <tr>
+                                <th>Required</th>
+                                <th>Parameter Name</th>
+                                <th>Dictionary Name</th>
+                                <th>Dictionary Source</th>
+                                <th>Dependancies</th>
+                                <th>Default</th>
+                                <th>Data Type</th>
+                                <th>Entry Schema</th>
+                            </tr>
+                        </thead>
+                        <tbody>
+                            <tr *ngFor="let dict of resourceDictionaryRes">
+                                <td>
+                                    <img *ngIf="dict.definition?.property?.required"
+                                        src="/assets/img/icon-required-yes.svg">
+                                    <img *ngIf="!dict.definition?.property?.required"
+                                        src="/assets/img/icon-required-no.svg">
+                                </td>
+                                <td>{{ dict.name }}</td>
+                                <td>{{ dict.name }}</td>
+                                <td>
+                                    <select class="custom-select" (click)="selectSource(dict,$event)">
+                                        <option *ngFor="let val of dict.definition.sources | keyvalue">
+                                            {{initMap(dict.name,val)}}
+                                        </option>
+
+                                    </select>
+                                </td>
+                                <td>
+                                    <!-- <select class="custom-select">
+                                        <option *ngFor="let val of getKeys(dependancies)">
+                                            {{ getValue(dict.name)}}</option>
+
+                                    </select> -->
+                                    <input type="text" class="form-control" [ngModel]="getValue(dict.name)">
+                                    <!-- {{ dict.definition.sources }} -->
+                                </td>
+                                <td>{{ dict.definition?.property?.default }}</td>
+                                <td>{{ dict.definition?.property?.type }}</td>
+                                <td>{{ dict.definition?.property['entry_schema'] }}</td>
+                            </tr>
+                        </tbody>
+                    </table>
+                </div>
+
+                <div id="mapping-table-res" [hidden]="mappingRes?.length == 0" class="mapping-table mx-4 my-2">
+                    <table datatable [dtOptions]="dtOptions" [dtTrigger]="resTableDtTrigger" class="row-border hover">
+                        <thead>
+                            <tr>
+                                <th>Required</th>
+                                <th>Parameter Name</th>
+                                <th>Dictionary Name</th>
+                                <th>Dictionary Source</th>
+                                <th>Dependancies</th>
+                                <th>Default</th>
+                                <th>Data Type</th>
+                                <th>Entry Schema</th>
+                            </tr>
+                        </thead>
+                        <tbody>
+                            <tr *ngFor="let dict of mappingRes">
+                                <td>
+                                    <img *ngIf="dict.definition?.property?.required"
+                                        src="/assets/img/icon-required-yes.svg">
+                                    <img *ngIf="!dict.definition?.property?.required"
+                                        src="/assets/img/icon-required-no.svg">
+                                </td>
+                                <td>{{ dict['name'] }}</td>
+                                <td>{{ dict['name'] }}</td>
+                                <td>
+                                    <input type="text" class="form-control" [value]="dict['dictionary-source']"
+                                        disabled>
+
+                                </td>
+                                <td>
+                                    <input type="text" class="form-control" [value]="dict['dependencies']" disabled>
+                                    <!-- {{ dict.definition.sources }} -->
+                                </td>
+                                <td>{{ dict['property']['default'] }}</td>
+                                <td>{{ dict['property']['type'] }}</td>
+                                <td>{{ dict['property']['entry_schema'] }}</td>
+                            </tr>
+                        </tbody>
+                    </table>
+                </div>
+
 
-                
             </div>
 
-            
-        </div>
 
-        <div class="template-mapping-action">
-            <button class="btn btn-sm btn-outline-secondary">Cancel</button>
-            <button class="btn btn-sm btn-primary">Finish</button>
         </div>
+
     </div>
 </div>
 
 
-<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
+<div class="modal fade" id="templateModal" tabindex="-1" role="dialog" aria-labelledby="templateModalLabel"
     aria-hidden="true">
     <div class="modal-dialog" role="document">
         <div class="modal-content">
             <div class="modal-header">
-                <h5 class="modal-title" id="exampleModalLabel">Import File</h5>
+                <h5 class="modal-title" id="templateModalLabel">Import File</h5>
                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
-                    <span aria-hidden="true">&times;</span>
+                    <img src="assets/img/icon-close.svg" />
                 </button>
             </div>
             <div class="modal-body">
-                <ngx-file-drop dropZoneLabel="Drop files here" (onFileDrop)="dropped($event)"
-                    (onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)">
+                <ngx-file-drop [multiple]="false" [accept]="allowedExt" dropZoneLabel="Drop files here"
+                    (onFileDrop)="dropped($event)" (onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)">
                     <ng-template ngx-file-drop-content-tmp let-openFileSelector="openFileSelector">
                         <div class="folder-upload">
                             <img src="assets/img/folder-upload.svg" />
                                 Files
                             </button>
                         </div>
-                        <div class="folder-upload-type">Allowed file type: json</div>
+                        <div class="folder-upload-type">Allowed file type:
+                            {{allowedExt}}
+                        </div>
                     </ng-template>
                 </ngx-file-drop>
-                <div class="upload-table" *ngFor="let item of uploadedFiles; let i=index">
+                <div class="upload-table">
                     <table class="table">
                         <thead>
-                            <tr>
-                                <th>Name : {{ item.name }}</th>
+                            <tr *ngFor="let item of uploadedFiles; let i=index">
+                                <th width="40"><img src="assets/img/icon-file-code.svg" /></th>
+                                <th>{{ item.name }}</th>
+                                <th (click)="removeFile(i)" width="40" class="text-right"><img
+                                        src="assets/img/icon-remove-file.svg" /></th>
                             </tr>
                         </thead>
                     </table>
                 </div>
             </div>
+
             <div class="modal-footer">
-                <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal"
+                <button type="button" class="btn btn-sm btn-secondary btn-cancel" data-dismiss="modal"
                     (click)="resetTheUploadedFiles()">Cancel
                 </button>
-                <button type="button" class="btn btn-sm btn-primary" data-dismiss="modal" (click)="setFilesToStore()">
+
+                <button data-dismiss="modal" (click)="uploadFile()" class="btn btn-sm btn-primary" type="button">
                     Import
                 </button>
             </div>
         </div>
     </div>
+</div>
+
+<!-- Delete Modal -->
+<div class="modal fade" id="templateDeletionModal2" tabindex="-1" role="dialog"
+    aria-labelledby="templateDeletionModal2Label" aria-hidden="true">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title" id="templateDeletionModal2Label">Delete Script</h5>
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                </button>
+            </div>
+            <div class="modal-body">
+                <p>Are you sure you want to delete Template file
+                    <span>{{fileToDelete}}</span>?</p>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
+                <button type="button" (click)="confirmDelete()" data-dismiss="modal"
+                    class="btn btn-primary">Delete</button>
+            </div>
+        </div>
+    </div>
 </div>
\ No newline at end of file