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