be84e712784ec891e5708182769c9c4355a612a8
[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
134                     <mat-form-field>
135                         <mat-label>Filter</mat-label>
136                         <input matInput (keyup)="initApplyFilter($event)" placeholder="Ex. Mia" #input>
137                     </mat-form-field>
138
139                     <div class="btn-group mapping-editBar" role="group">
140                         <div class="custom-control custom-checkbox" tooltip="Select All" placement="bottom">
141                             <input type="checkbox" (click)="selectAllProps()" class="custom-control-input"
142                                 id="customCheck1"
143                                 [checked]="resourceDictionaryRes.length>0&&resourceDictionaryRes.length === this.selectedProps.size">
144                             <label class="custom-control-label" for="customCheck1"></label>
145                         </div>
146                         <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="reMap()"
147                             tooltip="Re-mapping" placement="bottom"><i class="icon-autoMap"></i></button>
148                         <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="removeProps()"
149                             tooltip="Remove" placement="bottom"><i class="icon-delete-sm"></i></button>
150                         <div style="line-height: 35px;font-size: 10px;">
151                             <span>{{selectedProps.size}} selected </span>
152                             <span>({{resourceDictionaryRes.length}} attributes in total)</span>
153                         </div>
154                     </div>
155
156                     <div class="mat-elevation-z8">
157                         <table mat-table [dataSource]="initDataSource" matSort>
158
159                             <!-- Required 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
184                             <!-- Name Column -->
185                             <ng-container matColumnDef="Template Input">
186                                 <th mat-header-cell *matHeaderCellDef> Template Input </th>
187                                 <td mat-cell *matCellDef="let dict">
188                                     <div class="custom-control custom-checkbox reuiredInput">
189                                         <input type="checkbox" class="custom-control-input" #tempInput
190                                             (click)="setProp(tempInput,'input-param',initDataSource.filteredData.indexOf(dict))"
191                                             id="inputCheck-{{dict.name}}">
192                                         <label class="custom-control-label" for="inputCheck-{{dict.name}}"></label>
193                                     </div>
194                                 </td>
195                             </ng-container>
196
197                             <!-- Weight Column -->
198                             <ng-container matColumnDef="name">
199                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Parameter Name </th>
200                                 <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
201                             </ng-container>
202                             <!-- Weight Column -->
203                             <ng-container matColumnDef="Dictionary Name">
204                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Name </th>
205                                 <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
206                             </ng-container>
207
208                             <!-- Symbol Column -->
209                             <ng-container matColumnDef="dictionary-source">
210                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Source </th>
211                                 <td mat-cell *matCellDef="let dict">
212                                     <select class="custom-select" (click)="selectSource(dict,$event)">
213                                         <option *ngFor="let val of dict.definition.sources | keyvalue">
214                                             {{initMap(dict.name,val)}}
215                                         </option>
216
217                                     </select>
218                                 </td>
219                             </ng-container>
220
221
222                             <!-- Symbol Column -->
223                             <ng-container matColumnDef="dependencies">
224                                 <th mat-header-cell *matHeaderCellDef> Dependancies </th>
225                                 <td mat-cell *matCellDef="let dict">
226                                     <input type="text" class="form-control" [ngModel]="getValue(dict.name)">
227                                 </td>
228                             </ng-container>
229
230                             <!-- Symbol Column -->
231                             <ng-container matColumnDef="default">
232                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Default </th>
233                                 <td mat-cell *matCellDef="let dict"> {{ dict.definition?.property?.default }} </td>
234                             </ng-container>
235
236                             <!-- Symbol Column -->
237                             <ng-container matColumnDef="Velocity">
238                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Velocity </th>
239                                 <td mat-cell *matCellDef="let dict">
240                                     <input type="text" class="form-control" #velocity
241                                         (input)="setVelocity(initDataSource.filteredData.indexOf(dict),velocity.value)">
242                                 </td>
243
244
245
246                             </ng-container>
247
248                             <!-- Symbol Column -->
249                             <ng-container matColumnDef="Data Type">
250                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Data Type </th>
251                                 <td mat-cell *matCellDef="let dict"> {{  dict.definition?.property?.type  }} </td>
252                             </ng-container>
253
254                             <!-- Symbol Column -->
255                             <ng-container matColumnDef="Entry Schema">
256                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Entry Schema </th>
257                                 <td mat-cell *matCellDef="let dict"> {{dict.definition?.property['entry_schema']}} </td>
258                             </ng-container>
259
260                             <tr mat-header-row *matHeaderRowDef="initColumn"></tr>
261                             <tr mat-row *matRowDef="let row; columns: initColumn;"></tr>
262
263                             <!-- Row shown when there is no matching data. -->
264                             <tr class="mat-row" *matNoDataRow>
265                                 <td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td>
266                             </tr>
267                         </table>
268
269                         <mat-paginator [pageSizeOptions]="[10, 25,50, 100]"></mat-paginator>
270                     </div>
271                 </div>
272                 <!------ View Table------->
273                 <div id="mapping-table-res" [hidden]="mappingRes?.length == 0" class="mapping-table mx-4 my-2">
274
275
276                     <mat-form-field>
277                         <mat-label>Filter</mat-label>
278                         <input matInput (keyup)="applyFilter($event)" placeholder="Ex. Mia" #input>
279                     </mat-form-field>
280
281                     <div class="mat-elevation-z8">
282                         <table mat-table [dataSource]="dataSource" matSort>
283
284                             <!-- Required Column -->
285                             <ng-container matColumnDef="Required">
286                                 <th mat-header-cell *matHeaderCellDef> Required </th>
287                                 <td mat-cell *matCellDef="let dict">
288                                     <img *ngIf="dict?.property?.required" src="/assets/img/icon-required-yes.svg">
289                                     <img *ngIf="!dict?.property?.required" src="/assets/img/icon-required-no.svg">
290                                 </td>
291                             </ng-container>
292
293                             <!-- Name Column -->
294                             <ng-container matColumnDef="Template Input">
295                                 <th mat-header-cell *matHeaderCellDef> Template Input </th>
296                                 <td mat-cell *matCellDef="let dict">
297                                     <img *ngIf="dict['input-param']" src="/assets/img/icon-required-yes.svg">
298                                     <img *ngIf="!dict['input-param']" src="/assets/img/icon-required-no.svg">
299                                 </td>
300                             </ng-container>
301
302                             <!-- Weight Column -->
303                             <ng-container matColumnDef="name">
304                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Parameter Name </th>
305                                 <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
306                             </ng-container>
307                             <!-- Weight Column -->
308                             <ng-container matColumnDef="Dictionary Name">
309                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Name </th>
310                                 <td mat-cell *matCellDef="let dict"> {{dict['name'] }} </td>
311                             </ng-container>
312
313                             <!-- Symbol Column -->
314                             <ng-container matColumnDef="dictionary-source">
315                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Dictionary Source </th>
316                                 <td mat-cell *matCellDef="let dict">
317                                     <input type="text" class="form-control" [value]="dict['dictionary-source']"
318                                         disabled>
319                                 </td>
320                             </ng-container>
321
322
323                             <!-- Symbol Column -->
324                             <ng-container matColumnDef="dependencies">
325                                 <th mat-header-cell *matHeaderCellDef> Dependancies </th>
326                                 <td mat-cell *matCellDef="let dict">
327                                     <input type="text" class="form-control" [value]="dict['dependencies']" disabled>
328                                 </td>
329                             </ng-container>
330
331                             <!-- Symbol Column -->
332                             <ng-container matColumnDef="default">
333                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Default </th>
334                                 <td mat-cell *matCellDef="let dict"> {{dict['property']['default']}} </td>
335                             </ng-container>
336
337                             <!-- Symbol Column -->
338                             <ng-container matColumnDef="Velocity">
339                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Velocity </th>
340                                 <td mat-cell *matCellDef="let dict">
341                                     <span *ngIf="dict?.property?.metadata">
342                                         {{dict?.property?.metadata['transform-template']}}
343                                     </span>
344                                     <span *ngIf="!dict?.property?.metadata"></span>
345                                 </td>
346
347
348
349                             </ng-container>
350
351                             <!-- Symbol Column -->
352                             <ng-container matColumnDef="Data Type">
353                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Data Type </th>
354                                 <td mat-cell *matCellDef="let dict"> {{ dict['property']['type'] }} </td>
355                             </ng-container>
356
357                             <!-- Symbol Column -->
358                             <ng-container matColumnDef="Entry Schema">
359                                 <th mat-header-cell *matHeaderCellDef mat-sort-header> Entry Schema </th>
360                                 <td mat-cell *matCellDef="let dict"> {{dict['property']['entry_schema']}} </td>
361                             </ng-container>
362
363                             <tr mat-header-row *matHeaderRowDef="resColumns"></tr>
364                             <tr mat-row *matRowDef="let row; columns: resColumns;"></tr>
365
366                             <!-- Row shown when there is no matching data. -->
367                             <tr class="mat-row" *matNoDataRow>
368                                 <td class="mat-cell" colspan="4">No data matching the filter "{{input.value}}"</td>
369                             </tr>
370                         </table>
371
372                         <mat-paginator [pageSizeOptions]="[10, 25,50, 100]"></mat-paginator>
373                     </div>
374
375                 </div>
376
377
378             </div>
379
380
381         </div>
382
383     </div>
384 </div>
385
386
387 <div class="modal fade" id="templateModal" tabindex="-1" role="dialog" aria-labelledby="templateModalLabel"
388     aria-hidden="true">
389     <div class="modal-dialog" role="document">
390         <div class="modal-content">
391             <div class="modal-header">
392                 <h5 class="modal-title" id="templateModalLabel">Import File</h5>
393                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
394                     <img src="assets/img/icon-close.svg" />
395                 </button>
396             </div>
397             <div class="modal-body">
398                 <ngx-file-drop [multiple]="false" [accept]="allowedExt" dropZoneLabel="Drop files here"
399                     (onFileDrop)="dropped($event)" (onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)">
400                     <ng-template ngx-file-drop-content-tmp let-openFileSelector="openFileSelector">
401                         <div class="folder-upload">
402                             <img src="assets/img/folder-upload.svg" />
403                         </div>
404                         <div class="folder-upload-text">
405                             Drag & Drop file
406                         </div>
407                         <div class="folder-upload-text">or
408                             <button type="button" class="btn btn-sm btn-primary" (click)="openFileSelector()">Browse
409                                 Files
410                             </button>
411                         </div>
412                         <div class="folder-upload-type">Allowed file type:
413                             {{allowedExt}}
414                         </div>
415                     </ng-template>
416                 </ngx-file-drop>
417                 <div class="upload-table">
418                     <table class="table">
419                         <thead>
420                             <tr *ngFor="let item of uploadedFiles; let i=index">
421                                 <th width="40"><img src="assets/img/icon-file-code.svg" /></th>
422                                 <th>{{ item.name }}</th>
423                                 <th (click)="removeFile(i)" width="40" class="text-right"><img
424                                         src="assets/img/icon-remove-file.svg" class="btn-modal-remove-file" /></th>
425                             </tr>
426                         </thead>
427                     </table>
428                 </div>
429             </div>
430
431             <div class="modal-footer">
432                 <button type="button" class="btn btn-sm btn-secondary btn-cancel" data-dismiss="modal"
433                     (click)="resetTheUploadedFiles()">Cancel
434                 </button>
435
436                 <button data-dismiss="modal" (click)="uploadFile()" class="btn btn-sm btn-primary" type="button">
437                     Import
438                 </button>
439             </div>
440         </div>
441     </div>
442 </div>
443
444 <!-- Delete Modal -->
445 <div class="modal fade" id="templateDeletionModal2" tabindex="-1" role="dialog"
446     aria-labelledby="templateDeletionModal2Label" aria-hidden="true">
447     <div class="modal-dialog" role="document">
448         <div class="modal-content">
449             <div class="modal-header">
450                 <h5 class="modal-title" id="templateDeletionModal2Label">Delete Script</h5>
451                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
452                     <img src="assets/img/icon-close.svg" />
453                 </button>
454             </div>
455             <div class="modal-body">
456                 <p>Are you sure you want to delete Template file
457                     <span>{{fileToDelete}}</span>?</p>
458             </div>
459             <div class="modal-footer">
460                 <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
461                 <button type="button" (click)="confirmDelete()" data-dismiss="modal"
462                     class="btn btn-primary">Delete</button>
463             </div>
464         </div>
465     </div>
466 </div>