6dc12072834c9f6ce00d3db493e3e8afddaad0ac
[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
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="btn-group mapping-editBar" role="group">
134                         <div class="custom-control custom-checkbox" tooltip="Select All" placement="bottom">
135                             <input type="checkbox" (click)="selectAllProps()" class="custom-control-input"
136                                 id="customCheck1"
137                                 [checked]="resourceDictionaryRes.length>0&&resourceDictionaryRes.length === this.selectedProps.size">
138                             <label class="custom-control-label" for="customCheck1"></label>
139                         </div>
140                         <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="reMap()"
141                             tooltip="Re-mapping" placement="bottom"><i class="icon-autoMap"></i></button>
142                         <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="removeProps()"
143                             tooltip="Remove" placement="bottom"><i class="icon-delete-sm"></i></button>
144                         <div style="line-height: 35px;font-size: 10px;">
145                             <span>{{selectedProps.size}} selected </span>
146                             <span>({{resourceDictionaryRes.length}} attributes in total)</span>
147                         </div>
148                     </div>
149                     <table datatable id="init-table" [dtOptions]="initDtOptions" [dtTrigger]="dtTrigger"
150                         class="row-border hover">
151                         <thead>
152                             <tr>
153                                 <th></th>
154                                 <th>Required</th>
155                                 <th>Template Input</th>
156                                 <th>Parameter Name</th>
157                                 <th>Dictionary Name</th>
158                                 <th>Dictionary Source</th>
159                                 <th>Dependancies</th>
160                                 <th>Default</th>
161                                 <th>Velocity</th>
162                                 <th>Data Type</th>
163                                 <th>Entry Schema</th>
164                             </tr>
165                         </thead>
166                         <tbody>
167                             <tr *ngFor="let dict of resourceDictionaryRes;let i=index;trackBy: identify">
168                                 <td>
169                                     <div class="custom-control custom-checkbox" tooltip="Select" placement="bottom">
170                                         <input type="checkbox" class="custom-control-input"
171                                             id="customCheck-{{dict.name}}" [checked]="selectedProps.has(dict.name)"
172                                             (click)="selectProp(dict.name)">
173                                         <label class="custom-control-label" for="customCheck-{{dict.name}}"></label>
174                                     </div>
175                                     <!-- <input type="checkbox" [checked]="selectedProps.has(dict.name)"
176                                         (click)="selectProp(dict.name)"></td> -->
177                                 </td>
178                                 <td>
179                                     <div class="custom-control custom-checkbox reuiredInput">
180                                         <input type="checkbox" class="custom-control-input" #requiredInput
181                                             (click)="setProp(requiredInput,'required',i)"
182                                             id="requiredCheck-{{dict.name}}">
183                                         <label class="custom-control-label" for="requiredCheck-{{dict.name}}"></label>
184                                     </div>
185                                 </td>
186                                 <td>
187                                     <div class="custom-control custom-checkbox reuiredInput">
188                                         <input type="checkbox" class="custom-control-input" #tempInput
189                                             (click)="setProp(tempInput,'input-param',i)" id="inputCheck-{{dict.name}}">
190                                         <label class="custom-control-label" for="inputCheck-{{dict.name}}"></label>
191                                     </div>
192                                 </td>
193                                 <td>{{ dict.name }}</td>
194                                 <td>{{ dict.name }}</td>
195                                 <td>
196                                     <select class="custom-select" (click)="selectSource(dict,$event)">
197                                         <option *ngFor="let val of dict.definition.sources | keyvalue">
198                                             {{initMap(dict.name,val)}}
199                                         </option>
200
201                                     </select>
202                                 </td>
203                                 <td>
204                                     <!-- <select class="custom-select">
205                                         <option *ngFor="let val of getKeys(dependancies)">
206                                             {{ getValue(dict.name)}}</option>
207                                     </select> -->
208                                     <input type="text" class="form-control" [ngModel]="getValue(dict.name)">
209                                     <!-- {{ dict.definition.sources }} -->
210                                 </td>
211                                 <td>{{ dict.definition?.property?.default }}</td>
212                                 <td><input type="text" class="form-control" #velocity
213                                         (input)="setVelocity(i,velocity.value)"></td>
214                                 <td>{{ dict.definition?.property?.type }}</td>
215                                 <td>{{ dict.definition?.property['entry_schema'] }}</td>
216                             </tr>
217                         </tbody>
218                     </table>
219                 </div>
220
221                 <div id="mapping-table-res" [hidden]="mappingRes?.length == 0" class="mapping-table mx-4 my-2">
222                     <!-- <div class="btn-group mapping-editBar" role="group">
223                         <div class="custom-control custom-checkbox" tooltip="Select All" placement="bottom">
224                             <input type="checkbox" (click)="selectAllProps()" class="custom-control-input"
225                                 id="customCheck2"
226                                 [checked]="resourceDictionaryRes.length>0&&resourceDictionaryRes.length === this.selectedProps.size">
227                             <label class="custom-control-label" for="customCheck2"></label>
228                         </div>
229                         <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="reMap()"
230                             tooltip="Re-mapping" placement="bottom"><i class="icon-autoMap"></i></button>
231                         <button [disabled]="selectedProps.size <=0" type="button" class="btn" (click)="removeProps()"
232                             tooltip="Remove" placement="bottom"><i class="icon-delete-sm"></i></button>
233                     </div> -->
234                     <table datatable id="res-table" [dtOptions]="dtOptions" [dtTrigger]="resTableDtTrigger"
235                         class="row-border hover">
236                         <thead>
237                             <tr>
238                                 <!-- <th></th> -->
239                                 <th>Required</th>
240                                 <th>Template Input</th>
241                                 <th>Parameter Name</th>
242                                 <th>Dictionary Name</th>
243                                 <th>Dictionary Source</th>
244                                 <th>Dependancies</th>
245                                 <th>Default</th>
246                                 <th>Velocity</th>
247                                 <th>Data Type</th>
248                                 <th>Entry Schema</th>
249                             </tr>
250                         </thead>
251                         <tbody>
252                             <tr *ngFor="let dict of mappingRes">
253                                 <!-- <td>
254                                     <div class="custom-control custom-checkbox" tooltip="Select" placement="bottom">
255                                         <input type="checkbox" class="custom-control-input"
256                                             id="customCheck2-{{dict.name}}" [checked]="selectedProps.has(dict.name)"
257                                             (click)="selectProp(dict.name)">
258                                         <label class="custom-control-label" for="customCheck2-{{dict.name}}"></label>
259                                     </div>
260                                 </td> -->
261                                 <td>
262                                     <img *ngIf="dict?.property?.required" src="/assets/img/icon-required-yes.svg">
263                                     <img *ngIf="!dict?.property?.required" src="/assets/img/icon-required-no.svg">
264                                 </td>
265                                 <td>
266                                     <img *ngIf="dict['input-param']" src="/assets/img/icon-required-yes.svg">
267                                     <img *ngIf="!dict['input-param']" src="/assets/img/icon-required-no.svg">
268                                 </td>
269                                 <td>{{ dict['name'] }}</td>
270                                 <td>{{ dict['name'] }}</td>
271                                 <td>
272                                     <input type="text" class="form-control" [value]="dict['dictionary-source']"
273                                         disabled>
274
275                                 </td>
276                                 <td>
277                                     <input type="text" class="form-control" [value]="dict['dependencies']" disabled>
278                                     <!-- {{ dict.definition.sources }} -->
279                                 </td>
280                                 <td>{{ dict['property']['default'] }}</td>
281                                 <td *ngIf="dict?.property?.metadata">
282                                     {{dict?.property?.metadata['transform-template']}}
283                                 </td>
284                                 <td *ngIf="!dict?.property?.metadata"></td>
285                                 <td>{{ dict['property']['type'] }}</td>
286                                 <td>{{ dict['property']['entry_schema'] }}</td>
287                             </tr>
288                         </tbody>
289                     </table>
290                 </div>
291
292
293             </div>
294
295
296         </div>
297
298     </div>
299 </div>
300
301
302 <div class="modal fade" id="templateModal" tabindex="-1" role="dialog" aria-labelledby="templateModalLabel"
303     aria-hidden="true">
304     <div class="modal-dialog" role="document">
305         <div class="modal-content">
306             <div class="modal-header">
307                 <h5 class="modal-title" id="templateModalLabel">Import File</h5>
308                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
309                     <img src="assets/img/icon-close.svg" />
310                 </button>
311             </div>
312             <div class="modal-body">
313                 <ngx-file-drop [multiple]="false" [accept]="allowedExt" dropZoneLabel="Drop files here"
314                     (onFileDrop)="dropped($event)" (onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)">
315                     <ng-template ngx-file-drop-content-tmp let-openFileSelector="openFileSelector">
316                         <div class="folder-upload">
317                             <img src="assets/img/folder-upload.svg" />
318                         </div>
319                         <div class="folder-upload-text">
320                             Drag & Drop file
321                         </div>
322                         <div class="folder-upload-text">or
323                             <button type="button" class="btn btn-sm btn-primary" (click)="openFileSelector()">Browse
324                                 Files
325                             </button>
326                         </div>
327                         <div class="folder-upload-type">Allowed file type:
328                             {{allowedExt}}
329                         </div>
330                     </ng-template>
331                 </ngx-file-drop>
332                 <div class="upload-table">
333                     <table class="table">
334                         <thead>
335                             <tr *ngFor="let item of uploadedFiles; let i=index">
336                                 <th width="40"><img src="assets/img/icon-file-code.svg" /></th>
337                                 <th>{{ item.name }}</th>
338                                 <th (click)="removeFile(i)" width="40" class="text-right"><img
339                                         src="assets/img/icon-remove-file.svg" class="btn-modal-remove-file" /></th>
340                             </tr>
341                         </thead>
342                     </table>
343                 </div>
344             </div>
345
346             <div class="modal-footer">
347                 <button type="button" class="btn btn-sm btn-secondary btn-cancel" data-dismiss="modal"
348                     (click)="resetTheUploadedFiles()">Cancel
349                 </button>
350
351                 <button data-dismiss="modal" (click)="uploadFile()" class="btn btn-sm btn-primary" type="button">
352                     Import
353                 </button>
354             </div>
355         </div>
356     </div>
357 </div>
358
359 <!-- Delete Modal -->
360 <div class="modal fade" id="templateDeletionModal2" tabindex="-1" role="dialog"
361     aria-labelledby="templateDeletionModal2Label" aria-hidden="true">
362     <div class="modal-dialog" role="document">
363         <div class="modal-content">
364             <div class="modal-header">
365                 <h5 class="modal-title" id="templateDeletionModal2Label">Delete Script</h5>
366                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
367                     <img src="assets/img/icon-close.svg" />
368                 </button>
369             </div>
370             <div class="modal-body">
371                 <p>Are you sure you want to delete Template file
372                     <span>{{fileToDelete}}</span>?</p>
373             </div>
374             <div class="modal-footer">
375                 <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
376                 <button type="button" (click)="confirmDelete()" data-dismiss="modal"
377                     class="btn btn-primary">Delete</button>
378             </div>
379         </div>
380     </div>
381 </div>