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