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