82010db1c8abd71346b57911a6d3cb99ad78bbbe
[ccsdk/cds.git] /
1 <div class="row template-mapping-action">
2     <div class="col">
3         <h6 [hidden]="edit" class="create-title">Create Template</h6>
4         <button (click)="openListView()" [hidden]="!edit" class="btn btn-outline-secondary"><i
5                 class="fa fa-chevron-left mr-2"></i>Template List</button>
6     </div>
7     <div class="col text-right">
8         <button (click)="cancel()" [hidden]="!templatesExist || edit" class="btn btn-outline-danger"
9             title="Delete Template">Cancel</button>
10         <button data-toggle="modal" [hidden]="!edit" data-target="#templateDeletionModal2"
11             class="btn btn-outline-danger" title="Delete Template">Delete</button>
12         <button (click)="clear()" [hidden]="fileName?.length <=0 || edit"
13             class="btn btn-outline-secondary">Clear</button>
14         <button tourAnchor="tm-templateFinish" (click)="saveToStore()" [disabled]="fileName?.length <=0"
15             title="Submit template and close" class="btn btn-primary">Finish</button>
16     </div>
17 </div>
18 <div class="card creat-card">
19     <div class="single-line-model">
20         <label class="label-name">Name
21             <span _ngcontent-uew-c3="">*</span>
22         </label>
23
24         <div class="label-input">
25             <input tourAnchor="tm-templateName" type="input" [disabled]="edit" [(ngModel)]="fileName"
26                 placeholder="Template name" name="templateName" autofocus [autofocus]="true">
27         </div>
28     </div>
29 </div>
30
31 <div class="template-mapping-accordion">
32     <div class="accordion" id="accordion">
33         <div class="card">
34             <div class="card-header" id="headingOne">
35                 <h5 class="mb-0 d-flex justify-content-between">
36                     <button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" id="templateTab"
37                         aria-expanded="true" aria-controls="collapseOne">
38                         1. Template <span class="accordian-title">{{currentTemplate?.fileName?.split('/')[1]}}</span>
39                     </button>
40
41                 </h5>
42             </div>
43
44             <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
45                 <div class="card-body">
46                     <div tourAnchor="tm-templateType" class="single-line">
47                         <label class="label-name">Template Type</label>
48                         <div class="label-input">
49                             <label name="trst" (click)="allowedExt=['.vtl'];templateExt='vtl'">
50                                 <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
51                                     name="exampleRadios" id="exampleRadios1" value=vtl>
52                                 <span>
53                                     Velocity
54                                 </span>
55                             </label>
56                             <label name="trst" (click)="allowedExt=['.j2','.jinja2'];templateExt='j2'">
57                                 <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
58                                     name="exampleRadios" id="exampleRadios1" value=j2>
59
60                                 <span>
61                                     Jinja
62                                 </span>
63                             </label>
64                             <label tourAnchor="tm-templateContent" name="trst"
65                                 (click)="allowedExt=['.kt'];templateExt='kt'">
66                                 <input class="form-check-input" [(ngModel)]="templateExt" type="radio"
67                                     name="exampleRadios" id="exampleRadios1" value=kt>
68
69                                 <span>
70                                     Kotlin
71                                 </span>
72                             </label>
73                         </div>
74                     </div>
75                     <div class="create-template-import">Use the editor to add parameters or you can also
76                         <a href="#" data-toggle="modal" (click)="allowedExt=['.'+templateExt]"
77                             data-target="#templateModal"><b>Import
78                                 File</b></a>. <br /> <span class="templateNote"><i class="icon-info"
79                                 aria-hidden="true"></i> When you import new file, the new attributes will replace
80                             current attributes.</span></div>
81                     <div class="editor-container mb-4">
82                         <app-source-editor [lang]="'velocity'" (textChange)="textChanges($event,templateInfo.fileName)"
83                             [(text)]="templateFileContent">
84                         </app-source-editor>
85                     </div>
86                 </div>
87             </div>
88         </div>
89         <div class="card">
90             <div class="card-header" id="headingTwo">
91                 <h5 class="mb-0">
92                     <button tourAnchor="tm-mappingContent" class="btn btn-link collapsed" id="mappingTab"
93                         data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false"
94                         aria-controls="collapseTwo">
95                         2. Manage Mapping <span
96                             class="accordian-title">{{currentMapping?.fileName?.split('/')[1]}}</span>
97                     </button>
98                 </h5>
99             </div>
100             <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
101                 <div class="card-body">
102                     <p class="text-center"><b>Select a source to load config parameters</b></p>
103                     <div class="text-center">
104                         <button [disabled]="!(templateFileContent?.trim()?.length > 0)"
105                             (click)="getMappingTableFromTemplate($event)" class="mapping-source-load" [ngClass]="templateFileContent?.trim()?.length > 0
106                             ?'hover-enable':'hover-disable'">
107                             <i class="icon-use-attributes"></i>
108                             <br />
109                             <span>Use Current Template Instance</span>
110                         </button>
111                         <a href="#" (click)="allowedExt=['.csv','.xml']" data-toggle="modal"
112                             data-target="#templateModal" class="mapping-source-load">
113                             <i class="icon-upload-attributes"></i>
114                             <br />
115                             <div>Upload Attributes List</div>
116                             <div class="source-load-note">CSV or XML files</div>
117                         </a>
118                         <!-- <a href="#" class="mapping-source-load">
119                             <i class="icon-import-cds"></i>
120                         <br/>
121                             <span>Import from SDC Model</span>
122                         </a> -->
123                     </div>
124
125                     <div class="table-container">
126
127
128                     </div>
129
130                 </div>
131
132                 <div id="mapping-table" [hidden]="resourceDictionaryRes?.length == 0" class="mapping-table mx-4 my-2">
133                     <div class="mat-elevation-z8">
134                         <!--Edit Buttons-->
135                         <div class="btn-group mapping-editBar" role="group">
136                             <div class="custom-control custom-checkbox" tooltip="Select All" placement="bottom">
137                                 <input type="checkbox" (click)="selectAllProps()" class="custom-control-input"
138                                     id="customCheck1"
139                                     [checked]="resourceDictionaryRes.length>0&&resourceDictionaryRes.length === this.selectedProps.size">
140                                 <label class="custom-control-label" for="customCheck1"></label>
141                             </div>
142                             <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="reMap()"
143                                 tooltip="Re-mapping" placement="bottom"><i class="icon-autoMap"></i></button>
144                             <button [disabled]="selectedProps.size <=0" type="button" class="btn"
145                                 (click)="removeProps()" tooltip="Remove" placement="bottom"><i
146                                     class="icon-delete-sm"></i></button>
147                             <div style="line-height: 35px;font-size: 10px;">
148                                 <span>{{selectedProps.size}} selected </span>
149                                 <span>({{resourceDictionaryRes.length}} attributes in total)</span>
150                             </div>
151                         </div>
152                         <mat-paginator [pageSizeOptions]="[10, 25,50, 100,this.resourceDictionaryRes.length]">
153                         </mat-paginator>
154                         <mat-form-field class="tableFilter float-right">
155                             <mat-label>Filter</mat-label>
156                             <input matInput (keyup)="initApplyFilter($event)" placeholder="Ex. Mia" #input>
157                         </mat-form-field>
158                         <table mat-table matSortDisableClear [dataSource]="initDataSource" matSort>
159                             <!-- select Column -->
160                             <ng-container matColumnDef="select">
161                                 <th mat-header-cell *matHeaderCellDef> </th>
162                                 <td mat-cell *matCellDef="let dict">
163                                     <div class="custom-control custom-checkbox" tooltip="Select" placement="bottom">
164                                         <input type="checkbox" class="custom-control-input"
165                                             id="customCheck-{{dict.name}}" [checked]="selectedProps.has(dict.name)"
166                                             (click)="selectProp(dict.name)">
167                                         <label class="custom-control-label" for="customCheck-{{dict.name}}"></label>
168                                     </div>
169                                 </td>
170                             </ng-container>
171                             <!-- Required Column -->
172                             <ng-container matColumnDef="Required">
173                                 <th mat-header-cell *matHeaderCellDef> Required </th>
174                                 <td mat-cell *matCellDef="let dict">
175                                     <div class="custom-control custom-checkbox reuiredInput">
176                                         <input type="checkbox" class="custom-control-input" #requiredInput
177                                             (click)="setProp(requiredInput,'required',initDataSource.filteredData.indexOf(dict))"
178                                             id="requiredCheck-{{dict.name}}">
179                                         <label class="custom-control-label" for="requiredCheck-{{dict.name}}"></label>
180                                     </div>
181                                 </td>
182                             </ng-container>
183                             <!-- Template Input Column -->
184                             <ng-container matColumnDef="Template Input">
185                                 <th mat-header-cell *matHeaderCellDef> Template Input </th>
186                                 <td mat-cell *matCellDef="let dict">
187                                     <div class="custom-control custom-checkbox reuiredInput">
188                                         <input type="checkbox" class="custom-control-input" #tempInput
189                                             (click)="setProp(tempInput,'input-param',initDataSource.filteredData.indexOf(dict))"
190                                             id="inputCheck-{{dict.name}}">
191                                         <label class="custom-control-label" for="inputCheck-{{dict.name}}"></label>
192                                     </div>
193                                 </td>
194                             </ng-container>
195                             <!-- Parameter Name Column -->
196                             <ng-container matColumnDef="name">
197                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Parameter Name </th>
198                                 <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
199                             </ng-container>
200                             <!-- Dictionary Name Column -->
201                             <ng-container matColumnDef="Dictionary Name">
202                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Name </th>
203                                 <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
204                             </ng-container>
205                             <!-- Dictionary Source Column -->
206                             <ng-container matColumnDef="dictionary-source">
207                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Source </th>
208                                 <td mat-cell *matCellDef="let dict">
209                                     <select class="custom-select" (click)="selectSource(dict,$event)">
210                                         <option *ngFor="let val of dict.definition.sources | keyvalue">
211                                             {{initMap(dict.name,val)}}
212                                         </option>
213
214                                     </select>
215                                 </td>
216                             </ng-container>
217                             <!-- Dependancies Column -->
218                             <ng-container matColumnDef="dependencies">
219                                 <th mat-header-cell *matHeaderCellDef> Dependancies </th>
220                                 <td mat-cell *matCellDef="let dict">
221                                     <input type="text" class="form-control" [ngModel]="getValue(dict.name)">
222                                 </td>
223                             </ng-container>
224                             <!-- Default Column -->
225                             <ng-container matColumnDef="default">
226                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Default </th>
227                                 <td mat-cell *matCellDef="let dict"> {{ dict.definition?.property?.default }} </td>
228                             </ng-container>
229                             <!-- Velocity Column -->
230                             <ng-container matColumnDef="Velocity">
231                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Velocity </th>
232                                 <td mat-cell *matCellDef="let dict">
233                                     <input type="text" class="form-control" #velocity
234                                         (input)="setVelocity(initDataSource.filteredData.indexOf(dict),velocity.value)">
235                                 </td>
236
237
238
239                             </ng-container>
240                             <!-- Data Type Column -->
241                             <ng-container matColumnDef="Data Type">
242                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Data Type </th>
243                                 <td mat-cell *matCellDef="let dict"> {{  dict.definition?.property?.type  }} </td>
244                             </ng-container>
245                             <!-- Entry Schema Column -->
246                             <ng-container matColumnDef="Entry Schema">
247                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Entry Schema </th>
248                                 <td mat-cell *matCellDef="let dict"> {{dict.definition?.property['entry_schema']}} </td>
249                             </ng-container>
250                             <tr mat-header-row *matHeaderRowDef="initColumn"></tr>
251                             <tr mat-row *matRowDef="let row; columns: initColumn;"></tr>
252                             <!-- Row shown when there is no matching data. -->
253                             <tr class="mat-row" *matNoDataRow>
254                                 <td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td>
255                             </tr>
256                         </table>
257                     </div>
258                 </div>
259                 <!------ View Table------->
260                 <div id="mapping-table-res" [hidden]="mappingRes?.length == 0" class="mapping-table mx-4 my-2">
261                     <div class="mat-elevation-z8">
262                         <mat-form-field class="tableFilter float-right">
263                             <mat-label>Filter</mat-label>
264                             <input matInput (keyup)="applyFilter($event)" placeholder="Ex. Mia" #input>
265                         </mat-form-field>
266                         <mat-paginator #paginate="matPaginator" [pageSizeOptions]="[10, 25,50, 100]"></mat-paginator>
267                         <table matSortDisableClear mat-table [dataSource]="dataSource" #sort="matSort" matSort>
268                             <!-- Required Column -->
269                             <ng-container matColumnDef="Required">
270                                 <th mat-header-cell *matHeaderCellDef> Required </th>
271                                 <td mat-cell *matCellDef="let dict">
272                                     <img *ngIf="dict?.property?.required" src="/assets/img/icon-required-yes.svg">
273                                     <img *ngIf="!dict?.property?.required" src="/assets/img/icon-required-no.svg">
274                                 </td>
275                             </ng-container>
276                             <!-- Template Input Column -->
277                             <ng-container matColumnDef="Template Input">
278                                 <th mat-header-cell *matHeaderCellDef> Template Input </th>
279                                 <td mat-cell *matCellDef="let dict">
280                                     <img *ngIf="dict['input-param']" src="/assets/img/icon-required-yes.svg">
281                                     <img *ngIf="!dict['input-param']" src="/assets/img/icon-required-no.svg">
282                                 </td>
283                             </ng-container>
284                             <!-- Parameter Name Column -->
285                             <ng-container matColumnDef="name">
286                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Parameter Name </th>
287                                 <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
288                             </ng-container>
289                             <!-- Dictionary Name Column -->
290                             <ng-container matColumnDef="Dictionary Name">
291                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Name </th>
292                                 <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
293                             </ng-container>
294                             <!-- Dictionary Source Column -->
295                             <ng-container matColumnDef="dictionary-source">
296                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Source </th>
297                                 <td mat-cell *matCellDef="let dict">
298                                     <input type="text" class="form-control" [value]="dict['dictionary-source']"
299                                         disabled>
300                                 </td>
301                             </ng-container>
302                             <!-- Dependancies Column -->
303                             <ng-container matColumnDef="dependencies">
304                                 <th mat-header-cell *matHeaderCellDef> Dependancies </th>
305                                 <td mat-cell *matCellDef="let dict">
306                                     <input type="text" class="form-control" [value]="dict['dependencies']" disabled>
307                                 </td>
308                             </ng-container>
309                             <!-- default Column -->
310                             <ng-container matColumnDef="default">
311                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Default </th>
312                                 <td mat-cell *matCellDef="let dict"> {{dict['property']['default']}} </td>
313                             </ng-container>
314                             <!-- Velocity Column -->
315                             <ng-container matColumnDef="Velocity">
316                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Velocity </th>
317                                 <td mat-cell *matCellDef="let dict">
318                                     <span *ngIf="dict?.property?.metadata">
319                                         {{dict?.property?.metadata['transform-template']}}
320                                     </span>
321                                     <span *ngIf="!dict?.property?.metadata"></span>
322                                 </td>
323
324
325
326                             </ng-container>
327                             <!-- Data Type Column -->
328                             <ng-container matColumnDef="Data Type">
329                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Data Type </th>
330                                 <td mat-cell *matCellDef="let dict"> {{ dict['property']['type'] }} </td>
331                             </ng-container>
332                             <!-- Entry Schema Column -->
333                             <ng-container matColumnDef="Entry Schema">
334                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Entry Schema </th>
335                                 <td mat-cell *matCellDef="let dict"> {{dict['property']['entry_schema']}} </td>
336                             </ng-container>
337                             <tr mat-header-row *matHeaderRowDef="resColumns"></tr>
338                             <tr mat-row *matRowDef="let row; columns: resColumns;"></tr>
339                             <!-- Row shown when there is no matching data. -->
340                             <tr class="mat-row" *matNoDataRow>
341                                 <td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td>
342                             </tr>
343                         </table>
344                     </div>
345                 </div>
346             </div>
347         </div>
348     </div>
349 </div>
350
351
352 <div class="modal fade" id="templateModal" tabindex="-1" role="dialog" aria-labelledby="templateModalLabel"
353     aria-hidden="true">
354     <div class="modal-dialog" role="document">
355         <div class="modal-content">
356             <div class="modal-header">
357                 <h5 class="modal-title" id="templateModalLabel">Import File</h5>
358                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
359                     <img src="assets/img/icon-close.svg" />
360                 </button>
361             </div>
362             <div class="modal-body">
363                 <ngx-file-drop [multiple]="false" [accept]="allowedExt" dropZoneLabel="Drop files here"
364                     (onFileDrop)="dropped($event)" (onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)">
365                     <ng-template ngx-file-drop-content-tmp let-openFileSelector="openFileSelector">
366                         <div class="folder-upload">
367                             <img src="assets/img/folder-upload.svg" />
368                         </div>
369                         <div class="folder-upload-text">
370                             Drag & Drop file
371                         </div>
372                         <div class="folder-upload-text">or
373                             <button type="button" class="btn btn-sm btn-primary" (click)="openFileSelector()">Browse
374                                 Files
375                             </button>
376                         </div>
377                         <div class="folder-upload-type">Allowed file type:
378                             {{allowedExt}}
379                         </div>
380                     </ng-template>
381                 </ngx-file-drop>
382                 <div class="upload-table">
383                     <table class="table">
384                         <thead>
385                             <tr *ngFor="let item of uploadedFiles; let i=index">
386                                 <th width="40"><img src="assets/img/icon-file-code.svg" /></th>
387                                 <th>{{ item.name }}</th>
388                                 <th (click)="removeFile(i)" width="40" class="text-right"><img
389                                         src="assets/img/icon-remove-file.svg" class="btn-modal-remove-file" /></th>
390                             </tr>
391                         </thead>
392                     </table>
393                 </div>
394             </div>
395
396             <div class="modal-footer">
397                 <button type="button" class="btn btn-sm btn-secondary btn-cancel" data-dismiss="modal"
398                     (click)="resetTheUploadedFiles()">Cancel
399                 </button>
400
401                 <button data-dismiss="modal" (click)="uploadFile()" class="btn btn-sm btn-primary" type="button">
402                     Import
403                 </button>
404             </div>
405         </div>
406     </div>
407 </div>
408
409 <!-- Delete Modal -->
410 <div class="modal fade" id="templateDeletionModal2" tabindex="-1" role="dialog"
411     aria-labelledby="templateDeletionModal2Label" aria-hidden="true">
412     <div class="modal-dialog" role="document">
413         <div class="modal-content">
414             <div class="modal-header">
415                 <h5 class="modal-title" id="templateDeletionModal2Label">Delete Script</h5>
416                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
417                     <img src="assets/img/icon-close.svg" />
418                 </button>
419             </div>
420             <div class="modal-body">
421                 <p>Are you sure you want to delete Template file
422                     <span>{{fileToDelete}}</span>?</p>
423             </div>
424             <div class="modal-footer">
425                 <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
426                 <button type="button" (click)="confirmDelete()" data-dismiss="modal"
427                     class="btn btn-primary">Delete</button>
428             </div>
429         </div>
430     </div>
431 </div>