Apply style to mat-table in Mapping
[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 e6149c8..70b1644 100644 (file)
@@ -1,4 +1,20 @@
-<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 (click)="cancel()" [hidden]="!templatesExist || edit" class="btn btn-outline-danger"
+            title="Delete Template">Cancel</button>
+        <button data-toggle="modal" [hidden]="!edit" data-target="#templateDeletionModal2"
+            class="btn btn-outline-danger" title="Delete Template">Delete</button>
+        <button (click)="clear()" [hidden]="fileName?.length <=0 || edit"
+            class="btn btn-outline-secondary">Clear</button>
+        <button tourAnchor="tm-templateFinish" (click)="saveToStore()" [disabled]="fileName?.length <=0"
+            title="Submit template and close" class="btn btn-primary">Finish</button>
+    </div>
+</div>
 <div class="card creat-card">
     <div class="single-line-model">
         <label class="label-name">Name
@@ -6,7 +22,8 @@
         </label>
 
         <div class="label-input">
-            <input type="input" [(ngModel)]="fileName" placeholder="Template name">
+            <input tourAnchor="tm-templateName" type="input" [disabled]="edit" [(ngModel)]="fileName"
+                placeholder="Template name" name="templateName" autofocus [autofocus]="true">
         </div>
     </div>
 </div>
@@ -16,8 +33,8 @@
         <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">
+                    <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" id="templateTab"
+                        aria-expanded="true" aria-controls="collapseOne">
                         1. Template <span class="accordian-title">{{currentTemplate?.fileName?.split('/')[1]}}</span>
                     </button>
 
 
             <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
                 <div class="card-body">
-                    <div class="single-line">
+                    <div tourAnchor="tm-templateType" class="single-line">
                         <label class="label-name">Template Type</label>
                         <div class="label-input">
-                            <label name="trst" (click)="allowedExt=['.vtl']">
+                            <label name="trst" (click)="allowedExt=['.vtl'];templateExt='vtl'">
                                 <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
-                                    name="exampleRadios" id="exampleRadios1" value=Velcoity>
+                                    name="exampleRadios" id="exampleRadios1" value=vtl>
                                 <span>
-                                    Velcoity
+                                    Velocity
                                 </span>
                             </label>
-                            <label name="trst" (click)="allowedExt=['.j2','.jinja2']">
+                            <label name="trst" (click)="allowedExt=['.j2','.jinja2'];templateExt='j2'">
                                 <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
-                                    name="exampleRadios" id="exampleRadios1" value=Jinja>
+                                    name="exampleRadios" id="exampleRadios1" value=j2>
 
                                 <span>
                                     Jinja
                                 </span>
                             </label>
-                            <label name="trst" (click)="allowedExt=['.kt']">
+                            <label tourAnchor="tm-templateContent" name="trst"
+                                (click)="allowedExt=['.kt'];templateExt='kt'">
                                 <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
-                                    name="exampleRadios" id="exampleRadios1" value=Kotlin>
+                                    name="exampleRadios" id="exampleRadios1" value=kt>
 
                                 <span>
                                     Kotlin
                         </div>
                     </div>
                     <div class="create-template-import">Use the editor to add parameters or you can also
-                        <a href="#" data-toggle="modal" (click)="allowedExt=[getFileExtension()]"
+                        <a href="#" data-toggle="modal" (click)="allowedExt=['.'+templateExt]"
                             data-target="#templateModal"><b>Import
-                                File</b></a></div>
+                                File</b></a>. <br /> <span class="templateNote"><i class="icon-info"
+                                aria-hidden="true"></i> When you import new file, the new attributes will replace
+                            current attributes.</span></div>
                     <div class="editor-container mb-4">
-                        <app-source-editor (textChange)="textChanges($event,templateInfo.fileName)"
-                            [(text)]="templateFileContent"></app-source-editor>
+                        <app-source-editor [lang]="'velocity'" (textChange)="textChanges($event,templateInfo.fileName)"
+                            [(text)]="templateFileContent">
+                        </app-source-editor>
                     </div>
                 </div>
             </div>
@@ -68,8 +89,9 @@
         <div class="card">
             <div class="card-header" id="headingTwo">
                 <h5 class="mb-0">
-                    <button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo"
-                        aria-expanded="false" aria-controls="collapseTwo">
+                    <button tourAnchor="tm-mappingContent" class="btn btn-link collapsed" id="mappingTab"
+                        data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false"
+                        aria-controls="collapseTwo">
                         2. Manage Mapping <span
                             class="accordian-title">{{currentMapping?.fileName?.split('/')[1]}}</span>
                     </button>
                 <div class="card-body">
                     <p class="text-center"><b>Select a source to load config parameters</b></p>
                     <div class="text-center">
-                        <a href="#" (click)="getMappingTableFromTemplate($event)" class="mapping-source-load">
+                        <button [disabled]="!(templateFileContent?.trim()?.length > 0)"
+                            (click)="getMappingTableFromTemplate($event)" class="mapping-source-load" [ngClass]="templateFileContent?.trim()?.length > 0
+                            ?'hover-enable':'hover-disable'">
                             <i class="icon-use-attributes"></i>
                             <br />
                             <span>Use Current Template Instance</span>
-                        </a>
-                        <a href="#" (click)="allowedExt=['.csv']" data-toggle="modal" data-target="#templateModal"
-                            class="mapping-source-load">
+                        </button>
+                        <a href="#" (click)="allowedExt=['.csv','.xml']" 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>
+                            <div class="source-load-note">CSV or XML files</div>
                         </a>
                         <!-- <a href="#" class="mapping-source-load">
                             <i class="icon-import-cds"></i>
 
 
                     </div>
+
                 </div>
-                <div id="mapping-table" [hidden]="resourceDictionaryRes?.length == 0" class="mx-4 my-2">
-                    <table datatable [dtOptions]="dtOptions" [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">
+
+                <div id="mapping-table" [hidden]="resourceDictionaryRes?.length == 0" class="mapping-table mx-4 my-2">
+                    <div class="mat-elevation-z8">
+                        <!--Edit Buttons-->
+                        <div class="btn-group mapping-editBar" role="group">
+                            <div class="custom-control custom-checkbox" tooltip="Select All" placement="bottom">
+                                <input type="checkbox" (click)="selectAllProps()" class="custom-control-input"
+                                    id="customCheck1"
+                                    [checked]="resourceDictionaryRes.length>0&&resourceDictionaryRes.length === this.selectedProps.size">
+                                <label class="custom-control-label" for="customCheck1"></label>
+                            </div>
+                            <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="reMap()"
+                                tooltip="Re-mapping" placement="bottom"><i class="icon-autoMap"></i></button>
+                            <button [disabled]="selectedProps.size <=0" type="button" class="btn"
+                                (click)="removeProps()" tooltip="Remove" placement="bottom"><i
+                                    class="icon-delete-sm"></i></button>
+                            <div style="line-height: 35px;font-size: 10px;">
+                                <span>{{selectedProps.size}} selected </span>
+                                <span>({{resourceDictionaryRes.length}} attributes in total)</span>
+                            </div>
+                        </div>
+                        <mat-paginator [pageSizeOptions]="[10, 25,50, 100]"></mat-paginator>
+                        <mat-form-field class="tableFilter float-right">
+                            <mat-label>Filter</mat-label>
+                            <input matInput (keyup)="initApplyFilter($event)" placeholder="Ex. Mia" #input>
+                        </mat-form-field>
+                        <table mat-table [dataSource]="initDataSource" matSort>
+                            <!-- select Column -->
+                            <ng-container matColumnDef="select">
+                                <th mat-header-cell *matHeaderCellDef> </th>
+                                <td mat-cell *matCellDef="let dict">
+                                    <div class="custom-control custom-checkbox" tooltip="Select" placement="bottom">
+                                        <input type="checkbox" class="custom-control-input"
+                                            id="customCheck-{{dict.name}}" [checked]="selectedProps.has(dict.name)"
+                                            (click)="selectProp(dict.name)">
+                                        <label class="custom-control-label" for="customCheck-{{dict.name}}"></label>
+                                    </div>
                                 </td>
-                                <td>{{ dict.name }}</td>
-                                <td>{{ dict.name }}</td>
-                                <td>
+                            </ng-container>
+                            <!-- Required Column -->
+                            <ng-container matColumnDef="Required">
+                                <th mat-header-cell *matHeaderCellDef> Required </th>
+                                <td mat-cell *matCellDef="let dict">
+                                    <div class="custom-control custom-checkbox reuiredInput">
+                                        <input type="checkbox" class="custom-control-input" #requiredInput
+                                            (click)="setProp(requiredInput,'required',initDataSource.filteredData.indexOf(dict))"
+                                            id="requiredCheck-{{dict.name}}">
+                                        <label class="custom-control-label" for="requiredCheck-{{dict.name}}"></label>
+                                    </div>
+                                </td>
+                            </ng-container>
+                            <!-- Template Input Column -->
+                            <ng-container matColumnDef="Template Input">
+                                <th mat-header-cell *matHeaderCellDef> Template Input </th>
+                                <td mat-cell *matCellDef="let dict">
+                                    <div class="custom-control custom-checkbox reuiredInput">
+                                        <input type="checkbox" class="custom-control-input" #tempInput
+                                            (click)="setProp(tempInput,'input-param',initDataSource.filteredData.indexOf(dict))"
+                                            id="inputCheck-{{dict.name}}">
+                                        <label class="custom-control-label" for="inputCheck-{{dict.name}}"></label>
+                                    </div>
+                                </td>
+                            </ng-container>
+                            <!-- Parameter Name Column -->
+                            <ng-container matColumnDef="name">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Parameter Name </th>
+                                <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
+                            </ng-container>
+                            <!-- Dictionary Name Column -->
+                            <ng-container matColumnDef="Dictionary Name">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Name </th>
+                                <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
+                            </ng-container>
+                            <!-- Dictionary Source Column -->
+                            <ng-container matColumnDef="dictionary-source">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Source </th>
+                                <td mat-cell *matCellDef="let dict">
                                     <select class="custom-select" (click)="selectSource(dict,$event)">
                                         <option *ngFor="let val of dict.definition.sources | keyvalue">
                                             {{initMap(dict.name,val)}}
 
                                     </select>
                                 </td>
-                                <td>
-                                    <!-- <select class="custom-select">
-                                        <option *ngFor="let val of getKeys(dependancies)">
-                                            {{ getValue(dict.name)}}</option>
-
-                                    </select> -->
+                            </ng-container>
+                            <!-- Dependancies Column -->
+                            <ng-container matColumnDef="dependencies">
+                                <th mat-header-cell *matHeaderCellDef> Dependancies </th>
+                                <td mat-cell *matCellDef="let dict">
                                     <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>
+                            </ng-container>
+                            <!-- Default Column -->
+                            <ng-container matColumnDef="default">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Default </th>
+                                <td mat-cell *matCellDef="let dict"> {{ dict.definition?.property?.default }} </td>
+                            </ng-container>
+                            <!-- Velocity Column -->
+                            <ng-container matColumnDef="Velocity">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Velocity </th>
+                                <td mat-cell *matCellDef="let dict">
+                                    <input type="text" class="form-control" #velocity
+                                        (input)="setVelocity(initDataSource.filteredData.indexOf(dict),velocity.value)">
+                                </td>
 
-                <div id="mapping-table" [hidden]="mappingRes?.length == 0" class="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>
+
+
+                            </ng-container>
+                            <!-- Data Type Column -->
+                            <ng-container matColumnDef="Data Type">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Data Type </th>
+                                <td mat-cell *matCellDef="let dict"> {{  dict.definition?.property?.type  }} </td>
+                            </ng-container>
+                            <!-- Entry Schema Column -->
+                            <ng-container matColumnDef="Entry Schema">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Entry Schema </th>
+                                <td mat-cell *matCellDef="let dict"> {{dict.definition?.property['entry_schema']}} </td>
+                            </ng-container>
+                            <tr mat-header-row *matHeaderRowDef="initColumn"></tr>
+                            <tr mat-row *matRowDef="let row; columns: initColumn;"></tr>
+                            <!-- Row shown when there is no matching data. -->
+                            <tr class="mat-row" *matNoDataRow>
+                                <td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td>
                             </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">
+                        </table>
+                    </div>
+                </div>
+                <!------ View Table------->
+                <div id="mapping-table-res" [hidden]="mappingRes?.length == 0" class="mapping-table mx-4 my-2">
+                    <div class="mat-elevation-z8">
+                        <mat-form-field class="tableFilter float-right">
+                            <mat-label>Filter</mat-label>
+                            <input matInput (keyup)="applyFilter($event)" placeholder="Ex. Mia" #input>
+                        </mat-form-field>
+                        <mat-paginator [pageSizeOptions]="[10, 25,50, 100]"></mat-paginator>
+                        <table mat-table [dataSource]="dataSource" matSort>
+                            <!-- Required Column -->
+                            <ng-container matColumnDef="Required">
+                                <th mat-header-cell *matHeaderCellDef> Required </th>
+                                <td mat-cell *matCellDef="let dict">
+                                    <img *ngIf="dict?.property?.required" src="/assets/img/icon-required-yes.svg">
+                                    <img *ngIf="!dict?.property?.required" src="/assets/img/icon-required-no.svg">
                                 </td>
-                                <td>{{ dict['name'] }}</td>
-                                <td>{{ dict['name'] }}</td>
-                                <td>
+                            </ng-container>
+                            <!-- Template Input Column -->
+                            <ng-container matColumnDef="Template Input">
+                                <th mat-header-cell *matHeaderCellDef> Template Input </th>
+                                <td mat-cell *matCellDef="let dict">
+                                    <img *ngIf="dict['input-param']" src="/assets/img/icon-required-yes.svg">
+                                    <img *ngIf="!dict['input-param']" src="/assets/img/icon-required-no.svg">
+                                </td>
+                            </ng-container>
+                            <!-- Parameter Name Column -->
+                            <ng-container matColumnDef="name">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Parameter Name </th>
+                                <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
+                            </ng-container>
+                            <!-- Dictionary Name Column -->
+                            <ng-container matColumnDef="Dictionary Name">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Name </th>
+                                <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
+                            </ng-container>
+                            <!-- Dictionary Source Column -->
+                            <ng-container matColumnDef="dictionary-source">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Source </th>
+                                <td mat-cell *matCellDef="let dict">
                                     <input type="text" class="form-control" [value]="dict['dictionary-source']"
                                         disabled>
-
                                 </td>
-                                <td>
+                            </ng-container>
+                            <!-- Dependancies Column -->
+                            <ng-container matColumnDef="dependencies">
+                                <th mat-header-cell *matHeaderCellDef> Dependancies </th>
+                                <td mat-cell *matCellDef="let dict">
                                     <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>
+                            </ng-container>
+                            <!-- default Column -->
+                            <ng-container matColumnDef="default">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Default </th>
+                                <td mat-cell *matCellDef="let dict"> {{dict['property']['default']}} </td>
+                            </ng-container>
+                            <!-- Velocity Column -->
+                            <ng-container matColumnDef="Velocity">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Velocity </th>
+                                <td mat-cell *matCellDef="let dict">
+                                    <span *ngIf="dict?.property?.metadata">
+                                        {{dict?.property?.metadata['transform-template']}}
+                                    </span>
+                                    <span *ngIf="!dict?.property?.metadata"></span>
+                                </td>
 
 
-            </div>
 
-
-        </div>
-        <div class="template-mapping-action">
-            <button (click)="cancel()" class="btn btn-outline-secondary">Cancel</button>
-            <button (click)="saveToStore()" class="btn btn-primary">Submit</button>
+                            </ng-container>
+                            <!-- Data Type Column -->
+                            <ng-container matColumnDef="Data Type">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Data Type </th>
+                                <td mat-cell *matCellDef="let dict"> {{ dict['property']['type'] }} </td>
+                            </ng-container>
+                            <!-- Entry Schema Column -->
+                            <ng-container matColumnDef="Entry Schema">
+                                <th mat-header-cell *matHeaderCellDef mat-sort-header> Entry Schema </th>
+                                <td mat-cell *matCellDef="let dict"> {{dict['property']['entry_schema']}} </td>
+                            </ng-container>
+                            <tr mat-header-row *matHeaderRowDef="resColumns"></tr>
+                            <tr mat-row *matRowDef="let row; columns: resColumns;"></tr>
+                            <!-- Row shown when there is no matching data. -->
+                            <tr class="mat-row" *matNoDataRow>
+                                <td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td>
+                            </tr>
+                        </table>
+                    </div>
+                </div>
+            </div>
         </div>
     </div>
 </div>
                             <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 width="40" class="text-right"><img src="assets/img/icon-remove-file.svg" /></th>
+                                <th (click)="removeFile(i)" width="40" class="text-right"><img
+                                        src="assets/img/icon-remove-file.svg" class="btn-modal-remove-file" /></th>
                             </tr>
                         </thead>
                     </table>
             </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)="uploadFile();openListView()">
+
+                <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">
+                    <img src="assets/img/icon-close.svg" />
+                </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