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